Block: bio.c:1232:6: error: variable 'i' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]

From: Naresh Kamboju
Date: Mon Jul 11 2022 - 08:44:56 EST


Following regression found with clang i386 and x86 builds failed on
Linux next-20220711 tag. Please find the build error logs.

Reported-by: Linux Kernel Functional Testing <lkft@xxxxxxxxxx>
Reported-by: Naresh Kamboju <naresh.kamboju@xxxxxxxxxx>

Regressions found on i386:

- build-clang-12-defconfig
- build-clang-nightly-lkftconfig
- build-clang-13-defconfig
- build-clang-12-lkftconfig
- build-clang-14-lkftconfig
- build-clang-nightly-defconfig
- build-clang-13-lkftconfig

Regressions found on x86_64:

- build-clang-nightly-x86_64_defconfig
- build-clang-nightly-lkftconfig
- build-clang-13-lkftconfig
- build-clang-12-lkftconfig
- build-clang-13-lkftconfig-kcsan
- build-clang-14-lkftconfig
- build-clang-14-x86_64_defconfig

make --silent --keep-going --jobs=8
O=/home/tuxbuild/.cache/tuxmake/builds/1/build LLVM=1 LLVM_IAS=1
ARCH=x86_64 CROSS_COMPILE=x86_64-linux-gnu- 'HOSTCC=sccache clang'
'CC=sccache clang'
block/bio.c:1232:6: error: variable 'i' is used uninitialized whenever
'if' condition is true [-Werror,-Wsometimes-uninitialized]
if (unlikely(!size)) {
^~~~~~~~~~~~~~~
include/linux/compiler.h:78:22: note: expanded from macro 'unlikely'
# define unlikely(x) __builtin_expect(!!(x), 0)
^~~~~~~~~~~~~~~~~~~~~~~~~~
block/bio.c:1254:9: note: uninitialized use occurs here
while (i < nr_pages)
^
block/bio.c:1232:2: note: remove the 'if' if its condition is always false
if (unlikely(!size)) {
^~~~~~~~~~~~~~~~~~~~~~
block/bio.c:1202:17: note: initialize the variable 'i' to silence this warning
unsigned len, i;
^
= 0
1 error generated.

Build details:
---------------
download_url: https://builds.tuxbuild.com/2BnQO6OXSJejfpLO4fQ3fWa5wVT/,
git_describe: next-20220711,
git_repo: https://gitlab.com/Linaro/lkft/mirrors/next/linux-next,
git_sha: 4112a8699ae2eac797415b9be1d7901b3f79e772,
git_short_log: 4112a8699ae2 (\Add linux-next specific files
for 20220711\),
kconfig: https://builds.tuxbuild.com/2BnQO6OXSJejfpLO4fQ3fWa5wVT/config
kernel_version: 5.19.0-rc6,
make_variables: {
LLVM: 1,
LLVM_IAS: 1
},

Steps to reproduce:
tuxmake --runtime podman --target-arch x86_64 --toolchain clang-14
--kconfig https://builds.tuxbuild.com/2BnQO6OXSJejfpLO4fQ3fWa5wVT/config
LLVM=1 LLVM_IAS=1

Best regards
Naresh Kamboju

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