Skip to content

Commit 09884f3

Browse files
rscharfegitster
authored andcommitted
mingw: make argv2 in try_shell_exec() non-const
Prepare for a stricter type check in COPY_ARRAY by removing the const qualifier of argv2, like we already do to placate Visual Studio. We have to add it back using explicit casts when actually using the variable, unfortunately, because GCC (rightly) refuses to add it implicitly. Similar casts are already used in mingw_execv(). Signed-off-by: René Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6bae53b commit 09884f3

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

compat/mingw.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1839,16 +1839,13 @@ static int try_shell_exec(const char *cmd, char *const *argv)
18391839
if (prog) {
18401840
int exec_id;
18411841
int argc = 0;
1842-
#ifndef _MSC_VER
1843-
const
1844-
#endif
18451842
char **argv2;
18461843
while (argv[argc]) argc++;
18471844
ALLOC_ARRAY(argv2, argc + 1);
18481845
argv2[0] = (char *)cmd; /* full path to the script file */
18491846
COPY_ARRAY(&argv2[1], &argv[1], argc);
1850-
exec_id = trace2_exec(prog, argv2);
1851-
pid = mingw_spawnv(prog, argv2, 1);
1847+
exec_id = trace2_exec(prog, (const char **)argv2);
1848+
pid = mingw_spawnv(prog, (const char **)argv2, 1);
18521849
if (pid >= 0) {
18531850
int status;
18541851
if (waitpid(pid, &status, 0) < 0)

0 commit comments

Comments
 (0)