public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] warnings from gcc-4.4 build
Date: Fri, 10 Jul 2009 22:49:01 -0400	[thread overview]
Message-ID: <200907102249.02699.vapier@gentoo.org> (raw)
In-Reply-To: <20090710230528.8398B832E416@gemini.denx.de>

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 

      reply	other threads:[~2009-07-11  2:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-30 15:28 [U-Boot] warnings from gcc-4.4 build Kumar Gala
2009-07-01 13:53 ` Detlev Zundel
2009-07-04 23:33 ` Wolfgang Denk
2009-07-06 15:10   ` Kumar Gala
2009-07-06 17:52     ` Scott Wood
2009-07-10 23:05       ` Wolfgang Denk
2009-07-11  2:49         ` Mike Frysinger [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200907102249.02699.vapier@gentoo.org \
    --to=vapier@gentoo.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox