Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1619183 > unrolled thread

[PATCH v2 0/5] Refactoring with ltrim() and rtrim()

Started byTaeung Song <treeze.taeung@gmail.com>
First post2017-04-08 03:00 +0200
Last post2017-04-08 03:00 +0200
Articles 5 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [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

#1619183 — [PATCH v2 0/5] Refactoring with ltrim() and rtrim()

FromTaeung Song <treeze.taeung@gmail.com>
Date2017-04-08 03:00 +0200
Subject[PATCH v2 0/5] Refactoring with ltrim() and rtrim()
Message-ID<ttMTn-6DM-9@gated-at.bofh.it>
Hi, :)

It is to simply refactor the code about stip strings
with ltrim() and rtrim().

I'd appreciate some feedback on this PATCHset.

The code is avaiable at 'refactor-trim-v2' branch in

  git://github.com/taeung/linux-perf

Thanks,
Taeung

v2:
- remove changes unrelated to the main purpose of PATCH (Arnaldo)

Taeung Song (5):
  perf annotate: Refactor the code to parse disassemble lines with
    {l,r}trim()
  perf annotate: Use stripped line instead of raw disassemble line
  perf ui browser: Refactor the code to parse color configs with ltrim()
  perf pmu: Refactor wordwrap() with ltrim()
  perf tools: Refactor the code to strip command name with {l,r}trim()

 tools/perf/ui/browser.c    |  2 +-
 tools/perf/util/annotate.c | 46 +++++++++-------------------------------------
 tools/perf/util/event.c    | 11 ++---------
 tools/perf/util/pmu.c      |  3 +--
 4 files changed, 13 insertions(+), 49 deletions(-)

-- 
2.7.4

[toc] | [next] | [standalone]


#1619184 — [PATCH v2 5/5] perf tools: Refactor the code to strip command name with {l,r}trim()

FromTaeung Song <treeze.taeung@gmail.com>
Date2017-04-08 03:00 +0200
Subject[PATCH v2 5/5] perf tools: Refactor the code to strip command name with {l,r}trim()
Message-ID<ttMTo-6DM-21@gated-at.bofh.it>
In reply to#1619183
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

[toc] | [prev] | [next] | [standalone]


#1619362 — Re: [PATCH v2 5/5] perf tools: Refactor the code to strip command name with {l,r}trim()

FromDavid Ahern <dsahern@gmail.com>
Date2017-04-08 20:50 +0200
SubjectRe: [PATCH v2 5/5] perf tools: Refactor the code to strip command name with {l,r}trim()
Message-ID<tu3AR-v6-5@gated-at.bofh.it>
In reply to#1619184
On 4/7/17 8:52 PM, Taeung Song wrote:
> 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(-)
> 

Acked-by: David Ahern <dsahern@gmail.com>

[toc] | [prev] | [next] | [standalone]


#1619442 — Re: [PATCH v2 5/5] perf tools: Refactor the code to strip command name with {l,r}trim()

FromTaeung Song <treeze.taeung@gmail.com>
Date2017-04-09 07:40 +0200
SubjectRe: [PATCH v2 5/5] perf tools: Refactor the code to strip command name with {l,r}trim()
Message-ID<tudJT-79W-1@gated-at.bofh.it>
In reply to#1619362
Hi David,

On 04/09/2017 03:48 AM, David Ahern wrote:
> On 4/7/17 8:52 PM, Taeung Song wrote:
>> 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(-)
>>
>
> Acked-by: David Ahern <dsahern@gmail.com>
>

Thank you!

  - Taeung

[toc] | [prev] | [next] | [standalone]


#1619185 — [PATCH v2 3/5] perf ui browser: Refactor the code to parse color configs with ltrim()

FromTaeung Song <treeze.taeung@gmail.com>
Date2017-04-08 03:00 +0200
Subject[PATCH v2 3/5] perf ui browser: Refactor the code to parse color configs with ltrim()
Message-ID<ttMTo-6DM-25@gated-at.bofh.it>
In reply to#1619183
When parsing {fore, back} ground color configs,
use ltrim() instead of just while loop and isspace().

Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Taeung Song <treeze.taeung@gmail.com>
---
 tools/perf/ui/browser.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/ui/browser.c b/tools/perf/ui/browser.c
index 3eb3edb..9e47ccb 100644
--- a/tools/perf/ui/browser.c
+++ b/tools/perf/ui/browser.c
@@ -579,7 +579,7 @@ static int ui_browser__color_config(const char *var, const char *value,
 			break;
 
 		*bg = '\0';
-		while (isspace(*++bg));
+		bg = ltrim(++bg);
 		ui_browser__colorsets[i].bg = bg;
 		ui_browser__colorsets[i].fg = fg;
 		return 0;
-- 
2.7.4

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web