[coreboot] [Patch] remove some warnings

Kevin O'Connor kevin at koconnor.net
Sun Mar 21 17:38:43 CET 2010


On Sun, Mar 21, 2010 at 05:27:31PM +0100, Stefan Reinauer wrote:
> On 3/21/10 4:57 PM, Kevin O'Connor wrote:
> > It's about pointer aliases.  Let's say one had code like:
> >
> >   void myfunc(u16 *s, u32 *l) {
> >       printf("%d", *l);
> >       *s += 1;
> >       *l += 1;
> >       printf("%d", *l);
> >   }
> >
> > Then gcc is free to assume that *s and *l don't point to the same
> > memory location. 
> Very obviously they don't. But why would that prevent us from casting a
> char [] to struct acpi_hdr?

The cast was from an "unsigned char []" - which is actually important
as "char *" is treated specially while "unsigned char *" is not.

Otherwise, the compiler didn't stop the cast - it's just generating a
warning that it's dangerous.  (That is, it's letting the user know
that any memory accesses via the "unsigned char *" reference wont
necessarily be seen from the "struct acpi_hdr *" reference and
vice-versa.)

Did I miss something?

-Kevin




More information about the coreboot mailing list