From: tip-bot for Jiri Olsa <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: hpa@zytor.com, wangnan0@huawei.com, jolsa@kernel.org,
mingo@kernel.org, linux-kernel@vger.kernel.org,
tglx@linutronix.de, acme@redhat.com, a.p.zijlstra@chello.nl,
namhyung@kernel.org, jpoimboe@redhat.com, dsahern@gmail.com
Subject: [tip:perf/urgent] tools lib subcmd: Add OPT_STRING_OPTARG_SET option
Date: Wed, 4 Jan 2017 23:51:14 -0800 [thread overview]
Message-ID: <tip-b66fb1da5a8cac3f5c3cdbe41937c91efc4e76a4@git.kernel.org> (raw)
In-Reply-To: <1483431600-19887-2-git-send-email-jolsa@kernel.org>
Commit-ID: b66fb1da5a8cac3f5c3cdbe41937c91efc4e76a4
Gitweb: http://git.kernel.org/tip/b66fb1da5a8cac3f5c3cdbe41937c91efc4e76a4
Author: Jiri Olsa <jolsa@kernel.org>
AuthorDate: Tue, 3 Jan 2017 09:19:54 +0100
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 3 Jan 2017 11:10:38 -0300
tools lib subcmd: Add OPT_STRING_OPTARG_SET option
To allow string options with a default argument and variable set when
the option is used.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Wang Nan <wangnan0@huawei.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1483431600-19887-2-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/lib/subcmd/parse-options.c | 3 +++
tools/lib/subcmd/parse-options.h | 5 +++++
2 files changed, 8 insertions(+)
diff --git a/tools/lib/subcmd/parse-options.c b/tools/lib/subcmd/parse-options.c
index 3284bb1..8aad811 100644
--- a/tools/lib/subcmd/parse-options.c
+++ b/tools/lib/subcmd/parse-options.c
@@ -213,6 +213,9 @@ static int get_value(struct parse_opt_ctx_t *p,
else
err = get_arg(p, opt, flags, (const char **)opt->value);
+ if (opt->set)
+ *(bool *)opt->set = true;
+
/* PARSE_OPT_NOEMPTY: Allow NULL but disallow empty string. */
if (opt->flags & PARSE_OPT_NOEMPTY) {
const char *val = *(const char **)opt->value;
diff --git a/tools/lib/subcmd/parse-options.h b/tools/lib/subcmd/parse-options.h
index 8866ac4..11c3be3 100644
--- a/tools/lib/subcmd/parse-options.h
+++ b/tools/lib/subcmd/parse-options.h
@@ -137,6 +137,11 @@ struct option {
{ .type = OPTION_STRING, .short_name = (s), .long_name = (l), \
.value = check_vtype(v, const char **), (a), .help = (h), \
.flags = PARSE_OPT_OPTARG, .defval = (intptr_t)(d) }
+#define OPT_STRING_OPTARG_SET(s, l, v, os, a, h, d) \
+ { .type = OPTION_STRING, .short_name = (s), .long_name = (l), \
+ .value = check_vtype(v, const char **), (a), .help = (h), \
+ .flags = PARSE_OPT_OPTARG, .defval = (intptr_t)(d), \
+ .set = check_vtype(os, bool *)}
#define OPT_STRING_NOEMPTY(s, l, v, a, h) { .type = OPTION_STRING, .short_name = (s), .long_name = (l), .value = check_vtype(v, const char **), (a), .help = (h), .flags = PARSE_OPT_NOEMPTY}
#define OPT_DATE(s, l, v, h) \
{ .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value = (v), .argh = "time", .help = (h), .callback = parse_opt_approxidate_cb }
next prev parent reply other threads:[~2017-01-05 7:53 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-03 8:19 [PATCH 0/7] perf tools: Add switch-output size and time threshold options Jiri Olsa
2017-01-03 8:19 ` [PATCH 1/7] tools lib subcmd: Add OPT_STRING_OPTARG_SET option Jiri Olsa
2017-01-05 7:51 ` tip-bot for Jiri Olsa [this message]
2017-01-03 8:19 ` [PATCH 2/7] perf record: Make __record_options static Jiri Olsa
2017-01-05 7:51 ` [tip:perf/urgent] " tip-bot for Jiri Olsa
2017-01-03 8:19 ` [PATCH 3/7] perf record: Fix --switch-output documentation and comment Jiri Olsa
2017-01-05 7:52 ` [tip:perf/urgent] " tip-bot for Jiri Olsa
2017-01-03 8:19 ` [PATCH 4/7] perf record: Add struct switch_output Jiri Olsa
2017-01-03 8:19 ` [PATCH 5/7] perf record: Change switch-output option to take optional argument Jiri Olsa
2017-01-03 8:19 ` [PATCH 6/7] perf record: Add switch-output size option argument Jiri Olsa
2017-01-03 14:20 ` Arnaldo Carvalho de Melo
2017-01-03 14:21 ` Arnaldo Carvalho de Melo
2017-01-03 14:32 ` Jiri Olsa
2017-01-03 14:49 ` Arnaldo Carvalho de Melo
2017-01-03 15:33 ` David Ahern
2017-01-03 16:12 ` Arnaldo Carvalho de Melo
2017-01-03 16:23 ` David Ahern
2017-01-03 19:42 ` Jiri Olsa
2017-01-03 8:20 ` [PATCH 7/7] perf record: Add switch-output time " Jiri Olsa
2017-01-03 9:51 ` [PATCH 0/7] perf tools: Add switch-output size and time threshold options Wangnan (F)
2017-01-03 10:39 ` Jiri Olsa
2017-01-10 13:35 ` Arnaldo Carvalho de Melo
2017-01-10 18:40 ` Jiri Olsa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tip-b66fb1da5a8cac3f5c3cdbe41937c91efc4e76a4@git.kernel.org \
--to=tipbot@zytor.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@redhat.com \
--cc=dsahern@gmail.com \
--cc=hpa@zytor.com \
--cc=jolsa@kernel.org \
--cc=jpoimboe@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=tglx@linutronix.de \
--cc=wangnan0@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox