Fix: cli: don't log error when using help command with a plugin name
authorSimon Marchi <simon.marchi@efficios.com>
Thu, 26 Sep 2019 15:28:51 +0000 (11:28 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Sun, 29 Sep 2019 17:10:49 +0000 (13:10 -0400)
commit4bf5c85fc4fe021489669155ae5de25e86397575
tree2e716eb8a9f1228e026302bb49474d1c92695380
parentd4db9beb2e8e00eaa60a5f89f745b1add05a7d64
Fix: cli: don't log error when using help command with a plugin name

When using the help command with a plugin name, it works, but Babeltrace
logs an error:

    09-26 16:37:03.782 10054 10054 E CLI/CFG-CLI-ARGS plugin_comp_cls_names@babeltrace2-cfg-cli-args.c:189 Missing component class type (`source`, `filter`, or `sink`).

This is problematic, because this is a valid use of the command.
Logging an error is unnecessarily alarming.

The current code takes the argument (in our case, a plugin name such as
"ctf") and passes it through plugin_comp_cls_names.  The function can't
parse the string as a component class name, so logs the error mentioned
above.  The caller, bt_config_help_from_args, sees that the function has
failed, so falls back to assuming the string is a plugin name, which
then works correctly.

To avoid this, the sophisticated solution I chose was to look for an
unescaped dot in the argument.  If there's one, we treat it as a
component class name, if there isn't, we treat is as a plugin name.

Change-Id: I76b791e5d44436fdc5b10a3c10e3579a0783b04d
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2101
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
src/cli/babeltrace2-cfg-cli-args.c
tests/Makefile.am
tests/cli/test_help [new file with mode: 0755]
This page took 0.026362 seconds and 4 git commands to generate.