[PATCH 2/2] power: power_i2c: ret is uninitialised if not DM_I2C

Quentin Schulz quentin.schulz at cherry.de
Mon Aug 11 17:12:47 CEST 2025


Hi Andrew,

On 8/7/25 4:28 PM, Andrew Goodbody wrote:
> In pmic_reg_read ret is only assigned to inside #if
> CONFIG_IS_ENABLED(DM_I2C) so move the test and return ret inside as well
> and also guard the declaration of ret with CONFIG_IS_ENABLED(DM_I2C) to
> prevent a warning about an unused variable.
> 
> This issue was found by Smatch.
> 
> Signed-off-by: Andrew Goodbody <andrew.goodbody at linaro.org>
> ---
>   drivers/power/power_i2c.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/power/power_i2c.c b/drivers/power/power_i2c.c
> index c2fc1c6b42f..58289ecce67 100644
> --- a/drivers/power/power_i2c.c
> +++ b/drivers/power/power_i2c.c
> @@ -75,7 +75,7 @@ int pmic_reg_read(struct pmic *p, u32 reg, u32 *val)
>   {
>   	unsigned char buf[4] = { 0 };
>   	u32 ret_val = 0;
> -	int ret;
> +	int __maybe_unused ret;

Or move the declaration with the struct udevice *dev; afetr the #if 
CONFIG_IS_ENABLED(DM_I2C)?

Reviewed-by: Quentin Schulz <quentin.schulz at cherry.de>

in any case.

Thanks!
Quentin


More information about the U-Boot mailing list