All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf probe: check if *ptr2 is zero and not ptr2
@ 2016-10-03 10:34 Colin King
  2016-10-03 11:19 ` Arnaldo Carvalho de Melo
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Colin King @ 2016-10-03 10:34 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Alexander Shishkin, Masami Hiramatsu, Ravi Bangoria, Wang Nan
  Cc: linux-kernel

From: Colin Ian King <colin.king@canonical.com>

Static anaylsis with cppcheck detected an incorrect comparison:
[tools/perf/util/probe-event.c:216]: (warning) Char literal compared with
pointer 'ptr2'. Did you intend to dereference it?

Dereference ptr2 for the comparison to fix this.

Fixes: 35726d3a4ca9 ("perf probe: Fix to cut off incompatible chars from group name")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 tools/perf/util/probe-event.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index fcfbef0..d281ae2 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -213,7 +213,7 @@ static int convert_exec_to_group(const char *exec, char **result)
 		goto out;
 	}
 
-	for (ptr2 = ptr1; ptr2 != '\0'; ptr2++) {
+	for (ptr2 = ptr1; *ptr2 != '\0'; ptr2++) {
 		if (!isalnum(*ptr2) && *ptr2 != '_') {
 			*ptr2 = '\0';
 			break;
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] perf probe: check if *ptr2 is zero and not ptr2
  2016-10-03 10:34 [PATCH] perf probe: check if *ptr2 is zero and not ptr2 Colin King
@ 2016-10-03 11:19 ` Arnaldo Carvalho de Melo
  2016-10-03 11:22   ` Colin Ian King
  2016-10-04  2:28 ` Masami Hiramatsu
  2016-10-04  8:09 ` [tip:perf/urgent] perf probe: Check " tip-bot for Colin Ian King
  2 siblings, 1 reply; 6+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-10-03 11:19 UTC (permalink / raw)
  To: Colin King
  Cc: Peter Zijlstra, Ingo Molnar, Alexander Shishkin, Masami Hiramatsu,
	Ravi Bangoria, Wang Nan, linux-kernel

Em Mon, Oct 03, 2016 at 11:34:31AM +0100, Colin King escreveu:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Static anaylsis with cppcheck detected an incorrect comparison:
> [tools/perf/util/probe-event.c:216]: (warning) Char literal compared with
> pointer 'ptr2'. Did you intend to dereference it?

What tool was used for that?

- Arnaldo
 
> Dereference ptr2 for the comparison to fix this.
> 
> Fixes: 35726d3a4ca9 ("perf probe: Fix to cut off incompatible chars from group name")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  tools/perf/util/probe-event.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
> index fcfbef0..d281ae2 100644
> --- a/tools/perf/util/probe-event.c
> +++ b/tools/perf/util/probe-event.c
> @@ -213,7 +213,7 @@ static int convert_exec_to_group(const char *exec, char **result)
>  		goto out;
>  	}
>  
> -	for (ptr2 = ptr1; ptr2 != '\0'; ptr2++) {
> +	for (ptr2 = ptr1; *ptr2 != '\0'; ptr2++) {
>  		if (!isalnum(*ptr2) && *ptr2 != '_') {
>  			*ptr2 = '\0';
>  			break;
> -- 
> 2.9.3

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] perf probe: check if *ptr2 is zero and not ptr2
  2016-10-03 11:19 ` Arnaldo Carvalho de Melo
@ 2016-10-03 11:22   ` Colin Ian King
  2016-10-03 11:45     ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 6+ messages in thread
From: Colin Ian King @ 2016-10-03 11:22 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Peter Zijlstra, Ingo Molnar, Alexander Shishkin, Masami Hiramatsu,
	Ravi Bangoria, Wang Nan, linux-kernel

On 03/10/16 12:19, Arnaldo Carvalho de Melo wrote:
> Em Mon, Oct 03, 2016 at 11:34:31AM +0100, Colin King escreveu:
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> Static anaylsis with cppcheck detected an incorrect comparison:
>> [tools/perf/util/probe-event.c:216]: (warning) Char literal compared with
>> pointer 'ptr2'. Did you intend to dereference it?
> 
> What tool was used for that?

cppcheck https://github.com/danmar/cppcheck - I run it nearly daily on
linux-next and linux

> 
> - Arnaldo
>  
>> Dereference ptr2 for the comparison to fix this.
>>
>> Fixes: 35726d3a4ca9 ("perf probe: Fix to cut off incompatible chars from group name")
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>> ---
>>  tools/perf/util/probe-event.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
>> index fcfbef0..d281ae2 100644
>> --- a/tools/perf/util/probe-event.c
>> +++ b/tools/perf/util/probe-event.c
>> @@ -213,7 +213,7 @@ static int convert_exec_to_group(const char *exec, char **result)
>>  		goto out;
>>  	}
>>  
>> -	for (ptr2 = ptr1; ptr2 != '\0'; ptr2++) {
>> +	for (ptr2 = ptr1; *ptr2 != '\0'; ptr2++) {
>>  		if (!isalnum(*ptr2) && *ptr2 != '_') {
>>  			*ptr2 = '\0';
>>  			break;
>> -- 
>> 2.9.3

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] perf probe: check if *ptr2 is zero and not ptr2
  2016-10-03 11:22   ` Colin Ian King
@ 2016-10-03 11:45     ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 6+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-10-03 11:45 UTC (permalink / raw)
  To: Colin Ian King
  Cc: Peter Zijlstra, Ingo Molnar, Alexander Shishkin, Masami Hiramatsu,
	Ravi Bangoria, Wang Nan, linux-kernel

Em Mon, Oct 03, 2016 at 12:22:25PM +0100, Colin Ian King escreveu:
> On 03/10/16 12:19, Arnaldo Carvalho de Melo wrote:
> > Em Mon, Oct 03, 2016 at 11:34:31AM +0100, Colin King escreveu:
> >> From: Colin Ian King <colin.king@canonical.com>
> >>
> >> Static anaylsis with cppcheck detected an incorrect comparison:
> >> [tools/perf/util/probe-event.c:216]: (warning) Char literal compared with
> >> pointer 'ptr2'. Did you intend to dereference it?
> > 
> > What tool was used for that?
> 
> cppcheck https://github.com/danmar/cppcheck - I run it nearly daily on
> linux-next and linux

Thanks, I'll try to get it and use it before upstreaming stuff,

- Arnaldo
 
> > 
> > - Arnaldo
> >  
> >> Dereference ptr2 for the comparison to fix this.
> >>
> >> Fixes: 35726d3a4ca9 ("perf probe: Fix to cut off incompatible chars from group name")
> >> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> >> ---
> >>  tools/perf/util/probe-event.c | 2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
> >> index fcfbef0..d281ae2 100644
> >> --- a/tools/perf/util/probe-event.c
> >> +++ b/tools/perf/util/probe-event.c
> >> @@ -213,7 +213,7 @@ static int convert_exec_to_group(const char *exec, char **result)
> >>  		goto out;
> >>  	}
> >>  
> >> -	for (ptr2 = ptr1; ptr2 != '\0'; ptr2++) {
> >> +	for (ptr2 = ptr1; *ptr2 != '\0'; ptr2++) {
> >>  		if (!isalnum(*ptr2) && *ptr2 != '_') {
> >>  			*ptr2 = '\0';
> >>  			break;
> >> -- 
> >> 2.9.3

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] perf probe: check if *ptr2 is zero and not ptr2
  2016-10-03 10:34 [PATCH] perf probe: check if *ptr2 is zero and not ptr2 Colin King
  2016-10-03 11:19 ` Arnaldo Carvalho de Melo
@ 2016-10-04  2:28 ` Masami Hiramatsu
  2016-10-04  8:09 ` [tip:perf/urgent] perf probe: Check " tip-bot for Colin Ian King
  2 siblings, 0 replies; 6+ messages in thread
From: Masami Hiramatsu @ 2016-10-04  2:28 UTC (permalink / raw)
  To: Colin King
  Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Alexander Shishkin, Ravi Bangoria, Wang Nan, linux-kernel

On Mon,  3 Oct 2016 11:34:31 +0100
Colin King <colin.king@canonical.com> wrote:

> From: Colin Ian King <colin.king@canonical.com>
> 
> Static anaylsis with cppcheck detected an incorrect comparison:
> [tools/perf/util/probe-event.c:216]: (warning) Char literal compared with
> pointer 'ptr2'. Did you intend to dereference it?
> 
> Dereference ptr2 for the comparison to fix this.

Oops, right!

Acked-by: Masami Hiramatsu <mhiramat@kernel.org>

Thanks!

> 
> Fixes: 35726d3a4ca9 ("perf probe: Fix to cut off incompatible chars from group name")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  tools/perf/util/probe-event.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
> index fcfbef0..d281ae2 100644
> --- a/tools/perf/util/probe-event.c
> +++ b/tools/perf/util/probe-event.c
> @@ -213,7 +213,7 @@ static int convert_exec_to_group(const char *exec, char **result)
>  		goto out;
>  	}
>  
> -	for (ptr2 = ptr1; ptr2 != '\0'; ptr2++) {
> +	for (ptr2 = ptr1; *ptr2 != '\0'; ptr2++) {
>  		if (!isalnum(*ptr2) && *ptr2 != '_') {
>  			*ptr2 = '\0';
>  			break;
> -- 
> 2.9.3
> 


-- 
Masami Hiramatsu <mhiramat@kernel.org>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [tip:perf/urgent] perf probe: Check if *ptr2 is zero and not ptr2
  2016-10-03 10:34 [PATCH] perf probe: check if *ptr2 is zero and not ptr2 Colin King
  2016-10-03 11:19 ` Arnaldo Carvalho de Melo
  2016-10-04  2:28 ` Masami Hiramatsu
@ 2016-10-04  8:09 ` tip-bot for Colin Ian King
  2 siblings, 0 replies; 6+ messages in thread
From: tip-bot for Colin Ian King @ 2016-10-04  8:09 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: mhiramat, colin.king, ravi.bangoria, acme, wangnan0, tglx, mingo,
	hpa, alexander.shishkin, linux-kernel, peterz

Commit-ID:  ead1a57457c0324a167f3f9e3a70e26c2d75fb12
Gitweb:     http://git.kernel.org/tip/ead1a57457c0324a167f3f9e3a70e26c2d75fb12
Author:     Colin Ian King <colin.king@canonical.com>
AuthorDate: Mon, 3 Oct 2016 11:34:31 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 3 Oct 2016 11:24:12 -0300

perf probe: Check if *ptr2 is zero and not ptr2

Static anaylsis with cppcheck[1] detected an incorrect comparison:
[tools/perf/util/probe-event.c:216]: (warning) Char literal compared
with pointer 'ptr2'. Did you intend to dereference it?

Dereference ptr2 for the comparison to fix this.

1: https://sourceforge.net/p/cppcheck/wiki/Home/

Signed-off-by: Colin King <colin.king@canonical.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
Cc: Wang Nan <wangnan0@huawei.com>
Fixes: 35726d3a4ca9 ("perf probe: Fix to cut off incompatible chars from group name")
Link: http://lkml.kernel.org/r/20161003103431.18534-1-colin.king@canonical.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/probe-event.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index fcfbef0..d281ae2 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -213,7 +213,7 @@ static int convert_exec_to_group(const char *exec, char **result)
 		goto out;
 	}
 
-	for (ptr2 = ptr1; ptr2 != '\0'; ptr2++) {
+	for (ptr2 = ptr1; *ptr2 != '\0'; ptr2++) {
 		if (!isalnum(*ptr2) && *ptr2 != '_') {
 			*ptr2 = '\0';
 			break;

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-10-04  8:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-03 10:34 [PATCH] perf probe: check if *ptr2 is zero and not ptr2 Colin King
2016-10-03 11:19 ` Arnaldo Carvalho de Melo
2016-10-03 11:22   ` Colin Ian King
2016-10-03 11:45     ` Arnaldo Carvalho de Melo
2016-10-04  2:28 ` Masami Hiramatsu
2016-10-04  8:09 ` [tip:perf/urgent] perf probe: Check " tip-bot for Colin Ian King

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.