diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Keep string literals behind const pointers
Git's DEVELOPER=1 build turns on -Wwrite-strings as an error, and the
literals stored through plain char pointers failed cgit's own objects
there. The exec filter's argv takes the cast execvp needs once, the
way git's run-command does.
Diffstat (limited to 'source/filter.c')
| -rw-r--r-- | source/filter.c | 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
1 file changed, 4 insertions, 3 deletions
diff --git a/source/filter.c b/source/filter.c index 6e16537..3ffd077 100644 --- a/source/filter.c +++ b/source/filter.c @@ -47,7 +47,8 @@ static int open_exec_filter(struct cgit_filter *base, va_list ap) // cgit ignores SIGPIPE and the disposition survives exec, so a // filter that writes to a closed pipe would otherwise carry on. signal(SIGPIPE, SIG_DFL); - execvp(filter->cmd, filter->argv); + // execvp leaves argv alone, but its prototype predates const. + execvp(filter->cmd, (char *const *)filter->argv); // The child shares the parent's page buffer, cache lock and exit // handlers, so it must not die through them. fprintf(stderr, "[cgit] Unable to exec filter %s: %s\n", filter->cmd, strerror(errno)); @@ -95,7 +96,7 @@ static void cleanup_exec_filter(struct cgit_filter *base) free(filter->argv); filter->argv = NULL; - free(filter->cmd); + free((char *)filter->cmd); filter->cmd = NULL; } @@ -116,7 +117,7 @@ static struct cgit_filter *new_exec_filter(const char *cmd, int argument_count) return &filter->base; } -void cgit_exec_filter_init(struct cgit_exec_filter *filter, char *cmd, char **argv) +void cgit_exec_filter_init(struct cgit_exec_filter *filter, const char *cmd, const char **argv) { memset(filter, 0, sizeof(*filter)); filter->base.open = open_exec_filter; |
