public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/2] perf-tools: minor cleanup in parse_single_tracepoint_event() when parsing id
@ 2011-01-17 18:13 Franck Bui-Huu
  0 siblings, 0 replies; only message in thread
From: Franck Bui-Huu @ 2011-01-17 18:13 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo; +Cc: lkml

From: Franck Bui-Huu <fbuihuu@gmail.com>

And trust the kernel to return a valid number as the previous code
already assume.

Signed-off-by: Franck Bui-Huu <fbuihuu@gmail.com>
---
 tools/perf/util/parse-events.c |   16 +++++-----------
 1 files changed, 5 insertions(+), 11 deletions(-)

diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index a58407e..777ce03 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -414,25 +414,19 @@ parse_single_tracepoint_event(char *sys_name,
 			      const char **strp)
 {
 	char evt_path[MAXPATHLEN];
-	char id_buf[4];
 	u64 id;
-	int fd;
+	FILE *fp;
 	size_t len;
 
 	snprintf(evt_path, MAXPATHLEN, "%s/%s/%s/id", debugfs_path,
 		 sys_name, evt_name);
 
-	fd = open(evt_path, O_RDONLY);
-	if (fd < 0)
-		return EVT_FAILED;
-
-	if (read(fd, id_buf, sizeof(id_buf)) < 0) {
-		close(fd);
+	fp = fopen(evt_path, "r");
+	if (!fp)
 		return EVT_FAILED;
-	}
+	fscanf(fp, "%Lu", &id);
+	fclose(fp);
 
-	close(fd);
-	id = atoll(id_buf);
 	attr->config = id;
 	attr->type = PERF_TYPE_TRACEPOINT;
 
-- 
1.7.3.2

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2011-01-17 18:14 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-17 18:13 [PATCH 2/2] perf-tools: minor cleanup in parse_single_tracepoint_event() when parsing id Franck Bui-Huu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox