[Spice-devel] [spice-gtk v1 1/5] win-usb-dev: Make usage of early return

Victor Toso victortoso at redhat.com
Mon Nov 14 23:26:51 UTC 2016


From: Victor Toso <me at victortoso.com>

No need for if else here.
Signed-off-by: Victor Toso <victortoso at redhat.com>
---
 src/win-usb-dev.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/win-usb-dev.c b/src/win-usb-dev.c
index 1cf9f21..a857b02 100644
--- a/src/win-usb-dev.c
+++ b/src/win-usb-dev.c
@@ -108,12 +108,11 @@ GQuark g_udev_client_error_quark(void)
 
 GUdevClient *g_udev_client_new(const gchar* const *subsystems)
 {
-    if (!singleton) {
-        singleton = g_initable_new(G_UDEV_TYPE_CLIENT, NULL, NULL, NULL);
-        return singleton;
-    } else {
+    if (singleton != NULL)
         return g_object_ref(singleton);
-    }
+
+    singleton = g_initable_new(G_UDEV_TYPE_CLIENT, NULL, NULL, NULL);
+    return singleton;
 }
 
 
-- 
2.9.3



More information about the Spice-devel mailing list