[systemd-commits] src/libsystemd

David Herrmann dvdhrm at kemper.freedesktop.org
Thu Aug 28 13:45:28 PDT 2014


 src/libsystemd/sd-event/sd-event.c |   13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

New commits:
commit 32b13b2f58b916ea22626e89cdd8cdb70ca6b6c9
Author: David Herrmann <dh.herrmann at gmail.com>
Date:   Thu Aug 28 22:44:28 2014 +0200

    sd-event: simplify sd_event_source_set_name()
    
    free_and_strdup() does exactly the same as sd_event_source_set_name(), use
    it!

diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c
index c92e065..985ff28 100644
--- a/src/libsystemd/sd-event/sd-event.c
+++ b/src/libsystemd/sd-event/sd-event.c
@@ -1227,20 +1227,9 @@ _public_ sd_event_source* sd_event_source_unref(sd_event_source *s) {
 }
 
 _public_ int sd_event_source_set_name(sd_event_source *s, const char *name) {
-        char *new_name = NULL;
-
         assert_return(s, -EINVAL);
 
-        if (name) {
-                new_name = strdup(name);
-                if (!new_name)
-                        return -ENOMEM;
-        }
-
-        free(s->name);
-        s->name = new_name;
-
-        return 0;
+        return free_and_strdup(&s->name, name);
 }
 
 _public_ int sd_event_source_get_name(sd_event_source *s, const char **name) {



More information about the systemd-commits mailing list