From: phk Date: Tue, 4 Apr 2006 07:46:30 +0000 (+0000) Subject: Reverse constification of Argv functions. After cascading through all X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=34cc972ee706ca0c069bdcaffad74b13bae9739b;p=varnish Reverse constification of Argv functions. After cascading through all the CLI functions we hit the fact that the evbuffer functions in libevent are not properly constified. It's better to deconst the error messages and just "let it be known" that argv[0] is const (or NULL). git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@110 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/include/cli_priv.h b/varnish-cache/include/cli_priv.h index 24bb76d5..841b3d4f 100644 --- a/varnish-cache/include/cli_priv.h +++ b/varnish-cache/include/cli_priv.h @@ -11,7 +11,7 @@ struct cli; /* NB: struct cli is opaque at this level. */ -typedef void cli_func_t(struct cli*, const char **av, void *priv); +typedef void cli_func_t(struct cli*, char **av, void *priv); struct cli_proto { /* These must match the CLI_* macros in cli.h */ diff --git a/varnish-cache/include/libvarnish.h b/varnish-cache/include/libvarnish.h index 8c332a2b..963d4350 100644 --- a/varnish-cache/include/libvarnish.h +++ b/varnish-cache/include/libvarnish.h @@ -3,8 +3,8 @@ */ /* from libvarnish/argv.c */ -void FreeArgv(const char **argv); -const char **ParseArgv(const char *s, int comment); +void FreeArgv(char **argv); +char **ParseArgv(const char *s, int comment); /* Assert zero return value */ diff --git a/varnish-cache/lib/libvarnish/argv.c b/varnish-cache/lib/libvarnish/argv.c index 50e31c68..8448a8d9 100644 --- a/varnish-cache/lib/libvarnish/argv.c +++ b/varnish-cache/lib/libvarnish/argv.c @@ -96,10 +96,10 @@ BackSlashDecode(const char *s, const char *e) return (p); } -const char ** +char ** ParseArgv(const char *s, int comment) { - const char **argv; + char **argv; const char *p; int nargv, largv; int i, quote; @@ -131,7 +131,7 @@ ParseArgv(const char *s, int comment) if (*s == '\\') { i = BackSlash(s, NULL); if (i == 0) { - argv[0] = "Illegal backslash sequence"; + argv[0] = (void*)(uintptr_t)"Illegal backslash sequence"; return (argv); } s += i; @@ -146,7 +146,7 @@ ParseArgv(const char *s, int comment) if (*s == '"') break; if (*s == '\0') { - argv[0] = "Missing '\"'"; + argv[0] = (void*)(uintptr_t)"Missing '\"'"; return (argv); } s++; @@ -164,12 +164,12 @@ ParseArgv(const char *s, int comment) } void -FreeArgv(const char **argv) +FreeArgv(char **argv) { int i; for (i = 1; argv[i] != NULL; i++) - free((void *)(uintptr_t)argv[i]); + free(argv[i]); free(argv); } diff --git a/varnish-cache/lib/libvarnish/cli.c b/varnish-cache/lib/libvarnish/cli.c index 4e75acf0..1e665303 100644 --- a/varnish-cache/lib/libvarnish/cli.c +++ b/varnish-cache/lib/libvarnish/cli.c @@ -19,7 +19,7 @@ */ void -cli_func_help(struct cli *cli, const char **av, void *priv) +cli_func_help(struct cli *cli, char **av, void *priv) { struct cli_proto *cp; @@ -41,7 +41,7 @@ cli_func_help(struct cli *cli, const char **av, void *priv) void cli_dispatch(struct cli *cli, struct cli_proto *clp, const char *line) { - const char **av; + char **av; unsigned u; struct cli_proto *cp;