On Sun, Mar 10, 2019 at 04:46:08PM +0200, Yuri Benditovich wrote: > When processing list of USB devices, avoid allocating memory > for devices which later will be skipped. Use existing libusb > struct first to check whether the device shall be excluded. I probably would reword the short log "win-usb-dev: do not allocate memory for hub devices" -> "win-usb-dev: skip hub devices early in g_udev_client_list_devices" > -static gboolean g_udev_skip_search(GUdevDevice *udev) > +static gboolean g_udev_skip_search(libusb_device *dev) > { > - GUdevDeviceInfo* udevinfo; > gboolean skip; > + uint8_t addr = libusb_get_device_address(dev); > + struct libusb_device_descriptor desc; > > - g_return_val_if_fail(G_UDEV_DEVICE(udev), FALSE); > - > - udevinfo = udev->priv->udevinfo; > - g_return_val_if_fail(udevinfo != NULL, FALSE); > + libusb_get_device_descriptor(dev, &desc); Do you know if these libusb_get_device_descriptor/libusb_get_device_address are going to be expensive compared to using cached values? > > - skip = ((udevinfo->addr == 0xff) || /* root hub (HCD) */ > + skip = ((addr == 0xff) || /* root hub (HCD) */ > #if defined(LIBUSBX_API_VERSION) && (LIBUSBX_API_VERSION >= 0x010000FF) > - (udevinfo->addr == 1) || /* root hub addr for libusbx >= 1.0.13 */ > + (addr == 1) || /* root hub addr for libusbx >= 1.0.13 */ Note for later: I'm not sure this still needs to be conditional as we depend on libusb 1.0.16 now. Looks good otherwise, Christophe
Attachment:
signature.asc
Description: PGP signature
_______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel