Misc: Minor cleanup

This commit is contained in:
CharlesThobe 2023-05-03 17:08:00 +03:00 committed by refractionpcsx2
parent 30f7685435
commit 7aff4ee4cb
1 changed files with 14 additions and 15 deletions

View File

@ -75,9 +75,9 @@ std::string GetOSVersionString()
#ifdef DBUS_API
static dbus_uint32_t s_screensaver_dbus_cookie;
bool ChangeScreenSaverStateDBus(const bool inhibit_requested, const char* program_name, const char* reason)
{
static dbus_uint32_t s_cookie;
// "error_dbus" doesn't need to be cleared in the end with "dbus_message_unref" at least if there is
// no error set, since calling "dbus_error_free" reinitializes it like "dbus_error_init" after freeing.
DBusError error_dbus;
@ -109,9 +109,8 @@ bool ChangeScreenSaverStateDBus(const bool inhibit_requested, const char* progra
else
{
// Only Append the cookie.
if (!dbus_message_iter_append_basic(&message_itr, DBUS_TYPE_UINT32, &s_screensaver_dbus_cookie))
if (!dbus_message_iter_append_basic(&message_itr, DBUS_TYPE_UINT32, &s_cookie))
goto cleanup;
s_screensaver_dbus_cookie = 0;
}
// Send message and get response.
if (!(response = dbus_connection_send_with_reply_and_block(connection, message, DBUS_TIMEOUT_USE_DEFAULT, &error_dbus))
@ -120,7 +119,7 @@ bool ChangeScreenSaverStateDBus(const bool inhibit_requested, const char* progra
if (inhibit_requested)
{
// Get the cookie from the response message.
if (!dbus_message_get_args(response, &error_dbus, DBUS_TYPE_UINT32, &s_screensaver_dbus_cookie, DBUS_TYPE_INVALID))
if (!dbus_message_get_args(response, &error_dbus, DBUS_TYPE_UINT32, &s_cookie, DBUS_TYPE_INVALID))
goto cleanup;
}
dbus_message_unref(message);