[U-Boot] warnings from gcc-4.4 build

Scott Wood scottwood at freescale.com
Mon Jul 6 19:52:33 CEST 2009


On Mon, Jul 06, 2009 at 10:10:20AM -0500, Kumar Gala wrote:
> static int ata_scsiop_read_capacity10(ccb *pccb)
> {
>          u8 buf[8];
> 
>          memset(buf, 0, 8);
> 
>          *(u32 *) buf = le32_to_cpu(ataid[pccb->target]->lba_capacity);
> 
>          buf[6] = 512 >> 8;
>          buf[7] = 512 & 0xff;
> 
>          memcpy(pccb->pdata, buf, 8);
> 
>          return 0;
> }
> 
> how do we fix this (the *u32 *)buf ... line is the one causing  
> warnings ?

Use a union.

> For dlmalloc I think we might want to look at updating to a newer  
> version of the code.

Agreed in general, though I'm nervous about enabling strict aliasing on
any malloc implementation (except possibly one that makes sure to operate
on char pointers, at least to a degree required to create optimization
barriers).  Its whole purpose in life is to reinterpret portions of
memory -- consider some hyperoptimizing compiler that does
inter-procedural analysis and ends up moving accesses across the free()
boundary because it couldn't find any intervening access through a
pointer to the same type (or char).

-Scott


More information about the U-Boot mailing list