[Spice-devel] [spice-gtk Win32 v5 09/22] spice_usb_device_get_description: use device-descriptor only to get <vid, pid>

Marc-André Lureau marcandre.lureau at gmail.com
Mon Jul 9 07:27:04 PDT 2012


ack, (misc style below)

On Mon, Jul 9, 2012 at 2:14 PM, Uri Lublin <uril at redhat.com> wrote:
> In preparation for a different SpiceUsbDevice.
>
> With the new SpiceUsbDeviceInfo, <vid,pid> will be provided by
> SpiceUsbDevice, and not by the device_descriptor (from libusb)
> ---
>  gtk/usb-device-manager.c |   17 +++++++++++------
>  1 files changed, 11 insertions(+), 6 deletions(-)
>
> diff --git a/gtk/usb-device-manager.c b/gtk/usb-device-manager.c
> index 9f29c76..04c3169 100644
> --- a/gtk/usb-device-manager.c
> +++ b/gtk/usb-device-manager.c
> @@ -1031,25 +1031,30 @@ gchar *spice_usb_device_get_description(SpiceUsbDevice *_device, const gchar *fo
>  #ifdef USE_USBREDIR
>      libusb_device *device = (libusb_device *)_device;
>      struct libusb_device_descriptor desc;
> -    int bus, address;
> +    int bus, address, vid, pid;
>      gchar *description, *descriptor, *manufacturer = NULL, *product = NULL;
>
>      g_return_val_if_fail(device != NULL, NULL);
>
>      bus     = libusb_get_bus_number(device);
>      address = libusb_get_device_address(device);
> +    vid     = -1;
> +    pid     = -1;
>
>      if (libusb_get_device_descriptor(device, &desc) == LIBUSB_SUCCESS) {
> -        spice_usb_util_get_device_strings(bus, address,
> -                                          desc.idVendor, desc.idProduct,
> -                                          &manufacturer, &product);
> +        vid = desc.idVendor;
> +        pid = desc.idProduct;
> +    }
> +
> +    if ((vid > 0) && (pid > 0)) {

(those extra parenthesis aren't needed)

>          descriptor = g_strdup_printf("[%04x:%04x]", desc.idVendor, desc.idProduct);
>      } else {
> -        spice_usb_util_get_device_strings(bus, address, -1, -1,
> -                                          &manufacturer, &product);
>          descriptor = g_strdup("");
>      }
>
> +    spice_usb_util_get_device_strings(bus, address, vid, pid,
> +                                      &manufacturer, &product);
> +
>      if (!format)
>          format = _("%s %s %s at %d-%d");
>
> --
> 1.7.1
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel



-- 
Marc-André Lureau


More information about the Spice-devel mailing list