From 0704ea57b7ed3f9c46f30afea3329a4e5a9d0ea9 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Tue, 7 Apr 2015 15:20:54 +0200 Subject: [PATCH] bus: use free_and_strdup() Save some LOCs by replacing strdup()+error-handling+free+assign with free_and_strdup(). --- src/libsystemd/sd-bus/bus-util.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/libsystemd/sd-bus/bus-util.c b/src/libsystemd/sd-bus/bus-util.c index 45882abaad9..ea2379db30e 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; }