[PATCH 2/2] perf-tools: minor cleanup in parse_single_tracepoint_event() when parsing id

From: Franck Bui-Huu
Date: Mon Jan 17 2011 - 13:14:05 EST


From: Franck Bui-Huu <fbuihuu@xxxxxxxxx>

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

Signed-off-by: Franck Bui-Huu <fbuihuu@xxxxxxxxx>
---
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/