perf-counter: use 'int' instead of size_t
authorAndy Zhou <azhou@nicira.com>
Wed, 15 Apr 2015 00:25:32 +0000 (17:25 -0700)
committerAndy Zhou <azhou@nicira.com>
Wed, 15 Apr 2015 00:25:43 +0000 (17:25 -0700)
'size_t' does not allow for catching the case where 'read' returns
an error code, which is a negative number.

Reported-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: Andy Zhou <azhou@nicira.com>
lib/perf-counter.c

index b700e49..4188f6b 100644 (file)
@@ -39,7 +39,7 @@ static int fd__ = 0;
 uint64_t
 perf_counter_read(uint64_t *counter)
 {
-    size_t size = sizeof *counter;
+    int size = sizeof *counter;
 
     if (fd__ <= 0 || read(fd__, counter, size) < size) {
         *counter = 0;