From: Kefu Chai Date: Fri, 12 Jun 2026 06:19:08 +0000 (+0800) Subject: common/cmdparse: tighten the check for positional and req in desc X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8dfb7b10f9e781704c2da234cf3188a53571499d;p=ceph.git 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 --- 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); }