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


Groups > linux.kernel > #1570624 > unrolled thread

[PATCH v2 1/4] perf tools: Create for_each_event macro for tracepoints iteration

Started byTaeung Song <treeze.taeung@gmail.com>
First post2017-01-31 12:40 +0100
Last post2017-02-01 15:50 +0100
Articles 6 — 4 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v2 1/4] perf tools: Create for_each_event macro for tracepoints iteration Taeung Song <treeze.taeung@gmail.com> - 2017-01-31 12:40 +0100
    Re: [PATCH v2 1/4] perf tools: Create for_each_event macro for  tracepoints iteration Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-01-31 13:30 +0100
      Re: [PATCH v2 1/4] perf tools: Create for_each_event macro for  tracepoints iteration Steven Rostedt <rostedt@goodmis.org> - 2017-01-31 18:40 +0100
    Re: [PATCH v2 1/4] perf tools: Create for_each_event macro for  tracepoints iteration Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-01-31 13:30 +0100
      Re: [PATCH v2 1/4] perf tools: Create for_each_event macro for  tracepoints iteration Taeung Song <treeze.taeung@gmail.com> - 2017-02-01 08:10 +0100
    [tip:perf/core] perf tools: Create for_each_event macro for  tracepoints iteration tip-bot for Taeung Song <tipbot@zytor.com> - 2017-02-01 15:50 +0100

#1570624 — [PATCH v2 1/4] perf tools: Create for_each_event macro for tracepoints iteration

FromTaeung Song <treeze.taeung@gmail.com>
Date2017-01-31 12:40 +0100
Subject[PATCH v2 1/4] perf tools: Create for_each_event macro for tracepoints iteration
Message-ID<t5EX0-8E-7@gated-at.bofh.it>
Such as for_each_subsystem and for_each_event in util/parse-events.c,
add new macros 'for_each_event' for easy iteration over the tracepoints
in order to be more compact and readable.

Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Frederic Weisbecker <fweisbec@gmail.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/trace-event-info.c | 38 ++++++++++++++++++--------------------
 1 file changed, 18 insertions(+), 20 deletions(-)

diff --git a/tools/perf/util/trace-event-info.c b/tools/perf/util/trace-event-info.c
index ceb0e27..fb6d95d 100644
--- a/tools/perf/util/trace-event-info.c
+++ b/tools/perf/util/trace-event-info.c
@@ -170,6 +170,12 @@ static bool name_in_tp_list(char *sys, struct tracepoint_path *tps)
 	return false;
 }
 
+#define for_each_event(dir, dent, tps)				\
+	while ((dent = readdir(dir)))				\
+		if (dent->d_type == DT_DIR &&			\
+		    (strcmp(dent->d_name, ".")) &&		\
+		    (strcmp(dent->d_name, "..")))		\
+
 static int copy_event_system(const char *sys, struct tracepoint_path *tps)
 {
 	struct dirent *dent;
@@ -186,12 +192,10 @@ static int copy_event_system(const char *sys, struct tracepoint_path *tps)
 		return -errno;
 	}
 
-	while ((dent = readdir(dir))) {
-		if (dent->d_type != DT_DIR ||
-		    strcmp(dent->d_name, ".") == 0 ||
-		    strcmp(dent->d_name, "..") == 0 ||
-		    !name_in_tp_list(dent->d_name, tps))
+	for_each_event(dir, dent, tps) {
+		if (!name_in_tp_list(dent->d_name, tps))
 			continue;
+
 		if (asprintf(&format, "%s/%s/format", sys, dent->d_name) < 0) {
 			err = -ENOMEM;
 			goto out;
@@ -210,12 +214,10 @@ static int copy_event_system(const char *sys, struct tracepoint_path *tps)
 	}
 
 	rewinddir(dir);
-	while ((dent = readdir(dir))) {
-		if (dent->d_type != DT_DIR ||
-		    strcmp(dent->d_name, ".") == 0 ||
-		    strcmp(dent->d_name, "..") == 0 ||
-		    !name_in_tp_list(dent->d_name, tps))
+	for_each_event(dir, dent, tps) {
+		if (!name_in_tp_list(dent->d_name, tps))
 			continue;
+
 		if (asprintf(&format, "%s/%s/format", sys, dent->d_name) < 0) {
 			err = -ENOMEM;
 			goto out;
@@ -290,13 +292,11 @@ static int record_event_files(struct tracepoint_path *tps)
 		goto out;
 	}
 
-	while ((dent = readdir(dir))) {
-		if (dent->d_type != DT_DIR ||
-		    strcmp(dent->d_name, ".") == 0 ||
-		    strcmp(dent->d_name, "..") == 0 ||
-		    strcmp(dent->d_name, "ftrace") == 0 ||
+	for_each_event(dir, dent, tps) {
+		if (!strcmp(dent->d_name, "ftrace") ||
 		    !system_in_tp_list(dent->d_name, tps))
 			continue;
+
 		count++;
 	}
 
@@ -307,13 +307,11 @@ static int record_event_files(struct tracepoint_path *tps)
 	}
 
 	rewinddir(dir);
-	while ((dent = readdir(dir))) {
-		if (dent->d_type != DT_DIR ||
-		    strcmp(dent->d_name, ".") == 0 ||
-		    strcmp(dent->d_name, "..") == 0 ||
-		    strcmp(dent->d_name, "ftrace") == 0 ||
+	for_each_event(dir, dent, tps) {
+		if (!strcmp(dent->d_name, "ftrace") ||
 		    !system_in_tp_list(dent->d_name, tps))
 			continue;
+
 		if (asprintf(&sys, "%s/%s", path, dent->d_name) < 0) {
 			err = -ENOMEM;
 			goto out;
-- 
2.7.4

[toc] | [next] | [standalone]


#1570663 — Re: [PATCH v2 1/4] perf tools: Create for_each_event macro for tracepoints iteration

FromArnaldo Carvalho de Melo <acme@kernel.org>
Date2017-01-31 13:30 +0100
SubjectRe: [PATCH v2 1/4] perf tools: Create for_each_event macro for tracepoints iteration
Message-ID<t5FJo-DW-11@gated-at.bofh.it>
In reply to#1570624
Em Tue, Jan 31, 2017 at 09:21:16AM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Tue, Jan 31, 2017 at 08:38:28PM +0900, Taeung Song escreveu:
> > -	while ((dent = readdir(dir))) {
> > -		if (dent->d_type != DT_DIR ||
> > -		    strcmp(dent->d_name, ".") == 0 ||
> > -		    strcmp(dent->d_name, "..") == 0 ||
> > -		    strcmp(dent->d_name, "ftrace") == 0 ||
> > +	for_each_event(dir, dent, tps) {
> > +		if (!strcmp(dent->d_name, "ftrace") ||
> >  		    !system_in_tp_list(dent->d_name, tps))
> >  			continue;

> the existing style was == 0, you switched it to !, equivalent, but
> gratuitous, keeping the existing style would make reviewing slightly
> faster, as the pattern wouldn't have changed.
 
Here it is:

-       while ((dent = readdir(dir))) {
-               if (dent->d_type != DT_DIR ||
-                   strcmp(dent->d_name, ".") == 0 ||
-                   strcmp(dent->d_name, "..") == 0 ||
-                   strcmp(dent->d_name, "ftrace") == 0 ||
+       for_each_event(dir, dent, tps) {
+               if (strcmp(dent->d_name, "ftrace") == 0 ||
                    !system_in_tp_list(dent->d_name, tps))
                        continue;

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


#1570922 — Re: [PATCH v2 1/4] perf tools: Create for_each_event macro for tracepoints iteration

FromSteven Rostedt <rostedt@goodmis.org>
Date2017-01-31 18:40 +0100
SubjectRe: [PATCH v2 1/4] perf tools: Create for_each_event macro for tracepoints iteration
Message-ID<t5Kzn-3vy-3@gated-at.bofh.it>
In reply to#1570663
On Tue, 31 Jan 2017 09:23:48 -0300
Arnaldo Carvalho de Melo <acme@kernel.org> wrote:

> Em Tue, Jan 31, 2017 at 09:21:16AM -0300, Arnaldo Carvalho de Melo escreveu:
> > Em Tue, Jan 31, 2017 at 08:38:28PM +0900, Taeung Song escreveu:  
> > > -	while ((dent = readdir(dir))) {
> > > -		if (dent->d_type != DT_DIR ||
> > > -		    strcmp(dent->d_name, ".") == 0 ||
> > > -		    strcmp(dent->d_name, "..") == 0 ||
> > > -		    strcmp(dent->d_name, "ftrace") == 0 ||
> > > +	for_each_event(dir, dent, tps) {
> > > +		if (!strcmp(dent->d_name, "ftrace") ||
> > >  		    !system_in_tp_list(dent->d_name, tps))
> > >  			continue;  
> 
> > the existing style was == 0, you switched it to !, equivalent, but
> > gratuitous, keeping the existing style would make reviewing slightly
> > faster, as the pattern wouldn't have changed.  
>  
> Here it is:
> 
> -       while ((dent = readdir(dir))) {
> -               if (dent->d_type != DT_DIR ||
> -                   strcmp(dent->d_name, ".") == 0 ||
> -                   strcmp(dent->d_name, "..") == 0 ||
> -                   strcmp(dent->d_name, "ftrace") == 0 ||
> +       for_each_event(dir, dent, tps) {
> +               if (strcmp(dent->d_name, "ftrace") == 0 ||
>                     !system_in_tp_list(dent->d_name, tps))
>                         continue;

Thanks, because I always screw up the !strcmp(). Thus I find the "== 0"
to me is easier to process "matches" and "!= 0" is "doesn't match".

-- Steve

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


#1570666 — Re: [PATCH v2 1/4] perf tools: Create for_each_event macro for tracepoints iteration

FromArnaldo Carvalho de Melo <acme@kernel.org>
Date2017-01-31 13:30 +0100
SubjectRe: [PATCH v2 1/4] perf tools: Create for_each_event macro for tracepoints iteration
Message-ID<t5FJo-DW-13@gated-at.bofh.it>
In reply to#1570624
Em Tue, Jan 31, 2017 at 08:38:28PM +0900, Taeung Song escreveu:
> Such as for_each_subsystem and for_each_event in util/parse-events.c,
> add new macros 'for_each_event' for easy iteration over the tracepoints
> in order to be more compact and readable.

Looks ok, applied, but look below for some minor suggestions.

- Arnaldo
 
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Cc: Frederic Weisbecker <fweisbec@gmail.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/trace-event-info.c | 38 ++++++++++++++++++--------------------
>  1 file changed, 18 insertions(+), 20 deletions(-)
> 
> diff --git a/tools/perf/util/trace-event-info.c b/tools/perf/util/trace-event-info.c
> index ceb0e27..fb6d95d 100644
> --- a/tools/perf/util/trace-event-info.c
> +++ b/tools/perf/util/trace-event-info.c
> @@ -170,6 +170,12 @@ static bool name_in_tp_list(char *sys, struct tracepoint_path *tps)
>  	return false;
>  }
>  
> +#define for_each_event(dir, dent, tps)				\
> +	while ((dent = readdir(dir)))				\
> +		if (dent->d_type == DT_DIR &&			\
> +		    (strcmp(dent->d_name, ".")) &&		\
> +		    (strcmp(dent->d_name, "..")))		\
> +
>  static int copy_event_system(const char *sys, struct tracepoint_path *tps)
>  {
>  	struct dirent *dent;
> @@ -186,12 +192,10 @@ static int copy_event_system(const char *sys, struct tracepoint_path *tps)
>  		return -errno;
>  	}
>  
> -	while ((dent = readdir(dir))) {
> -		if (dent->d_type != DT_DIR ||
> -		    strcmp(dent->d_name, ".") == 0 ||
> -		    strcmp(dent->d_name, "..") == 0 ||
> -		    !name_in_tp_list(dent->d_name, tps))
> +	for_each_event(dir, dent, tps) {
> +		if (!name_in_tp_list(dent->d_name, tps))
>  			continue;
> +
>  		if (asprintf(&format, "%s/%s/format", sys, dent->d_name) < 0) {
>  			err = -ENOMEM;
>  			goto out;
> @@ -210,12 +214,10 @@ static int copy_event_system(const char *sys, struct tracepoint_path *tps)
>  	}
>  
>  	rewinddir(dir);
> -	while ((dent = readdir(dir))) {
> -		if (dent->d_type != DT_DIR ||
> -		    strcmp(dent->d_name, ".") == 0 ||
> -		    strcmp(dent->d_name, "..") == 0 ||
> -		    !name_in_tp_list(dent->d_name, tps))
> +	for_each_event(dir, dent, tps) {
> +		if (!name_in_tp_list(dent->d_name, tps))
>  			continue;
> +
>  		if (asprintf(&format, "%s/%s/format", sys, dent->d_name) < 0) {
>  			err = -ENOMEM;
>  			goto out;
> @@ -290,13 +292,11 @@ static int record_event_files(struct tracepoint_path *tps)
>  		goto out;
>  	}
>  
> -	while ((dent = readdir(dir))) {
> -		if (dent->d_type != DT_DIR ||
> -		    strcmp(dent->d_name, ".") == 0 ||
> -		    strcmp(dent->d_name, "..") == 0 ||
> -		    strcmp(dent->d_name, "ftrace") == 0 ||
> +	for_each_event(dir, dent, tps) {
> +		if (!strcmp(dent->d_name, "ftrace") ||

the existing style was == 0, you switched it to !, equivalent, but
gratuitous, keeping the existing style would make reviewing slightly
faster, as the pattern wouldn't have changed.

>  		    !system_in_tp_list(dent->d_name, tps))
>  			continue;
> +
>  		count++;
>  	}
>  
> @@ -307,13 +307,11 @@ static int record_event_files(struct tracepoint_path *tps)
>  	}
>  
>  	rewinddir(dir);
> -	while ((dent = readdir(dir))) {
> -		if (dent->d_type != DT_DIR ||
> -		    strcmp(dent->d_name, ".") == 0 ||
> -		    strcmp(dent->d_name, "..") == 0 ||
> -		    strcmp(dent->d_name, "ftrace") == 0 ||
> +	for_each_event(dir, dent, tps) {
> +		if (!strcmp(dent->d_name, "ftrace") ||

Ditto.

>  		    !system_in_tp_list(dent->d_name, tps))
>  			continue;
> +
>  		if (asprintf(&sys, "%s/%s", path, dent->d_name) < 0) {
>  			err = -ENOMEM;
>  			goto out;
> -- 
> 2.7.4

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


#1571288 — Re: [PATCH v2 1/4] perf tools: Create for_each_event macro for tracepoints iteration

FromTaeung Song <treeze.taeung@gmail.com>
Date2017-02-01 08:10 +0100
SubjectRe: [PATCH v2 1/4] perf tools: Create for_each_event macro for tracepoints iteration
Message-ID<t5Xdg-2MX-11@gated-at.bofh.it>
In reply to#1570666
Hi, Arnaldo :)

On 01/31/2017 09:21 PM, Arnaldo Carvalho de Melo wrote:
> Em Tue, Jan 31, 2017 at 08:38:28PM +0900, Taeung Song escreveu:
>> Such as for_each_subsystem and for_each_event in util/parse-events.c,
>> add new macros 'for_each_event' for easy iteration over the tracepoints
>> in order to be more compact and readable.
>
> Looks ok, applied, but look below for some minor suggestions.
>
> - Arnaldo
>
>> Cc: Steven Rostedt <rostedt@goodmis.org>
>> Cc: Frederic Weisbecker <fweisbec@gmail.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/trace-event-info.c | 38 ++++++++++++++++++--------------------
>>  1 file changed, 18 insertions(+), 20 deletions(-)
>>
>> diff --git a/tools/perf/util/trace-event-info.c b/tools/perf/util/trace-event-info.c
>> index ceb0e27..fb6d95d 100644
>> --- a/tools/perf/util/trace-event-info.c
>> +++ b/tools/perf/util/trace-event-info.c
>> @@ -170,6 +170,12 @@ static bool name_in_tp_list(char *sys, struct tracepoint_path *tps)
>>  	return false;
>>  }
>>
>> +#define for_each_event(dir, dent, tps)				\
>> +	while ((dent = readdir(dir)))				\
>> +		if (dent->d_type == DT_DIR &&			\
>> +		    (strcmp(dent->d_name, ".")) &&		\
>> +		    (strcmp(dent->d_name, "..")))		\
>> +
>>  static int copy_event_system(const char *sys, struct tracepoint_path *tps)
>>  {
>>  	struct dirent *dent;
>> @@ -186,12 +192,10 @@ static int copy_event_system(const char *sys, struct tracepoint_path *tps)
>>  		return -errno;
>>  	}
>>
>> -	while ((dent = readdir(dir))) {
>> -		if (dent->d_type != DT_DIR ||
>> -		    strcmp(dent->d_name, ".") == 0 ||
>> -		    strcmp(dent->d_name, "..") == 0 ||
>> -		    !name_in_tp_list(dent->d_name, tps))
>> +	for_each_event(dir, dent, tps) {
>> +		if (!name_in_tp_list(dent->d_name, tps))
>>  			continue;
>> +
>>  		if (asprintf(&format, "%s/%s/format", sys, dent->d_name) < 0) {
>>  			err = -ENOMEM;
>>  			goto out;
>> @@ -210,12 +214,10 @@ static int copy_event_system(const char *sys, struct tracepoint_path *tps)
>>  	}
>>
>>  	rewinddir(dir);
>> -	while ((dent = readdir(dir))) {
>> -		if (dent->d_type != DT_DIR ||
>> -		    strcmp(dent->d_name, ".") == 0 ||
>> -		    strcmp(dent->d_name, "..") == 0 ||
>> -		    !name_in_tp_list(dent->d_name, tps))
>> +	for_each_event(dir, dent, tps) {
>> +		if (!name_in_tp_list(dent->d_name, tps))
>>  			continue;
>> +
>>  		if (asprintf(&format, "%s/%s/format", sys, dent->d_name) < 0) {
>>  			err = -ENOMEM;
>>  			goto out;
>> @@ -290,13 +292,11 @@ static int record_event_files(struct tracepoint_path *tps)
>>  		goto out;
>>  	}
>>
>> -	while ((dent = readdir(dir))) {
>> -		if (dent->d_type != DT_DIR ||
>> -		    strcmp(dent->d_name, ".") == 0 ||
>> -		    strcmp(dent->d_name, "..") == 0 ||
>> -		    strcmp(dent->d_name, "ftrace") == 0 ||
>> +	for_each_event(dir, dent, tps) {
>> +		if (!strcmp(dent->d_name, "ftrace") ||
>
> the existing style was == 0, you switched it to !, equivalent, but
> gratuitous, keeping the existing style would make reviewing slightly
> faster, as the pattern wouldn't have changed.
>

I understood !!
In the future, I'll think this when making some patches.

Thanks,
Taeung

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


#1571607 — [tip:perf/core] perf tools: Create for_each_event macro for tracepoints iteration

Fromtip-bot for Taeung Song <tipbot@zytor.com>
Date2017-02-01 15:50 +0100
Subject[tip:perf/core] perf tools: Create for_each_event macro for tracepoints iteration
Message-ID<t64oq-7aO-5@gated-at.bofh.it>
In reply to#1570624
Commit-ID:  43d41deb71fe1850264e5dd8109211683954ea14
Gitweb:     http://git.kernel.org/tip/43d41deb71fe1850264e5dd8109211683954ea14
Author:     Taeung Song <treeze.taeung@gmail.com>
AuthorDate: Tue, 31 Jan 2017 20:38:28 +0900
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 31 Jan 2017 16:20:08 -0300

perf tools: Create for_each_event macro for tracepoints iteration

Similar to for_each_subsystem and for_each_event in util/parse-events.c,
add new macro 'for_each_event' for easy iteration over the tracepoints
in order to be more compact and readable.

Signed-off-by: Taeung Song <treeze.taeung@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1485862711-20216-2-git-send-email-treeze.taeung@gmail.com
[ Slight change to keep existing style for checking strcmp() return ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/trace-event-info.c | 38 ++++++++++++++++++--------------------
 1 file changed, 18 insertions(+), 20 deletions(-)

diff --git a/tools/perf/util/trace-event-info.c b/tools/perf/util/trace-event-info.c
index ceb0e27..e7d60d0 100644
--- a/tools/perf/util/trace-event-info.c
+++ b/tools/perf/util/trace-event-info.c
@@ -170,6 +170,12 @@ static bool name_in_tp_list(char *sys, struct tracepoint_path *tps)
 	return false;
 }
 
+#define for_each_event(dir, dent, tps)				\
+	while ((dent = readdir(dir)))				\
+		if (dent->d_type == DT_DIR &&			\
+		    (strcmp(dent->d_name, ".")) &&		\
+		    (strcmp(dent->d_name, "..")))		\
+
 static int copy_event_system(const char *sys, struct tracepoint_path *tps)
 {
 	struct dirent *dent;
@@ -186,12 +192,10 @@ static int copy_event_system(const char *sys, struct tracepoint_path *tps)
 		return -errno;
 	}
 
-	while ((dent = readdir(dir))) {
-		if (dent->d_type != DT_DIR ||
-		    strcmp(dent->d_name, ".") == 0 ||
-		    strcmp(dent->d_name, "..") == 0 ||
-		    !name_in_tp_list(dent->d_name, tps))
+	for_each_event(dir, dent, tps) {
+		if (!name_in_tp_list(dent->d_name, tps))
 			continue;
+
 		if (asprintf(&format, "%s/%s/format", sys, dent->d_name) < 0) {
 			err = -ENOMEM;
 			goto out;
@@ -210,12 +214,10 @@ static int copy_event_system(const char *sys, struct tracepoint_path *tps)
 	}
 
 	rewinddir(dir);
-	while ((dent = readdir(dir))) {
-		if (dent->d_type != DT_DIR ||
-		    strcmp(dent->d_name, ".") == 0 ||
-		    strcmp(dent->d_name, "..") == 0 ||
-		    !name_in_tp_list(dent->d_name, tps))
+	for_each_event(dir, dent, tps) {
+		if (!name_in_tp_list(dent->d_name, tps))
 			continue;
+
 		if (asprintf(&format, "%s/%s/format", sys, dent->d_name) < 0) {
 			err = -ENOMEM;
 			goto out;
@@ -290,13 +292,11 @@ static int record_event_files(struct tracepoint_path *tps)
 		goto out;
 	}
 
-	while ((dent = readdir(dir))) {
-		if (dent->d_type != DT_DIR ||
-		    strcmp(dent->d_name, ".") == 0 ||
-		    strcmp(dent->d_name, "..") == 0 ||
-		    strcmp(dent->d_name, "ftrace") == 0 ||
+	for_each_event(dir, dent, tps) {
+		if (strcmp(dent->d_name, "ftrace") == 0 ||
 		    !system_in_tp_list(dent->d_name, tps))
 			continue;
+
 		count++;
 	}
 
@@ -307,13 +307,11 @@ static int record_event_files(struct tracepoint_path *tps)
 	}
 
 	rewinddir(dir);
-	while ((dent = readdir(dir))) {
-		if (dent->d_type != DT_DIR ||
-		    strcmp(dent->d_name, ".") == 0 ||
-		    strcmp(dent->d_name, "..") == 0 ||
-		    strcmp(dent->d_name, "ftrace") == 0 ||
+	for_each_event(dir, dent, tps) {
+		if (strcmp(dent->d_name, "ftrace") == 0 ||
 		    !system_in_tp_list(dent->d_name, tps))
 			continue;
+
 		if (asprintf(&sys, "%s/%s", path, dent->d_name) < 0) {
 			err = -ENOMEM;
 			goto out;

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web