On Fri, 6 Jan 2006, Oliver Neukum wrote: > Am Freitag, 6. Januar 2006 23:18 schrieb Alan Stern: > > I don't know why struct usb_device_descriptor is packed. In fact, most of > > the structures defined in usb_ch9.h are packed for no apparent reason. > > Maybe it's so you can dereference descriptors embedded in the > > rawdescriptors array; those definitely are _not_ aligned. > > I went through this file checking for the size of a structure and > noticed that these structuress are packed. Not being able to understand > the reason I proposed to change that. Russell objected. This makes > no sense. EIther none of these structures should be packed, or all > should be packed.
I didn't see Russell's objection. Why does he think the structures need to be packed? Note that there are places where the code refers to sizeof(struct usb_descriptor_header), this would cause problems. They should be changed to use USB_DT_HEADER_SIZE, which should be #defined to 2 in usb_ch9.h. Likewise for the other descriptor types. Consider also this code from input/hid-core.c: if (usb_get_extra_descriptor(interface, HID_DT_HID, &hdesc) && (!interface->desc.bNumEndpoints || usb_get_extra_descriptor(&interface->endpoint[0], HID_DT_HID, &hdesc))) { dbg("class descriptor not present\n"); return NULL; } for (n = 0; n < hdesc->bNumDescriptors; n++) if (hdesc->desc[n].bDescriptorType == HID_DT_REPORT) rsize = le16_to_cpu(hdesc->desc[n].wDescriptorLength); Since usb_get_extra_descriptor returns unaligned pointers, the reference to hdesc->desc[n].wDescriptorLength might cause an exception. Of course, that could be changed too. Alan Stern ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click _______________________________________________ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel