From: Taeung Song Date: Fri, 7 Apr 2017 14:24:21 +0000 (+0900) Subject: perf tools: Refactor the code to strip command name with {l,r}trim() X-Git-Tag: MMI-PSA29.97-13-9~5737^2~12^2~11 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=bdd97ca63faa374c98314d53c0bcaedb473c5a33;p=GitHub%2FMotorolaMobilityLLC%2Fkernel-slsi.git perf tools: Refactor the code to strip command name with {l,r}trim() After reading command name from /proc//status, use ltrim() and rtrim() to strip command name, not using just while loop, isspace() and etc. Signed-off-by: Taeung Song Acked-by: David Ahern Cc: Don Zickus Cc: Jiri Olsa Cc: Masami Hiramatsu Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Wang Nan Link: http://lkml.kernel.org/r/1491575061-704-6-git-send-email-treeze.taeung@gmail.com Signed-off-by: Arnaldo Carvalho de Melo --- 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;