]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: dbus - use set_ensure_put
authorSusant Sahani <ssahani@vmware.com>
Mon, 18 Jan 2021 18:10:57 +0000 (19:10 +0100)
committerSusant Sahani <ssahani@vmware.com>
Mon, 18 Jan 2021 20:53:22 +0000 (21:53 +0100)
src/core/dbus.c

index 3e435c98ca2ec64bd9f98a1cf9bc9e24f730f2b5..5db484b8de64531da0a9c5a0dc126d0d813b6dd7 100644 (file)
@@ -679,12 +679,6 @@ static int bus_on_connection(sd_event_source *s, int fd, uint32_t revents, void
                 return 0;
         }
 
-        r = set_ensure_allocated(&m->private_buses, NULL);
-        if (r < 0) {
-                log_oom();
-                return 0;
-        }
-
         r = sd_bus_new(&bus);
         if (r < 0) {
                 log_warning_errno(r, "Failed to allocate new private connection bus: %m");
@@ -752,13 +746,17 @@ static int bus_on_connection(sd_event_source *s, int fd, uint32_t revents, void
                 return 0;
         }
 
-        r = set_put(m->private_buses, bus);
+        r = set_ensure_put(&m->private_buses, NULL, bus);
+        if (r == -ENOMEM) {
+                log_oom();
+                return 0;
+        }
         if (r < 0) {
                 log_warning_errno(r, "Failed to add new connection bus to set: %m");
                 return 0;
         }
 
-        bus = NULL;
+        TAKE_PTR(bus);
 
         log_debug("Accepted new private connection.");