Skip to content

Commit

Permalink
Remove unreachable codes for vhci
Browse files Browse the repository at this point in the history
Old vhci gave unnecessary null check for descriptors in pluginfo which
are statically allocated. Those unreachable codes are removed.

See #251 (comment)
  • Loading branch information
cezanne committed Jul 19, 2021
1 parent 397b75d commit 62de496
Showing 1 changed file with 8 additions and 25 deletions.
33 changes: 8 additions & 25 deletions driver/vhci/vhci_plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,36 +50,19 @@ vhci_init_vpdo(pvpdo_dev_t vpdo)
static void
setup_vpdo_with_dsc_dev(pvpdo_dev_t vpdo, PUSB_DEVICE_DESCRIPTOR dsc_dev)
{
if (dsc_dev) {
vpdo->vendor = dsc_dev->idVendor;
vpdo->product = dsc_dev->idProduct;
vpdo->revision = dsc_dev->bcdDevice;
vpdo->usbclass = dsc_dev->bDeviceClass;
vpdo->subclass = dsc_dev->bDeviceSubClass;
vpdo->protocol = dsc_dev->bDeviceProtocol;
vpdo->speed = (UCHAR)get_usb_speed(dsc_dev->bcdUSB);
vpdo->num_configurations = dsc_dev->bNumConfigurations;
} else {
/* TODO: can happen? */
vpdo->vendor = 0;
vpdo->product = 0;
vpdo->revision = 0;
vpdo->usbclass = 0;
vpdo->subclass = 0;
vpdo->protocol = 0;
vpdo->speed = USB_SPEED_LOW;
vpdo->num_configurations = 1;
}
vpdo->vendor = dsc_dev->idVendor;
vpdo->product = dsc_dev->idProduct;
vpdo->revision = dsc_dev->bcdDevice;
vpdo->usbclass = dsc_dev->bDeviceClass;
vpdo->subclass = dsc_dev->bDeviceSubClass;
vpdo->protocol = dsc_dev->bDeviceProtocol;
vpdo->speed = (UCHAR)get_usb_speed(dsc_dev->bcdUSB);
vpdo->num_configurations = dsc_dev->bNumConfigurations;
}

static void
setup_vpdo_with_dsc_conf(pvpdo_dev_t vpdo, PUSB_CONFIGURATION_DESCRIPTOR dsc_conf)
{
if (!dsc_conf) {
vpdo->inum = 0;
return;
}

vpdo->inum = dsc_conf->bNumInterfaces;

/* Many devices have 0 usb class number in a device descriptor.
Expand Down

0 comments on commit 62de496

Please sign in to comment.