]> git.ipfire.org Git - pakfire.git/commitdiff
libpakfire: execute: Make argv const
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 11 Jan 2021 17:53:00 +0000 (17:53 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 11 Jan 2021 17:53:00 +0000 (17:53 +0000)
This would be easier to handle because it usually comes as a const array
and we can avoid creating a copy of it.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/execute.c
src/libpakfire/include/pakfire/execute.h

index 4025a20612556e386cc770089b39b48ad20be7b0..59f98743bd9119ce28805457c1bf1c694d1e3618 100644 (file)
@@ -36,7 +36,7 @@ struct pakfire_execute_env {
     Pakfire pakfire;
     const char* root;
     const char* command;
-    char** argv;
+    const char** argv;
     char* envp[20];
 };
 
@@ -55,13 +55,13 @@ static int pakfire_execute_fork(Pakfire pakfire, struct pakfire_execute_env* env
     }
 
     // exec() command
-    r = execve(env->command, env->argv, env->envp);
+    r = execve(env->command, (char**)env->argv, env->envp);
 
     // We should not get here
     return errno;
 }
 
-PAKFIRE_EXPORT int pakfire_execute(Pakfire pakfire, const char* command, char** argv, int flags) {
+PAKFIRE_EXPORT int pakfire_execute(Pakfire pakfire, const char* command, const char** argv, int flags) {
     struct pakfire_execute_env env;
 
     // Setup environment
index d15459d3f5e78ef993acf31e059c8e63cfc08dbd..8f2b46bcc4d88b03085f55c9934c4df0642a4a7c 100644 (file)
@@ -23,6 +23,6 @@
 
 #include <pakfire/types.h>
 
-int pakfire_execute(Pakfire pakfire, const char* command, char** argv, int flags);
+int pakfire_execute(Pakfire pakfire, const char* command, const char** argv, int flags);
 
 #endif /* PAKFIRE_EXECUTE_H */