mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] perf subcmd: Bugfix more exactly handle the error about 'PARSE_OPT_EXCLUSIVE'
@ 2016-03-07 14:59 Taeung Song
  0 siblings, 0 replies; only message in thread
From: Taeung Song @ 2016-03-07 14:59 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: linux-kernel, Jiri Olsa, Namhyung Kim, Ingo Molnar,
	Peter Zijlstra, Taeung Song

perf-probe have two options '--list' and '--func'.
This options have a option flag 'PARSE_OPT_EXCLUSIVE'.
But when that kind of this options are used at same time,
handling this error has latent problem.
(Even though there isn't any problem at this point in time e.g)

    # perf probe --list --funcs
    Error: option `funcs' cannot be used with list
    Usage: perf probe [<options>] 'PROBEDEF' ['PROBEDEF' ...]
       or: perf probe [<options>] --add 'PROBEDEF' [--add 'PROBEDEF' ...]
       or: perf probe [<options>] --del '[GROUP:]EVENT' ...
       or: perf probe --list [GROUP:]EVENT ...
       or: perf probe [<options>] --line 'LINEDESC'
       or: perf probe [<options>] --vars 'PROBEPOINT'
       or: perf probe [<options>] --funcs

       -F, --funcs <[FILTER]>
                             Show potential probe-able functions.
       -l, --list <[GROUP:]EVENT>
                             list up probe events

When finding used options among all options,
using prefixcmp() has a latent problem.
When comparing long name of options, if used
two options has simailar long name that same prefix
usage of a option can be repeatedly printed i.e.

    # perf config --list-all --list
    Error: option `list' cannot be used with list-all
    Usage: perf config [<file-option>] [options]

        -l, --list            show current config variables
        -a, --list-all        show current and all possible config variables with default values
        -a, --list-all        show current and all possible config variables with default values

So I fix it to avoid repeat output.

Of course, current perf-config hasn't 'list-all'
option yet but I think this problem might occur
by other sub-command in future.

Before:

    # perf probe --list --funcs
    Error: option `funcs' cannot be used with list
    Usage: perf probe [<options>] 'PROBEDEF' ['PROBEDEF' ...]
       or: perf probe [<options>] --add 'PROBEDEF' [--add 'PROBEDEF' ...]
       or: perf probe [<options>] --del '[GROUP:]EVENT' ...
       or: perf probe --list [GROUP:]EVENT ...
       or: perf probe [<options>] --line 'LINEDESC'
       or: perf probe [<options>] --vars 'PROBEPOINT'
       or: perf probe [<options>] --funcs

       -F, --funcs <[FILTER]>
                             Show potential probe-able functions.
       -l, --list <[GROUP:]EVENT>
                             list up probe events

    # perf config --list-all --list
    Error: option `list' cannot be used with list-all
    Usage: perf config [<file-option>] [options]

        -l, --list            show current config variables
        -a, --list-all        show current and all possible config variables with default values
        -a, --list-all        show current and all possible config variables with default values

After:

    # perf probe --list --funcs
    Error: option `funcs' cannot be used with list
    Usage: perf probe [<options>] 'PROBEDEF' ['PROBEDEF' ...]
       or: perf probe [<options>] --add 'PROBEDEF' [--add 'PROBEDEF' ...]
       or: perf probe [<options>] --del '[GROUP:]EVENT' ...
       or: perf probe --list [GROUP:]EVENT ...
       or: perf probe [<options>] --line 'LINEDESC'
       or: perf probe [<options>] --vars 'PROBEPOINT'
       or: perf probe [<options>] --funcs

       -F, --funcs <[FILTER]>
                             Show potential probe-able functions.
       -l, --list <[GROUP:]EVENT>
                             list up probe events

    # perf config --list-all --list
    Error: option `list' cannot be used with list-all
    Usage: perf config [<file-option>] [options]

        -l, --list            show current config variables
        -a, --list-all        show current and all possible config variables with default values

Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Taeung Song <treeze.taeung@gmail.com>
---
 tools/lib/subcmd/parse-options.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/lib/subcmd/parse-options.c b/tools/lib/subcmd/parse-options.c
index 981bb44..b217b90 100644
--- a/tools/lib/subcmd/parse-options.c
+++ b/tools/lib/subcmd/parse-options.c
@@ -911,7 +911,7 @@ opt:
 		if (opts->long_name == NULL)
 			continue;
 
-		if (!prefixcmp(opts->long_name, optstr))
+		if (!strcmp(opts->long_name, optstr))
 			print_option_help(opts, 0);
 		if (!prefixcmp("no-", optstr) &&
 		    !prefixcmp(opts->long_name, optstr + 3))
-- 
2.5.0

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-03-07 14:59 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-07 14:59 [PATCH v2] perf subcmd: Bugfix more exactly handle the error about 'PARSE_OPT_EXCLUSIVE' Taeung Song

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®