From 9b059ee0222be8393fdef5575eb78927ba4ef0a4 Mon Sep 17 00:00:00 2001 From: Susant Sahani Date: Mon, 18 Jan 2021 19:10:57 +0100 Subject: [PATCH] core: dbus - use set_ensure_put --- src/core/dbus.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) 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."); -- 2.47.3