Skip to contentSkip to conversation

rtc: pfc8563: fix uninitialized variable warning

PATCH In review Arnd Bergmann 2 participants 2 messages May 12, 2015 – May 14, 2015 Real time clock (RTC)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rtc: pfc8563: fix uninitialized variable warning

Gcc is unable to prove that alm_pending is always initialized when it is used, so it prints a harmless warning:

drivers/rtc/rtc-pcf8563.c: In function 'pcf8563_probe':
drivers/rtc/rtc-pcf8563.c:449:5: warning: 'alm_pending' may be used uninitialized in this function [-Wmaybe-uninitialized]

This uses the same conditional expression that is used inside of the pcf8563_get_alarm_mode() function, to help gcc figure it out and shut up that warning, and make the ARM defconfigs build again with no warnings.

Fixes a45d528aab8b ("rtc: pcf8563: clear expired alarm at boot time")
drivers/rtc/rtc-pcf8563.c +1 -1
index 0ba7e59929be..8e52c029cf1a 100644
@@ -437,7 +437,7 @@ static int pcf8563_probe(struct i2c_client *client,
 	}
 
 	err = pcf8563_get_alarm_mode(client, NULL, &alm_pending);
-	if (err < 0) {
+	if (err) {
 		dev_err(&client->dev, "%s: read error\n", __func__);
 		return err;
 	}
Acked-by on v1 1/1
#1 lore raw

Hi Andrew,

Quoted 6 lines · Arnd Bergmann

Gcc is unable to prove that alm_pending is always initialized when it is used, so it prints a harmless warning:

drivers/rtc/rtc-pcf8563.c: In function 'pcf8563_probe':
drivers/rtc/rtc-pcf8563.c:449:5: warning: 'alm_pending' may be used uninitialized in this function [-Wmaybe-uninitialized]

Quoted 8 lines

This uses the same conditional expression that is used inside of the pcf8563_get_alarm_mode() function, to help gcc figure it out and shut up that warning, and make the ARM defconfigs build again with no warnings.

Fixes a45d528aab8b ("rtc: pcf8563: clear expired alarm at boot time")

Can you send that fix to Linus for the next 4.1 rc?

You can add my

I hope that will be the last one :)

Thanks!

Signature · 3 lines
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com