Commit bdd97ca6 authored by Taeung Song's avatar Taeung Song Committed by Arnaldo Carvalho de Melo

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: default avatarTaeung Song <treeze.taeung@gmail.com>
Acked-by: default avatarDavid Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1491575061-704-6-git-send-email-treeze.taeung@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent aa4beb10
...@@ -106,7 +106,7 @@ static int perf_event__get_comm_ids(pid_t pid, char *comm, size_t len, ...@@ -106,7 +106,7 @@ static int perf_event__get_comm_ids(pid_t pid, char *comm, size_t len,
int fd; int fd;
size_t size = 0; size_t size = 0;
ssize_t n; ssize_t n;
char *nl, *name, *tgids, *ppids; char *name, *tgids, *ppids;
*tgid = -1; *tgid = -1;
*ppid = -1; *ppid = -1;
...@@ -134,14 +134,7 @@ static int perf_event__get_comm_ids(pid_t pid, char *comm, size_t len, ...@@ -134,14 +134,7 @@ static int perf_event__get_comm_ids(pid_t pid, char *comm, size_t len,
if (name) { if (name) {
name += 5; /* strlen("Name:") */ name += 5; /* strlen("Name:") */
name = rtrim(ltrim(name));
while (*name && isspace(*name))
++name;
nl = strchr(name, '\n');
if (nl)
*nl = '\0';
size = strlen(name); size = strlen(name);
if (size >= len) if (size >= len)
size = len - 1; size = len - 1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment