mirror of
https://github.com/LineageOS/android_kernel_fxtec_sm6115.git
synced 2026-04-02 19:13:21 +00:00
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>
Signed-off-by: Ulrich Hecht <uli@kernel.org>
This commit is contained in:
committed by
Ulrich Hecht
parent
bec75701d7
commit
e9b1a59dfe
@ -345,7 +345,7 @@ int madera_dev_init(struct madera *madera)
|
||||
struct device *dev = madera->dev;
|
||||
unsigned int hwid;
|
||||
int (*patch_fn)(struct madera *) = NULL;
|
||||
const struct mfd_cell *mfd_devs;
|
||||
const struct mfd_cell *mfd_devs = NULL;
|
||||
int n_devs = 0;
|
||||
int i, ret;
|
||||
|
||||
@ -496,7 +496,7 @@ int madera_dev_init(struct madera *madera)
|
||||
goto err_reset;
|
||||
}
|
||||
|
||||
if (!n_devs) {
|
||||
if (!n_devs || !mfd_devs) {
|
||||
dev_err(madera->dev, "Device ID 0x%x not a %s\n", hwid,
|
||||
madera->type_name);
|
||||
ret = -ENODEV;
|
||||
|
||||
Reference in New Issue
Block a user