From: Susant Sahani Date: Mon, 18 Jan 2021 18:10:57 +0000 (+0100) Subject: core: dbus - use set_ensure_put X-Git-Tag: v248-rc1~306^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9b059ee0222be8393fdef5575eb78927ba4ef0a4;p=thirdparty%2Fsystemd.git core: dbus - use set_ensure_put --- diff --git a/src/core/dbus.c b/src/core/dbus.c index 3e435c98ca2..5db484b8de6 100644 --- a/src/core/dbus.c +++ b/src/core/dbus.c @@ -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.");