bridge.c:157:11: error: variable 'err' is used uninitialized whenever 'if' condition is false

From: Naresh Kamboju
Date: Mon Sep 06 2021 - 05:11:11 EST


[Please ignore if it is already reported]

Following build warnings/ errors noticed while building linux mainline
master branch
with clang-nightly, clang-13, clang-12, clang-11 and clang-10 for
arm64 architecture.
Whereas gcc-11 build pass.

# to reproduce this build locally: tuxmake --target-arch=arm64
--kconfig=defconfig --toolchain=clang-nightly --wrapper=none
--environment=KBUILD_BUILD_TIMESTAMP=@1630870764
--environment=KBUILD_BUILD_USER=tuxmake
--environment=KBUILD_BUILD_HOST=tuxmake --runtime=podman
--image=855116176053.dkr.ecr.us-east-1.amazonaws.com/tuxmake/arm64_clang-nightly
config default kernel xipkernel modules dtbs dtbs-legacy debugkernel
headers
make --silent --keep-going --jobs=8
O=/home/tuxbuild/.cache/tuxmake/builds/current ARCH=arm64
CROSS_COMPILE=aarch64-linux-gnu- HOSTCC=clang CC=clang defconfig
make --silent --keep-going --jobs=8
O=/home/tuxbuild/.cache/tuxmake/builds/current ARCH=arm64
CROSS_COMPILE=aarch64-linux-gnu- HOSTCC=clang CC=clang
scripts/dtc/include-prefixes/arm/bcm2711-rpi-4-b.dts:220.10-231.4:
Warning (pci_device_reg): /scb/pcie@7d500000/pci@1,0: PCI unit address
format error, expected 0,0
scripts/dtc/include-prefixes/arm/bcm2711-rpi-4-b.dts:220.10-231.4:
Warning (pci_device_reg): /scb/pcie@7d500000/pci@1,0: PCI unit address
format error, expected 0,0
arch/arm64/boot/dts/rockchip/rk3399-gru.dtsi:464.3-52: Warning
(pci_device_reg): /pcie@f8000000/pcie@0,0:reg: PCI reg address is not
configuration space
arch/arm64/boot/dts/rockchip/rk3399-gru.dtsi:464.3-52: Warning
(pci_device_reg): /pcie@f8000000/pcie@0,0:reg: PCI reg address is not
configuration space
arch/arm64/boot/dts/rockchip/rk3399-gru.dtsi:464.3-52: Warning
(pci_device_reg): /pcie@f8000000/pcie@0,0:reg: PCI reg address is not
configuration space
arch/arm64/boot/dts/rockchip/rk3399-gru.dtsi:464.3-52: Warning
(pci_device_reg): /pcie@f8000000/pcie@0,0:reg: PCI reg address is not
configuration space
arch/arm64/kvm/hyp/nvhe/Makefile:58: FORCE prerequisite is missing
drivers/net/ethernet/mellanox/mlx5/core/en/rep/bridge.c:157:11: error:
variable 'err' is used uninitialized whenever 'if' condition is false
[-Werror,-Wsometimes-uninitialized]
else if (mlx5_esw_bridge_dev_same_hw(rep, esw))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/mellanox/mlx5/core/en/rep/bridge.c:164:9: note:
uninitialized use occurs here
return err;
^~~
drivers/net/ethernet/mellanox/mlx5/core/en/rep/bridge.c:157:7: note:
remove the 'if' if its condition is always true
else if (mlx5_esw_bridge_dev_same_hw(rep, esw))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/mellanox/mlx5/core/en/rep/bridge.c:140:9: note:
initialize the variable 'err' to silence this warning
int err;
^
= 0
drivers/net/ethernet/mellanox/mlx5/core/en/rep/bridge.c:262:7: error:
variable 'err' is used uninitialized whenever switch case is taken
[-Werror,-Wsometimes-uninitialized]
case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS:
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/mellanox/mlx5/core/en/rep/bridge.c:276:9: note:
uninitialized use occurs here
return err;
^~~
drivers/net/ethernet/mellanox/mlx5/core/en/rep/bridge.c:257:7: error:
variable 'err' is used uninitialized whenever 'if' condition is false
[-Werror,-Wsometimes-uninitialized]
if (attr->u.brport_flags.mask & ~(BR_LEARNING |
BR_FLOOD | BR_MCAST_FLOOD)) {

^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/mellanox/mlx5/core/en/rep/bridge.c:276:9: note:
uninitialized use occurs here
return err;
^~~
drivers/net/ethernet/mellanox/mlx5/core/en/rep/bridge.c:257:3: note:
remove the 'if' if its condition is always true
if (attr->u.brport_flags.mask & ~(BR_LEARNING |
BR_FLOOD | BR_MCAST_FLOOD)) {

^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/mellanox/mlx5/core/en/rep/bridge.c:247:9: note:
initialize the variable 'err' to silence this warning
int err;
^
= 0
3 errors generated.
make[6]: *** [scripts/Makefile.build:277:
drivers/net/ethernet/mellanox/mlx5/core/en/rep/bridge.o] Error 1
make[6]: Target '__build' not remade because of errors.
make[5]: *** [scripts/Makefile.build:540:
drivers/net/ethernet/mellanox/mlx5/core] Error 2
make[5]: Target '__build' not remade because of errors.
make[4]: *** [scripts/Makefile.build:540: drivers/net/ethernet/mellanox] Error 2
make[4]: Target '__build' not remade because of errors.
make[3]: *** [scripts/Makefile.build:540: drivers/net/ethernet] Error 2
make[3]: Target '__build' not remade because of errors.
make[2]: *** [scripts/Makefile.build:540: drivers/net] Error 2
make[2]: Target '__build' not remade because of errors.
make[1]: *** [Makefile:1872: drivers] Error 2
make[1]: Target '__all' not remade because of errors.
make: *** [Makefile:219: __sub-make] Error 2
make: Target '__all' not remade because of errors.

Build config:
https://builds.tuxbuild.com/1xjZrnXEZfc3qYzziclNRaugAaN/config

Reported-by: Linux Kernel Functional Testing <lkft@xxxxxxxxxx>

meta data:
-----------
git_describe: v5.14-9687-g27151f177827
git_repo: https://gitlab.com/Linaro/lkft/mirrors/torvalds/linux-mainline
git_sha: 27151f177827d478508e756c7657273261aaf8a9
git_short_log: 27151f177827 (\Merge tag
'perf-tools-for-v5.15-2021-09-04' of
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux\)
kconfig: [
defconfig
],
kernel_version: 5.14.0
status_message: failure while building tuxmake target(s): default
target_arch: arm64
toolchain: clang-nightly, clang-13, clang-12, clang-11 and clang-10

steps to reproduce:
https://builds.tuxbuild.com/1xjZrnXEZfc3qYzziclNRaugAaN/tuxmake_reproducer.sh

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