]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
common/cmdparse: tighten the check for positional and req in desc 69429/head
authorKefu Chai <k.chai@proxmox.com>
Fri, 12 Jun 2026 06:19:08 +0000 (14:19 +0800)
committerKefu Chai <k.chai@proxmox.com>
Fri, 12 Jun 2026 06:25:31 +0000 (14:25 +0800)
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 <k.chai@proxmox.com>
src/common/cmdparse.cc

index bd5898b54c7bb86d0a6ddfe8269529d4f3fd3ce4..e07015e8dfce7d8502ea66bac4b9ad90f7f13bae 100644 (file)
@@ -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);
       }