Re: [PATCH] perf probe: check if *ptr2 is zero and not ptr2

From: Masami Hiramatsu
Date: Mon Oct 03 2016 - 22:28:35 EST


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

> From: Colin Ian King <colin.king@xxxxxxxxxxxxx>
>
> 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@xxxxxxxxxx>

Thanks!

>
> Fixes: 35726d3a4ca9 ("perf probe: Fix to cut off incompatible chars from group name")
> Signed-off-by: Colin Ian King <colin.king@xxxxxxxxxxxxx>
> ---
> 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@xxxxxxxxxx>