diff options
author | Namhyung Kim <namhyung@kernel.org> | 2013-12-09 00:34:09 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-12-09 13:39:57 -0500 |
commit | 7ef2e813476273ac9c9138f002d8f4cb28e5adad (patch) | |
tree | 39f812c265f2ff0ae3e28c2985a789ee6c40ebc5 /tools/lib | |
parent | 28942c87e5e907f591d77547203e86ad1089b499 (diff) |
tools lib traceevent: Get rid of die() in pevent_filter_clear_trivial()
Change the function signature to return error code and not call die()
anymore.
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-13-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/lib')
-rw-r--r-- | tools/lib/traceevent/event-parse.h | 2 | ||||
-rw-r--r-- | tools/lib/traceevent/parse-filter.c | 21 |
2 files changed, 16 insertions, 7 deletions
diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h index 620c27a72960..6e23f197175f 100644 --- a/tools/lib/traceevent/event-parse.h +++ b/tools/lib/traceevent/event-parse.h | |||
@@ -860,7 +860,7 @@ int pevent_event_filtered(struct event_filter *filter, | |||
860 | 860 | ||
861 | void pevent_filter_reset(struct event_filter *filter); | 861 | void pevent_filter_reset(struct event_filter *filter); |
862 | 862 | ||
863 | void pevent_filter_clear_trivial(struct event_filter *filter, | 863 | int pevent_filter_clear_trivial(struct event_filter *filter, |
864 | enum filter_trivial_type type); | 864 | enum filter_trivial_type type); |
865 | 865 | ||
866 | void pevent_filter_free(struct event_filter *filter); | 866 | void pevent_filter_free(struct event_filter *filter); |
diff --git a/tools/lib/traceevent/parse-filter.c b/tools/lib/traceevent/parse-filter.c index a4d5bb23a110..ab402fb2dcf7 100644 --- a/tools/lib/traceevent/parse-filter.c +++ b/tools/lib/traceevent/parse-filter.c | |||
@@ -1504,8 +1504,10 @@ int pevent_update_trivial(struct event_filter *dest, struct event_filter *source | |||
1504 | * @type: remove only true, false, or both | 1504 | * @type: remove only true, false, or both |
1505 | * | 1505 | * |
1506 | * Removes filters that only contain a TRUE or FALES boolean arg. | 1506 | * Removes filters that only contain a TRUE or FALES boolean arg. |
1507 | * | ||
1508 | * Returns 0 on success and -1 if there was a problem. | ||
1507 | */ | 1509 | */ |
1508 | void pevent_filter_clear_trivial(struct event_filter *filter, | 1510 | int pevent_filter_clear_trivial(struct event_filter *filter, |
1509 | enum filter_trivial_type type) | 1511 | enum filter_trivial_type type) |
1510 | { | 1512 | { |
1511 | struct filter_type *filter_type; | 1513 | struct filter_type *filter_type; |
@@ -1514,13 +1516,15 @@ void pevent_filter_clear_trivial(struct event_filter *filter, | |||
1514 | int i; | 1516 | int i; |
1515 | 1517 | ||
1516 | if (!filter->filters) | 1518 | if (!filter->filters) |
1517 | return; | 1519 | return 0; |
1518 | 1520 | ||
1519 | /* | 1521 | /* |
1520 | * Two steps, first get all ids with trivial filters. | 1522 | * Two steps, first get all ids with trivial filters. |
1521 | * then remove those ids. | 1523 | * then remove those ids. |
1522 | */ | 1524 | */ |
1523 | for (i = 0; i < filter->filters; i++) { | 1525 | for (i = 0; i < filter->filters; i++) { |
1526 | int *new_ids; | ||
1527 | |||
1524 | filter_type = &filter->event_filters[i]; | 1528 | filter_type = &filter->event_filters[i]; |
1525 | if (filter_type->filter->type != FILTER_ARG_BOOLEAN) | 1529 | if (filter_type->filter->type != FILTER_ARG_BOOLEAN) |
1526 | continue; | 1530 | continue; |
@@ -1535,19 +1539,24 @@ void pevent_filter_clear_trivial(struct event_filter *filter, | |||
1535 | break; | 1539 | break; |
1536 | } | 1540 | } |
1537 | 1541 | ||
1538 | ids = realloc(ids, sizeof(*ids) * (count + 1)); | 1542 | new_ids = realloc(ids, sizeof(*ids) * (count + 1)); |
1539 | if (!ids) | 1543 | if (!new_ids) { |
1540 | die("Can't allocate ids"); | 1544 | free(ids); |
1545 | return -1; | ||
1546 | } | ||
1547 | |||
1548 | ids = new_ids; | ||
1541 | ids[count++] = filter_type->event_id; | 1549 | ids[count++] = filter_type->event_id; |
1542 | } | 1550 | } |
1543 | 1551 | ||
1544 | if (!count) | 1552 | if (!count) |
1545 | return; | 1553 | return 0; |
1546 | 1554 | ||
1547 | for (i = 0; i < count; i++) | 1555 | for (i = 0; i < count; i++) |
1548 | pevent_filter_remove_event(filter, ids[i]); | 1556 | pevent_filter_remove_event(filter, ids[i]); |
1549 | 1557 | ||
1550 | free(ids); | 1558 | free(ids); |
1559 | return 0; | ||
1551 | } | 1560 | } |
1552 | 1561 | ||
1553 | /** | 1562 | /** |