* Re: [PATCH] libperf tests: Avoid uninitialized variable warning.
2021-01-14 21:23 [PATCH] libperf tests: Avoid uninitialized variable warning Ian Rogers
@ 2021-01-15 7:41 ` Namhyung Kim
2021-01-15 8:34 ` Jiri Olsa
2021-01-15 18:58 ` Arnaldo Carvalho de Melo
2 siblings, 0 replies; 4+ messages in thread
From: Namhyung Kim @ 2021-01-15 7:41 UTC (permalink / raw)
To: Ian Rogers
Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Mark Rutland, Alexander Shishkin, Jiri Olsa, linux-kernel,
Stephane Eranian
Hi Ian,
On Fri, Jan 15, 2021 at 6:23 AM Ian Rogers <irogers@google.com> wrote:
>
> The variable bf is read (for a write call) without being initialized
> triggering a memory sanitizer warning. Use bf in the read and switch the
> write to reading from a string.
>
> Signed-off-by: Ian Rogers <irogers@google.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Thanks,
Namhyung
> ---
> tools/lib/perf/tests/test-evlist.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/lib/perf/tests/test-evlist.c b/tools/lib/perf/tests/test-evlist.c
> index 6d8ebe0c2504..1b225fe34a72 100644
> --- a/tools/lib/perf/tests/test-evlist.c
> +++ b/tools/lib/perf/tests/test-evlist.c
> @@ -208,7 +208,6 @@ static int test_mmap_thread(void)
> char path[PATH_MAX];
> int id, err, pid, go_pipe[2];
> union perf_event *event;
> - char bf;
> int count = 0;
>
> snprintf(path, PATH_MAX, "%s/kernel/debug/tracing/events/syscalls/sys_enter_prctl/id",
> @@ -229,6 +228,7 @@ static int test_mmap_thread(void)
> pid = fork();
> if (!pid) {
> int i;
> + char bf;
>
> read(go_pipe[0], &bf, 1);
>
> @@ -266,7 +266,7 @@ static int test_mmap_thread(void)
> perf_evlist__enable(evlist);
>
> /* kick the child and wait for it to finish */
> - write(go_pipe[1], &bf, 1);
> + write(go_pipe[1], "A", 1);
> waitpid(pid, NULL, 0);
>
> /*
> --
> 2.30.0.296.g2bfb1c46d8-goog
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] libperf tests: Avoid uninitialized variable warning.
2021-01-14 21:23 [PATCH] libperf tests: Avoid uninitialized variable warning Ian Rogers
2021-01-15 7:41 ` Namhyung Kim
@ 2021-01-15 8:34 ` Jiri Olsa
2021-01-15 18:58 ` Arnaldo Carvalho de Melo
2 siblings, 0 replies; 4+ messages in thread
From: Jiri Olsa @ 2021-01-15 8:34 UTC (permalink / raw)
To: Ian Rogers
Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Mark Rutland, Alexander Shishkin, Namhyung Kim, linux-kernel,
Stephane Eranian
On Thu, Jan 14, 2021 at 01:23:04PM -0800, Ian Rogers wrote:
> The variable bf is read (for a write call) without being initialized
> triggering a memory sanitizer warning. Use bf in the read and switch the
> write to reading from a string.
>
> Signed-off-by: Ian Rogers <irogers@google.com>
Acked-by: Jiri Olsa <jolsa@redhat.com>
thanks,
jirka
> ---
> tools/lib/perf/tests/test-evlist.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/lib/perf/tests/test-evlist.c b/tools/lib/perf/tests/test-evlist.c
> index 6d8ebe0c2504..1b225fe34a72 100644
> --- a/tools/lib/perf/tests/test-evlist.c
> +++ b/tools/lib/perf/tests/test-evlist.c
> @@ -208,7 +208,6 @@ static int test_mmap_thread(void)
> char path[PATH_MAX];
> int id, err, pid, go_pipe[2];
> union perf_event *event;
> - char bf;
> int count = 0;
>
> snprintf(path, PATH_MAX, "%s/kernel/debug/tracing/events/syscalls/sys_enter_prctl/id",
> @@ -229,6 +228,7 @@ static int test_mmap_thread(void)
> pid = fork();
> if (!pid) {
> int i;
> + char bf;
>
> read(go_pipe[0], &bf, 1);
>
> @@ -266,7 +266,7 @@ static int test_mmap_thread(void)
> perf_evlist__enable(evlist);
>
> /* kick the child and wait for it to finish */
> - write(go_pipe[1], &bf, 1);
> + write(go_pipe[1], "A", 1);
> waitpid(pid, NULL, 0);
>
> /*
> --
> 2.30.0.296.g2bfb1c46d8-goog
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] libperf tests: Avoid uninitialized variable warning.
2021-01-14 21:23 [PATCH] libperf tests: Avoid uninitialized variable warning Ian Rogers
2021-01-15 7:41 ` Namhyung Kim
2021-01-15 8:34 ` Jiri Olsa
@ 2021-01-15 18:58 ` Arnaldo Carvalho de Melo
2 siblings, 0 replies; 4+ messages in thread
From: Arnaldo Carvalho de Melo @ 2021-01-15 18:58 UTC (permalink / raw)
To: Ian Rogers
Cc: Peter Zijlstra, Ingo Molnar, Mark Rutland, Alexander Shishkin,
Jiri Olsa, Namhyung Kim, linux-kernel, Stephane Eranian
Em Thu, Jan 14, 2021 at 01:23:04PM -0800, Ian Rogers escreveu:
> The variable bf is read (for a write call) without being initialized
> triggering a memory sanitizer warning. Use bf in the read and switch the
> write to reading from a string.
>
> Signed-off-by: Ian Rogers <irogers@google.com>
Thanks, applied.
- Arnaldo
> ---
> tools/lib/perf/tests/test-evlist.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/lib/perf/tests/test-evlist.c b/tools/lib/perf/tests/test-evlist.c
> index 6d8ebe0c2504..1b225fe34a72 100644
> --- a/tools/lib/perf/tests/test-evlist.c
> +++ b/tools/lib/perf/tests/test-evlist.c
> @@ -208,7 +208,6 @@ static int test_mmap_thread(void)
> char path[PATH_MAX];
> int id, err, pid, go_pipe[2];
> union perf_event *event;
> - char bf;
> int count = 0;
>
> snprintf(path, PATH_MAX, "%s/kernel/debug/tracing/events/syscalls/sys_enter_prctl/id",
> @@ -229,6 +228,7 @@ static int test_mmap_thread(void)
> pid = fork();
> if (!pid) {
> int i;
> + char bf;
>
> read(go_pipe[0], &bf, 1);
>
> @@ -266,7 +266,7 @@ static int test_mmap_thread(void)
> perf_evlist__enable(evlist);
>
> /* kick the child and wait for it to finish */
> - write(go_pipe[1], &bf, 1);
> + write(go_pipe[1], "A", 1);
> waitpid(pid, NULL, 0);
>
> /*
> --
> 2.30.0.296.g2bfb1c46d8-goog
>
--
- Arnaldo
^ permalink raw reply [flat|nested] 4+ messages in thread