[Spice-devel] [PATCH spice-gtk 2/5] usb-device-manager: Error check spice_usb_device_manager_device_to_libdev calls

Christophe Fergeau cfergeau at redhat.com
Tue Apr 23 11:05:49 PDT 2013


On Tue, Apr 23, 2013 at 02:19:49PM +0200, Hans de Goede wrote:
> Under Windows all calls to spice_usb_device_manager_device_to_libdev may fail,
> so error check them all.

I don't think I'd make that conditional on the windows code as this makes
things less readable, and this does not hurt to have these checks on linux.
ACK either way.

Christophe

> 
> Signed-off-by: Hans de Goede <hdegoede at redhat.com>
> ---
>  gtk/usb-device-manager.c | 13 +++++++++++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/gtk/usb-device-manager.c b/gtk/usb-device-manager.c
> index 76f82b2..dc334bd 100644
> --- a/gtk/usb-device-manager.c
> +++ b/gtk/usb-device-manager.c
> @@ -1090,7 +1090,10 @@ static void spice_usb_device_manager_check_redir_on_connect(
>              continue;
>  
>          libdev = spice_usb_device_manager_device_to_libdev(self, device);
> -
> +#ifdef G_OS_WIN32
> +        if (libdev == NULL)
> +            continue;
> +#endif
>          if (usbredirhost_check_device_filter(
>                              priv->redirect_on_connect_rules,
>                              priv->redirect_on_connect_rules_count,
> @@ -1448,7 +1451,13 @@ spice_usb_device_manager_can_redirect_device(SpiceUsbDeviceManager  *self,
>          libusb_device *libdev;
>  
>          libdev = spice_usb_device_manager_device_to_libdev(self, device);
> -        g_return_val_if_fail(libdev != NULL, FALSE);
> +#ifdef G_OS_WIN32
> +        if (libdev == NULL) {
> +            g_set_error_literal(err, SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
> +                                _("Some USB devices were not found"));
> +            return FALSE;
> +        }
> +#endif
>          filter_ok = (usbredirhost_check_device_filter(
>                              guest_filter_rules, guest_filter_rules_count,
>                              libdev, 0) == 0);
> -- 
> 1.8.2
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20130423/fccf9a6d/attachment.pgp>


More information about the Spice-devel mailing list