[Spice-devel] [PATCH spice-gtk 2/7] usb-device-manager: Reduce some conditional code handling !USE_USBREDIR first

Frediano Ziglio fziglio at redhat.com
Thu Jul 11 13:00:49 UTC 2019


Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 src/usb-device-manager.c | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/src/usb-device-manager.c b/src/usb-device-manager.c
index 479558f4..0a979210 100644
--- a/src/usb-device-manager.c
+++ b/src/usb-device-manager.c
@@ -213,19 +213,15 @@ G_DEFINE_BOXED_TYPE(SpiceUsbDevice, spice_usb_device, g_object_ref, g_object_unr
  */
 gboolean spice_usb_device_manager_is_redirecting(SpiceUsbDeviceManager *self)
 {
-#ifdef USE_USBREDIR
-
-#ifdef G_OS_WIN32
+#ifndef USE_USBREDIR
+    return FALSE;
+#elif defined(G_OS_WIN32)
     gboolean redirecting;
     g_object_get(self->priv->udev, "redirecting", &redirecting, NULL);
     return redirecting;
 #else
     return self->priv->redirecting;
 #endif
-
-#else
-    return FALSE;
-#endif
 }
 
 static void spice_usb_device_manager_initable_iface_init(GInitableIface *iface);
@@ -261,7 +257,11 @@ static gboolean spice_usb_device_manager_initable_init(GInitable  *initable,
                                                        GCancellable  *cancellable,
                                                        GError        **err)
 {
-#ifdef USE_USBREDIR
+#ifndef USE_USBREDIR
+    g_set_error_literal(err, SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
+                        _("USB redirection support not compiled in"));
+    return FALSE;
+#else
     SpiceUsbDeviceManager *self = SPICE_USB_DEVICE_MANAGER(initable);
     SpiceUsbDeviceManagerPrivate *priv = self->priv;
     GList *list;
@@ -306,10 +306,6 @@ static gboolean spice_usb_device_manager_initable_init(GInitable  *initable,
     g_list_free(list);
 
     return TRUE;
-#else
-    g_set_error_literal(err, SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
-                        _("USB redirection support not compiled in"));
-    return FALSE;
 #endif
 }
 
-- 
2.20.1



More information about the Spice-devel mailing list