Commit 452958fd authored by Namhyung Kim's avatar Namhyung Kim Committed by Arnaldo Carvalho de Melo

perf tools: Get rid of die() calls in trace-data-read.c

Convert them to pr_debug() and propagate error code.
Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1363850332-25297-9-git-send-email-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 4a31e565
...@@ -130,17 +130,23 @@ static char *read_string(void) ...@@ -130,17 +130,23 @@ static char *read_string(void)
for (;;) { for (;;) {
r = read(input_fd, &c, 1); r = read(input_fd, &c, 1);
if (r < 0) if (r < 0) {
die("reading input file"); pr_debug("reading input file");
goto out;
}
if (!r) if (!r) {
die("no data"); pr_debug("no data");
goto out;
}
if (repipe) { if (repipe) {
int retw = write(STDOUT_FILENO, &c, 1); int retw = write(STDOUT_FILENO, &c, 1);
if (retw <= 0 || retw != r) if (retw <= 0 || retw != r) {
die("repiping input file string"); pr_debug("repiping input file string");
goto out;
}
} }
buf[size++] = c; buf[size++] = c;
...@@ -155,7 +161,7 @@ static char *read_string(void) ...@@ -155,7 +161,7 @@ static char *read_string(void)
str = malloc(size); str = malloc(size);
if (str) if (str)
memcpy(str, buf, size); memcpy(str, buf, size);
out:
return str; return str;
} }
...@@ -219,8 +225,10 @@ static int read_header_files(struct pevent *pevent) ...@@ -219,8 +225,10 @@ static int read_header_files(struct pevent *pevent)
if (do_read(buf, 12) < 0) if (do_read(buf, 12) < 0)
return -1; return -1;
if (memcmp(buf, "header_page", 12) != 0) if (memcmp(buf, "header_page", 12) != 0) {
die("did not read header page"); pr_debug("did not read header page");
return -1;
}
size = read8(pevent); size = read8(pevent);
skip(size); skip(size);
...@@ -234,8 +242,10 @@ static int read_header_files(struct pevent *pevent) ...@@ -234,8 +242,10 @@ static int read_header_files(struct pevent *pevent)
if (do_read(buf, 13) < 0) if (do_read(buf, 13) < 0)
return -1; return -1;
if (memcmp(buf, "header_event", 13) != 0) if (memcmp(buf, "header_event", 13) != 0) {
die("did not read header event"); pr_debug("did not read header event");
return -1;
}
size = read8(pevent); size = read8(pevent);
header_event = malloc(size); header_event = malloc(size);
...@@ -353,13 +363,17 @@ ssize_t trace_report(int fd, struct pevent **ppevent, bool __repipe) ...@@ -353,13 +363,17 @@ ssize_t trace_report(int fd, struct pevent **ppevent, bool __repipe)
if (do_read(buf, 3) < 0) if (do_read(buf, 3) < 0)
return -1; return -1;
if (memcmp(buf, test, 3) != 0) if (memcmp(buf, test, 3) != 0) {
die("no trace data in the file"); pr_debug("no trace data in the file");
return -1;
}
if (do_read(buf, 7) < 0) if (do_read(buf, 7) < 0)
return -1; return -1;
if (memcmp(buf, "tracing", 7) != 0) if (memcmp(buf, "tracing", 7) != 0) {
die("not a trace file (missing 'tracing' tag)"); pr_debug("not a trace file (missing 'tracing' tag)");
return -1;
}
version = read_string(); version = read_string();
if (version == NULL) if (version == NULL)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment