[Spice-devel] [spice-gtk v2 5/9] usb-redir: cosmetic changes in hotplug_callback

Victor Toso victortoso at redhat.com
Tue Jul 23 13:18:55 UTC 2019


Hi,

On Tue, Jul 23, 2019 at 10:40:47AM +0300, Yuri Benditovich wrote:
> Sorry, this is a typo in the comment - should be unexpected condition,
> i.e. exactly the bug in the code

Yes, this is minor and can be fixed before pushing.

From 1/9 to 5/9,
Acked-by: Victor Toso <victortoso at redhat.com>

> On Tue, Jul 23, 2019 at 10:33 AM Frediano Ziglio <fziglio at redhat.com> wrote:
> >
> > >
> > > Unify parameter name for libusb_device.
> > > Use g_return_val_if_fail for expected condition.
> >
> > See https://developer.gnome.org/glib/stable/glib-Warnings-and-Assertions.html#g-return-val-if-fail
> > g_return_val_if_fail represents a bug in the code, not an "expected condition".
> >
> > > Remove redundant casting.
> > >
> > > Signed-off-by: Yuri Benditovich <yuri.benditovich at daynix.com>
> > > ---
> > >  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;
> > >  }
> >
> > Frediano
> _______________________________________________
> 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/6c405a2b/attachment.sig>


More information about the Spice-devel mailing list