From: Kefu Chai Date: Fri, 21 May 2021 12:10:38 +0000 (+0800) Subject: crimson/osd: disable allow_guessing when parsing command line options X-Git-Tag: v17.1.0~1883^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F41476%2Fhead;p=ceph.git crimson/osd: disable allow_guessing when parsing command line options we pass "--id " to ceph-osd for specifying the osd id, but seastar app template also provides an option of "--idle-poll-time-us arg". boost::program_option::command_line_parser() uses default_style when parsing options. and default_style includes allow_guessing, which in turn matches partial option as well, so "--id" matches with "--idle" when we are trying to figure out which options are consumed by seastar app template, and which are not. see https://www.boost.org/doc/libs/1_76_0/doc/html/boost/program_options/command_line_style/style_t.html so, in this change, stype is specified explicitly, and "allow_guessing" is removed from the "default_style" before being passed to style(), so that only the full option name are matched. Signed-off-by: Kefu Chai --- diff --git a/src/crimson/osd/main.cc b/src/crimson/osd/main.cc index 04f8ca7cf3363..78eed27ab550c 100644 --- a/src/crimson/osd/main.cc +++ b/src/crimson/osd/main.cc @@ -37,7 +37,10 @@ auto partition_args(seastar::app_template& app, char** argv_begin, char** argv_e // collect all options consumed by seastar::app_template auto parsed = bpo::command_line_parser(std::distance(argv_begin, argv_end), argv_begin) - .options(app.get_options_description()).allow_unregistered().run(); + .options(app.get_options_description()) + .style(bpo::command_line_style::default_style & + ~bpo::command_line_style::allow_guessing) + .allow_unregistered().run(); auto unknown_args = bpo::collect_unrecognized(parsed.options, bpo::include_positional); std::vector ceph_args, app_args;