[U-Boot] warnings from gcc-4.4 build
Mike Frysinger
vapier at gentoo.org
Sat Jul 11 04:49:01 CEST 2009
On Friday 10 July 2009 19:05:28 Wolfgang Denk wrote:
> Scott Wood wrote:
> > 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.
>
> Or simply a temporary variable to perform the conversion in two
> separate steps.
a union is generally what people are moving to to avoid aliasing issues, but
that's only when rewriting the code isnt trivial to do. in this case, it
should be as you say and it would be simpler. and the buf[] could be tossed
completely as well as the largely useless memset().
probably something like:
u32 cap = le32_to_cpu(ataid[pccb->target]->lba_capacity);
memcpy(pccb->pdata, &cap, sizeof(cap));
pccb->pdata[4] = pccb->pdata[5] = '\0';
pccb->pdata[6] = 512 >> 8;
pccb->pdata[7] = 512 & 0xff;
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090710/557bdd8d/attachment.pgp
More information about the U-Boot
mailing list