diff options
author | Namhyung Kim <namhyung@kernel.org> | 2013-12-09 00:34:04 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-12-09 13:39:40 -0500 |
commit | 234520d3fbe43ef72268c4959f85ae326459378c (patch) | |
tree | d1b5247b170cb705a3c6c1cd104d6f112a25231a | |
parent | 4f24416331e9a507e953e90d4534e9a9802cbc12 (diff) |
tools lib traceevent: Get rid of malloc_or_die() in add_event()
Make it return error value since its only caller find_event() now can
handle allocation error properly.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Reviewed-by: Steven Rostedt <rostedt@goodmis.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung.kim@lge.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1386567251-22751-8-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/lib/traceevent/parse-filter.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/tools/lib/traceevent/parse-filter.c b/tools/lib/traceevent/parse-filter.c index b3a61d4fe38e..2b73abfb0c9f 100644 --- a/tools/lib/traceevent/parse-filter.c +++ b/tools/lib/traceevent/parse-filter.c | |||
@@ -245,15 +245,19 @@ static void free_arg(struct filter_arg *arg) | |||
245 | free(arg); | 245 | free(arg); |
246 | } | 246 | } |
247 | 247 | ||
248 | static void add_event(struct event_list **events, | 248 | static int add_event(struct event_list **events, |
249 | struct event_format *event) | 249 | struct event_format *event) |
250 | { | 250 | { |
251 | struct event_list *list; | 251 | struct event_list *list; |
252 | 252 | ||
253 | list = malloc_or_die(sizeof(*list)); | 253 | list = malloc(sizeof(*list)); |
254 | if (list == NULL) | ||
255 | return -1; | ||
256 | |||
254 | list->next = *events; | 257 | list->next = *events; |
255 | *events = list; | 258 | *events = list; |
256 | list->event = event; | 259 | list->event = event; |
260 | return 0; | ||
257 | } | 261 | } |
258 | 262 | ||
259 | static int event_match(struct event_format *event, | 263 | static int event_match(struct event_format *event, |
@@ -276,6 +280,7 @@ find_event(struct pevent *pevent, struct event_list **events, | |||
276 | regex_t ereg; | 280 | regex_t ereg; |
277 | regex_t sreg; | 281 | regex_t sreg; |
278 | int match = 0; | 282 | int match = 0; |
283 | int fail = 0; | ||
279 | char *reg; | 284 | char *reg; |
280 | int ret; | 285 | int ret; |
281 | int i; | 286 | int i; |
@@ -310,7 +315,10 @@ find_event(struct pevent *pevent, struct event_list **events, | |||
310 | event = pevent->events[i]; | 315 | event = pevent->events[i]; |
311 | if (event_match(event, sys_name ? &sreg : NULL, &ereg)) { | 316 | if (event_match(event, sys_name ? &sreg : NULL, &ereg)) { |
312 | match = 1; | 317 | match = 1; |
313 | add_event(events, event); | 318 | if (add_event(events, event) < 0) { |
319 | fail = 1; | ||
320 | break; | ||
321 | } | ||
314 | } | 322 | } |
315 | } | 323 | } |
316 | 324 | ||
@@ -320,6 +328,8 @@ find_event(struct pevent *pevent, struct event_list **events, | |||
320 | 328 | ||
321 | if (!match) | 329 | if (!match) |
322 | return -1; | 330 | return -1; |
331 | if (fail) | ||
332 | return -2; | ||
323 | 333 | ||
324 | return 0; | 334 | return 0; |
325 | } | 335 | } |