mirror of
https://github.com/FeralInteractive/gamemode.git
synced 2025-06-07 08:07:20 +02:00
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.
This commit is contained in:
parent
c34186be07
commit
4a577b8c7c
@ -269,21 +269,21 @@ int game_mode_inhibit_screensaver(bool inhibit)
|
|||||||
const char *function = inhibit ? "Inhibit" : "UnInhibit";
|
const char *function = inhibit ? "Inhibit" : "UnInhibit";
|
||||||
|
|
||||||
sd_bus_message *msg = NULL;
|
sd_bus_message *msg = NULL;
|
||||||
sd_bus *bus = NULL;
|
sd_bus *bus_local = NULL;
|
||||||
sd_bus_error err;
|
sd_bus_error err;
|
||||||
memset(&err, 0, sizeof(sd_bus_error));
|
memset(&err, 0, sizeof(sd_bus_error));
|
||||||
|
|
||||||
int result = -1;
|
int result = -1;
|
||||||
|
|
||||||
// Open the user bus
|
// Open the user bus
|
||||||
int ret = sd_bus_open_user(&bus);
|
int ret = sd_bus_open_user(&bus_local);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
LOG_ERROR("Could not connect to user bus: %s\n", strerror(-ret));
|
LOG_ERROR("Could not connect to user bus: %s\n", strerror(-ret));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inhibit) {
|
if (inhibit) {
|
||||||
ret = sd_bus_call_method(bus,
|
ret = sd_bus_call_method(bus_local,
|
||||||
service,
|
service,
|
||||||
object_path,
|
object_path,
|
||||||
interface,
|
interface,
|
||||||
@ -294,7 +294,7 @@ int game_mode_inhibit_screensaver(bool inhibit)
|
|||||||
"com.feralinteractive.GameMode",
|
"com.feralinteractive.GameMode",
|
||||||
"GameMode Activated");
|
"GameMode Activated");
|
||||||
} else {
|
} else {
|
||||||
ret = sd_bus_call_method(bus,
|
ret = sd_bus_call_method(bus_local,
|
||||||
service,
|
service,
|
||||||
object_path,
|
object_path,
|
||||||
interface,
|
interface,
|
||||||
@ -330,5 +330,7 @@ int game_mode_inhibit_screensaver(bool inhibit)
|
|||||||
result = 0;
|
result = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sd_bus_unref(bus_local);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user