Skip to contentSkip to conversation

perfcounter: fix unhandled io return value

PATCH New Frederic Weisbecker 1 participant 1 message Jun 25, 2009 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perfcounter: fix unhandled io return value

Building latest perfcounter fails on the following error:

cc1: warnings being treated as errors
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.

---
 tools/perf/builtin-record.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
tools/perf/builtin-record.c +4 -1
index 798a56d..d18546f 100644
@@ -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);
 
Signature · 1 line
1.6.2.3