[U-Boot] IP_t should be a "packed" struct

Wolfgang Denk wd at denx.de
Wed Jan 28 22:38:28 CET 2009


Dear Ben Warren,

In message <4980CC59.1070302 at gmail.com> you wrote:
>
> > My idea should be to declare a define like this
> >
> > #define PKT_HEADER __attribute__((__packed__))
> >
> > my 2EuroCents.
> >
> > best regards,
> >
> > luigi
> >
> >   
> OK, sounds good.  Send a patch please.

Hm... and what does this give us?

How long  until  sombebody  detects  that  all  the  data  structures
describing  device  register  layout  or so many processors and chips
don't use any __packed__ either? Except for some (IMHO broken, but  I
know  that  I'm  more  attached  to PowerPC anyway) ARM systems it is
sufficient to use a "sane" selection of data types.


I vote against changing this code. Just for a quick  cross-check:  do
the   corresponding   data  structs  in  the  Linux  kernel  use  any
__packed__?

Here is for example a copy of /usr/include/netinet/ip.h :

...
struct iphdr
  {
#if __BYTE_ORDER == __LITTLE_ENDIAN
    unsigned int ihl:4;
    unsigned int version:4;
#elif __BYTE_ORDER == __BIG_ENDIAN
    unsigned int version:4;
    unsigned int ihl:4;
#else
# error	"Please fix <bits/endian.h>"
#endif
    u_int8_t tos;
    u_int16_t tot_len;
    u_int16_t id;
    u_int16_t frag_off;
    u_int8_t ttl;
    u_int8_t protocol;
    u_int16_t check;
    u_int32_t saddr;
    u_int32_t daddr;
    /*The options start here. */
  };
...

Do you see any __packed__?

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
The C-shell doesn't parse. It adhoculates.
    - Casper.Dik at Holland.Sun.COM in <3ol96k$b2j at engnews2.Eng.Sun.COM>


More information about the U-Boot mailing list