]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
test_default_session_servicedirs: simplify to a single exit code-path
authorSimon McVittie <simon.mcvittie@collabora.co.uk>
Mon, 2 Nov 2015 14:15:14 +0000 (14:15 +0000)
committerRalf Habacker <ralf.habacker@freenet.de>
Mon, 2 Nov 2015 22:22:42 +0000 (23:22 +0100)
A similar simplification was already done on master as part of commit
f830e14, Bug #83539.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=92721
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
bus/config-parser.c

index 3f59730b1a5390d20bf5a810aa3432350c68d0ff..3a5ecc34b04cb83cfa1f3a66fda85e9d0993d8e0 100644 (file)
@@ -3402,11 +3402,18 @@ test_default_session_servicedirs (void)
   DBusList *link;
   DBusString progs;
   int i;
-
+  dbus_bool_t ret = FALSE;
 #ifdef DBUS_WIN
   const char *common_progs;
   char buffer[1024];
+#endif
+
+  /* On Unix we don't actually use this variable, but it's easier to handle the
+   * deallocation if we always allocate it, whether needed or not */
+  if (!_dbus_string_init (&progs))
+    _dbus_assert_not_reached ("OOM allocating progs");
 
+#ifdef DBUS_WIN
   if (_dbus_get_install_root(buffer, sizeof(buffer)))
     {
       strcat(buffer,DBUS_DATADIR);
@@ -3415,27 +3422,17 @@ test_default_session_servicedirs (void)
     }
 #endif
 
-  /* On Unix we don't actually use this variable, but it's easier to handle the
-   * deallocation if we always allocate it, whether needed or not */
-  if (!_dbus_string_init (&progs))
-    _dbus_assert_not_reached ("OOM allocating progs");
-
 #ifndef DBUS_UNIX
   common_progs = _dbus_getenv ("CommonProgramFiles");
 
   if (common_progs) 
     {
       if (!_dbus_string_append (&progs, common_progs)) 
-        {
-          _dbus_string_free (&progs);
-          return FALSE;
-        }
+        goto out;
 
       if (!_dbus_string_append (&progs, "/dbus-1/services")) 
-        {
-          _dbus_string_free (&progs);
-          return FALSE;
-        }
+        goto out;
+
       test_session_service_dir_matches[1] = _dbus_string_get_const_data(&progs);
     }
 #endif
@@ -3457,8 +3454,7 @@ test_default_session_servicedirs (void)
           printf ("error with default session service directories\n");
              dbus_free (link->data);
          _dbus_list_free_link (link);
-          _dbus_string_free (&progs);
-          return FALSE;
+          goto out;
         }
  
       dbus_free (link->data);
@@ -3485,8 +3481,7 @@ test_default_session_servicedirs (void)
           printf ("more directories parsed than in match set\n");
           dbus_free (link->data);
           _dbus_list_free_link (link);
-          _dbus_string_free (&progs);
-          return FALSE;
+          goto out;
         }
  
       if (strcmp (test_session_service_dir_matches[i], 
@@ -3497,8 +3492,7 @@ test_default_session_servicedirs (void)
                   test_session_service_dir_matches[i]);
           dbus_free (link->data);
           _dbus_list_free_link (link);
-          _dbus_string_free (&progs);
-          return FALSE;
+          goto out;
         }
 
       ++i;
@@ -3511,13 +3505,14 @@ test_default_session_servicedirs (void)
     {
       printf ("extra data %s in the match set was not matched\n",
               test_session_service_dir_matches[i]);
-
-      _dbus_string_free (&progs);
-      return FALSE;
+      goto out;
     }
-    
+
+  ret = TRUE;
+
+out:
   _dbus_string_free (&progs);
-  return TRUE;
+  return ret;
 }
 
 static const char *test_system_service_dir_matches[] =