From 8dfb7b10f9e781704c2da234cf3188a53571499d Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Fri, 12 Jun 2026 14:19:08 +0800 Subject: [PATCH] common/cmdparse: tighten the check for positional and req in desc we encode the description of a certain command, with comma-separated values, which are represented in "key=value" form. the keys are a set of configuration names, and their values' types are known. among them, "positional" and "req" are of boolean type. before this change, we consider "true" and "True" as true, otherwise we consider the value as false. but this setting leads to confusion and could be a headache for maintainers. since all commands are determined at compile-time, and all commands' descs use "req=true" or "req=false" if "req" is specified, we are allowed to tighten the check to enforce that these values are "true" or "false". this change serves as part of a sanity check of all command descriptions, as all command descriptions are formatted into JSON with the "get_command_description" asok command and the mon command with the same name. and it does not change the runtime behavior. Signed-off-by: Kefu Chai --- src/common/cmdparse.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/common/cmdparse.cc b/src/common/cmdparse.cc index bd5898b54c7b..e07015e8dfce 100644 --- a/src/common/cmdparse.cc +++ b/src/common/cmdparse.cc @@ -192,9 +192,11 @@ dump_cmd_to_json(Formatter *f, uint64_t features, const string& cmd) if (!HAVE_FEATURE(features, SERVER_QUINCY)) { continue; } - f->dump_bool(key, value == "true" || value == "True"); + assert(value == "true" || value == "false"); + f->dump_bool(key, value == "true"); } else if (key == "req" && HAVE_FEATURE(features, SERVER_QUINCY)) { - f->dump_bool(key, value == "true" || value == "True"); + assert(value == "true" || value == "false"); + f->dump_bool(key, value == "true"); } else { f->dump_string(key, value); } -- 2.47.3