aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung.kim@lge.com>2012-09-06 22:49:46 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-09-07 11:15:07 -0400
commit0ca8da00ad170c12c12350c3a2500591a7bec535 (patch)
treeb491d60e8e4958021420999a44da95072b9677c9
parent245c5a18433090da0e1a799bdb0faa78552b5992 (diff)
tools lib traceevent: Get rid of die() from pevent_register_event_handler
If memory allocation for handler fails, return gracefully instead of calling die(). Note that casts to void * are needed because gcc complained about discarding 'const' qualifier during implicit argument cast. Signed-off-by: Namhyung Kim <namhyung@kernel.org> Acked-by: Steven Rostedt <rostedt@goodmis.org> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Steven Rostedt <rostedt@goodmis.org> Link: http://lkml.kernel.org/r/1346986187-5170-2-git-send-email-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/lib/traceevent/event-parse.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index 6d5e75987a3d..17fd01d46e60 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -5183,7 +5183,12 @@ int pevent_register_event_handler(struct pevent *pevent,
5183 5183
5184 not_found: 5184 not_found:
5185 /* Save for later use. */ 5185 /* Save for later use. */
5186 handle = malloc_or_die(sizeof(*handle)); 5186 handle = malloc(sizeof(*handle));
5187 if (!handle) {
5188 do_warning("Failed to allocate event handler");
5189 return PEVENT_ERRNO__MEM_ALLOC_FAILED;
5190 }
5191
5187 memset(handle, 0, sizeof(*handle)); 5192 memset(handle, 0, sizeof(*handle));
5188 handle->id = id; 5193 handle->id = id;
5189 if (event_name) 5194 if (event_name)
@@ -5193,7 +5198,11 @@ int pevent_register_event_handler(struct pevent *pevent,
5193 5198
5194 if ((event_name && !handle->event_name) || 5199 if ((event_name && !handle->event_name) ||
5195 (sys_name && !handle->sys_name)) { 5200 (sys_name && !handle->sys_name)) {
5196 die("Failed to allocate event/sys name"); 5201 do_warning("Failed to allocate event/sys name");
5202 free((void *)handle->event_name);
5203 free((void *)handle->sys_name);
5204 free(handle);
5205 return PEVENT_ERRNO__MEM_ALLOC_FAILED;
5197 } 5206 }
5198 5207
5199 handle->func = func; 5208 handle->func = func;