Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753122AbcCGO7X (ORCPT ); Mon, 7 Mar 2016 09:59:23 -0500 Received: from mail-pa0-f68.google.com ([209.85.220.68]:33576 "EHLO mail-pa0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752675AbcCGO7Q (ORCPT ); Mon, 7 Mar 2016 09:59:16 -0500 From: Taeung Song To: Arnaldo Carvalho de Melo Cc: linux-kernel@vger.kernel.org, Jiri Olsa , Namhyung Kim , Ingo Molnar , Peter Zijlstra , Taeung Song Subject: [PATCH v2] perf subcmd: Bugfix more exactly handle the error about 'PARSE_OPT_EXCLUSIVE' Date: Mon, 7 Mar 2016 23:59:10 +0900 Message-Id: <1457362750-30921-1-git-send-email-treeze.taeung@gmail.com> X-Mailer: git-send-email 2.5.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4467 Lines: 113 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 [] 'PROBEDEF' ['PROBEDEF' ...] or: perf probe [] --add 'PROBEDEF' [--add 'PROBEDEF' ...] or: perf probe [] --del '[GROUP:]EVENT' ... or: perf probe --list [GROUP:]EVENT ... or: perf probe [] --line 'LINEDESC' or: perf probe [] --vars 'PROBEPOINT' or: perf probe [] --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 [] [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 [] 'PROBEDEF' ['PROBEDEF' ...] or: perf probe [] --add 'PROBEDEF' [--add 'PROBEDEF' ...] or: perf probe [] --del '[GROUP:]EVENT' ... or: perf probe --list [GROUP:]EVENT ... or: perf probe [] --line 'LINEDESC' or: perf probe [] --vars 'PROBEPOINT' or: perf probe [] --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 [] [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 [] 'PROBEDEF' ['PROBEDEF' ...] or: perf probe [] --add 'PROBEDEF' [--add 'PROBEDEF' ...] or: perf probe [] --del '[GROUP:]EVENT' ... or: perf probe --list [GROUP:]EVENT ... or: perf probe [] --line 'LINEDESC' or: perf probe [] --vars 'PROBEPOINT' or: perf probe [] --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 [] [options] -l, --list show current config variables -a, --list-all show current and all possible config variables with default values Cc: Namhyung Kim Cc: Jiri Olsa Cc: Ingo Molnar Signed-off-by: Taeung Song --- 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