2023-03-23 08:01:43

by Naresh Kamboju

[permalink] [raw]
Subject: mm/mmap.c:939:11: error: variable 'next' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]

Following multiple build warnings / errors noticed while building
Linux next-20230323 with clang-16 for x86_64.

Reported-by: Linux Kernel Functional Testing <[email protected]>

Build warnings / errors:
---------
mm/mmap.c:939:11: error: variable 'next' is used uninitialized
whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
else if (!curr)
^~~~~
mm/mmap.c:952:15: note: uninitialized use occurs here
merge_next = next && mpol_equal(policy, vma_policy(next)) &&
^~~~
mm/mmap.c:939:7: note: remove the 'if' if its condition is always true
else if (!curr)
^~~~~~~~~~
mm/mmap.c:912:36: note: initialize the variable 'next' to silence this warning
struct vm_area_struct *curr, *next, *res;
^
= NULL
1 error generated.
make[3]: *** [scripts/Makefile.build:252: mm/mmap.o] Error 1

mm/vmalloc.c:3543:6: error: variable 'remains' is used uninitialized
whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]
if (bitmap_empty(vb->used_map, VMAP_BBMAP_BITS)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mm/vmalloc.c:3587:17: note: uninitialized use occurs here
return count - remains + zero_iter(iter, remains);
^~~~~~~
mm/vmalloc.c:3543:2: note: remove the 'if' if its condition is always false
if (bitmap_empty(vb->used_map, VMAP_BBMAP_BITS)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mm/vmalloc.c:3539:6: error: variable 'remains' is used uninitialized
whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]
if (!vb)
^~~
mm/vmalloc.c:3587:17: note: uninitialized use occurs here
return count - remains + zero_iter(iter, remains);
^~~~~~~
mm/vmalloc.c:3539:2: note: remove the 'if' if its condition is always false
if (!vb)
^~~~~~~~
mm/vmalloc.c:3524:16: note: initialize the variable 'remains' to
silence this warning
size_t remains, n;
^
= 0
2 errors generated.
make[3]: *** [scripts/Makefile.build:252: mm/vmalloc.o] Error 1
make[3]: Target 'mm/' not remade because of errors.

steps to reproduce:
----------

tuxmake \
--runtime podman \
--target-arch x86_64 \
--toolchain clang-16 LLVM=1 LLVM_IAS=1 \
--kconfig https://storage.tuxsuite.com/public/linaro/lkft/builds/2NOjxURhByyb4dR3Ld788iuYvAR/config

Related discussion on mailing list,
- https://lore.kernel.org/llvm/[email protected]/
- https://lore.kernel.org/llvm/[email protected]/T/#t


--
Linaro LKFT
https://lkft.linaro.org


2023-03-23 09:47:05

by Vlastimil Babka

[permalink] [raw]
Subject: Re: mm/mmap.c:939:11: error: variable 'next' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]

On 3/23/23 08:58, Naresh Kamboju wrote:
> Following multiple build warnings / errors noticed while building
> Linux next-20230323 with clang-16 for x86_64.
>
> Reported-by: Linux Kernel Functional Testing <[email protected]>
>
> Build warnings / errors:
> ---------
> mm/mmap.c:939:11: error: variable 'next' is used uninitialized
> whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
> else if (!curr)
> ^~~~~
> mm/mmap.c:952:15: note: uninitialized use occurs here
> merge_next = next && mpol_equal(policy, vma_policy(next)) &&
> ^~~~
> mm/mmap.c:939:7: note: remove the 'if' if its condition is always true
> else if (!curr)
> ^~~~~~~~~~
> mm/mmap.c:912:36: note: initialize the variable 'next' to silence this warning
> struct vm_area_struct *curr, *next, *res;
> ^
> = NULL

Same issue as https://lore.kernel.org/all/CA%2BG9fYvBxp38KEggtvtvVtGMaSBdL3NDV9ns%[email protected]/
Thus already resolved in the next -next hopefully.

> 1 error generated.
> make[3]: *** [scripts/Makefile.build:252: mm/mmap.o] Error 1
>
> mm/vmalloc.c:3543:6: error: variable 'remains' is used uninitialized
> whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]
> if (bitmap_empty(vb->used_map, VMAP_BBMAP_BITS)) {
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> mm/vmalloc.c:3587:17: note: uninitialized use occurs here
> return count - remains + zero_iter(iter, remains);
> ^~~~~~~
> mm/vmalloc.c:3543:2: note: remove the 'if' if its condition is always false
> if (bitmap_empty(vb->used_map, VMAP_BBMAP_BITS)) {
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> mm/vmalloc.c:3539:6: error: variable 'remains' is used uninitialized
> whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]
> if (!vb)
> ^~~
> mm/vmalloc.c:3587:17: note: uninitialized use occurs here
> return count - remains + zero_iter(iter, remains);
> ^~~~~~~
> mm/vmalloc.c:3539:2: note: remove the 'if' if its condition is always false
> if (!vb)
> ^~~~~~~~
> mm/vmalloc.c:3524:16: note: initialize the variable 'remains' to
> silence this warning
> size_t remains, n;
> ^
> = 0
> 2 errors generated.
> make[3]: *** [scripts/Makefile.build:252: mm/vmalloc.o] Error 1
> make[3]: Target 'mm/' not remade because of errors.
>
> steps to reproduce:
> ----------
>
> tuxmake \
> --runtime podman \
> --target-arch x86_64 \
> --toolchain clang-16 LLVM=1 LLVM_IAS=1 \
> --kconfig https://storage.tuxsuite.com/public/linaro/lkft/builds/2NOjxURhByyb4dR3Ld788iuYvAR/config
>
> Related discussion on mailing list,
> - https://lore.kernel.org/llvm/[email protected]/
> - https://lore.kernel.org/llvm/[email protected]/T/#t
>
>
> --
> Linaro LKFT
> https://lkft.linaro.org
>