linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] perf probe: Fix uninitialized variable
@ 2024-12-11  8:55 James Clark
  2024-12-11  8:55 ` [PATCH v2 1/2] " James Clark
  2024-12-11  8:55 ` [PATCH v2 2/2] perf probe: Rename err label James Clark
  0 siblings, 2 replies; 7+ messages in thread
From: James Clark @ 2024-12-11  8:55 UTC (permalink / raw)
  To: linux-perf-users, namhyung, acme, mhiramat
  Cc: James Clark, Peter Zijlstra, Ingo Molnar, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Ian Rogers, Adrian Hunter,
	Liang, Kan, Leo Yan, Dr. David Alan Gilbert, Dima Kogan,
	linux-kernel

Changes since V1:

 * Split into a fixes commit and tidyup
 * Pick up tags

James Clark (2):
  perf probe: Fix uninitialized variable
  perf probe: Rename err label

 tools/perf/util/probe-event.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

-- 
2.34.1


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

* [PATCH v2 1/2] perf probe: Fix uninitialized variable
  2024-12-11  8:55 [PATCH v2 0/2] perf probe: Fix uninitialized variable James Clark
@ 2024-12-11  8:55 ` James Clark
  2024-12-11 13:15   ` Arnaldo Carvalho de Melo
  2024-12-11  8:55 ` [PATCH v2 2/2] perf probe: Rename err label James Clark
  1 sibling, 1 reply; 7+ messages in thread
From: James Clark @ 2024-12-11  8:55 UTC (permalink / raw)
  To: linux-perf-users, namhyung, acme, mhiramat
  Cc: James Clark, Arnaldo Carvalho de Melo, Peter Zijlstra,
	Ingo Molnar, Mark Rutland, Alexander Shishkin, Jiri Olsa,
	Ian Rogers, Adrian Hunter, Liang, Kan, Leo Yan, Dima Kogan,
	Dr. David Alan Gilbert, linux-kernel

Since the linked fixes: commit, err is returned uninitialized due to the
removal of "return 0". Initialize err to fix it.

This fixes the following intermittent test failure on release builds:

 $ perf test "testsuite_probe"
 ...
 -- [ FAIL ] -- perf_probe :: test_invalid_options :: mutually exclusive options :: -L foo -V bar (output regexp parsing)
 Regexp not found: \"Error: switch .+ cannot be used with switch .+\"
 ...

Fixes: 080e47b2a237 ("perf probe: Introduce quotation marks support")
Tested-by: Namhyung Kim <namhyung@kernel.org>
Reviewed-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: James Clark <james.clark@linaro.org>
---
 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 6d51a4c98ad7..eaa0318e9b87 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -1370,7 +1370,7 @@ int parse_line_range_desc(const char *arg, struct line_range *lr)
 {
 	char *buf = strdup(arg);
 	char *p;
-	int err;
+	int err = 0;
 
 	if (!buf)
 		return -ENOMEM;
-- 
2.34.1


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

* [PATCH v2 2/2] perf probe: Rename err label
  2024-12-11  8:55 [PATCH v2 0/2] perf probe: Fix uninitialized variable James Clark
  2024-12-11  8:55 ` [PATCH v2 1/2] " James Clark
@ 2024-12-11  8:55 ` James Clark
  2025-01-13 15:47   ` Arnaldo Carvalho de Melo
  1 sibling, 1 reply; 7+ messages in thread
From: James Clark @ 2024-12-11  8:55 UTC (permalink / raw)
  To: linux-perf-users, namhyung, acme, mhiramat
  Cc: James Clark, Arnaldo Carvalho de Melo, Peter Zijlstra,
	Ingo Molnar, Mark Rutland, Alexander Shishkin, Jiri Olsa,
	Ian Rogers, Adrian Hunter, Liang, Kan, Leo Yan,
	Dr. David Alan Gilbert, linux-kernel

Rename err to out to avoid confusion because buf is still supposed to be
freed in non error cases.

Tested-by: Namhyung Kim <namhyung@kernel.org>
Reviewed-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: James Clark <james.clark@linaro.org>
---
 tools/perf/util/probe-event.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index eaa0318e9b87..35af6570cf9b 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -1383,20 +1383,20 @@ int parse_line_range_desc(const char *arg, struct line_range *lr)
 		if (p == buf) {
 			semantic_error("No file/function name in '%s'.\n", p);
 			err = -EINVAL;
-			goto err;
+			goto out;
 		}
 		*(p++) = '\0';
 
 		err = parse_line_num(&p, &lr->start, "start line");
 		if (err)
-			goto err;
+			goto out;
 
 		if (*p == '+' || *p == '-') {
 			const char c = *(p++);
 
 			err = parse_line_num(&p, &lr->end, "end line");
 			if (err)
-				goto err;
+				goto out;
 
 			if (c == '+') {
 				lr->end += lr->start;
@@ -1416,11 +1416,11 @@ int parse_line_range_desc(const char *arg, struct line_range *lr)
 		if (lr->start > lr->end) {
 			semantic_error("Start line must be smaller"
 				       " than end line.\n");
-			goto err;
+			goto out;
 		}
 		if (*p != '\0') {
 			semantic_error("Tailing with invalid str '%s'.\n", p);
-			goto err;
+			goto out;
 		}
 	}
 
@@ -1431,7 +1431,7 @@ int parse_line_range_desc(const char *arg, struct line_range *lr)
 			lr->file = strdup_esq(p);
 			if (lr->file == NULL) {
 				err = -ENOMEM;
-				goto err;
+				goto out;
 			}
 		}
 		if (*buf != '\0')
@@ -1439,7 +1439,7 @@ int parse_line_range_desc(const char *arg, struct line_range *lr)
 		if (!lr->function && !lr->file) {
 			semantic_error("Only '@*' is not allowed.\n");
 			err = -EINVAL;
-			goto err;
+			goto out;
 		}
 	} else if (strpbrk_esq(buf, "/."))
 		lr->file = strdup_esq(buf);
@@ -1448,10 +1448,10 @@ int parse_line_range_desc(const char *arg, struct line_range *lr)
 	else {	/* Invalid name */
 		semantic_error("'%s' is not a valid function name.\n", buf);
 		err = -EINVAL;
-		goto err;
+		goto out;
 	}
 
-err:
+out:
 	free(buf);
 	return err;
 }
-- 
2.34.1


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

* Re: [PATCH v2 1/2] perf probe: Fix uninitialized variable
  2024-12-11  8:55 ` [PATCH v2 1/2] " James Clark
@ 2024-12-11 13:15   ` Arnaldo Carvalho de Melo
  2024-12-11 17:18     ` Namhyung Kim
  0 siblings, 1 reply; 7+ messages in thread
From: Arnaldo Carvalho de Melo @ 2024-12-11 13:15 UTC (permalink / raw)
  To: James Clark
  Cc: linux-perf-users, namhyung, mhiramat, Arnaldo Carvalho de Melo,
	Peter Zijlstra, Ingo Molnar, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Ian Rogers, Adrian Hunter, Liang, Kan, Leo Yan,
	Dima Kogan, Dr. David Alan Gilbert, linux-kernel

On Wed, Dec 11, 2024 at 08:55:23AM +0000, James Clark wrote:
> Since the linked fixes: commit, err is returned uninitialized due to the
> removal of "return 0". Initialize err to fix it.
> 
> This fixes the following intermittent test failure on release builds:
> 
>  $ perf test "testsuite_probe"
>  ...
>  -- [ FAIL ] -- perf_probe :: test_invalid_options :: mutually exclusive options :: -L foo -V bar (output regexp parsing)
>  Regexp not found: \"Error: switch .+ cannot be used with switch .+\"
>  ...

So Namhyung, this one should go to perf-tools, I can pick the second on
perf-tools-next, so that we keep perf-tools as small as possible.

- Arnaldo
 
> Fixes: 080e47b2a237 ("perf probe: Introduce quotation marks support")
> Tested-by: Namhyung Kim <namhyung@kernel.org>
> Reviewed-by: Arnaldo Carvalho de Melo <acme@redhat.com>
> Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
> Signed-off-by: James Clark <james.clark@linaro.org>
> ---
>  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 6d51a4c98ad7..eaa0318e9b87 100644
> --- a/tools/perf/util/probe-event.c
> +++ b/tools/perf/util/probe-event.c
> @@ -1370,7 +1370,7 @@ int parse_line_range_desc(const char *arg, struct line_range *lr)
>  {
>  	char *buf = strdup(arg);
>  	char *p;
> -	int err;
> +	int err = 0;
>  
>  	if (!buf)
>  		return -ENOMEM;
> -- 
> 2.34.1

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

* Re: [PATCH v2 1/2] perf probe: Fix uninitialized variable
  2024-12-11 13:15   ` Arnaldo Carvalho de Melo
@ 2024-12-11 17:18     ` Namhyung Kim
  2024-12-12  7:08       ` Namhyung Kim
  0 siblings, 1 reply; 7+ messages in thread
From: Namhyung Kim @ 2024-12-11 17:18 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: James Clark, linux-perf-users, mhiramat, Arnaldo Carvalho de Melo,
	Peter Zijlstra, Ingo Molnar, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Ian Rogers, Adrian Hunter, Liang, Kan, Leo Yan,
	Dima Kogan, Dr. David Alan Gilbert, linux-kernel

Hello,

On Wed, Dec 11, 2024 at 10:15:30AM -0300, Arnaldo Carvalho de Melo wrote:
> On Wed, Dec 11, 2024 at 08:55:23AM +0000, James Clark wrote:
> > Since the linked fixes: commit, err is returned uninitialized due to the
> > removal of "return 0". Initialize err to fix it.
> > 
> > This fixes the following intermittent test failure on release builds:
> > 
> >  $ perf test "testsuite_probe"
> >  ...
> >  -- [ FAIL ] -- perf_probe :: test_invalid_options :: mutually exclusive options :: -L foo -V bar (output regexp parsing)
> >  Regexp not found: \"Error: switch .+ cannot be used with switch .+\"
> >  ...
> 
> So Namhyung, this one should go to perf-tools, I can pick the second on
> perf-tools-next, so that we keep perf-tools as small as possible.

Sure, will replace and force-push.

Thanks,
Namhyung


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

* Re: [PATCH v2 1/2] perf probe: Fix uninitialized variable
  2024-12-11 17:18     ` Namhyung Kim
@ 2024-12-12  7:08       ` Namhyung Kim
  0 siblings, 0 replies; 7+ messages in thread
From: Namhyung Kim @ 2024-12-12  7:08 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: James Clark, linux-perf-users, mhiramat, Arnaldo Carvalho de Melo,
	Peter Zijlstra, Ingo Molnar, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Ian Rogers, Adrian Hunter, Liang, Kan, Leo Yan,
	Dima Kogan, Dr. David Alan Gilbert, linux-kernel

On Wed, Dec 11, 2024 at 09:18:45AM -0800, Namhyung Kim wrote:
> Hello,
> 
> On Wed, Dec 11, 2024 at 10:15:30AM -0300, Arnaldo Carvalho de Melo wrote:
> > On Wed, Dec 11, 2024 at 08:55:23AM +0000, James Clark wrote:
> > > Since the linked fixes: commit, err is returned uninitialized due to the
> > > removal of "return 0". Initialize err to fix it.
> > > 
> > > This fixes the following intermittent test failure on release builds:
> > > 
> > >  $ perf test "testsuite_probe"
> > >  ...
> > >  -- [ FAIL ] -- perf_probe :: test_invalid_options :: mutually exclusive options :: -L foo -V bar (output regexp parsing)
> > >  Regexp not found: \"Error: switch .+ cannot be used with switch .+\"
> > >  ...
> > 
> > So Namhyung, this one should go to perf-tools, I can pick the second on
> > perf-tools-next, so that we keep perf-tools as small as possible.
> 
> Sure, will replace and force-push.

Applied patch 1 to perf-tools, thanks!

Best regards,
Namhyung


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

* Re: [PATCH v2 2/2] perf probe: Rename err label
  2024-12-11  8:55 ` [PATCH v2 2/2] perf probe: Rename err label James Clark
@ 2025-01-13 15:47   ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 7+ messages in thread
From: Arnaldo Carvalho de Melo @ 2025-01-13 15:47 UTC (permalink / raw)
  To: James Clark
  Cc: linux-perf-users, namhyung, mhiramat, Arnaldo Carvalho de Melo,
	Peter Zijlstra, Ingo Molnar, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Ian Rogers, Adrian Hunter, Liang, Kan, Leo Yan,
	Dr. David Alan Gilbert, linux-kernel

On Wed, Dec 11, 2024 at 08:55:24AM +0000, James Clark wrote:
> Rename err to out to avoid confusion because buf is still supposed to be
> freed in non error cases.

Thanks, applied to perf-tools-next,

- Arnaldo
 
> Tested-by: Namhyung Kim <namhyung@kernel.org>
> Reviewed-by: Arnaldo Carvalho de Melo <acme@redhat.com>
> Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
> Signed-off-by: James Clark <james.clark@linaro.org>
> ---
>  tools/perf/util/probe-event.c | 18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
> index eaa0318e9b87..35af6570cf9b 100644
> --- a/tools/perf/util/probe-event.c
> +++ b/tools/perf/util/probe-event.c
> @@ -1383,20 +1383,20 @@ int parse_line_range_desc(const char *arg, struct line_range *lr)
>  		if (p == buf) {
>  			semantic_error("No file/function name in '%s'.\n", p);
>  			err = -EINVAL;
> -			goto err;
> +			goto out;
>  		}
>  		*(p++) = '\0';
>  
>  		err = parse_line_num(&p, &lr->start, "start line");
>  		if (err)
> -			goto err;
> +			goto out;
>  
>  		if (*p == '+' || *p == '-') {
>  			const char c = *(p++);
>  
>  			err = parse_line_num(&p, &lr->end, "end line");
>  			if (err)
> -				goto err;
> +				goto out;
>  
>  			if (c == '+') {
>  				lr->end += lr->start;
> @@ -1416,11 +1416,11 @@ int parse_line_range_desc(const char *arg, struct line_range *lr)
>  		if (lr->start > lr->end) {
>  			semantic_error("Start line must be smaller"
>  				       " than end line.\n");
> -			goto err;
> +			goto out;
>  		}
>  		if (*p != '\0') {
>  			semantic_error("Tailing with invalid str '%s'.\n", p);
> -			goto err;
> +			goto out;
>  		}
>  	}
>  
> @@ -1431,7 +1431,7 @@ int parse_line_range_desc(const char *arg, struct line_range *lr)
>  			lr->file = strdup_esq(p);
>  			if (lr->file == NULL) {
>  				err = -ENOMEM;
> -				goto err;
> +				goto out;
>  			}
>  		}
>  		if (*buf != '\0')
> @@ -1439,7 +1439,7 @@ int parse_line_range_desc(const char *arg, struct line_range *lr)
>  		if (!lr->function && !lr->file) {
>  			semantic_error("Only '@*' is not allowed.\n");
>  			err = -EINVAL;
> -			goto err;
> +			goto out;
>  		}
>  	} else if (strpbrk_esq(buf, "/."))
>  		lr->file = strdup_esq(buf);
> @@ -1448,10 +1448,10 @@ int parse_line_range_desc(const char *arg, struct line_range *lr)
>  	else {	/* Invalid name */
>  		semantic_error("'%s' is not a valid function name.\n", buf);
>  		err = -EINVAL;
> -		goto err;
> +		goto out;
>  	}
>  
> -err:
> +out:
>  	free(buf);
>  	return err;
>  }
> -- 
> 2.34.1
> 

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

end of thread, other threads:[~2025-01-13 15:47 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-11  8:55 [PATCH v2 0/2] perf probe: Fix uninitialized variable James Clark
2024-12-11  8:55 ` [PATCH v2 1/2] " James Clark
2024-12-11 13:15   ` Arnaldo Carvalho de Melo
2024-12-11 17:18     ` Namhyung Kim
2024-12-12  7:08       ` Namhyung Kim
2024-12-11  8:55 ` [PATCH v2 2/2] perf probe: Rename err label James Clark
2025-01-13 15:47   ` Arnaldo Carvalho de Melo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).