diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2009-12-28 19:48:33 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-12-30 05:59:57 -0500 |
commit | ae99fb2c335ef018520950ddc9692faacab39cf2 (patch) | |
tree | 9476516a203657b118f878d8ca6b4d0793a12c1e /tools/perf/util/header.c | |
parent | 769885f372300a7fcfb9e54e4e2990718d40b529 (diff) |
perf header: perf_header__push_event() shouldn't die
Just propagate eventual errors.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
LKML-Reference: <1262047716-23171-2-git-send-email-acme@infradead.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/util/header.c')
-rw-r--r-- | tools/perf/util/header.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 6b3cb94e8a2b..709e3252f049 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c | |||
@@ -105,24 +105,28 @@ struct perf_trace_event_type { | |||
105 | static int event_count; | 105 | static int event_count; |
106 | static struct perf_trace_event_type *events; | 106 | static struct perf_trace_event_type *events; |
107 | 107 | ||
108 | void perf_header__push_event(u64 id, const char *name) | 108 | int perf_header__push_event(u64 id, const char *name) |
109 | { | 109 | { |
110 | if (strlen(name) > MAX_EVENT_NAME) | 110 | if (strlen(name) > MAX_EVENT_NAME) |
111 | pr_warning("Event %s will be truncated\n", name); | 111 | pr_warning("Event %s will be truncated\n", name); |
112 | 112 | ||
113 | if (!events) { | 113 | if (!events) { |
114 | events = malloc(sizeof(struct perf_trace_event_type)); | 114 | events = malloc(sizeof(struct perf_trace_event_type)); |
115 | if (!events) | 115 | if (events == NULL) |
116 | die("nomem"); | 116 | return -ENOMEM; |
117 | } else { | 117 | } else { |
118 | events = realloc(events, (event_count + 1) * sizeof(struct perf_trace_event_type)); | 118 | struct perf_trace_event_type *nevents; |
119 | if (!events) | 119 | |
120 | die("nomem"); | 120 | nevents = realloc(events, (event_count + 1) * sizeof(*events)); |
121 | if (nevents == NULL) | ||
122 | return -ENOMEM; | ||
123 | events = nevents; | ||
121 | } | 124 | } |
122 | memset(&events[event_count], 0, sizeof(struct perf_trace_event_type)); | 125 | memset(&events[event_count], 0, sizeof(struct perf_trace_event_type)); |
123 | events[event_count].event_id = id; | 126 | events[event_count].event_id = id; |
124 | strncpy(events[event_count].name, name, MAX_EVENT_NAME - 1); | 127 | strncpy(events[event_count].name, name, MAX_EVENT_NAME - 1); |
125 | event_count++; | 128 | event_count++; |
129 | return 0; | ||
126 | } | 130 | } |
127 | 131 | ||
128 | char *perf_header__find_event(u64 id) | 132 | char *perf_header__find_event(u64 id) |