perf-tools: minor cleanup in parse_single_tracepoint_event() when parsing id
PATCH 2/2 perf-tools: minor cleanup in parse_single_tracepoint_event() when parsing id
From: Franck Bui-Huu <[email protected]>
And trust the kernel to return a valid number as the previous code already assume.
Signed-off-by Franck Bui-Huu <[email protected]>
--- tools/perf/util/parse-events.c | 16 +++++----------- 1 files changed, 5 insertions(+), 11 deletions(-)
tools/perf/util/parse-events.c +5 -11
@@ -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 ;
Signature · 1 line
1.7.3.2