From 4a577b8c7c80eece1a4251f2cc48eff1dafc014a Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Thu, 21 Mar 2019 13:54:59 +0100 Subject: [PATCH] Rename local variable to un-shadow the global bus The local variable 'bus' was shadowing the global 'bus' variable; to not confuse the two, rename the local one. Also unref the local bus, i.e. fix a small memory leak. --- daemon/dbus_messaging.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/daemon/dbus_messaging.c b/daemon/dbus_messaging.c index ca52486..ac72c9c 100644 --- a/daemon/dbus_messaging.c +++ b/daemon/dbus_messaging.c @@ -269,21 +269,21 @@ int game_mode_inhibit_screensaver(bool inhibit) const char *function = inhibit ? "Inhibit" : "UnInhibit"; sd_bus_message *msg = NULL; - sd_bus *bus = NULL; + sd_bus *bus_local = NULL; sd_bus_error err; memset(&err, 0, sizeof(sd_bus_error)); int result = -1; // Open the user bus - int ret = sd_bus_open_user(&bus); + int ret = sd_bus_open_user(&bus_local); if (ret < 0) { LOG_ERROR("Could not connect to user bus: %s\n", strerror(-ret)); return -1; } if (inhibit) { - ret = sd_bus_call_method(bus, + ret = sd_bus_call_method(bus_local, service, object_path, interface, @@ -294,7 +294,7 @@ int game_mode_inhibit_screensaver(bool inhibit) "com.feralinteractive.GameMode", "GameMode Activated"); } else { - ret = sd_bus_call_method(bus, + ret = sd_bus_call_method(bus_local, service, object_path, interface, @@ -330,5 +330,7 @@ int game_mode_inhibit_screensaver(bool inhibit) result = 0; } + sd_bus_unref(bus_local); + return result; }