[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MiNT] [Highwire] gcc4



Am Mittwoch, den 08.09.2010, 20:38 +0200 schrieb Peter Slegg
<p.slegg@scubadivers.co.uk>:
> On Mon, 06 Sep 2010 11:37:53 , Vincent Rivière
> <vincent.riviere@freesbee.fr> wrote:
>> Peter Slegg wrote:
>> >                  *((long **)p_answ)++/*[3..4]*/ = gsi_;
>>
>> Split that into 2 lines (untested):
>> *((long **)p_answ)/*[3..4]*/ = gsi_;
>> p_answ += 2;
>>
>> Still not type clean, but it will work as expected.
>>
> 
> Those original lines were in a block of code that had two versions:
> 
>         case GS_REQUEST:
>             {
>             #if 1  /* an optimized version of the below original */
>                 const GS_INFO *sender;
>                 short answ[8], *p_answ = answ;
>                 long *gsi_ = (long *)gsi;
> 
>                 *p_answ++              /*[0]*/ = GS_REPLY;
>                 *p_answ++              /*[1]*/ = gl_apid;
>                 *p_answ++              /*[2]*/ = 0;
> /*                *((long **)p_answ)++ //[3..4]// = gsi_;  */
>                 *((long **)p_answ)     /*[3..4]*/ = gsi_;
>                 p_answ += 2;
> 
>                 *gsi_++ = sizeof(GS_INFO);
>                 *gsi_++ = (0x0120L << 16) ¦ GSM_COMMAND;
>                 *gsi_   = 0L;
> /*                *((long *)p_answ)++ //[5..6]// = 1;  */
>                 *((long *)p_answ)     /*[5..6]*/ = 1;
>                 p_answ += 2;
>                 *p_answ                /*[7]*/ = msg[7];
> 
>                 sender = *(GS_INFO **)&msg[3];
>                 if (sender) {
>                     if (sender->version >= 0x0070) {
>                         *--p_answ/*[6]*/ = 0;
>                         gsapp = msg[1];
>                     }
>                 }
>             #else
>                 const GS_INFO *sender = *(GS_INFO **)&msg[3];
>                 WORD answ[8];
> 
>                 answ[0] = GS_REPLY;
>                 answ[1] = gl_apid;
>                 answ[2] = 0;
>                 answ[3] = 0;
>                 answ[4] = 0;
>                 answ[5] = 0;
>                 answ[6] = 1;
>                 answ[7] = msg[7];
> 
>                 gsi->len = sizeof(GS_INFO);
>                 gsi->version = 0x0120;
>                 gsi->msgs = GSM_COMMAND;
>                 gsi->ext = 0L;
> 
>                 *(const GS_INFO **)&answ[3] = gsi;
> 
>                 if (sender)
>                 {
>                     if (sender->version >= 0x0070)
>                     {
>                         answ[6] = 0;
>                         gsapp = msg[1];
>                     }
>                 }
>             #endif
> 
> I tried the unoptimised version but I think it is causing HW to crash
> so I have switched back to the optimised one that all recent betas
> are using.
> 
> Now I am back to dealing with:
> 
> error: cast discards qualifiers from pointer target type
> const char *cmd = *(const char **)&msg[3];
> 
> you would think that all those const would keep it happy ;-)
> 
> Peter