Hi, On Sun, Jul 14, 2019 at 05:07:39PM +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@xxxxxxxxxx> > --- > 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 9964c4f..829d81d 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); Just to highlight that if error is null, nothing happens. It can be NULL in several places on this stack as it comes all the way from spice_usb_device_manager_get() > 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; Apart from indentation issue pointed by Frediano, Acked-by: Victor Toso <victortoso@xxxxxxxxxx> > } > #ifndef G_OS_WIN32 > -- > 2.17.1 > > _______________________________________________ > Spice-devel mailing list > Spice-devel@xxxxxxxxxxxxxxxxxxxxx > https://lists.freedesktop.org/mailman/listinfo/spice-devel
Attachment:
signature.asc
Description: PGP signature
_______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel