From f71fd5094743d10c172819daebf691ccf33bd88f Mon Sep 17 00:00:00 2001 From: phk Date: Tue, 25 Sep 2007 10:25:51 +0000 Subject: [PATCH] Make the arguments to CLI functions const-const. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@2036 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishd/cache.h | 4 ++-- varnish-cache/bin/varnishd/cache_ban.c | 4 ++-- varnish-cache/bin/varnishd/cache_cli.c | 2 +- varnish-cache/bin/varnishd/cache_pool.c | 2 +- varnish-cache/bin/varnishd/cache_vcl.c | 8 ++++---- varnish-cache/bin/varnishd/mgt_child.c | 4 ++-- varnish-cache/bin/varnishd/mgt_cli.c | 13 +++++++------ varnish-cache/bin/varnishd/mgt_param.c | 4 ++-- varnish-cache/bin/varnishd/mgt_vcc.c | 12 ++++++------ varnish-cache/include/cli_priv.h | 2 +- varnish-cache/lib/libvarnish/cli.c | 4 ++-- varnish-cache/lib/libvarnish/cli_common.c | 2 +- 12 files changed, 31 insertions(+), 30 deletions(-) diff --git a/varnish-cache/bin/varnishd/cache.h b/varnish-cache/bin/varnishd/cache.h index 499c2ef2..a511ba9b 100644 --- a/varnish-cache/bin/varnishd/cache.h +++ b/varnish-cache/bin/varnishd/cache.h @@ -413,8 +413,8 @@ extern struct backend_method backend_method_round_robin; /* cache_ban.c */ void AddBan(const char *, int hash); void BAN_Init(void); -void cli_func_url_purge(struct cli *cli, char **av, void *priv); -void cli_func_hash_purge(struct cli *cli, char **av, void *priv); +void cli_func_url_purge(struct cli *cli, const char * const *av, void *priv); +void cli_func_hash_purge(struct cli *cli, const char * const *av, void *priv); void BAN_NewObj(struct object *o); int BAN_CheckObject(struct object *o, const char *url, const char *hash); diff --git a/varnish-cache/bin/varnishd/cache_ban.c b/varnish-cache/bin/varnishd/cache_ban.c index 2cd7ffa8..2bdc77ef 100644 --- a/varnish-cache/bin/varnishd/cache_ban.c +++ b/varnish-cache/bin/varnishd/cache_ban.c @@ -102,7 +102,7 @@ BAN_CheckObject(struct object *o, const char *url, const char *hash) } void -cli_func_url_purge(struct cli *cli, char **av, void *priv) +cli_func_url_purge(struct cli *cli, const char * const *av, void *priv) { (void)priv; @@ -111,7 +111,7 @@ cli_func_url_purge(struct cli *cli, char **av, void *priv) } void -cli_func_hash_purge(struct cli *cli, char **av, void *priv) +cli_func_hash_purge(struct cli *cli, const char * const *av, void *priv) { (void)priv; diff --git a/varnish-cache/bin/varnishd/cache_cli.c b/varnish-cache/bin/varnishd/cache_cli.c index 8eb7cfe9..aabe8d81 100644 --- a/varnish-cache/bin/varnishd/cache_cli.c +++ b/varnish-cache/bin/varnishd/cache_cli.c @@ -47,7 +47,7 @@ /*--------------------------------------------------------------------*/ static void -cli_func_start(struct cli *cli, char **av, void *priv) +cli_func_start(struct cli *cli, const char * const *av, void *priv) { (void)cli; diff --git a/varnish-cache/bin/varnishd/cache_pool.c b/varnish-cache/bin/varnishd/cache_pool.c index 2a5de71a..cc0c1c52 100644 --- a/varnish-cache/bin/varnishd/cache_pool.c +++ b/varnish-cache/bin/varnishd/cache_pool.c @@ -434,7 +434,7 @@ WRK_Init(void) /*--------------------------------------------------------------------*/ void -cli_func_dump_pool(struct cli *cli, char **av, void *priv) +cli_func_dump_pool(struct cli *cli, const char * const *av, void *priv) { (void)cli; diff --git a/varnish-cache/bin/varnishd/cache_vcl.c b/varnish-cache/bin/varnishd/cache_vcl.c index 052224b1..7be68f67 100644 --- a/varnish-cache/bin/varnishd/cache_vcl.c +++ b/varnish-cache/bin/varnishd/cache_vcl.c @@ -195,7 +195,7 @@ VCL_Load(const char *fn, const char *name, struct cli *cli) /*--------------------------------------------------------------------*/ void -cli_func_config_list(struct cli *cli, char **av, void *priv) +cli_func_config_list(struct cli *cli, const char * const *av, void *priv) { struct vcls *vcl; @@ -210,7 +210,7 @@ cli_func_config_list(struct cli *cli, char **av, void *priv) } void -cli_func_config_load(struct cli *cli, char **av, void *priv) +cli_func_config_load(struct cli *cli, const char * const *av, void *priv) { (void)av; @@ -221,7 +221,7 @@ cli_func_config_load(struct cli *cli, char **av, void *priv) } void -cli_func_config_discard(struct cli *cli, char **av, void *priv) +cli_func_config_discard(struct cli *cli, const char * const *av, void *priv) { struct vcls *vcl; @@ -257,7 +257,7 @@ cli_func_config_discard(struct cli *cli, char **av, void *priv) } void -cli_func_config_use(struct cli *cli, char **av, void *priv) +cli_func_config_use(struct cli *cli, const char * const *av, void *priv) { struct vcls *vcl; diff --git a/varnish-cache/bin/varnishd/mgt_child.c b/varnish-cache/bin/varnishd/mgt_child.c index 2072ec73..b14cbb6c 100644 --- a/varnish-cache/bin/varnishd/mgt_child.c +++ b/varnish-cache/bin/varnishd/mgt_child.c @@ -435,7 +435,7 @@ mgt_run(int dflag, const char *T_arg) /*--------------------------------------------------------------------*/ void -mcf_server_startstop(struct cli *cli, char **av, void *priv) +mcf_server_startstop(struct cli *cli, const char * const *av, void *priv) { (void)av; @@ -452,7 +452,7 @@ mcf_server_startstop(struct cli *cli, char **av, void *priv) /*--------------------------------------------------------------------*/ void -mcf_server_status(struct cli *cli, char **av, void *priv) +mcf_server_status(struct cli *cli, const char * const *av, void *priv) { (void)av; (void)priv; diff --git a/varnish-cache/bin/varnishd/mgt_cli.c b/varnish-cache/bin/varnishd/mgt_cli.c index c6ac6828..38f4e79b 100644 --- a/varnish-cache/bin/varnishd/mgt_cli.c +++ b/varnish-cache/bin/varnishd/mgt_cli.c @@ -62,7 +62,7 @@ static int cli_i = -1, cli_o = -1; /*--------------------------------------------------------------------*/ static void -mcf_stats(struct cli *cli, char **av, void *priv) +mcf_stats(struct cli *cli, const char * const *av, void *priv) { (void)av; @@ -82,10 +82,11 @@ mcf_stats(struct cli *cli, char **av, void *priv) */ static void -mcf_passthru(struct cli *cli, char **av, void *priv) +mcf_passthru(struct cli *cli, const char * const *av, void *priv) { struct vsb *sb; - char *p; + const char *p; + char *q; unsigned u; int i; @@ -127,10 +128,10 @@ mcf_passthru(struct cli *cli, char **av, void *priv) xxxassert(i == vsb_len(sb)); vsb_delete(sb); - i = cli_readres(cli_i, &u, &p, params->cli_timeout); + i = cli_readres(cli_i, &u, &q, params->cli_timeout); cli_result(cli, u); - cli_out(cli, "%s", p); - free(p); + cli_out(cli, "%s", q); + free(q); } diff --git a/varnish-cache/bin/varnishd/mgt_param.c b/varnish-cache/bin/varnishd/mgt_param.c index 911380b7..fa8d9ff7 100644 --- a/varnish-cache/bin/varnishd/mgt_param.c +++ b/varnish-cache/bin/varnishd/mgt_param.c @@ -766,7 +766,7 @@ static struct parspec parspec[] = { /*--------------------------------------------------------------------*/ void -mcf_param_show(struct cli *cli, char **av, void *priv) +mcf_param_show(struct cli *cli, const char * const *av, void *priv) { struct parspec *pp; const char *p, *q; @@ -854,7 +854,7 @@ MCF_ParamSet(struct cli *cli, const char *param, const char *val) /*--------------------------------------------------------------------*/ void -mcf_param_set(struct cli *cli, char **av, void *priv) +mcf_param_set(struct cli *cli, const char * const *av, void *priv) { (void)priv; diff --git a/varnish-cache/bin/varnishd/mgt_vcc.c b/varnish-cache/bin/varnishd/mgt_vcc.c index c8d27f37..cc1d50a6 100644 --- a/varnish-cache/bin/varnishd/mgt_vcc.c +++ b/varnish-cache/bin/varnishd/mgt_vcc.c @@ -474,7 +474,7 @@ mgt_vcc_init(void) /*--------------------------------------------------------------------*/ void -mcf_config_inline(struct cli *cli, char **av, void *priv) +mcf_config_inline(struct cli *cli, const char * const *av, void *priv) { char *vf, *p; struct vsb *sb; @@ -504,7 +504,7 @@ mcf_config_inline(struct cli *cli, char **av, void *priv) } void -mcf_config_load(struct cli *cli, char **av, void *priv) +mcf_config_load(struct cli *cli, const char * const *av, void *priv) { char *vf; struct vsb *sb; @@ -550,7 +550,7 @@ mcf_find_vcl(struct cli *cli, const char *name) } void -mcf_config_use(struct cli *cli, char **av, void *priv) +mcf_config_use(struct cli *cli, const char * const *av, void *priv) { unsigned status; char *p; @@ -577,7 +577,7 @@ mcf_config_use(struct cli *cli, char **av, void *priv) } void -mcf_config_discard(struct cli *cli, char **av, void *priv) +mcf_config_discard(struct cli *cli, const char * const *av, void *priv) { unsigned status; char *p; @@ -602,7 +602,7 @@ mcf_config_discard(struct cli *cli, char **av, void *priv) } void -mcf_config_list(struct cli *cli, char **av, void *priv) +mcf_config_list(struct cli *cli, const char * const *av, void *priv) { unsigned status; char *p; @@ -628,7 +628,7 @@ mcf_config_list(struct cli *cli, char **av, void *priv) * XXX: This should take an option argument to show all (include) files */ void -mcf_config_show(struct cli *cli, char **av, void *priv) +mcf_config_show(struct cli *cli, const char * const *av, void *priv) { struct vclprog *vp; void *dlh, *sym; diff --git a/varnish-cache/include/cli_priv.h b/varnish-cache/include/cli_priv.h index 603901d7..0cc1fd6c 100644 --- a/varnish-cache/include/cli_priv.h +++ b/varnish-cache/include/cli_priv.h @@ -37,7 +37,7 @@ struct cli; /* NB: struct cli is opaque at this level. */ -typedef void cli_func_t(struct cli*, char **av, void *priv); +typedef void cli_func_t(struct cli*, const char * const *av, void *priv); struct cli_proto { /* These must match the CLI_* macros in cli.h */ diff --git a/varnish-cache/lib/libvarnish/cli.c b/varnish-cache/lib/libvarnish/cli.c index 4d15fb42..10a715b6 100644 --- a/varnish-cache/lib/libvarnish/cli.c +++ b/varnish-cache/lib/libvarnish/cli.c @@ -46,7 +46,7 @@ */ void -cli_func_help(struct cli *cli, char **av, void *priv) +cli_func_help(struct cli *cli, const char * const *av, void *priv) { struct cli_proto *cp; @@ -123,7 +123,7 @@ cli_dispatch(struct cli *cli, struct cli_proto *clp, const char *line) break; } - cp->func(cli, av, cp->priv); + cp->func(cli, (const char * const *)av, cp->priv); } while (0); FreeArgv(av); diff --git a/varnish-cache/lib/libvarnish/cli_common.c b/varnish-cache/lib/libvarnish/cli_common.c index 1e17b5b6..69922fcb 100644 --- a/varnish-cache/lib/libvarnish/cli_common.c +++ b/varnish-cache/lib/libvarnish/cli_common.c @@ -179,7 +179,7 @@ cli_readres(int fd, unsigned *status, char **ptr, double tmo) /*--------------------------------------------------------------------*/ void -cli_func_ping(struct cli *cli, char **av, void *priv) +cli_func_ping(struct cli *cli, const char * const *av, void *priv) { time_t t; -- 2.39.5