Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1619184
| From | Taeung Song <treeze.taeung@gmail.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH v2 5/5] perf tools: Refactor the code to strip command name with {l,r}trim() |
| Date | 2017-04-08 03:00 +0200 |
| Message-ID | <ttMTo-6DM-21@gated-at.bofh.it> (permalink) |
| References | <ttMTn-6DM-9@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
After reading command name from /proc/<pid>/status,
use ltrim() and rtrim() to strip command name, not using
just while loop, isspace() and etc.
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Taeung Song <treeze.taeung@gmail.com>
---
tools/perf/util/event.c | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 76b9c6b..8255a26 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;
--
2.7.4
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v2 0/5] Refactoring with ltrim() and rtrim() Taeung Song <treeze.taeung@gmail.com> - 2017-04-08 03:00 +0200
[PATCH v2 5/5] perf tools: Refactor the code to strip command name with {l,r}trim() Taeung Song <treeze.taeung@gmail.com> - 2017-04-08 03:00 +0200
Re: [PATCH v2 5/5] perf tools: Refactor the code to strip command name with {l,r}trim() David Ahern <dsahern@gmail.com> - 2017-04-08 20:50 +0200
Re: [PATCH v2 5/5] perf tools: Refactor the code to strip command name with {l,r}trim() Taeung Song <treeze.taeung@gmail.com> - 2017-04-09 07:40 +0200
[PATCH v2 3/5] perf ui browser: Refactor the code to parse color configs with ltrim() Taeung Song <treeze.taeung@gmail.com> - 2017-04-08 03:00 +0200
csiph-web