Le mardi 04 avril 2006 à 08:54 -0700, David Brownell a écrit : > On Wednesday 15 March 2006 5:33 am, you wrote: > > Hello, > > > > Lsusb is reporting wrong size for configuration descriptor on big endian > > system. > > I join a small patch to fix it. > > This breaks behavior on little-endian systems ... Sorry,
A new patch, this time tested on i386 and ppc.
Index: lsusb.c =================================================================== RCS file: /cvsroot/linux-usb/usbutils/lsusb.c,v retrieving revision 1.24 diff -u -r1.24 lsusb.c --- lsusb.c 14 Feb 2006 05:09:09 -0000 1.24 +++ lsusb.c 4 Apr 2006 19:57:41 -0000 @@ -97,6 +97,11 @@ return buf[0] | (buf[1] << 8) | (buf[2] << 16) | (buf[3] << 24); } +static unsigned int convert_le_u16 (const unsigned char *buf) +{ + return buf[0] | (buf[1] << 8); +} + /* ---------------------------------------------------------------------- */ /* workaround libusb API goofs: "byte" should never be sign extended; @@ -363,7 +368,8 @@ " bConfigurationValue %5u\n" " iConfiguration %5u %s\n" " bmAttributes 0x%02x\n", - config->bLength, config->bDescriptorType, config->wTotalLength, + config->bLength, config->bDescriptorType, + convert_le_u16((unsigned char *)&config->wTotalLength), config->bNumInterfaces, config->bConfigurationValue, config->iConfiguration, cfg, config->bmAttributes); if (!(config->bmAttributes & 0x80))