[at-spi2-core/gnome-41: 4/14] Use a helper variable for the --address command line argument




commit 313fd9bc2a8170c0bf4f4b8c7393742ef3cb1196
Author: Federico Mena Quintero <federico gnome org>
Date:   Thu Dec 9 18:10:52 2021 -0600

    Use a helper variable for the --address command line argument
    
    It's awkward to fiddle with argv[HARDCODED_NUMBER] later.

 bus/at-spi-bus-launcher.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
---
diff --git a/bus/at-spi-bus-launcher.c b/bus/at-spi-bus-launcher.c
index a9c8c0da..b253076e 100644
--- a/bus/at-spi-bus-launcher.c
+++ b/bus/at-spi-bus-launcher.c
@@ -308,7 +308,18 @@ setup_bus_child_daemon (gpointer data)
 static gboolean
 ensure_a11y_bus_daemon (A11yBusLauncher *app, char *config_path)
 {
-  char *argv[] = { DBUS_DAEMON, config_path, "--nofork", "--print-address", "3", NULL, NULL };
+  char *address_param;
+
+  if (app->socket_name)
+    {
+      address_param = g_strconcat ("--address=unix:path=", app->socket_name, NULL);
+    }
+  else
+    {
+      address_param = NULL;
+    }
+
+  char *argv[] = { DBUS_DAEMON, config_path, "--nofork", "--print-address", "3", address_param, NULL };
   GPid pid;
   char addr_buf[2048];
   GError *error = NULL;
@@ -318,9 +329,6 @@ ensure_a11y_bus_daemon (A11yBusLauncher *app, char *config_path)
 
   g_clear_pointer (&app->a11y_launch_error_message, g_free);
 
-  if (app->socket_name)
-    argv[5] = g_strconcat ("--address=unix:path=", app->socket_name, NULL);
-
   if (!g_spawn_async (NULL,
                       argv,
                       NULL,
@@ -333,11 +341,11 @@ ensure_a11y_bus_daemon (A11yBusLauncher *app, char *config_path)
       app->a11y_bus_pid = -1;
       app->a11y_launch_error_message = g_strdup (error->message);
       g_clear_error (&error);
-      g_free (argv[5]);
+      g_free (address_param);
       goto error;
     }
 
-  g_free (argv[5]);
+  g_free (address_param);
   close (app->pipefd[1]);
   app->pipefd[1] = -1;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]