Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 323776
b: refs/heads/master
c: 67ed939
h: refs/heads/master
v: v3
  • Loading branch information
Namhyung Kim authored and Arnaldo Carvalho de Melo committed Sep 7, 2012
1 parent a220519 commit 7244d8f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0ca8da00ad170c12c12350c3a2500591a7bec535
refs/heads/master: 67ed939c9eb029c28057eb75de456a9d0e899fd4
26 changes: 20 additions & 6 deletions trunk/tools/lib/traceevent/event-parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -5080,6 +5080,7 @@ int pevent_register_print_function(struct pevent *pevent,
struct pevent_func_params *param;
enum pevent_func_arg_type type;
va_list ap;
int ret;

func_handle = find_func_handler(pevent, name);
if (func_handle) {
Expand All @@ -5092,14 +5093,21 @@ int pevent_register_print_function(struct pevent *pevent,
remove_func_handler(pevent, name);
}

func_handle = malloc_or_die(sizeof(*func_handle));
func_handle = malloc(sizeof(*func_handle));
if (!func_handle) {
do_warning("Failed to allocate function handler");
return PEVENT_ERRNO__MEM_ALLOC_FAILED;
}
memset(func_handle, 0, sizeof(*func_handle));

func_handle->ret_type = ret_type;
func_handle->name = strdup(name);
func_handle->func = func;
if (!func_handle->name)
die("Failed to allocate function name");
if (!func_handle->name) {
do_warning("Failed to allocate function name");
free(func_handle);
return PEVENT_ERRNO__MEM_ALLOC_FAILED;
}

next_param = &(func_handle->params);
va_start(ap, name);
Expand All @@ -5109,11 +5117,17 @@ int pevent_register_print_function(struct pevent *pevent,
break;

if (type < 0 || type >= PEVENT_FUNC_ARG_MAX_TYPES) {
warning("Invalid argument type %d", type);
do_warning("Invalid argument type %d", type);
ret = PEVENT_ERRNO__INVALID_ARG_TYPE;
goto out_free;
}

param = malloc_or_die(sizeof(*param));
param = malloc(sizeof(*param));
if (!param) {
do_warning("Failed to allocate function param");
ret = PEVENT_ERRNO__MEM_ALLOC_FAILED;
goto out_free;
}
param->type = type;
param->next = NULL;

Expand All @@ -5131,7 +5145,7 @@ int pevent_register_print_function(struct pevent *pevent,
out_free:
va_end(ap);
free_func_handle(func_handle);
return -1;
return ret;
}

/**
Expand Down
3 changes: 2 additions & 1 deletion trunk/tools/lib/traceevent/event-parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,8 @@ enum pevent_flag {
_PE(READ_ID_FAILED, "failed to read event id"), \
_PE(READ_FORMAT_FAILED, "failed to read event format"), \
_PE(READ_PRINT_FAILED, "failed to read event print fmt"), \
_PE(OLD_FTRACE_ARG_FAILED,"failed to allocate field name for ftrace")
_PE(OLD_FTRACE_ARG_FAILED,"failed to allocate field name for ftrace"),\
_PE(INVALID_ARG_TYPE, "invalid argument type")

#undef _PE
#define _PE(__code, __str) PEVENT_ERRNO__ ## __code
Expand Down

0 comments on commit 7244d8f

Please sign in to comment.