summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Withnall <pwithnall@endlessos.org>2021-11-15 12:17:50 +0000
committerRay Strode <halfline@gmail.com>2021-12-10 14:53:40 +0000
commitbef44514ea306b42d07f58d6744658d5a2d651b4 (patch)
tree4860e89882e8c34d476e0020e94ae967dc69aeb9
parent5692e121313c315c09d271e87445b6d4a5c6e650 (diff)
downloadgnome-session-bef44514ea306b42d07f58d6744658d5a2d651b4.tar.gz
dbus-client: Simplify some memory handling
Use `g_autoptr()` to remove a label and simplify the control flow. This introduces no functional changes. Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
-rw-r--r--gnome-session/gsm-dbus-client.c27
1 files changed, 8 insertions, 19 deletions
diff --git a/gnome-session/gsm-dbus-client.c b/gnome-session/gsm-dbus-client.c
index b42faff7..cf3b1f15 100644
--- a/gnome-session/gsm-dbus-client.c
+++ b/gnome-session/gsm-dbus-client.c
@@ -140,19 +140,15 @@ get_caller_info (GsmDBusClient *client,
uid_t *calling_uid_out,
pid_t *calling_pid_out)
{
- GDBusConnection *connection;
- gboolean retval;
+ g_autoptr(GDBusConnection) connection = NULL;
GError *error;
- GVariant *uid_variant, *pid_variant;
+ g_autoptr(GVariant) uid_variant = NULL;
+ g_autoptr(GVariant) pid_variant = NULL;
uid_t uid;
pid_t pid;
- retval = FALSE;
- connection = NULL;
- uid_variant = pid_variant = NULL;
-
if (sender == NULL) {
- goto out;
+ return FALSE;
}
error = NULL;
@@ -161,7 +157,7 @@ get_caller_info (GsmDBusClient *client,
if (error != NULL) {
g_warning ("error getting session bus: %s", error->message);
g_error_free (error);
- goto out;
+ return FALSE;
}
uid_variant = g_dbus_connection_call_sync (connection,
@@ -177,7 +173,7 @@ get_caller_info (GsmDBusClient *client,
if (error != NULL) {
g_debug ("GetConnectionUnixUser() failed: %s", error->message);
g_error_free (error);
- goto out;
+ return FALSE;
}
pid_variant = g_dbus_connection_call_sync (connection,
@@ -193,7 +189,7 @@ get_caller_info (GsmDBusClient *client,
if (error != NULL) {
g_debug ("GetConnectionUnixProcessID() failed: %s", error->message);
g_error_free (error);
- goto out;
+ return FALSE;
}
g_variant_get (uid_variant, "(u)", &uid);
@@ -206,17 +202,10 @@ get_caller_info (GsmDBusClient *client,
*calling_pid_out = pid;
}
- retval = TRUE;
-
g_debug ("uid = %d", uid);
g_debug ("pid = %d", pid);
-out:
- g_clear_pointer (&uid_variant, (GDestroyNotify) g_variant_unref);
- g_clear_pointer (&pid_variant, (GDestroyNotify) g_variant_unref);
- g_clear_object (&connection);
-
- return retval;
+ return TRUE;
}
static void