Skip to contentSkip to conversation

pinctrl: amd: avoid maybe-uninitalized warning

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

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

PATCH 1/1 pinctrl: amd: avoid maybe-uninitalized warning

Since gpio_dev->hwbank_num is now a variable, the compiler cannot figure out if pin_num is initialized at all:

drivers/pinctrl/pinctrl-amd.c: In function 'amd_gpio_dbg_show':
drivers/pinctrl/pinctrl-amd.c:210:3: warning: 'pin_num' may be used uninitialized in this function [-Wmaybe-uninitialized]
for (; i < pin_num; i++) {
^~~
drivers/pinctrl/pinctrl-amd.c:172:21: warning: 'i' may be used uninitialized in this function [-Wmaybe-uninitialized]

This adds a 'default' statement to make that case well-defined.

Fixes 3bfd44306c65 ("pinctrl: amd: Add support for additional GPIO")
---
 drivers/pinctrl/pinctrl-amd.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/pinctrl/pinctrl-amd.c +2 -0
index 7b95c1886f7b..9495e6eb76d1 100644
@@ -206,6 +206,8 @@ static void amd_gpio_dbg_show(struct seq_file *s, struct gpio_chip *gc)
 			i = 192;
 			pin_num = AMD_GPIO_PINS_BANK3 + i;
 			break;
+		default:
+			return;
 		}
 		for (; i < pin_num; i++) {
 			seq_printf(s, "pin%d\t", i);
Signature · 1 line
2.9.0
#1 lore raw
Quoted 5 lines · Arnd Bergmann

Since gpio_dev->hwbank_num is now a variable, the compiler cannot figure out if pin_num is initialized at all:

drivers/pinctrl/pinctrl-amd.c: In function 'amd_gpio_dbg_show':
drivers/pinctrl/pinctrl-amd.c:210:3: warning: 'pin_num' may be used uninitialized in this function [-Wmaybe-uninitialized]

Quoted 8 lines
   for (; i < pin_num; i++) {
   ^~~

drivers/pinctrl/pinctrl-amd.c:172:21: warning: 'i' may be used uninitialized in this function [-Wmaybe-uninitialized]

This adds a 'default' statement to make that case well-defined.

Fixes 3bfd44306c65 ("pinctrl: amd: Add support for additional GPIO")

Patch applied.

Yours,
Linus Walleij

#2 lore raw

Hi Linus,

You have already added patch for the same "[PATCH] pinctrl: amd: fix compilation warning" and applied to one of your fixed branch.

Do you feel this patch needs to be taken ?

Thanks,
Shyam

Quoted 21 lines · Linus Walleij
Quoted 5 lines · Arnd Bergmann

Since gpio_dev->hwbank_num is now a variable, the compiler cannot figure out if pin_num is initialized at all:

drivers/pinctrl/pinctrl-amd.c: In function 'amd_gpio_dbg_show':
drivers/pinctrl/pinctrl-amd.c:210:3: warning: 'pin_num' may be used uninitialized in this function [-Wmaybe-uninitialized]

Quoted 8 lines
   for (; i < pin_num; i++) {
   ^~~

drivers/pinctrl/pinctrl-amd.c:172:21: warning: 'i' may be used uninitialized in this function [-Wmaybe-uninitialized]

This adds a 'default' statement to make that case well-defined.

Fixes 3bfd44306c65 ("pinctrl: amd: Add support for additional GPIO")

Patch applied.

Yours,
Linus Walleij