Subject: Re: __attribute__ ((__packed__)) for struct ifreq
To: Jun-ichiro itojun Hagino <>
From: Chris G. Demetriou <>
List: tech-net
Date: 05/15/2000 09:55:40 (Jun-ichiro itojun Hagino) writes:
> 	It's extremely hard thing to do.  you are wizard if you made no mistake.
> 	- you need to allocate big-enough buffer before you call SIOCGIFCONF,
> 	  you end up doing SIOCGIFCONF couple of times to guess enough
> 	  buffer size.
> 	- ifreq pointer chasing - look at sa_len
> 	- bcopy before touching any of content on ifreq

funny, i wouldn't call this "wizardry," i'd call it "the proper way of
dealing with that interface/data structure.

If that interface or data structure is seriously causing people that
much grief, the right thing to do is reformulate it so that it's
better, not add an attribute to it which will encourage sloppy
programming practices and keep the compiler from generating efficient

the 'packed' attribute should pretty much _only_ be used for 'on the
wire' data structures, or other data structures where the
representation must be packed and is not 'fixable' due to other
constraints (e.g. the DOS MBR format, or other silly things).

In this case, 'packed' is the wrong thing.  Programmers should either
be taught to write code properly for the interface, or the interface
should be fixed via normal means, not magic.