[PATCH] perfcounter: handle some IO return values

From: Frederic Weisbecker
Date: Fri Jun 19 2009 - 20:01:59 EST


Building perfcounter tools raises the following warnings
(treated as errors):

builtin-record.c: In function âatexit_headerâ:
builtin-record.c:464: erreur: ignoring return value of âpwriteâ, declared with attribute warn_unused_result
builtin-record.c: In function â__cmd_recordâ:
builtin-record.c:503: erreur: ignoring return value of âreadâ, declared with attribute warn_unused_result

builtin-report.c: In function â__cmd_reportâ:
builtin-report.c:1403: erreur: ignoring return value of âreadâ, declared with attribute warn_unused_result

This patch handles these IO return values.

Signed-off-by: Frederic Weisbecker <fweisbec@xxxxxxxxx>
---
tools/perf/builtin-record.c | 9 +++++++--
tools/perf/builtin-report.c | 5 ++++-
2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index e2cebc0..d7ebbd7 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -461,7 +461,8 @@ static void atexit_header(void)
{
file_header.data_size += bytes_written;

- pwrite(output, &file_header, sizeof(file_header), 0);
+ if (pwrite(output, &file_header, sizeof(file_header), 0) == -1)
+ perror("failed to write on file headers");
}

static int __cmd_record(int argc, const char **argv)
@@ -500,7 +501,11 @@ static int __cmd_record(int argc, const char **argv)
}

if (!file_new) {
- read(output, &file_header, sizeof(file_header));
+ if (read(output, &file_header, sizeof(file_header)) == -1) {
+ perror("failed to read file headers");
+ exit(-1);
+ }
+
lseek(output, file_header.data_size, SEEK_CUR);
}

diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index de1b978..5eb5566 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -1400,7 +1400,10 @@ static int __cmd_report(void)
exit(0);
}

- read(input, &file_header, sizeof(file_header));
+ if (read(input, &file_header, sizeof(file_header)) == -1) {
+ perror("failed to read file headers");
+ exit(-1);
+ }

if (sort__has_parent &&
!(file_header.sample_type & PERF_SAMPLE_CALLCHAIN)) {
--
1.6.2.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/