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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
> ---
>  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@xxxxxxxxxxxxxxxxxxxxx
> http://lists.freedesktop.org/mailman/listinfo/spice-devel

Attachment: pgp0m675SIP_V.pgp
Description: PGP signature

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]