Subject: Re: __attribute__ ((__packed__)) for struct ifreq
To: Chris G. Demetriou <cgd@sibyte.com>
From: None <itojun@iijlab.net>
List: tech-net
Date: 05/16/2000 01:58:35
>> 	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
>code.

	this is the primary reason i've bringed in getifaddrs(3).

>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.

	i see, i'll back out the change.  sorry for the mess.

itojun