From: Andy Zhou Date: Tue, 14 Apr 2015 21:22:08 +0000 (-0700) Subject: perf-counter: fix compiler warnings X-Git-Tag: v2.4.0~329 X-Git-Url: http://git.cascardo.eti.br/?a=commitdiff_plain;h=296527dffb8b6f90f2305bd20bae36be3add3cdc;p=cascardo%2Fovs.git 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 --- 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; }