lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:	Mon, 17 Jan 2011 19:13:56 +0100
From:	Franck Bui-Huu <vagabon.xyz@...il.com>
To:	Arnaldo Carvalho de Melo <acme@...stprotocols.net>
Cc:	lkml <linux-kernel@...r.kernel.org>
Subject: [PATCH 2/2] perf-tools: minor cleanup in parse_single_tracepoint_event() when parsing id

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

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

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ