From 69395d4b08156c476c2275c4489992a5094e1787 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 2 Nov 2015 14:15:14 +0000 Subject: [PATCH 2/3] 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 --- bus/config-parser.c | 45 ++++++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/bus/config-parser.c b/bus/config-parser.c index 16cddbe..5249b6b 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[] = -- 2.6.2