perf record: Fix unhandled io return value
authorFrederic Weisbecker <fweisbec@gmail.com>
Thu, 25 Jun 2009 20:21:27 +0000 (22:21 +0200)
committerIngo Molnar <mingo@elte.hu>
Thu, 25 Jun 2009 20:25:55 +0000 (22:25 +0200)
Building latest perfcounter fails on the following error:

 builtin-record.c: In function ‘create_counter’:
 builtin-record.c:451: erreur: ignoring return value of ‘read’, declared with attribute warn_unused_result
 make: *** [builtin-record.o] Erreur 1

Just check if we successfully read the perf file descriptor.

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
LKML-Reference: <1245961287-5327-1-git-send-email-fweisbec@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
tools/perf/builtin-record.c

index 798a56d890e5ecb59ebd401cf5a7fad8baa77b0d..d18546f37d7c5661cfa0d6d55c7d921124461d00 100644 (file)
@@ -448,7 +448,10 @@ try_again:
                }
        }
 
-       read(fd[nr_cpu][counter], &read_data, sizeof(read_data));
+       if (read(fd[nr_cpu][counter], &read_data, sizeof(read_data)) == -1) {
+               perror("Unable to read perf file descriptor\n");
+               exit(-1);
+       }
 
        perf_header_attr__add_id(h_attr, read_data.id);