summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2015-11-02 14:15:14 +0000
committerRalf Habacker <ralf.habacker@freenet.de>2015-11-02 23:22:42 +0100
commit50b07fbb01d3f6fd42cc083f2ed0fb8670d1d37c (patch)
tree9cfbc39890402b3b3763a44c333dc669f9e3a9bf
parentd774aa9561e56ae0eb552a1f67ee5e53e92f7e8e (diff)
downloaddbus-50b07fbb01d3f6fd42cc083f2ed0fb8670d1d37c.tar.gz
test_default_session_servicedirs: simplify to a single exit code-path
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>
-rw-r--r--bus/config-parser.c45
1 files changed, 20 insertions, 25 deletions
diff --git a/bus/config-parser.c b/bus/config-parser.c
index 3f59730b..3a5ecc34 100644
--- a/bus/config-parser.c
+++ b/bus/config-parser.c
@@ -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[] =