[Spice-devel] [spice-gtk Win32 v4 02/17] Introduce SpiceUsbDeviceInfo to be kept instead of a libusb_device

Hans de Goede hdegoede at redhat.com
Thu Jul 5 23:30:54 PDT 2012


Hi,

Looking at the next patch in the series, I've one more remark on this one:

On 07/05/2012 10:43 PM, Uri Lublin wrote:
> +static SpiceUsbDeviceInfo *spice_usb_device_set_info(libusb_device *libdev)
> +{
> +    SpiceUsbDeviceInfo *info;
> +    struct libusb_device_descriptor desc;
> +    int errcode;
> +    const gchar *errstr;
> +    guint8 bus, addr;
> +
> +    g_return_val_if_fail(libdev != NULL, NULL);
> +
> +    bus = libusb_get_bus_number(libdev);
> +    addr = libusb_get_device_address(libdev);
> +
> +    errcode = libusb_get_device_descriptor(libdev, &desc);
> +    if (errcode < 0) {
> +        errstr = spice_usbutil_libusb_strerror(errcode);
> +        g_warning("cannot get device descriptor for (%p) %d.%d -- %s(%d)",
> +                  libdev, bus, addr, errstr, errcode);
> +        return NULL;
> +    }
> +
> +    info = g_new0(SpiceUsbDeviceInfo, 1);
> +
> +    info->busnum  = bus;
> +    info->devaddr = addr;
> +    info->vid = desc.idVendor;
> +    info->pid = desc.idProduct;
> +    info->ref = 1;
> +
> +    return info;
> +}

This function creates a new SpiceUsbDevice from the info in a libusb_device, so its
name is sort of confusing since it is not setting the info of the passed in object, but
creating a new object, I would like to see this renamed to: spice_usb_device_new

Regards,

Hans


More information about the Spice-devel mailing list