--- usbutils-0.11/lsusb.c.endian 2005-01-20 08:14:23.234480568 +0000 +++ usbutils-0.11/lsusb.c 2005-01-20 08:14:34.742731048 +0000 @@ -35,6 +35,13 @@ #include #include #include +#include + +#if __BYTE_ORDER == __BIG_ENDIAN +#define BE 1 +#else +#define BE 0 +#endif #include #ifdef HAVE_LINUX_USBDEVICE_FS_H @@ -290,8 +297,8 @@ static void dump_device(int fd, unsigned printf(" Warning: Invalid descriptor\n"); else if (buf[0] < 18) printf(" Warning: Descriptor too short\n"); - vid = buf[8] | (buf[9] << 8); - pid = buf[10] | (buf[11] << 8); + vid = *(u_int16_t *)(buf+8); + pid = *(u_int16_t *)(buf+10); get_vendor_string(vendor, sizeof(vendor), vid); get_product_string(product, sizeof(product), vid, pid); get_class_string(cls, sizeof(cls), buf[4]); @@ -315,8 +322,8 @@ static void dump_device(int fd, unsigned " iProduct %5u %s\n" " iSerial %5u %s\n" " bNumConfigurations %5u\n", - buf[0], buf[1], buf[3], buf[2], buf[4], cls, buf[5], subcls, buf[6], proto, buf[7], - vid, vendor, pid, product, buf[13], buf[12], buf[14], mfg, buf[15], prod, buf[16], serial, buf[17]); + buf[0], buf[1], buf[3-BE], buf[2+BE], buf[4], cls, buf[5], subcls, buf[6], proto, buf[7], + vid, vendor, pid, product, buf[13-BE], buf[12+BE], buf[14], mfg, buf[15], prod, buf[16], serial, buf[17]); dump_junk(buf, " ", 18); } @@ -1575,8 +1582,8 @@ static int dump_one_device(const char *p fprintf(stderr, "cannot get config descriptor, %s (%d)\n", strerror(errno), errno); goto err; } - vid = buf[8] | (buf[9] << 8); - pid = buf[10] | (buf[11] << 8); + vid = *(u_int16_t *)(buf+8); + pid = *(u_int16_t *)(buf+10); get_vendor_string(vendor, sizeof(vendor), vid); get_product_string(product, sizeof(product), vid, pid); printf("Device: ID %04x:%04x %s %s\n", vid, pid, vendor, product); @@ -1628,8 +1635,8 @@ static int list_devices(int bus, int dev fprintf(stderr, "cannot read device descriptor %s (%d)\n", strerror(errno), errno); goto err; } - vid = buf[8] | (buf[9] << 8); - pid = buf[10] | (buf[11] << 8); + vid = *(u_int16_t *)(buf+8); + pid = *(u_int16_t *)(buf+10); if (buf[0] >= USB_DT_DEVICE_SIZE && ((vendorid != -1 && vendorid != vid) || (productid != -1 && productid != pid))) goto err; status=0;