Skip to contentSkip to conversation

rtc: armada38x: hide maybe-uninitialized warning

PATCH In review Arnd Bergmann 2 participants 2 messages Jan 11, 2017 – Jan 12, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rtc: armada38x: hide maybe-uninitialized warning

The function is too complicated for gcc to realize that this variable does eventually get initialized, causing a harmless warning:

drivers/rtc/rtc-armada38x.c: In function 'read_rtc_register_wa':
drivers/rtc/rtc-armada38x.c:131:25: warning: 'index_max' may be used uninitialized in this function [-Wmaybe-uninitialized]

This adds an explicit initializion at the start of the function. I generally try to avoid that, but it seems appropriate here, as we start out with max=0 as well.

Fixes 61cffa2438e3 ("rtc: armada38x: Follow the new recommendation for errata implementation")
---
 drivers/rtc/rtc-armada38x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-armada38x.c +1 -1
index 6c9a2cbdc1a9..65e16965af7e 100644
@@ -90,7 +90,7 @@ static void rtc_update_mbus_timing_params(struct armada38x_rtc *rtc)
 
 static u32 read_rtc_register_wa(struct armada38x_rtc *rtc, u8 rtc_reg)
 {
-	int i, index_max, max = 0;
+	int i, index_max = 0, max = 0;
 
 	for (i = 0; i < SAMPLE_NR; i++) {
 		rtc->val_to_freq[i].value = readl(rtc->regs + rtc_reg);
Signature · 1 line
2.9.0
#1 lore raw

Hi Arnd,

Quoted 6 lines · Arnd Bergmann

The function is too complicated for gcc to realize that this variable does eventually get initialized, causing a harmless warning:

drivers/rtc/rtc-armada38x.c: In function 'read_rtc_register_wa':
drivers/rtc/rtc-armada38x.c:131:25: warning: 'index_max' may be used uninitialized in this function [-Wmaybe-uninitialized]

Quoted 6 lines

This adds an explicit initializion at the start of the function. I generally try to avoid that, but it seems appropriate here, as we start out with max=0 as well.

Fixes 61cffa2438e3 ("rtc: armada38x: Follow the new recommendation for errata implementation")

Actually, I fixed that one directly in the commit yesterday as it has been reported to me multiple times already.

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