diff options
| author | Namhyung Kim <namhyung.kim@lge.com> | 2013-03-21 03:18:51 -0400 |
|---|---|---|
| committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-03-21 12:37:13 -0400 |
| commit | 452958fdd05b43b6c91cfd1341f4fac2f3ce661f (patch) | |
| tree | 08f81195454f41f593ee9c88e73e8438f259af52 /tools/perf/util | |
| parent | 4a31e56599d42c5ac17b280228349948dee352c7 (diff) | |
perf tools: Get rid of die() calls in trace-data-read.c
Convert them to pr_debug() and propagate error code.
Signed-off-by: Namhyung 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.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util')
| -rw-r--r-- | tools/perf/util/trace-event-read.c | 44 |
1 files changed, 29 insertions, 15 deletions
diff --git a/tools/perf/util/trace-event-read.c b/tools/perf/util/trace-event-read.c index 877706bd454f..644ad3b4edec 100644 --- a/tools/perf/util/trace-event-read.c +++ b/tools/perf/util/trace-event-read.c | |||
| @@ -130,17 +130,23 @@ static char *read_string(void) | |||
| 130 | 130 | ||
| 131 | for (;;) { | 131 | for (;;) { |
| 132 | r = read(input_fd, &c, 1); | 132 | r = read(input_fd, &c, 1); |
| 133 | if (r < 0) | 133 | if (r < 0) { |
| 134 | die("reading input file"); | 134 | pr_debug("reading input file"); |
| 135 | goto out; | ||
| 136 | } | ||
| 135 | 137 | ||
| 136 | if (!r) | 138 | if (!r) { |
| 137 | die("no data"); | 139 | pr_debug("no data"); |
| 140 | goto out; | ||
| 141 | } | ||
| 138 | 142 | ||
| 139 | if (repipe) { | 143 | if (repipe) { |
| 140 | int retw = write(STDOUT_FILENO, &c, 1); | 144 | int retw = write(STDOUT_FILENO, &c, 1); |
| 141 | 145 | ||
| 142 | if (retw <= 0 || retw != r) | 146 | if (retw <= 0 || retw != r) { |
| 143 | die("repiping input file string"); | 147 | pr_debug("repiping input file string"); |
| 148 | goto out; | ||
| 149 | } | ||
| 144 | } | 150 | } |
| 145 | 151 | ||
| 146 | buf[size++] = c; | 152 | buf[size++] = c; |
| @@ -155,7 +161,7 @@ static char *read_string(void) | |||
| 155 | str = malloc(size); | 161 | str = malloc(size); |
| 156 | if (str) | 162 | if (str) |
| 157 | memcpy(str, buf, size); | 163 | memcpy(str, buf, size); |
| 158 | 164 | out: | |
| 159 | return str; | 165 | return str; |
| 160 | } | 166 | } |
| 161 | 167 | ||
| @@ -219,8 +225,10 @@ static int read_header_files(struct pevent *pevent) | |||
| 219 | if (do_read(buf, 12) < 0) | 225 | if (do_read(buf, 12) < 0) |
| 220 | return -1; | 226 | return -1; |
| 221 | 227 | ||
| 222 | if (memcmp(buf, "header_page", 12) != 0) | 228 | if (memcmp(buf, "header_page", 12) != 0) { |
| 223 | die("did not read header page"); | 229 | pr_debug("did not read header page"); |
| 230 | return -1; | ||
| 231 | } | ||
| 224 | 232 | ||
| 225 | size = read8(pevent); | 233 | size = read8(pevent); |
| 226 | skip(size); | 234 | skip(size); |
| @@ -234,8 +242,10 @@ static int read_header_files(struct pevent *pevent) | |||
| 234 | if (do_read(buf, 13) < 0) | 242 | if (do_read(buf, 13) < 0) |
| 235 | return -1; | 243 | return -1; |
| 236 | 244 | ||
| 237 | if (memcmp(buf, "header_event", 13) != 0) | 245 | if (memcmp(buf, "header_event", 13) != 0) { |
| 238 | die("did not read header event"); | 246 | pr_debug("did not read header event"); |
| 247 | return -1; | ||
| 248 | } | ||
| 239 | 249 | ||
| 240 | size = read8(pevent); | 250 | size = read8(pevent); |
| 241 | header_event = malloc(size); | 251 | header_event = malloc(size); |
| @@ -353,13 +363,17 @@ ssize_t trace_report(int fd, struct pevent **ppevent, bool __repipe) | |||
| 353 | 363 | ||
| 354 | if (do_read(buf, 3) < 0) | 364 | if (do_read(buf, 3) < 0) |
| 355 | return -1; | 365 | return -1; |
| 356 | if (memcmp(buf, test, 3) != 0) | 366 | if (memcmp(buf, test, 3) != 0) { |
| 357 | die("no trace data in the file"); | 367 | pr_debug("no trace data in the file"); |
| 368 | return -1; | ||
| 369 | } | ||
| 358 | 370 | ||
| 359 | if (do_read(buf, 7) < 0) | 371 | if (do_read(buf, 7) < 0) |
| 360 | return -1; | 372 | return -1; |
| 361 | if (memcmp(buf, "tracing", 7) != 0) | 373 | if (memcmp(buf, "tracing", 7) != 0) { |
| 362 | die("not a trace file (missing 'tracing' tag)"); | 374 | pr_debug("not a trace file (missing 'tracing' tag)"); |
| 375 | return -1; | ||
| 376 | } | ||
| 363 | 377 | ||
| 364 | version = read_string(); | 378 | version = read_string(); |
| 365 | if (version == NULL) | 379 | if (version == NULL) |
