[gnome-initial-setup/mcatanzaro/resurrect-software-page: 9/9] pkexec: Modernize with g_autoptr()
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-initial-setup/mcatanzaro/resurrect-software-page: 9/9] pkexec: Modernize with g_autoptr()
- Date: Tue, 10 Aug 2021 09:40:54 +0000 (UTC)
commit 8cb135b07710e094e60687796aeb64f85e2a0021
Author: Will Thompson <wjt endlessos org>
Date: Mon Aug 9 11:24:38 2021 +0100
pkexec: Modernize with g_autoptr()
The original version of this function (in Endless's fork) either
predated g_autoptr() being available for GSubprocess[Launcher], or
predated me knowing about it.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-initial-setup/-/merge_requests/121>
gnome-initial-setup/gis-pkexec.c | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
---
diff --git a/gnome-initial-setup/gis-pkexec.c b/gnome-initial-setup/gis-pkexec.c
index 5fb88090..9e1bfa9a 100644
--- a/gnome-initial-setup/gis-pkexec.c
+++ b/gnome-initial-setup/gis-pkexec.c
@@ -31,12 +31,11 @@ gis_pkexec (const gchar *command,
const gchar *user,
GError **error)
{
- GSubprocessLauncher *launcher = NULL;
- GSubprocess *process = NULL;
+ g_autoptr(GSubprocessLauncher) launcher = NULL;
+ g_autoptr(GSubprocess) process = NULL;
const gchar * const root_argv[] = { "pkexec", command, arg1, NULL };
const gchar * const user_argv[] = { "pkexec", "--user", user, command, arg1, NULL };
const gchar * const *argv = user == NULL ? root_argv : user_argv;
- gboolean ret = FALSE;
launcher = g_subprocess_launcher_new (G_SUBPROCESS_FLAGS_NONE);
@@ -48,18 +47,13 @@ gis_pkexec (const gchar *command,
if (!process) {
g_prefix_error (error, "Failed to create %s process: ", command);
- goto out;
+ return FALSE;
}
if (!g_subprocess_wait_check (process, NULL, error)) {
g_prefix_error (error, "%s failed: ", command);
- goto out;
+ return FALSE;
}
- ret = TRUE;
-
-out:
- g_clear_object (&process);
- g_clear_object (&launcher);
- return ret;
+ return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]