From 296527dffb8b6f90f2305bd20bae36be3add3cdc Mon Sep 17 00:00:00 2001 From: Andy Zhou Date: Tue, 14 Apr 2015 14:22:08 -0700 Subject: [PATCH] perf-counter: fix compiler warnings Gcc complains about: lib/perf-counter.c:43:13: error: ignoring return value of 'read', declared with attribute warn_unused_result [-Werror=unused-result] read(fd__, counter, sizeof(*counter)); Signed-off-by: Andy Zhou Acked-by: Russell Bryant --- lib/perf-counter.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/perf-counter.c b/lib/perf-counter.c index 7bd783451..b700e492b 100644 --- a/lib/perf-counter.c +++ b/lib/perf-counter.c @@ -39,9 +39,9 @@ static int fd__ = 0; uint64_t perf_counter_read(uint64_t *counter) { - if (fd__ > 0) { - read(fd__, counter, sizeof(*counter)); - } else { + size_t size = sizeof *counter; + + if (fd__ <= 0 || read(fd__, counter, size) < size) { *counter = 0; } -- 2.39.5