summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@gmail.com>2015-04-07 15:20:54 +0200
committerDavid Herrmann <dh.herrmann@gmail.com>2015-04-09 22:59:59 +0200
commit0704ea57b7ed3f9c46f30afea3329a4e5a9d0ea9 (patch)
tree8359cc11c789522e105ff130549f819a1680aaa0
parent0a790ab540b7669cc9711dc9bf22e09ac8dcff5a (diff)
bus: use free_and_strdup()
Save some LOCs by replacing strdup()+error-handling+free+assign with free_and_strdup().
-rw-r--r--src/libsystemd/sd-bus/bus-util.c10
1 files changed, 1 insertions, 9 deletions
diff --git a/src/libsystemd/sd-bus/bus-util.c b/src/libsystemd/sd-bus/bus-util.c
index 45882abaad..ea2379db30 100644
--- a/src/libsystemd/sd-bus/bus-util.c
+++ b/src/libsystemd/sd-bus/bus-util.c
@@ -946,7 +946,6 @@ static int map_basic(sd_bus *bus, const char *member, sd_bus_message *m, sd_bus_
switch (type) {
case SD_BUS_TYPE_STRING: {
const char *s;
- char *str;
char **p = userdata;
r = sd_bus_message_read_basic(m, type, &s);
@@ -956,14 +955,7 @@ static int map_basic(sd_bus *bus, const char *member, sd_bus_message *m, sd_bus_
if (isempty(s))
break;
- str = strdup(s);
- if (!str) {
- r = -ENOMEM;
- break;
- }
- free(*p);
- *p = str;
-
+ r = free_and_strdup(p, s);
break;
}