ws_pipe_spawn_sync: mark arguments as const where possible
authorPeter Wu <peter@lekensteyn.nl>
Thu, 22 Nov 2018 15:45:41 +0000 (16:45 +0100)
committerAnders Broman <a.broman58@gmail.com>
Thu, 22 Nov 2018 20:49:44 +0000 (20:49 +0000)
This avoids an unnecessary explicit cast. For clarity, rename the
working directory argument to match g_spawn_sync.

Change-Id: Idf7072cd590e686294d953f77da2a52c861a89c0
Reviewed-on: https://code.wireshark.org/review/30763
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
extcap.c
wsutil/ws_pipe.c
wsutil/ws_pipe.h

index 8bab624eed258377d80099a265792ff671a43a6f..cc3abd437e7d218e11b2537929624fd08d223bb8 100644 (file)
--- a/extcap.c
+++ b/extcap.c
@@ -347,7 +347,7 @@ static gboolean extcap_foreach(GList * arguments,
                     continue;
                 }
 
-                if (ws_pipe_spawn_sync((gchar *) dirname, extcap_path->str, cnt, args, &command_output))
+                if (ws_pipe_spawn_sync(dirname, extcap_path->str, cnt, args, &command_output))
                 {
                     cb_info.output = command_output;
                     cb_info.extcap = extcap_path->str;
@@ -358,7 +358,7 @@ static gboolean extcap_foreach(GList * arguments,
                 {
                     gchar ** fb_args = extcap_convert_arguments_to_array(fallback_arguments);
 
-                    if (ws_pipe_spawn_sync((gchar *) dirname, extcap_path->str, g_list_length(fallback_arguments), fb_args, &command_output))
+                    if (ws_pipe_spawn_sync(dirname, extcap_path->str, g_list_length(fallback_arguments), fb_args, &command_output))
                     {
                         cb_info.output = command_output;
                         cb_info.extcap = extcap_path->str;
index 90a3b84d97819c6e1fbd80806a727280c986a793..4615400900bdc74dec31daaceacb61058cb30f46 100644 (file)
@@ -33,7 +33,7 @@
 #include "wsutil/filesystem.h"
 #include "wsutil/ws_pipe.h"
 
-gboolean ws_pipe_spawn_sync(gchar *dirname, gchar *command, gint argc, gchar **args, gchar **command_output)
+gboolean ws_pipe_spawn_sync(const gchar *working_directory, const gchar *command, gint argc, gchar **args, gchar **command_output)
 {
     gboolean status = FALSE;
     gboolean result = FALSE;
@@ -212,7 +212,7 @@ gboolean ws_pipe_spawn_sync(gchar *dirname, gchar *command, gint argc, gchar **a
     g_setenv("PATH", oldpath, TRUE);
 #else
 
-    status = g_spawn_sync(dirname, argv, NULL,
+    status = g_spawn_sync(working_directory, argv, NULL,
                           (GSpawnFlags) 0, NULL, NULL, &local_output, NULL, &exit_status, NULL);
 
     if (status && exit_status != 0)
index 57403930d6cf734f9b8ac672ed8f7fa09a6b4984..0a3cad3c17715a63386a9f49294c682dbcb9dfc8 100644 (file)
@@ -42,14 +42,14 @@ typedef struct _ws_pipe_t {
 /**
  * @brief Run a process using g_spawn_sync on UNIX and Linux, and
  *        CreateProcess on Windows. Wait for it to finish.
- * @param [IN] dirname Initial working directory.
+ * @param [IN] working_directory Initial working directory.
  * @param [IN] command Command to run.
  * @param [IN] argc Number of arguments for the command, not including the command itself.
  * @param [IN] argv Arguments for the command, not including the command itself.
  * @param [OUT] command_output If not NULL, receives a copy of the command output. Must be g_freed.
  * @return TRUE on success or FALSE on failure.
  */
-WS_DLL_PUBLIC gboolean ws_pipe_spawn_sync ( gchar * dirname, gchar * command, gint argc, gchar ** argv, gchar ** command_output );
+WS_DLL_PUBLIC gboolean ws_pipe_spawn_sync(const gchar * working_directory, const gchar * command, gint argc, gchar ** argv, gchar ** command_output);
 
 /**
  * @brief Initialize a ws_pipe_t struct. Sets .pid to WS_INVALID_PID and all other members to 0 or NULL.