]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
mfd: madera: Work around false-positive -Wininitialized warning
authorArnd Bergmann <arnd@arndb.de>
Thu, 7 Aug 2025 07:19:28 +0000 (09:19 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 3 Dec 2025 11:45:08 +0000 (12:45 +0100)
commite29ee40c2e6ea43e8818deb52ba04ce96989d555
treee8d6bf8a038ab1c57db03c93a8002499ac679c7e
parent1237d51acb42d5773d30a9afda26e5f6abdcbbbe
mfd: madera: Work around false-positive -Wininitialized warning

[ Upstream commit 364752aa0c6ab0a06a2d5bfdb362c1ca407f1a30 ]

clang-21 warns about one uninitialized variable getting dereferenced
in madera_dev_init:

drivers/mfd/madera-core.c:739:10: error: variable 'mfd_devs' is uninitialized when used here [-Werror,-Wuninitialized]
  739 |                               mfd_devs, n_devs,
      |                               ^~~~~~~~
drivers/mfd/madera-core.c:459:33: note: initialize the variable 'mfd_devs' to silence this warning
  459 |         const struct mfd_cell *mfd_devs;
      |                                        ^
      |                                         = NULL

The code is actually correct here because n_devs is only nonzero
when mfd_devs is a valid pointer, but this is impossible for the
compiler to see reliably.

Change the logic to check for the pointer as well, to make this easier
for the compiler to follow.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20250807071932.4085458-1-arnd@kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/mfd/madera-core.c