[master] 8a69328 Make tweakers return an int, rather than calling VCLI_SetResult() directly.

Poul-Henning Kamp phk at varnish-cache.org
Tue Nov 12 14:04:28 CET 2013


commit 8a69328946f99e95f71c4d60b4e3525ca297272a
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue Nov 12 13:03:51 2013 +0000

    Make tweakers return an int, rather than calling VCLI_SetResult() directly.

diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c
index 131c70e..e2a0297 100644
--- a/bin/varnishd/mgt/mgt_param.c
+++ b/bin/varnishd/mgt/mgt_param.c
@@ -223,7 +223,8 @@ mcf_param_show(struct cli *cli, const char * const *av, void *priv)
 		} else {
 			VCLI_Out(cli, "%-*s", margin2, pp->name);
 		}
-		pp->func(cli, pp, NULL);
+		if (pp->func(cli, pp, NULL))
+			VCLI_SetResult(cli, CLIS_PARAM);
 		if (pp->units != NULL && *pp->units != '\0')
 			VCLI_Out(cli, " [%s]\n", pp->units);
 		else
@@ -310,7 +311,8 @@ MCF_ParamSet(struct cli *cli, const char *param, const char *val)
 		VCLI_Out(cli, "parameter \"%s\" is protected.", param);
 		return;
 	}
-	pp->func(cli, pp, val);
+	if (pp->func(cli, pp, val))
+		VCLI_SetResult(cli, CLIS_PARAM);
 
 	if (cli->result == CLIS_OK && heritage.param != NULL)
 		*heritage.param = mgt_param;
@@ -397,7 +399,8 @@ MCF_SetDefaults(struct cli *cli)
 		if (cli != NULL)
 			VCLI_Out(cli,
 			    "Set Default for %s = %s\n", pp->name, pp->def);
-		pp->func(cli, pp, pp->def);
+		if (pp->func(cli, pp, pp->def))
+			VCLI_SetResult(cli, CLIS_PARAM);
 		if (cli != NULL && cli->result != CLIS_OK)
 			return;
 	}
diff --git a/bin/varnishd/mgt/mgt_param.h b/bin/varnishd/mgt/mgt_param.h
index 70d4351..b0bba39 100644
--- a/bin/varnishd/mgt/mgt_param.h
+++ b/bin/varnishd/mgt/mgt_param.h
@@ -30,7 +30,7 @@
 
 struct parspec;
 
-typedef void tweak_t(struct cli *, const struct parspec *, const char *arg);
+typedef int tweak_t(struct cli *, const struct parspec *, const char *arg);
 
 struct parspec {
 	const char	*name;
@@ -51,23 +51,22 @@ struct parspec {
 	const char	*units;
 };
 
-tweak_t tweak_user;
-tweak_t tweak_group;
-tweak_t tweak_string;
 tweak_t tweak_bool;
-tweak_t tweak_waiter;
+tweak_t tweak_bytes;
 tweak_t tweak_bytes_u;
-tweak_t tweak_listen_address;
-tweak_t tweak_timeout;
 tweak_t tweak_generic_double;
+tweak_t tweak_group;
+tweak_t tweak_listen_address;
 tweak_t tweak_poolparam;
+tweak_t tweak_string;
+tweak_t tweak_timeout;
+tweak_t tweak_timeout_double;
+tweak_t tweak_uint;
+tweak_t tweak_user;
+tweak_t tweak_waiter;
 
 int tweak_generic_uint(struct cli *cli,
     volatile unsigned *dest, const char *arg, unsigned min, unsigned max);
-void tweak_uint(struct cli *cli, const struct parspec *par, const char *arg);
-void tweak_timeout_double(struct cli *cli,
-    const struct parspec *par, const char *arg);
-void tweak_bytes(struct cli *cli, const struct parspec *par, const char *arg);
 
 /* mgt_param_tbl.c */
 extern const struct parspec mgt_parspec[];
diff --git a/bin/varnishd/mgt/mgt_param_bits.c b/bin/varnishd/mgt/mgt_param_bits.c
index cda1154..24276f1 100644
--- a/bin/varnishd/mgt/mgt_param_bits.c
+++ b/bin/varnishd/mgt/mgt_param_bits.c
@@ -66,7 +66,7 @@ bit(uint8_t *p, unsigned no, enum bit_do act)
 /*--------------------------------------------------------------------
  */
 
-static void
+static int
 bit_tweak(struct cli *cli, uint8_t *p, unsigned l, const char *arg,
     const char * const *tags, const char *desc, const char *sign)
 {
@@ -78,17 +78,15 @@ bit_tweak(struct cli *cli, uint8_t *p, unsigned l, const char *arg,
 	av = VAV_Parse(arg, &n, ARGV_COMMA);
 	if (av[0] != NULL) {
 		VCLI_Out(cli, "Cannot parse: %s\n", av[0]);
-		VCLI_SetResult(cli, CLIS_PARAM);
 		VAV_Free(av);
-		return;
+		return (-1);
 	}
 	for (i = 1; av[i] != NULL; i++) {
 		s = av[i];
 		if (*s != '-' && *s != '+') {
 			VCLI_Out(cli, "Missing '+' or '-' (%s)\n", s);
-			VCLI_SetResult(cli, CLIS_PARAM);
 			VAV_Free(av);
-			return;
+			return (-1);
 		}
 		for (j = 0; j < l; j++) {
 			if (tags[j] != NULL && !strcasecmp(s + 1, tags[j]))
@@ -96,9 +94,8 @@ bit_tweak(struct cli *cli, uint8_t *p, unsigned l, const char *arg,
 		}
 		if (tags[j] == NULL) {
 			VCLI_Out(cli, "Unknown %s (%s)\n", desc, s);
-			VCLI_SetResult(cli, CLIS_PARAM);
 			VAV_Free(av);
-			return;
+			return (-1);
 		}
 		assert(j < l);
 		if (s[0] == *sign)
@@ -107,6 +104,7 @@ bit_tweak(struct cli *cli, uint8_t *p, unsigned l, const char *arg,
 			(void)bit(p, j, BCLR);
 	}
 	VAV_Free(av);
+	return (0);
 }
 
 
@@ -121,7 +119,7 @@ static const char * const VSL_tags[256] = {
 	NULL
 };
 
-static void
+static int
 tweak_vsl_mask(struct cli *cli, const struct parspec *par, const char *arg)
 {
 	unsigned j;
@@ -136,9 +134,9 @@ tweak_vsl_mask(struct cli *cli, const struct parspec *par, const char *arg)
 			(void)bit(mgt_param.vsl_mask, SLT_WorkThread, BSET);
 			(void)bit(mgt_param.vsl_mask, SLT_Hash, BSET);
 		} else {
-			bit_tweak(cli, mgt_param.vsl_mask,
+			return (bit_tweak(cli, mgt_param.vsl_mask,
 			    SLT__Reserved, arg, VSL_tags,
-			    "VSL tag", "-");
+			    "VSL tag", "-"));
 		}
 	} else {
 		s = "";
@@ -151,6 +149,7 @@ tweak_vsl_mask(struct cli *cli, const struct parspec *par, const char *arg)
 		if (*s == '\0')
 			VCLI_Out(cli, "(all enabled)");
 	}
+	return (0);
 }
 
 /*--------------------------------------------------------------------
@@ -164,7 +163,7 @@ static const char * const debug_tags[] = {
        NULL
 };
 
-static void
+static int
 tweak_debug(struct cli *cli, const struct parspec *par, const char *arg)
 {
 	const char *s;
@@ -176,8 +175,8 @@ tweak_debug(struct cli *cli, const struct parspec *par, const char *arg)
 			memset(mgt_param.debug_bits,
 			    0, sizeof mgt_param.debug_bits);
 		} else {
-			bit_tweak(cli, mgt_param.debug_bits,
-			    DBG_Reserved, arg, debug_tags, "debug bit", "+");
+			return (bit_tweak(cli, mgt_param.debug_bits,
+			    DBG_Reserved, arg, debug_tags, "debug bit", "+"));
 		}
 	} else {
 		s = "";
@@ -190,6 +189,7 @@ tweak_debug(struct cli *cli, const struct parspec *par, const char *arg)
 		if (*s == '\0')
 			VCLI_Out(cli, "none");
 	}
+	return (0);
 }
 
 /*--------------------------------------------------------------------
@@ -203,7 +203,7 @@ static const char * const feature_tags[] = {
        NULL
 };
 
-static void
+static int
 tweak_feature(struct cli *cli, const struct parspec *par, const char *arg)
 {
 	const char *s;
@@ -215,9 +215,9 @@ tweak_feature(struct cli *cli, const struct parspec *par, const char *arg)
 			memset(mgt_param.feature_bits,
 			    0, sizeof mgt_param.feature_bits);
 		} else {
-			bit_tweak(cli, mgt_param.feature_bits,
+			return (bit_tweak(cli, mgt_param.feature_bits,
 			    FEATURE_Reserved, arg, feature_tags,
-			    "feature bit", "+");
+			    "feature bit", "+"));
 		}
 	} else {
 		s = "";
@@ -230,6 +230,7 @@ tweak_feature(struct cli *cli, const struct parspec *par, const char *arg)
 		if (*s == '\0')
 			VCLI_Out(cli, "none");
 	}
+	return (0);
 }
 
 /*--------------------------------------------------------------------
diff --git a/bin/varnishd/mgt/mgt_param_tweak.c b/bin/varnishd/mgt/mgt_param_tweak.c
index ec5ef05..ee30f54 100644
--- a/bin/varnishd/mgt/mgt_param_tweak.c
+++ b/bin/varnishd/mgt/mgt_param_tweak.c
@@ -58,7 +58,7 @@
 
 /*--------------------------------------------------------------------*/
 
-static void
+static int
 tweak_generic_timeout(struct cli *cli, volatile unsigned *dst, const char *arg)
 {
 	unsigned u;
@@ -67,23 +67,23 @@ tweak_generic_timeout(struct cli *cli, volatile unsigned *dst, const char *arg)
 		u = strtoul(arg, NULL, 0);
 		if (u == 0) {
 			VCLI_Out(cli, "Timeout must be greater than zero\n");
-			VCLI_SetResult(cli, CLIS_PARAM);
-			return;
+			return (-1);
 		}
 		*dst = u;
 	} else
 		VCLI_Out(cli, "%u", *dst);
+	return (0);
 }
 
 /*--------------------------------------------------------------------*/
 
-void
+int
 tweak_timeout(struct cli *cli, const struct parspec *par, const char *arg)
 {
 	volatile unsigned *dest;
 
 	dest = par->priv;
-	tweak_generic_timeout(cli, dest, arg);
+	return (tweak_generic_timeout(cli, dest, arg));
 }
 
 /*--------------------------------------------------------------------*/
@@ -100,19 +100,16 @@ tweak_generic_timeout_double(struct cli *cli, volatile double *dest,
 		u = strtod(arg, &p);
 		if (*arg == '\0' || *p != '\0') {
 			VCLI_Out(cli, "Not a number(%s)\n", arg);
-			VCLI_SetResult(cli, CLIS_PARAM);
 			return (-1);
 		}
 		if (u < min) {
 			VCLI_Out(cli,
 			    "Timeout must be greater or equal to %.g\n", min);
-			VCLI_SetResult(cli, CLIS_PARAM);
 			return (-1);
 		}
 		if (u > max) {
 			VCLI_Out(cli,
 			    "Timeout must be less than or equal to %.g\n", max);
-			VCLI_SetResult(cli, CLIS_PARAM);
 			return (-1);
 		}
 		*dest = u;
@@ -121,19 +118,20 @@ tweak_generic_timeout_double(struct cli *cli, volatile double *dest,
 	return (0);
 }
 
-void
+int
 tweak_timeout_double(struct cli *cli, const struct parspec *par,
     const char *arg)
 {
 	volatile double *dest;
 
 	dest = par->priv;
-	(void)tweak_generic_timeout_double(cli, dest, arg, par->min, par->max);
+	return (tweak_generic_timeout_double(cli, dest, arg,
+	    par->min, par->max));
 }
 
 /*--------------------------------------------------------------------*/
 
-void
+int
 tweak_generic_double(struct cli *cli, const struct parspec *par,
     const char *arg)
 {
@@ -148,31 +146,29 @@ tweak_generic_double(struct cli *cli, const struct parspec *par,
 		if (*p != '\0') {
 			VCLI_Out(cli,
 			    "Not a number (%s)\n", arg);
-			VCLI_SetResult(cli, CLIS_PARAM);
-			return;
+			return (-1);
 		}
 		if (u < par->min) {
 			VCLI_Out(cli,
 			    "Must be greater or equal to %.g\n",
 				 par->min);
-			VCLI_SetResult(cli, CLIS_PARAM);
-			return;
+			return (-1);
 		}
 		if (u > par->max) {
 			VCLI_Out(cli,
 			    "Must be less than or equal to %.g\n",
 				 par->max);
-			VCLI_SetResult(cli, CLIS_PARAM);
-			return;
+			return (-1);
 		}
 		*dest = u;
 	} else
 		VCLI_Out(cli, "%f", *dest);
+	return (0);
 }
 
 /*--------------------------------------------------------------------*/
 
-void
+int
 tweak_bool(struct cli *cli, const struct parspec *par, const char *arg)
 {
 	volatile unsigned *dest;
@@ -204,14 +200,14 @@ tweak_bool(struct cli *cli, const struct parspec *par, const char *arg)
 			    mode ?
 				"use \"on\" or \"off\"\n" :
 				"use \"true\" or \"false\"\n");
-			VCLI_SetResult(cli, CLIS_PARAM);
-			return;
+			return (-1);
 		}
 	} else if (mode) {
 		VCLI_Out(cli, *dest ? "on" : "off");
 	} else {
 		VCLI_Out(cli, *dest ? "true" : "false");
 	}
+	return (0);
 }
 
 /*--------------------------------------------------------------------*/
@@ -231,18 +227,15 @@ tweak_generic_uint(struct cli *cli, volatile unsigned *dest, const char *arg,
 			u = strtoul(arg, &p, 0);
 			if (*arg == '\0' || *p != '\0') {
 				VCLI_Out(cli, "Not a number (%s)\n", arg);
-				VCLI_SetResult(cli, CLIS_PARAM);
 				return (-1);
 			}
 		}
 		if (u < min) {
 			VCLI_Out(cli, "Must be at least %u\n", min);
-			VCLI_SetResult(cli, CLIS_PARAM);
 			return (-1);
 		}
 		if (u > max) {
 			VCLI_Out(cli, "Must be no more than %u\n", max);
-			VCLI_SetResult(cli, CLIS_PARAM);
 			return (-1);
 		}
 		*dest = u;
@@ -256,7 +249,7 @@ tweak_generic_uint(struct cli *cli, volatile unsigned *dest, const char *arg,
 
 /*--------------------------------------------------------------------*/
 
-void
+int
 tweak_uint(struct cli *cli, const struct parspec *par, const char *arg)
 {
 	volatile unsigned *dest;
@@ -264,6 +257,7 @@ tweak_uint(struct cli *cli, const struct parspec *par, const char *arg)
 	dest = par->priv;
 	(void)tweak_generic_uint(cli, dest, arg,
 	    (uint)par->min, (uint)par->max);
+	return (0);
 }
 
 /*--------------------------------------------------------------------*/
@@ -291,7 +285,7 @@ fmt_bytes(struct cli *cli, uintmax_t t)
 	VCLI_Out(cli, "(bogus number)");
 }
 
-static void
+static int
 tweak_generic_bytes(struct cli *cli, volatile ssize_t *dest, const char *arg,
     double min, double max)
 {
@@ -305,51 +299,48 @@ tweak_generic_bytes(struct cli *cli, volatile ssize_t *dest, const char *arg,
 			VCLI_Out(cli, "%s\n", p);
 			VCLI_Out(cli,
 			    "  Try something like '80k' or '120M'\n");
-			VCLI_SetResult(cli, CLIS_PARAM);
-			return;
+			return (-1);
 		}
 		if ((uintmax_t)((ssize_t)r) != r) {
 			fmt_bytes(cli, r);
 			VCLI_Out(cli, " is too large for this architecture.\n");
-			VCLI_SetResult(cli, CLIS_PARAM);
-			return;
+			return (-1);
 		}
 		if (max != 0. && r > max) {
 			VCLI_Out(cli, "Must be no more than ");
 			fmt_bytes(cli, (uintmax_t)max);
 			VCLI_Out(cli, "\n");
-			VCLI_SetResult(cli, CLIS_PARAM);
-			return;
+			return (-1);
 		}
 		if (r < min) {
 			VCLI_Out(cli, "Must be at least ");
 			fmt_bytes(cli, (uintmax_t)min);
 			VCLI_Out(cli, "\n");
-			VCLI_SetResult(cli, CLIS_PARAM);
-			return;
+			return (-1);
 		}
 		*dest = r;
 	} else {
 		fmt_bytes(cli, *dest);
 	}
+	return (0);
 }
 
 /*--------------------------------------------------------------------*/
 
-void
+int
 tweak_bytes(struct cli *cli, const struct parspec *par, const char *arg)
 {
 	volatile ssize_t *dest;
 
 	assert(par->min >= 0);
 	dest = par->priv;
-	tweak_generic_bytes(cli, dest, arg, par->min, par->max);
+	return (tweak_generic_bytes(cli, dest, arg, par->min, par->max));
 }
 
 
 /*--------------------------------------------------------------------*/
 
-void
+int
 tweak_bytes_u(struct cli *cli, const struct parspec *par, const char *arg)
 {
 	volatile unsigned *d1;
@@ -359,8 +350,10 @@ tweak_bytes_u(struct cli *cli, const struct parspec *par, const char *arg)
 	assert(par->min >= 0);
 	d1 = par->priv;
 	dest = *d1;
-	tweak_generic_bytes(cli, &dest, arg, par->min, par->max);
+	if (tweak_generic_bytes(cli, &dest, arg, par->min, par->max))
+		return (-1);
 	*d1 = dest;
+	return (0);
 }
 
 /*--------------------------------------------------------------------
@@ -371,7 +364,7 @@ tweak_bytes_u(struct cli *cli, const struct parspec *par, const char *arg)
  * XXX: The magic init string is a hack for this.
  */
 
-void
+int
 tweak_user(struct cli *cli, const struct parspec *par, const char *arg)
 {
 	struct passwd *pw;
@@ -382,8 +375,7 @@ tweak_user(struct cli *cli, const struct parspec *par, const char *arg)
 			pw = getpwnam(arg);
 			if (pw == NULL) {
 				VCLI_Out(cli, "Unknown user");
-				VCLI_SetResult(cli, CLIS_PARAM);
-				return;
+				return(-1);
 			}
 			REPLACE(mgt_param.user, pw->pw_name);
 			mgt_param.uid = pw->pw_uid;
@@ -395,13 +387,14 @@ tweak_user(struct cli *cli, const struct parspec *par, const char *arg)
 	} else {
 		VCLI_Out(cli, "UID %d", (int)mgt_param.uid);
 	}
+	return (0);
 }
 
 /*--------------------------------------------------------------------
  * XXX: see comment for tweak_user, same thing here.
  */
 
-void
+int
 tweak_group(struct cli *cli, const struct parspec *par, const char *arg)
 {
 	struct group *gr;
@@ -412,8 +405,7 @@ tweak_group(struct cli *cli, const struct parspec *par, const char *arg)
 			gr = getgrnam(arg);
 			if (gr == NULL) {
 				VCLI_Out(cli, "Unknown group");
-				VCLI_SetResult(cli, CLIS_PARAM);
-				return;
+				return(-1);
 			}
 			REPLACE(mgt_param.group, gr->gr_name);
 			mgt_param.gid = gr->gr_gid;
@@ -425,6 +417,7 @@ tweak_group(struct cli *cli, const struct parspec *par, const char *arg)
 	} else {
 		VCLI_Out(cli, "GID %d", (int)mgt_param.gid);
 	}
+	return (0);
 }
 
 /*--------------------------------------------------------------------*/
@@ -443,38 +436,35 @@ clean_listen_sock_head(struct listen_sock_head *lsh)
 	}
 }
 
-void
+int
 tweak_listen_address(struct cli *cli, const struct parspec *par,
     const char *arg)
 {
 	char **av;
-	int i;
+	int i, retval = 0;
 	struct listen_sock		*ls;
 	struct listen_sock_head		lsh;
 
 	(void)par;
 	if (arg == NULL) {
 		VCLI_Quote(cli, mgt_param.listen_address);
-		return;
+		return (0);
 	}
 
 	av = VAV_Parse(arg, NULL, ARGV_COMMA);
 	if (av == NULL) {
 		VCLI_Out(cli, "Parse error: out of memory");
-		VCLI_SetResult(cli, CLIS_PARAM);
-		return;
+		return(-1);
 	}
 	if (av[0] != NULL) {
 		VCLI_Out(cli, "Parse error: %s", av[0]);
-		VCLI_SetResult(cli, CLIS_PARAM);
 		VAV_Free(av);
-		return;
+		return(-1);
 	}
 	if (av[1] == NULL) {
 		VCLI_Out(cli, "Empty listen address");
-		VCLI_SetResult(cli, CLIS_PARAM);
 		VAV_Free(av);
-		return;
+		return(-1);
 	}
 	VTAILQ_INIT(&lsh);
 	for (i = 1; av[i] != NULL; i++) {
@@ -485,7 +475,7 @@ tweak_listen_address(struct cli *cli, const struct parspec *par,
 		if (n == 0) {
 			VCLI_Out(cli, "Invalid listen address ");
 			VCLI_Quote(cli, av[i]);
-			VCLI_SetResult(cli, CLIS_PARAM);
+			retval = -1;
 			break;
 		}
 		for (j = 0; j < n; ++j) {
@@ -500,9 +490,9 @@ tweak_listen_address(struct cli *cli, const struct parspec *par,
 		free(ta);
 	}
 	VAV_Free(av);
-	if (cli != NULL && cli->result != CLIS_OK) {
+	if (retval) {
 		clean_listen_sock_head(&lsh);
-		return;
+		return (-1);
 	}
 
 	REPLACE(mgt_param.listen_address, arg);
@@ -517,11 +507,12 @@ tweak_listen_address(struct cli *cli, const struct parspec *par,
 		VTAILQ_INSERT_TAIL(&heritage.socks, ls, list);
 		heritage.nsocks++;
 	}
+	return (0);
 }
 
 /*--------------------------------------------------------------------*/
 
-void
+int
 tweak_string(struct cli *cli, const struct parspec *par, const char *arg)
 {
 	char **p = TRUST_ME(par->priv);
@@ -533,26 +524,28 @@ tweak_string(struct cli *cli, const struct parspec *par, const char *arg)
 	} else {
 		REPLACE(*p, arg);
 	}
+	return (0);
 }
 
 /*--------------------------------------------------------------------*/
 
-void
+int
 tweak_waiter(struct cli *cli, const struct parspec *par, const char *arg)
 {
 
 	/* XXX should have tweak_generic_string */
 	(void)par;
-	WAIT_tweak_waiter(cli, arg);
+	return (WAIT_tweak_waiter(cli, arg));
 }
 
 /*--------------------------------------------------------------------*/
 
-void
+int
 tweak_poolparam(struct cli *cli, const struct parspec *par, const char *arg)
 {
 	volatile struct poolparam *pp, px;
 	char **av;
+	int retval = 0;
 
 	pp = par->priv;
 	if (arg == NULL) {
@@ -563,35 +556,39 @@ tweak_poolparam(struct cli *cli, const struct parspec *par, const char *arg)
 		do {
 			if (av[0] != NULL) {
 				VCLI_Out(cli, "Parse error: %s", av[0]);
-				VCLI_SetResult(cli, CLIS_PARAM);
+				retval = -1;
 				break;
 			}
 			if (av[1] == NULL || av[2] == NULL || av[3] == NULL) {
 				VCLI_Out(cli,
 				    "Three fields required:"
 				    " min_pool, max_pool and max_age\n");
-				VCLI_SetResult(cli, CLIS_PARAM);
+				retval = -1;
 				break;
 			}
 			px = *pp;
-			if (tweak_generic_uint(cli, &px.min_pool, av[1],
-			    (uint)par->min, (uint)par->max))
+			retval = tweak_generic_uint(cli, &px.min_pool, av[1],
+			    (uint)par->min, (uint)par->max);
+			if (retval)
 				break;
-			if (tweak_generic_uint(cli, &px.max_pool, av[2],
-			    (uint)par->min, (uint)par->max))
+			retval = tweak_generic_uint(cli, &px.max_pool, av[2],
+			    (uint)par->min, (uint)par->max);
+			if (retval)
 				break;
-			if (tweak_generic_timeout_double(cli, &px.max_age,
-			    av[3], 0, 1e6))
+			retval = tweak_generic_timeout_double(cli,
+			    &px.max_age, av[3], 0, 1e6);
+			if (retval)
 				break;
 			if (px.min_pool > px.max_pool) {
 				VCLI_Out(cli,
 				    "min_pool cannot be larger"
 				    " than max_pool\n");
-				VCLI_SetResult(cli, CLIS_PARAM);
+				retval = -1;
 				break;
 			}
 			*pp = px;
 		} while(0);
 		VAV_Free(av);
 	}
+	return (retval);
 }
diff --git a/bin/varnishd/mgt/mgt_pool.c b/bin/varnishd/mgt/mgt_pool.c
index 1bfa994..8096170 100644
--- a/bin/varnishd/mgt/mgt_pool.c
+++ b/bin/varnishd/mgt/mgt_pool.c
@@ -54,13 +54,13 @@
 
 /*--------------------------------------------------------------------*/
 
-static void
+static int
 tweak_thread_pool_min(struct cli *cli, const struct parspec *par,
     const char *arg)
 {
 
-	(void)tweak_generic_uint(cli, &mgt_param.wthread_min, arg,
-	    (unsigned)par->min, mgt_param.wthread_max);
+	return (tweak_generic_uint(cli, &mgt_param.wthread_min, arg,
+	    (unsigned)par->min, mgt_param.wthread_max));
 }
 
 /*--------------------------------------------------------------------
@@ -69,7 +69,7 @@ tweak_thread_pool_min(struct cli *cli, const struct parspec *par,
  * XXX: "32bit" is a magic marker for 32bit systems.
  */
 
-static void
+static int
 tweak_stack_size(struct cli *cli, const struct parspec *par,
     const char *arg)
 {
@@ -77,21 +77,23 @@ tweak_stack_size(struct cli *cli, const struct parspec *par,
 
 	low = sysconf(_SC_THREAD_STACK_MIN);
 
-	tweak_bytes(cli, par, arg);
+	if (tweak_bytes(cli, par, arg))
+		return (-1);
 	if (mgt_param.wthread_stacksize < low)
 		mgt_param.wthread_stacksize = low;
+	return (0);
 }
 
 /*--------------------------------------------------------------------*/
 
-static void
+static int
 tweak_thread_pool_max(struct cli *cli, const struct parspec *par,
     const char *arg)
 {
 
 	(void)par;
-	(void)tweak_generic_uint(cli, &mgt_param.wthread_max, arg,
-	    mgt_param.wthread_min, UINT_MAX);
+	return (tweak_generic_uint(cli, &mgt_param.wthread_max, arg,
+	    mgt_param.wthread_min, UINT_MAX));
 }
 
 /*--------------------------------------------------------------------*/
diff --git a/bin/varnishd/waiter/mgt_waiter.c b/bin/varnishd/waiter/mgt_waiter.c
index 94d90ea..0d841a1 100644
--- a/bin/varnishd/waiter/mgt_waiter.c
+++ b/bin/varnishd/waiter/mgt_waiter.c
@@ -36,7 +36,6 @@
 #include "common/common.h"
 
 #include "waiter/waiter.h"
-#include "vcli.h"
 #include "vcli_priv.h"
 
 static const struct waiter *const vca_waiters[] = {
@@ -55,7 +54,7 @@ static const struct waiter *const vca_waiters[] = {
 
 struct waiter const *waiter;
 
-void
+int
 WAIT_tweak_waiter(struct cli *cli, const char *arg)
 {
 	int i;
@@ -73,18 +72,18 @@ WAIT_tweak_waiter(struct cli *cli, const char *arg)
 			VCLI_Out(cli, "%s%s", i == 0 ? "" : ", ",
 			    vca_waiters[i]->name);
 		VCLI_Out(cli, ")");
-		return;
+		return(0);
 	}
 	if (!strcmp(arg, WAITER_DEFAULT)) {
 		waiter = vca_waiters[0];
-		return;
+		return(0);
 	}
 	for (i = 0; vca_waiters[i]; i++) {
 		if (!strcmp(arg, vca_waiters[i]->name)) {
 			waiter = vca_waiters[i];
-			return;
+			return(0);
 		}
 	}
 	VCLI_Out(cli, "Unknown waiter");
-	VCLI_SetResult(cli, CLIS_PARAM);
+	return (-1);
 }
diff --git a/bin/varnishd/waiter/waiter.h b/bin/varnishd/waiter/waiter.h
index ce46e4d..5f1a546 100644
--- a/bin/varnishd/waiter/waiter.h
+++ b/bin/varnishd/waiter/waiter.h
@@ -43,7 +43,7 @@ struct waiter {
 
 /* mgt_waiter.c */
 extern struct waiter const * waiter;
-void WAIT_tweak_waiter(struct cli *cli, const char *arg);
+int WAIT_tweak_waiter(struct cli *cli, const char *arg);
 
 #if defined(HAVE_EPOLL_CTL)
 extern const struct waiter waiter_epoll;



More information about the varnish-commit mailing list