From: tip-bot for Namhyung Kim <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: acme@redhat.com, linux-kernel@vger.kernel.org, hpa@zytor.com,
mingo@kernel.org, a.p.zijlstra@chello.nl, namhyung.kim@lge.com,
namhyung@kernel.org, jolsa@redhat.com, fweisbec@gmail.com,
rostedt@goodmis.org, tglx@linutronix.de
Subject: [tip:perf/core] tools lib traceevent: Refactor create_arg_item()
Date: Mon, 16 Dec 2013 07:29:07 -0800 [thread overview]
Message-ID: <tip-c8ea690dd0d1385a766d68c51832497181e013b8@git.kernel.org> (raw)
In-Reply-To: <1386833777-3790-10-git-send-email-namhyung@kernel.org>
Commit-ID: c8ea690dd0d1385a766d68c51832497181e013b8
Gitweb: http://git.kernel.org/tip/c8ea690dd0d1385a766d68c51832497181e013b8
Author: Namhyung Kim <namhyung.kim@lge.com>
AuthorDate: Thu, 12 Dec 2013 16:36:12 +0900
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 13 Dec 2013 10:30:22 -0300
tools lib traceevent: Refactor create_arg_item()
So that it can return a proper pevent_errno value.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1386833777-3790-10-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/lib/traceevent/event-parse.h | 3 ++-
tools/lib/traceevent/parse-filter.c | 20 ++++++++++----------
2 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h
index 5e4392d..57b66ae 100644
--- a/tools/lib/traceevent/event-parse.h
+++ b/tools/lib/traceevent/event-parse.h
@@ -367,7 +367,8 @@ enum pevent_flag {
_PE(ILLEGAL_INTEGER_CMP,"illegal comparison for integer"), \
_PE(REPARENT_NOT_OP, "cannot reparent other than OP"), \
_PE(REPARENT_FAILED, "failed to reparent filter OP"), \
- _PE(BAD_FILTER_ARG, "bad arg in filter tree")
+ _PE(BAD_FILTER_ARG, "bad arg in filter tree"), \
+ _PE(UNEXPECTED_TYPE, "unexpected type (not a value)")
#undef _PE
#define _PE(__code, __str) PEVENT_ERRNO__ ## __code
diff --git a/tools/lib/traceevent/parse-filter.c b/tools/lib/traceevent/parse-filter.c
index 9b05892..8d71208 100644
--- a/tools/lib/traceevent/parse-filter.c
+++ b/tools/lib/traceevent/parse-filter.c
@@ -368,9 +368,9 @@ static void free_events(struct event_list *events)
}
}
-static struct filter_arg *
+static enum pevent_errno
create_arg_item(struct event_format *event, const char *token,
- enum event_type type, char **error_str)
+ enum event_type type, struct filter_arg **parg, char **error_str)
{
struct format_field *field;
struct filter_arg *arg;
@@ -378,7 +378,7 @@ create_arg_item(struct event_format *event, const char *token,
arg = allocate_arg();
if (arg == NULL) {
show_error(error_str, "failed to allocate filter arg");
- return NULL;
+ return PEVENT_ERRNO__MEM_ALLOC_FAILED;
}
switch (type) {
@@ -392,7 +392,7 @@ create_arg_item(struct event_format *event, const char *token,
if (!arg->value.str) {
free_arg(arg);
show_error(error_str, "failed to allocate string filter arg");
- return NULL;
+ return PEVENT_ERRNO__MEM_ALLOC_FAILED;
}
break;
case EVENT_ITEM:
@@ -420,11 +420,11 @@ create_arg_item(struct event_format *event, const char *token,
break;
default:
free_arg(arg);
- show_error(error_str, "expected a value but found %s",
- token);
- return NULL;
+ show_error(error_str, "expected a value but found %s", token);
+ return PEVENT_ERRNO__UNEXPECTED_TYPE;
}
- return arg;
+ *parg = arg;
+ return 0;
}
static struct filter_arg *
@@ -993,8 +993,8 @@ process_filter(struct event_format *event, struct filter_arg **parg,
case EVENT_SQUOTE:
case EVENT_DQUOTE:
case EVENT_ITEM:
- arg = create_arg_item(event, token, type, error_str);
- if (!arg)
+ ret = create_arg_item(event, token, type, &arg, error_str);
+ if (ret < 0)
goto fail;
if (!left_item)
left_item = arg;
next prev parent reply other threads:[~2013-12-16 15:29 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-12 7:36 [PATCHSET 00/14] tools lib traceevent: Get rid of *die() calls from parse-filter.c (v2) Namhyung Kim
2013-12-12 7:36 ` [PATCH 01/14] tools lib traceevent: Get rid of malloc_or_die() in show_error() Namhyung Kim
2013-12-16 15:27 ` [tip:perf/core] " tip-bot for Namhyung Kim
2013-12-12 7:36 ` [PATCH 02/14] tools lib traceevent: Get rid of die in add_filter_type() Namhyung Kim
2013-12-16 15:28 ` [tip:perf/core] " tip-bot for Namhyung Kim
2013-12-12 7:36 ` [PATCH 03/14] tools lib traceevent: Get rid of malloc_or_die() allocate_arg() Namhyung Kim
2013-12-16 15:28 ` [tip:perf/core] " tip-bot for Namhyung Kim
2013-12-12 7:36 ` [PATCH 04/14] tools lib traceevent: Get rid of malloc_or_die() in read_token() Namhyung Kim
2013-12-16 15:28 ` [tip:perf/core] " tip-bot for Namhyung Kim
2013-12-12 7:36 ` [PATCH 05/14] tools lib traceevent: Get rid of malloc_or_die() in find_event() Namhyung Kim
2013-12-16 15:28 ` [tip:perf/core] " tip-bot for Namhyung Kim
2013-12-12 7:36 ` [PATCH 06/14] tools lib traceevent: Get rid of die() in add_right() Namhyung Kim
2013-12-16 15:28 ` [tip:perf/core] " tip-bot for Namhyung Kim
2013-12-12 7:36 ` [PATCH 07/14] tools lib traceevent: Make add_left() return pevent_errno Namhyung Kim
2013-12-16 15:28 ` [tip:perf/core] " tip-bot for Namhyung Kim
2013-12-12 7:36 ` [PATCH 08/14] tools lib traceevent: Get rid of die() in reparent_op_arg() Namhyung Kim
2013-12-16 15:28 ` [tip:perf/core] " tip-bot for Namhyung Kim
2013-12-12 7:36 ` [PATCH 09/14] tools lib traceevent: Refactor create_arg_item() Namhyung Kim
2013-12-16 15:29 ` tip-bot for Namhyung Kim [this message]
2013-12-12 7:36 ` [PATCH 10/14] tools lib traceevent: Refactor process_filter() Namhyung Kim
2013-12-16 15:29 ` [tip:perf/core] " tip-bot for Namhyung Kim
2013-12-12 7:36 ` [PATCH 11/14] tools lib traceevent: Make pevent_filter_add_filter_str() return pevent_errno Namhyung Kim
2013-12-16 15:29 ` [tip:perf/core] " tip-bot for Namhyung Kim
2013-12-12 7:36 ` [PATCH 12/14] tools lib traceevent: Refactor pevent_filter_match() to get rid of die() Namhyung Kim
2013-12-16 15:29 ` [tip:perf/core] " tip-bot for Namhyung Kim
2013-12-12 7:36 ` [PATCH 13/14] tools lib traceevent: Get rid of die() in some string conversion funcitons Namhyung Kim
2013-12-12 18:41 ` Arnaldo Carvalho de Melo
2013-12-13 0:15 ` Namhyung Kim
2013-12-13 14:52 ` Arnaldo Carvalho de Melo
2013-12-16 4:49 ` Namhyung Kim
2013-12-16 12:40 ` Arnaldo Carvalho de Melo
2013-12-17 0:02 ` Namhyung Kim
2013-12-17 20:02 ` Arnaldo Carvalho de Melo
2013-12-18 4:09 ` Namhyung Kim
2013-12-18 10:33 ` [tip:perf/core] tools lib traceevent: Get rid of die() in some string conversion functions tip-bot for Namhyung Kim
2013-12-12 7:36 ` [PATCH 14/14] tools lib traceevent: Introduce pevent_filter_strerror() Namhyung Kim
2014-01-12 18:31 ` [tip:perf/core] " tip-bot for Namhyung Kim
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-c8ea690dd0d1385a766d68c51832497181e013b8@git.kernel.org \
--to=tipbot@zytor.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@redhat.com \
--cc=fweisbec@gmail.com \
--cc=hpa@zytor.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung.kim@lge.com \
--cc=namhyung@kernel.org \
--cc=rostedt@goodmis.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