Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1351671

[PATCH v2] perf subcmd: Bugfix more exactly handle the error about 'PARSE_OPT_EXCLUSIVE'

Path csiph.com!news.mixmin.net!aioe.org!bofh.it!news.nic.it!robomod
From Taeung Song <treeze.taeung@gmail.com>
Newsgroups linux.kernel
Subject [PATCH v2] perf subcmd: Bugfix more exactly handle the error about 'PARSE_OPT_EXCLUSIVE'
Date Mon, 07 Mar 2016 16:00:02 +0100
Message-ID <ra4NA-49R-13@gated-at.bofh.it> (permalink)
X-Original-To Arnaldo Carvalho de Melo <acme@kernel.org>
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=fUBHKPv2a89QY5w/cfutHHQcmpuh/NILUE6mPxMw8H4=; b=QpDunohzokkunoRYd80i7eBVKsQYePwV4ovArRXFJZM5mff60sEYybWN+z1B/nkDOA LG8Fr3IrKki7r5TJOswkYqSVrve2/yLdEiS9TTBAw3t8f9rUKi7BFrjp9NuNVQIgQq2i JjaWazkiuHAyHgUSdfPhgREVRxiD9trZo87cOXQ4yR5shbC2E5WtGsjOwYkv9p8XPBBq NxdbovJP7ySa5AdjTe/opOlpdSvgdt3eSmAzVKPW6/OPNaGrhrHUAd2rwiBCGVe3HxNg EEjkHGfi7mInemW3TdImczTxcYYfmE8gMXmiAxXxfbZg0tHvMKw++cOFT557x+4ztJOb T90A==
X-Google-Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=fUBHKPv2a89QY5w/cfutHHQcmpuh/NILUE6mPxMw8H4=; b=Fd7niWfUeaR53DAbloiaUxU5P9duBtMyrFXuXunyxhAZ3CxhJhMAZnSW0SbKoskWFT YL2I03QK+yLo8KOOGUz6oZ96FOcQXH21Y3Co4qMhScXvTSuwePlMTYwIKNI7d1IJZh22 jQ4dLNqw0HuBq9vcCiA1nnBXyjdpCgFaC8sEawzRSvkcO7KudjZAYK0VX0pEbt5XZLj5 f2FuTulSf9/ElPCiSrw8eJ6csZV1pm5mRJYBt0BS86GuUVU2EKIcjghDXHm+Q/MuD7VD 2I/ifFtTheYT4mVRWZAbVab32cPRTAlagSiApOFaSHwtkum5ZkdGFb1wDCfOEXwqCZJr ckOQ==
X-Gm-Message-State AD7BkJI4hGNuxxCbygbN30L8MKq//yN+V+B3Tm1nFq4RcqzitbZMVlEHGkTixi5ImIVeaQ==
X-Received by 10.66.145.68 with SMTP id ss4mr34191174pab.79.1457362755602; Mon, 07 Mar 2016 06:59:15 -0800 (PST)
X-Mailer git-send-email 2.5.0
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 113
Organization linux.* mail to news gateway
X-Original-Cc linux-kernel@vger.kernel.org, Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>, Ingo Molnar <mingo@kernel.org>, Peter Zijlstra <peterz@infradead.org>, Taeung Song <treeze.taeung@gmail.com>
X-Original-Date Mon, 7 Mar 2016 23:59:10 +0900
X-Original-Message-ID <1457362750-30921-1-git-send-email-treeze.taeung@gmail.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1351671

Show key headers only | View raw


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

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[PATCH v2] perf subcmd: Bugfix more exactly handle the error about 'PARSE_OPT_EXCLUSIVE' Taeung Song <treeze.taeung@gmail.com> - 2016-03-07 16:00 +0100

csiph-web