aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTaeung Song <[email protected]>2017-04-07 23:24:21 +0900
committerArnaldo Carvalho de Melo <[email protected]>2017-04-11 15:23:26 -0300
commitbdd97ca63faa374c98314d53c0bcaedb473c5a33 (patch)
tree29eaa7a0943e806f6a8d7fb7435cf650a0057809
parentaa4beb10a94358bf2474d1fc9c4ccde34660cc9d (diff)
perf tools: Refactor the code to strip command name with {l,r}trim()
After reading command name from /proc/<pid>/status, use ltrim() and rtrim() to strip command name, not using just while loop, isspace() and etc. Signed-off-by: Taeung Song <[email protected]> Acked-by: David Ahern <[email protected]> Cc: Don Zickus <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Masami Hiramatsu <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Wang Nan <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
-rw-r--r--tools/perf/util/event.c11
1 files changed, 2 insertions, 9 deletions
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 76b9c6bc8369..8255a26ac255 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -106,7 +106,7 @@ static int perf_event__get_comm_ids(pid_t pid, char *comm, size_t len,
int fd;
size_t size = 0;
ssize_t n;
- char *nl, *name, *tgids, *ppids;
+ char *name, *tgids, *ppids;
*tgid = -1;
*ppid = -1;
@@ -134,14 +134,7 @@ static int perf_event__get_comm_ids(pid_t pid, char *comm, size_t len,
if (name) {
name += 5; /* strlen("Name:") */
-
- while (*name && isspace(*name))
- ++name;
-
- nl = strchr(name, '\n');
- if (nl)
- *nl = '\0';
-
+ name = rtrim(ltrim(name));
size = strlen(name);
if (size >= len)
size = len - 1;