Skip to content

Commit

Permalink
tools lib traceevent: Refactor create_arg_item()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Namhyung Kim authored and Arnaldo Carvalho de Melo committed Dec 13, 2013
1 parent 7bb7355 commit c8ea690
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
3 changes: 2 additions & 1 deletion tools/lib/traceevent/event-parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 10 additions & 10 deletions tools/lib/traceevent/parse-filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -368,17 +368,17 @@ 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;

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) {
Expand All @@ -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:
Expand Down Expand Up @@ -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 *
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit c8ea690

Please sign in to comment.