[PATCH v7 05/20] usb-backend: add guard and doc to check_filter()

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

 



From: Victor Toso <me@xxxxxxxxxxxxxx>

* Add documentation on spice_usb_backend_device_check_filter()
* Add guard on libusb_device
* Adds G_GNUCE_INTERNAL as this is only called internally in
  usb-device-manager.c
* Changed the style a bit, still under 100 char in a single line

This is a preparatory patch for extending usb-backend for emulated
devices.

Signed-off-by: Victor Toso <victortoso@xxxxxxxxxx>
---
 src/usb-backend.c | 13 ++++++-------
 src/usb-backend.h |  4 +++-
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/usb-backend.c b/src/usb-backend.c
index 3258240..6ed957c 100644
--- a/src/usb-backend.c
+++ b/src/usb-backend.c
@@ -368,7 +368,6 @@ gboolean spice_usb_backend_device_isoch(SpiceUsbBackendDevice *dev)
         return dev->cached_isochronous;
     }
 
-
     rc = libusb_get_active_config_descriptor(libdev, &conf_desc);
     if (rc) {
         const char *desc = libusb_strerror(rc);
@@ -566,13 +565,13 @@ void spice_usb_backend_device_unref(SpiceUsbBackendDevice *dev)
     }
 }
 
-int spice_usb_backend_device_check_filter(
-    SpiceUsbBackendDevice *dev,
-    const struct usbredirfilter_rule *rules,
-    int count)
+G_GNUC_INTERNAL
+int spice_usb_backend_device_check_filter(SpiceUsbBackendDevice *dev,
+                                          const struct usbredirfilter_rule *rules,
+                                          int count)
 {
-    return usbredirhost_check_device_filter(
-        rules, count, dev->libusb_device, 0);
+    g_return_val_if_fail(dev->libusb_device != NULL, -EINVAL);
+    return usbredirhost_check_device_filter(rules, count, dev->libusb_device, 0);
 }
 
 static int usbredir_read_callback(void *user_data, uint8_t *data, int count)
diff --git a/src/usb-backend.h b/src/usb-backend.h
index 46b742e..46713c1 100644
--- a/src/usb-backend.h
+++ b/src/usb-backend.h
@@ -70,7 +70,9 @@ void spice_usb_backend_device_unref(SpiceUsbBackendDevice *dev);
 gconstpointer spice_usb_backend_device_get_libdev(const SpiceUsbBackendDevice *dev);
 const UsbDeviceInformation* spice_usb_backend_device_get_info(const SpiceUsbBackendDevice *dev);
 gboolean spice_usb_backend_device_isoch(SpiceUsbBackendDevice *dev);
-/* returns 0 if the device passes the filter */
+
+/* returns 0 if the device passes the filter otherwise returns the error value from
+ * usbredirhost_check_device_filter() such as -EIO or -ENOMEM */
 int spice_usb_backend_device_check_filter(SpiceUsbBackendDevice *dev,
                                           const struct usbredirfilter_rule *rules, int count);
 
-- 
2.21.0

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




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