Unify parameter name for libusb_device. Use g_return_val_if_fail for expected condition. Remove redundant casting. Signed-off-by: Yuri Benditovich <yuri.benditovich@xxxxxxxxxx> --- src/usb-backend.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/usb-backend.c b/src/usb-backend.c index 53ac430..e837579 100644 --- a/src/usb-backend.c +++ b/src/usb-backend.c @@ -108,21 +108,22 @@ static SpiceUsbBackendDevice *allocate_backend_device(libusb_device *libdev) } static int LIBUSB_CALL hotplug_callback(libusb_context *ctx, - libusb_device *device, + libusb_device *libdev, libusb_hotplug_event event, void *user_data) { - SpiceUsbBackend *be = (SpiceUsbBackend *)user_data; - if (be->hotplug_callback) { - SpiceUsbBackendDevice *dev; - gboolean val = event == LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED; - dev = allocate_backend_device(device); - if (dev) { - SPICE_DEBUG("created dev %p, usblib dev %p", dev, device); - libusb_ref_device(device); - be->hotplug_callback(be->hotplug_user_data, dev, val); - spice_usb_backend_device_unref(dev); - } + SpiceUsbBackend *be = user_data; + SpiceUsbBackendDevice *dev; + gboolean arrived = event == LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED; + + g_return_val_if_fail(be->hotplug_callback != NULL, 0); + + dev = allocate_backend_device(libdev); + if (dev) { + SPICE_DEBUG("created dev %p, usblib dev %p", dev, libdev); + libusb_ref_device(libdev); + be->hotplug_callback(be->hotplug_user_data, dev, arrived); + spice_usb_backend_device_unref(dev); } return 0; } -- 2.17.1 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel