Re: [PATCH 1/2] Fix mmap-thread-lookup.c unitialized memory usage

From: Arnaldo Carvalho de Melo
Date: Tue Jul 02 2019 - 23:09:35 EST


Em Tue, Jul 02, 2019 at 10:37:15AM -0700, Numfor Mbiziwo-Tiapo escreveu:
> Running the perf test command after building perf with a memory
> sanitizer causes a warning that says:
> WARNING: MemorySanitizer: use-of-uninitialized-value... in mmap-thread-lookup.c
> Initializing the go variable to 0 fixes this change.
>
> Signed-off-by: Numfor Mbiziwo-Tiapo <nums@xxxxxxxxxx>
> ---
> tools/perf/tests/mmap-thread-lookup.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/tests/mmap-thread-lookup.c b/tools/perf/tests/mmap-thread-lookup.c
> index 5ede9b561d32..b1abf4752f35 100644
> --- a/tools/perf/tests/mmap-thread-lookup.c
> +++ b/tools/perf/tests/mmap-thread-lookup.c
> @@ -52,7 +52,7 @@ static void *thread_fn(void *arg)
> {
> struct thread_data *td = arg;
> ssize_t ret;
> - int go;
> + int go = 0;
>
> if (thread_init(td))
> return NULL;

The test needs to write something to a file, whatever, so this doesn't
fix anything, just silences the compiler warning, which is a good thing.

I'll apply and adjust the cset commit log.

Thanks,

- Arnaldo