Re: usb: descriptor structures have to be packed

"Phil Endecott" <[email protected]>
Newsgroups gmane.linux.usb.devel
Message-ID <[email protected]>
Oleg Verych wrote:
> Your intro pseudo-code:
>
> |   g() {
> |      char c;
> |      struct S s; /* packed or not */
> |      (s.intfield)++;
> |      f(&s);
> |   }
>
> Due to `c', `s' gets to be unaligned, i.e. light turned before you've
> touched a switch: layout of `c' is independed, it's a byte, not followed
> by a byte, thus must be padded. No?.

No.  If struct S is packed then its alignment is 1 and it will be 
placed immediately after c.
This is not a bug, it is the intended consequence of declaring struct S 
as packed.  This is exactly why we must be careful about making such declarations.


Phil.





-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.