[Spice-devel] [PATCH v8 05/20] usb-backend: add guard and doc to check_filter()
Victor Toso
victortoso at redhat.com
Thu Sep 19 14:11:18 UTC 2019
From: Victor Toso <me at victortoso.com>
* Add documentation on spice_usb_backend_device_check_filter()
* Add guard on libusb_device
* Adds G_GNUC_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 at redhat.com>
Acked-by: Frediano Ziglio <fziglio at redhat.com>
---
src/usb-backend.c | 12 ++++++------
src/usb-backend.h | 4 +++-
2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/src/usb-backend.c b/src/usb-backend.c
index a6b5f07..14429cf 100644
--- a/src/usb-backend.c
+++ b/src/usb-backend.c
@@ -566,13 +566,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
More information about the Spice-devel
mailing list