From: Franck Bui-Huu <vagabon.xyz@gmail.com>
To: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: lkml <linux-kernel@vger.kernel.org>
Subject: [PATCH 2/2] perf-tools: minor cleanup in parse_single_tracepoint_event() when parsing id
Date: Mon, 17 Jan 2011 19:13:56 +0100 [thread overview]
Message-ID: <m3zkqzv1nf.fsf@gmail.com> (raw)
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
reply other threads:[~2011-01-17 18:14 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m3zkqzv1nf.fsf@gmail.com \
--to=vagabon.xyz@gmail.com \
--cc=acme@ghostprotocols.net \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox