summaryrefslogtreecommitdiff
path: root/bus
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2011-01-17 11:46:09 +0000
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2011-02-16 14:47:08 +0000
commit75cfd97fc23b777a9bed4d6953b62bd5805cda7d (patch)
tree7d2159f72f32e4d91c7d5e56533f0b12ec76b717 /bus
parentfbecc334356510c333e2742cead8600296f618dc (diff)
update_desktop_file_entry: unify cleanup code for success and failure cases
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=33126
Diffstat (limited to 'bus')
-rw-r--r--bus/activation.c35
1 files changed, 17 insertions, 18 deletions
diff --git a/bus/activation.c b/bus/activation.c
index f69bf202..5a8eced8 100644
--- a/bus/activation.c
+++ b/bus/activation.c
@@ -264,6 +264,7 @@ update_desktop_file_entry (BusActivation *activation,
DBusStat stat_buf;
DBusString file_path;
DBusError tmp_error;
+ dbus_bool_t retval;
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
@@ -286,14 +287,14 @@ update_desktop_file_entry (BusActivation *activation,
!_dbus_concat_dir_and_file (&file_path, filename))
{
BUS_SET_OOM (error);
- goto failed;
+ goto finally;
}
if (!_dbus_stat (&file_path, &stat_buf, NULL))
{
dbus_set_error (error, DBUS_ERROR_FAILED,
"Can't stat the service file\n");
- goto failed;
+ goto finally;
}
if (!bus_desktop_file_get_string (desktop_file,
@@ -301,14 +302,14 @@ update_desktop_file_entry (BusActivation *activation,
DBUS_SERVICE_NAME,
&name,
error))
- goto failed;
+ goto finally;
if (!bus_desktop_file_get_string (desktop_file,
DBUS_SERVICE_SECTION,
DBUS_SERVICE_EXEC,
&exec_tmp,
error))
- goto failed;
+ goto finally;
exec = _dbus_strdup (_dbus_replace_install_prefix (exec_tmp));
dbus_free (exec_tmp);
@@ -325,7 +326,7 @@ update_desktop_file_entry (BusActivation *activation,
if (dbus_error_has_name (&tmp_error, DBUS_ERROR_NO_MEMORY))
{
dbus_move_error (&tmp_error, error);
- goto failed;
+ goto finally;
}
else
{
@@ -348,7 +349,7 @@ update_desktop_file_entry (BusActivation *activation,
if (dbus_error_has_name (&tmp_error, DBUS_ERROR_NO_MEMORY))
{
dbus_move_error (&tmp_error, error);
- goto failed;
+ goto finally;
}
else
{
@@ -373,14 +374,14 @@ update_desktop_file_entry (BusActivation *activation,
{
dbus_set_error (error, DBUS_ERROR_FAILED,
"Service %s already exists in activation entry list\n", name);
- goto failed;
+ goto finally;
}
entry = dbus_new0 (BusActivationEntry, 1);
if (entry == NULL)
{
BUS_SET_OOM (error);
- goto failed;
+ goto finally;
}
entry->name = name;
@@ -394,18 +395,19 @@ update_desktop_file_entry (BusActivation *activation,
exec = NULL;
user = NULL;
systemd_service = NULL;
+
entry->s_dir = s_dir;
entry->filename = _dbus_strdup (_dbus_string_get_const_data (filename));
if (!entry->filename)
{
BUS_SET_OOM (error);
- goto failed;
+ goto finally;
}
if (!_dbus_hash_table_insert_string (activation->entries, entry->name, bus_activation_entry_ref (entry)))
{
BUS_SET_OOM (error);
- goto failed;
+ goto finally;
}
if (!_dbus_hash_table_insert_string (s_dir->entries, entry->filename, bus_activation_entry_ref (entry)))
@@ -413,7 +415,7 @@ update_desktop_file_entry (BusActivation *activation,
/* Revert the insertion in the entries table */
_dbus_hash_table_remove_string (activation->entries, entry->name);
BUS_SET_OOM (error);
- goto failed;
+ goto finally;
}
_dbus_verbose ("Added \"%s\" to list of services\n", entry->name);
@@ -427,7 +429,7 @@ update_desktop_file_entry (BusActivation *activation,
{
_dbus_verbose ("The new service name \"%s\" of service file \"%s\" already in cache, ignoring\n",
name, _dbus_string_get_const_data (&file_path));
- goto failed;
+ goto finally;
}
dbus_free (entry->name);
@@ -458,13 +460,10 @@ update_desktop_file_entry (BusActivation *activation,
}
entry->mtime = stat_buf.mtime;
+ retval = TRUE;
- _dbus_string_free (&file_path);
- bus_activation_entry_unref (entry);
-
- return TRUE;
-
-failed:
+finally:
+ /* if these have been transferred into entry, the variables will be NULL */
dbus_free (name);
dbus_free (exec);
dbus_free (user);