diff options
author | Steven Rostedt (Red Hat) <rostedt@goodmis.org> | 2015-09-21 16:23:50 -0400 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2015-09-22 12:51:55 -0400 |
commit | 10013a5cdfe3c6fcfbebf00e1fa146cb86c61de0 (patch) | |
tree | e9de5986b8b06b453b4582f021560b1dd91f9838 | |
parent | 32818c104b935c2f5d30c4568032cc27862521d1 (diff) | |
download | trace-cmd-10013a5cdfe3c6fcfbebf00e1fa146cb86c61de0.tar.gz |
trace-cmd: Remove malloc_or_die from trace-cmd.c
Remove the use cases of malloc_or_die() from trace-cmd.c, but obviously we
are keeping the function of malloc_or_die() itself. Use a more descriptive
output when failing allocations.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r-- | trace-cmd.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/trace-cmd.c b/trace-cmd.c index f6457859..1a62faaf 100644 --- a/trace-cmd.c +++ b/trace-cmd.c @@ -119,7 +119,9 @@ static void process_file_re(process_file_func func, } /* Handle the newline at end of names for the user */ - str = malloc_or_die(l + 3); + str = malloc(l + 3); + if (!str) + die("Failed to allocate reg ex %s", re); strcpy(str, re); if (re[l-1] == '$') strcpy(&str[l-1], "\n*$"); @@ -175,8 +177,10 @@ static char *get_event_file(const char *type, char *buf, int len) die("no event found in %s\n", buf); path = tracecmd_get_tracing_file("events"); - file = malloc_or_die(strlen(path) + strlen(system) + strlen(event) + - strlen(type) + strlen("///") + 1); + file = malloc(strlen(path) + strlen(system) + strlen(event) + + strlen(type) + strlen("///") + 1); + if (!file) + die("Failed to allocate event file %s %s", system, event); sprintf(file, "%s/%s/%s/%s", path, system, event, type); tracecmd_put_tracing_file(path); @@ -610,8 +614,10 @@ int main (int argc, char **argv) } if (buffer) { - path = malloc_or_die(strlen(buffer) + strlen("instances//") + - strlen(file) + 1); + path = malloc(strlen(buffer) + strlen("instances//") + + strlen(file) + 1); + if (path) + die("Failed to allocate instance path %s", file); sprintf(path, "instances/%s/%s", buffer, file); file = path; } |