Commit 8fa24e20 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Match output for boolean params to the default value so

we can choose to present on/off or true/false, depending on what
makes most sense.

Fixes	#1245
parent a54af587
...@@ -187,9 +187,16 @@ tweak_generic_double(struct cli *cli, const struct parspec *par, ...@@ -187,9 +187,16 @@ tweak_generic_double(struct cli *cli, const struct parspec *par,
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
static void void
tweak_generic_bool(struct cli *cli, volatile unsigned *dest, const char *arg) tweak_bool(struct cli *cli, const struct parspec *par, const char *arg)
{ {
volatile unsigned *dest;
int mode = 0;
if (!strcmp(par->def, "off") || !strcmp(par->def, "on"))
mode = 1;
dest = par->priv;
if (arg != NULL) { if (arg != NULL) {
if (!strcasecmp(arg, "off")) if (!strcasecmp(arg, "off"))
*dest = 0; *dest = 0;
...@@ -208,23 +215,18 @@ tweak_generic_bool(struct cli *cli, volatile unsigned *dest, const char *arg) ...@@ -208,23 +215,18 @@ tweak_generic_bool(struct cli *cli, volatile unsigned *dest, const char *arg)
else if (!strcasecmp(arg, "true")) else if (!strcasecmp(arg, "true"))
*dest = 1; *dest = 1;
else { else {
VCLI_Out(cli, "use \"on\" or \"off\"\n"); VCLI_Out(cli,
mode ?
"use \"on\" or \"off\"\n" :
"use \"true\" or \"false\"\n");
VCLI_SetResult(cli, CLIS_PARAM); VCLI_SetResult(cli, CLIS_PARAM);
return; return;
} }
} else } else if (mode) {
VCLI_Out(cli, *dest ? "on" : "off"); VCLI_Out(cli, *dest ? "on" : "off");
} } else {
VCLI_Out(cli, *dest ? "true" : "false");
/*--------------------------------------------------------------------*/ }
void
tweak_bool(struct cli *cli, const struct parspec *par, const char *arg)
{
volatile unsigned *dest;
dest = par->priv;
tweak_generic_bool(cli, dest, arg);
} }
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
......
...@@ -556,7 +556,7 @@ const struct parspec mgt_parspec[] = { ...@@ -556,7 +556,7 @@ const struct parspec mgt_parspec[] = {
"Disable this if you have very high hitrates and want" "Disable this if you have very high hitrates and want"
"to save the memory of one busyobj per worker thread.", "to save the memory of one busyobj per worker thread.",
0, 0,
"false", ""}, "off", "bool"},
{ "pool_vbc", tweak_poolparam, &mgt_param.vbc_pool, 0, 10000, { "pool_vbc", tweak_poolparam, &mgt_param.vbc_pool, 0, 10000,
"Parameters for backend connection memory pool.\n" "Parameters for backend connection memory pool.\n"
...@@ -582,9 +582,9 @@ const struct parspec mgt_parspec[] = { ...@@ -582,9 +582,9 @@ const struct parspec mgt_parspec[] = {
{ "obj_readonly", tweak_bool, &mgt_param.obj_readonly, 0, 0, { "obj_readonly", tweak_bool, &mgt_param.obj_readonly, 0, 0,
"If set, we do not update obj.hits and obj.lastuse to" "If set, we do not update obj.hits and obj.lastuse to"
"avoid dirtying VM pages associated with cached objects.", " avoid dirtying VM pages associated with cached objects.",
0, 0,
"false", ""}, "false", "bool"},
{ NULL, NULL, NULL } { NULL, NULL, NULL }
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment