Re: [linux-usb-devel] Re: need for packed attribute

David Brownell
2006-01-12T19:35:42Z

On Thursday 12 January 2006, Pete Zaitcev wrote (in another snide postscript):
>
> P.P.S. The USB stack was careful to use correct sizes historically.
> One grep of the source will tell you that all this stench emanates from
> the newer code, in particular the gadget and its attendant components,
> such as usbtest. Guess who wrote it: same gentleman who advocated adding
> ((packed)) to _all_ structures "used to talk to hardware". He just has
> no respect for coding practices, that's all.

You were the one who said "talk to hardware", as I had politely pointed
out off-line in previous email ... nobody else.

What you've done a couple times now is try to put those words in someone
else's mouth -- mine! -- which are clearly both (a) not what were actually
said, and (b) wrong. (FWIW it's something I've observed happening a lot
in the "traditional media" here in the US, it's not good there either.)

This what's known as not acting in good faith. "No respect for" ground
rules of discussion, for that matter ... if you're going to argue about
things, please don't put words in anyone's mouth. Certainly not mine.
(Even when the actual words said _are_ inconvenient to your agenda...)

The "packed" attribute is correct, since there's no guarantee that those
structures will be appearing in protocol data structures in GCC-friendly
layouts. Or even that the usb-if will generate protocol data structures
that happen to match GCC alignment rules, for that matter.

It's perfectly legal and common to have two seven-byte structures (like
non-audio endpoint descriptors) adjacent to each other, even when those
structures contain values otherwise subject to alignment restrictions (like
the maxpacket size, a __u16 value).

Moreover, there is no circumstance under which we'd want the compiler
expanding that seven byte data structure into an eight byte one, by
picking some place to insert a padding byte.

And for that matter, many/most of those protocol structures were declared
"packed" even in 2.4 kernels when Linux was extending them with host-side data
structures and making extra copies of them. The packing may have been
declared per-element rather than structure-wide, but it was still declared.
That's another way in which those comments of yours are wrong.

- Dave