summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorJonathan Boulle <jonathanboulle@gmail.com>2016-05-18 01:30:37 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-05-17 19:30:37 -0400
commita363a2e45f67eea5cc0a8fbbfc4a514f1b015cf7 (patch)
treeab32e7d7476b53a054f7bfe0cb8d78ef7061d057 /src/core
parentd6f5a432b08a2fd8652514735f8e2b51146cdcbb (diff)
core/dbus: use free_and_strdup to simplify code (#3279)
Makes it consistent with the other branches here.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/dbus-execute.c38
1 files changed, 7 insertions, 31 deletions
diff --git a/src/core/dbus-execute.c b/src/core/dbus-execute.c
index 9dfca14914..646bd779a2 100644
--- a/src/core/dbus-execute.c
+++ b/src/core/dbus-execute.c
@@ -839,16 +839,8 @@ int bus_exec_context_set_transient_property(
if (isempty(uu))
c->user = mfree(c->user);
- else {
- char *t;
-
- t = strdup(uu);
- if (!t)
- return -ENOMEM;
-
- free(c->user);
- c->user = t;
- }
+ else if (free_and_strdup(&c->user, uu) < 0)
+ return -ENOMEM;
unit_write_drop_in_private_format(u, mode, name, "User=%s\n", uu);
}
@@ -866,16 +858,8 @@ int bus_exec_context_set_transient_property(
if (isempty(gg))
c->group = mfree(c->group);
- else {
- char *t;
-
- t = strdup(gg);
- if (!t)
- return -ENOMEM;
-
- free(c->group);
- c->group = t;
- }
+ else if (free_and_strdup(&c->group, gg) < 0)
+ return -ENOMEM;
unit_write_drop_in_private_format(u, mode, name, "Group=%s\n", gg);
}
@@ -890,18 +874,10 @@ int bus_exec_context_set_transient_property(
if (mode != UNIT_CHECK) {
- if (isempty(id)) {
+ if (isempty(id))
c->syslog_identifier = mfree(c->syslog_identifier);
- } else {
- char *t;
-
- t = strdup(id);
- if (!t)
- return -ENOMEM;
-
- free(c->syslog_identifier);
- c->syslog_identifier = t;
- }
+ else if (free_and_strdup(&c->syslog_identifier, id) < 0)
+ return -ENOMEM;
unit_write_drop_in_private_format(u, mode, name, "SyslogIdentifier=%s\n", id);
}