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

Submitted by Frediano Ziglio on July 11, 2019, 1 p.m.

Details

Message ID 20190711130054.17867-2-fziglio@redhat.com
State Accepted
Commit ffc9a2495104c00831075db8fda5397dbd786a68
Headers show
Series "Series without cover letter" ( rev: 1 ) in Spice

Not browsing as part of any series.

Commit Message

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

Patch hide | download patch | download mbox

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
 }