[Spice-devel] [PATCH spice-gtk 13/14] usb: do not return GError on programmer pre-condition checks

Marc-André Lureau marcandre.lureau at gmail.com
Thu Apr 24 08:51:01 PDT 2014


Use regular g_return precondition checks.
---
 gtk/usb-device-manager.c | 26 +++-----------------------
 1 file changed, 3 insertions(+), 23 deletions(-)

diff --git a/gtk/usb-device-manager.c b/gtk/usb-device-manager.c
index 81e3c80..5f6bde1 100644
--- a/gtk/usb-device-manager.c
+++ b/gtk/usb-device-manager.c
@@ -230,8 +230,8 @@ static gboolean spice_usb_device_manager_initable_init(GInitable  *initable,
                                                        GCancellable  *cancellable,
                                                        GError        **err)
 {
-    SpiceUsbDeviceManager *self;
-    SpiceUsbDeviceManagerPrivate *priv;
+    SpiceUsbDeviceManager *self = SPICE_USB_DEVICE_MANAGER(initable);
+    SpiceUsbDeviceManagerPrivate *priv = self->priv;
 #ifdef USE_USBREDIR
     GList *list;
     GList *it;
@@ -239,27 +239,6 @@ static gboolean spice_usb_device_manager_initable_init(GInitable  *initable,
 #ifdef USE_GUDEV
     const gchar *const subsystems[] = {"usb", NULL};
 #endif
-#endif
-
-    g_return_val_if_fail(SPICE_IS_USB_DEVICE_MANAGER(initable), FALSE);
-    g_return_val_if_fail(err == NULL || *err == NULL, FALSE);
-
-    if (cancellable != NULL) {
-        g_set_error_literal(err, SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
-                            "Cancellable initialization not supported");
-        return FALSE;
-    }
-
-    self = SPICE_USB_DEVICE_MANAGER(initable);
-    priv = self->priv;
-
-    if (!priv->session) {
-        g_set_error_literal(err, SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
-                "SpiceUsbDeviceManager constructed without a session");
-        return FALSE;
-    }
-
-#ifdef USE_USBREDIR
 
 #ifdef G_OS_WIN32
     priv->installer = spice_win_usb_driver_new();
@@ -1296,6 +1275,7 @@ SpiceUsbDeviceManager *spice_usb_device_manager_get(SpiceSession *session,
     static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
 
     g_return_val_if_fail(err == NULL || *err == NULL, NULL);
+    g_return_val_if_fail(SPICE_IS_SESSION(session), NULL);
 
     g_static_mutex_lock(&mutex);
     self = session->priv->usb_manager;
-- 
1.8.5.3



More information about the Spice-devel mailing list