From: tip-bot for Jiri Olsa <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: tglx@linutronix.de, namhyung@kernel.org,
linux-kernel@vger.kernel.org, jolsa@kernel.org, acme@redhat.com,
dsahern@gmail.com, mingo@kernel.org, a.p.zijlstra@chello.nl,
hpa@zytor.com
Subject: [tip:perf/urgent] perf tools: Move new_term arguments into struct parse_events_term template
Date: Tue, 21 Feb 2017 00:13:51 -0800 [thread overview]
Message-ID: <tip-67b49b38f7bd6f34319b540ce824d5697241b3a8@git.kernel.org> (raw)
In-Reply-To: <1487340058-10496-3-git-send-email-jolsa@kernel.org>
Commit-ID: 67b49b38f7bd6f34319b540ce824d5697241b3a8
Gitweb: http://git.kernel.org/tip/67b49b38f7bd6f34319b540ce824d5697241b3a8
Author: Jiri Olsa <jolsa@kernel.org>
AuthorDate: Fri, 17 Feb 2017 15:00:55 +0100
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 17 Feb 2017 17:27:54 -0300
perf tools: Move new_term arguments into struct parse_events_term template
We need to add yet another parameter to new_term function in following
patch, so it's better to move first all the current params into template
struct parse_events_term and use it as a single argument.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1487340058-10496-3-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/parse-events.c | 69 ++++++++++++++++++++++++------------------
1 file changed, 39 insertions(+), 30 deletions(-)
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 281e44a..984d99a 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -2318,24 +2318,20 @@ int parse_events__is_hardcoded_term(struct parse_events_term *term)
return term->type_term != PARSE_EVENTS__TERM_TYPE_USER;
}
-static int new_term(struct parse_events_term **_term, int type_val,
- int type_term, char *config,
- char *str, u64 num, int err_term, int err_val)
+static int new_term(struct parse_events_term **_term,
+ struct parse_events_term *temp,
+ char *str, u64 num)
{
struct parse_events_term *term;
- term = zalloc(sizeof(*term));
+ term = malloc(sizeof(*term));
if (!term)
return -ENOMEM;
+ *term = *temp;
INIT_LIST_HEAD(&term->list);
- term->type_val = type_val;
- term->type_term = type_term;
- term->config = config;
- term->err_term = err_term;
- term->err_val = err_val;
- switch (type_val) {
+ switch (term->type_val) {
case PARSE_EVENTS__TERM_TYPE_NUM:
term->val.num = num;
break;
@@ -2358,10 +2354,15 @@ int parse_events_term__num(struct parse_events_term **term,
YYLTYPE *loc_term = loc_term_;
YYLTYPE *loc_val = loc_val_;
- return new_term(term, PARSE_EVENTS__TERM_TYPE_NUM, type_term,
- config, NULL, num,
- loc_term ? loc_term->first_column : 0,
- loc_val ? loc_val->first_column : 0);
+ struct parse_events_term temp = {
+ .type_val = PARSE_EVENTS__TERM_TYPE_NUM,
+ .type_term = type_term,
+ .config = config,
+ .err_term = loc_term ? loc_term->first_column : 0,
+ .err_val = loc_val ? loc_val->first_column : 0,
+ };
+
+ return new_term(term, &temp, NULL, num);
}
int parse_events_term__str(struct parse_events_term **term,
@@ -2371,37 +2372,45 @@ int parse_events_term__str(struct parse_events_term **term,
YYLTYPE *loc_term = loc_term_;
YYLTYPE *loc_val = loc_val_;
- return new_term(term, PARSE_EVENTS__TERM_TYPE_STR, type_term,
- config, str, 0,
- loc_term ? loc_term->first_column : 0,
- loc_val ? loc_val->first_column : 0);
+ struct parse_events_term temp = {
+ .type_val = PARSE_EVENTS__TERM_TYPE_STR,
+ .type_term = type_term,
+ .config = config,
+ .err_term = loc_term ? loc_term->first_column : 0,
+ .err_val = loc_val ? loc_val->first_column : 0,
+ };
+
+ return new_term(term, &temp, str, 0);
}
int parse_events_term__sym_hw(struct parse_events_term **term,
char *config, unsigned idx)
{
struct event_symbol *sym;
+ struct parse_events_term temp = {
+ .type_val = PARSE_EVENTS__TERM_TYPE_STR,
+ .type_term = PARSE_EVENTS__TERM_TYPE_USER,
+ .config = config ?: (char *) "event",
+ };
BUG_ON(idx >= PERF_COUNT_HW_MAX);
sym = &event_symbols_hw[idx];
- if (config)
- return new_term(term, PARSE_EVENTS__TERM_TYPE_STR,
- PARSE_EVENTS__TERM_TYPE_USER, config,
- (char *) sym->symbol, 0, 0, 0);
- else
- return new_term(term, PARSE_EVENTS__TERM_TYPE_STR,
- PARSE_EVENTS__TERM_TYPE_USER,
- (char *) "event", (char *) sym->symbol,
- 0, 0, 0);
+ return new_term(term, &temp, (char *) sym->symbol, 0);
}
int parse_events_term__clone(struct parse_events_term **new,
struct parse_events_term *term)
{
- return new_term(new, term->type_val, term->type_term, term->config,
- term->val.str, term->val.num,
- term->err_term, term->err_val);
+ struct parse_events_term temp = {
+ .type_val = term->type_val,
+ .type_term = term->type_term,
+ .config = term->config,
+ .err_term = term->err_term,
+ .err_val = term->err_val,
+ };
+
+ return new_term(new, &temp, term->val.str, term->val.num);
}
void parse_events_terms__purge(struct list_head *terms)
next prev parent reply other threads:[~2017-02-21 8:14 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-17 14:00 [PATCH 0/5] perf tools: Few fixes Jiri Olsa
2017-02-17 14:00 ` [PATCH 1/5] perf build: Add special fixdep cleaning rule Jiri Olsa
2017-02-21 8:13 ` [tip:perf/urgent] " tip-bot for Jiri Olsa
2017-02-17 14:00 ` [PATCH 2/5] perf tools: Move new_term arguments into struct parse_events_term template Jiri Olsa
2017-02-21 8:13 ` tip-bot for Jiri Olsa [this message]
2017-02-17 14:00 ` [PATCH 3/5] perf tools: Fail on using multiple bits long terms without value Jiri Olsa
2017-02-21 8:14 ` [tip:perf/urgent] " tip-bot for Jiri Olsa
2017-02-17 14:00 ` [PATCH 4/5] perf stat: Add -a as a default target Jiri Olsa
2017-02-17 14:27 ` Arnaldo Carvalho de Melo
2017-02-17 14:33 ` Jiri Olsa
2017-02-17 14:41 ` Arnaldo Carvalho de Melo
2017-02-17 14:43 ` Jiri Olsa
2017-02-17 17:00 ` [PATCHv2 " Jiri Olsa
2017-02-17 17:48 ` Boris Petkov
2017-02-18 17:52 ` Borislav Petkov
2017-02-20 7:13 ` Jiri Olsa
[not found] ` <20170220134433.GI4109@kernel.org>
2017-02-20 20:31 ` Borislav Petkov
2017-02-20 21:22 ` Arnaldo Carvalho de Melo
2017-02-20 22:47 ` Borislav Petkov
2017-02-21 7:54 ` Jiri Olsa
2017-02-21 11:04 ` Jiri Olsa
2017-02-21 11:20 ` Borislav Petkov
2017-02-21 13:34 ` Arnaldo Carvalho de Melo
2017-02-21 14:05 ` Borislav Petkov
2017-02-21 14:20 ` Arnaldo Carvalho de Melo
2017-02-21 8:14 ` [tip:perf/urgent] perf stat: Add -a as " tip-bot for Jiri Olsa
2017-02-17 14:00 ` [PATCH 5/5] perf record: Add -a as a " Jiri Olsa
2017-02-17 14:28 ` Arnaldo Carvalho de Melo
2017-02-17 17:00 ` Jiri Olsa
2017-02-21 8:15 ` [tip:perf/urgent] perf record: Add -a as " tip-bot for 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-67b49b38f7bd6f34319b540ce824d5697241b3a8@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=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=tglx@linutronix.de \
/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
Powered by JetHome