[Spice-devel] [spice-gtk v2 7/9] usb-redir: pass GError to hotplug registration procedure

Victor Toso victortoso at redhat.com
Tue Jul 23 13:44:38 UTC 2019


Hi,

On Tue, Jul 23, 2019 at 10:27:06AM +0300, Yuri Benditovich wrote:
> In case of possible error the procedure of hotplug
> registration does not return error information, just
> issues warning to the stderr, so the reason of the problem,
> if any, is not visible. Current commit adds GError parameter
> to the procedure to return the error details conventionally.
> 
> Signed-off-by: Yuri Benditovich <yuri.benditovich at daynix.com>
> ---
>  src/usb-backend.c        | 5 ++++-
>  src/usb-backend.h        | 3 ++-
>  src/usb-device-manager.c | 3 ++-
>  3 files changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/src/usb-backend.c b/src/usb-backend.c
> index 1581f90..486875e 100644
> --- a/src/usb-backend.c
> +++ b/src/usb-backend.c
> @@ -442,7 +442,8 @@ void spice_usb_backend_deregister_hotplug(SpiceUsbBackend *be)
>  
>  gboolean spice_usb_backend_register_hotplug(SpiceUsbBackend *be,
>                                              void *user_data,
> -                                            usb_hot_plug_callback proc)
> +                                            usb_hot_plug_callback proc,
> +                                            GError **error)
>  {
>      int rc;
>      const char *desc;
> @@ -456,6 +457,8 @@ gboolean spice_usb_backend_register_hotplug(SpiceUsbBackend *be,
>      if (rc != LIBUSB_SUCCESS) {
>          g_warning("Error initializing USB hotplug support: %s [%i]", desc, rc);
>          be->hotplug_callback = NULL;
> +        g_set_error(error, SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
> +                    "Error on USB hotplug detection: %s [%i]", desc, rc);

The GError can come all the way from
spice_usb_device_manager_get() so I think the description should
be internationalized 

Apart from that, looks fine.

>          return FALSE;
>      }
>      return TRUE;
> diff --git a/src/usb-backend.h b/src/usb-backend.h
> index 6da3981..814da46 100644
> --- a/src/usb-backend.h
> +++ b/src/usb-backend.h
> @@ -60,7 +60,8 @@ gboolean spice_usb_backend_handle_events(SpiceUsbBackend *be);
>  void spice_usb_backend_interrupt_event_handler(SpiceUsbBackend *be);
>  gboolean spice_usb_backend_register_hotplug(SpiceUsbBackend *be,
>                                              void *user_data,
> -                                            usb_hot_plug_callback proc);
> +                                            usb_hot_plug_callback proc,
> +                                            GError **error);
>  void spice_usb_backend_deregister_hotplug(SpiceUsbBackend *be);
>  
>  /* Spice USB backend device API */
> diff --git a/src/usb-device-manager.c b/src/usb-device-manager.c
> index 9300ad2..857d057 100644
> --- a/src/usb-device-manager.c
> +++ b/src/usb-device-manager.c
> @@ -257,7 +257,8 @@ static gboolean spice_usb_device_manager_initable_init(GInitable  *initable,
>  
>      /* Start listening for usb devices plug / unplug */
>      if (!spice_usb_backend_register_hotplug(priv->context, self,
> -                                            spice_usb_device_manager_hotplug_cb)) {
> +                                            spice_usb_device_manager_hotplug_cb,
> +                                            err)) {
>          return FALSE;
>      }
>  #ifndef G_OS_WIN32
> -- 
> 2.17.1
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20190723/fdee164b/attachment.sig>


More information about the Spice-devel mailing list