[ovs-dev] [v2] perf-counter: fix compiler warnings
Andy Zhou
azhou at nicira.com
Tue Apr 14 21:51:43 UTC 2015
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 <azhou at nicira.com>
---
v1->v2: Combine two 'if's into using only one.
---
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 7bd7834..a6e63ac 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 {
+ int size = sizeof *counter;
+
+ if ((fd__ <= 0) || read(fd__, counter, size) < size) {
*counter = 0;
}
--
1.9.1
More information about the dev
mailing list