]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-event: make _ref() calls NOPs when NULL is passed to them
authorLennart Poettering <lennart@poettering.net>
Thu, 19 Nov 2015 22:32:52 +0000 (23:32 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 19 Nov 2015 22:36:03 +0000 (23:36 +0100)
Let's make _ref() calls happy when NULL is passed to them, and simply
return NULL without any assertion logic. This makes them nicely
symmetric to the _unref() calls which also are happy to take NULL and
become NOPs then.

src/libsystemd/sd-event/sd-event.c

index 700ac691b5ba0710a3e67ba2fed4220c62b0c558..e68d76708a99c766d7ba4a7cbc93c61afd084ad2 100644 (file)
@@ -437,7 +437,9 @@ fail:
 }
 
 _public_ sd_event* sd_event_ref(sd_event *e) {
-        assert_return(e, NULL);
+
+        if (!e)
+                return NULL;
 
         assert(e->n_ref >= 1);
         e->n_ref++;
@@ -1339,7 +1341,9 @@ _public_ int sd_event_add_exit(
 }
 
 _public_ sd_event_source* sd_event_source_ref(sd_event_source *s) {
-        assert_return(s, NULL);
+
+        if (!s)
+                return NULL;
 
         assert(s->n_ref >= 1);
         s->n_ref++;