Skip to contentSkip to conversation

Input: gpio_keys - initialize the 'irq' variable

PATCH Superseded Fabio Estevam 2 participants 2 messages Dec 6, 2014 – Dec 8, 2014

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Input: gpio_keys - initialize the 'irq' variable

From: Fabio Estevam <[email protected]>

Commit f2d347ff70be453e ("Input: gpio_keys - add device tree support for interrupt only keys") caused the following build warning:

drivers/input/keyboard/gpio_keys.c: In function 'gpio_keys_probe':
drivers/input/keyboard/gpio_keys.c:647:15: warning: 'irq' may be used uninitialized in this function [-Wmaybe-uninitialized] drivers/input/keyboard/gpio_keys.c:622:7: note: 'irq' was declared here

Initialize 'irq' with a default value to fix it.

---
 drivers/input/keyboard/gpio_keys.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/keyboard/gpio_keys.c +1 -1
index aa13055..70e89d1 100644
@@ -619,7 +619,7 @@ gpio_keys_get_devtree_pdata(struct device *dev)
 	i = 0;
 	for_each_child_of_node(node, pp) {
 		int gpio = -1;
-		int irq;
+		int irq = -EINVAL;
 		enum of_gpio_flags flags;
 
 		if (!of_find_property(pp, "gpios", NULL)) {
Signature · 1 line
1.9.1
maintainer
#1 lore raw

Hi Fabio,

Quoted 22 lines · Fabio Estevam

From: Fabio Estevam <[email protected]>

Commit f2d347ff70be453e ("Input: gpio_keys - add device tree support for interrupt only keys") caused the following build warning:

drivers/input/keyboard/gpio_keys.c: In function 'gpio_keys_probe':
drivers/input/keyboard/gpio_keys.c:647:15: warning: 'irq' may be used uninitialized in this function [-Wmaybe-uninitialized] drivers/input/keyboard/gpio_keys.c:622:7: note: 'irq' was declared here

Initialize 'irq' with a default value to fix it.

---
 drivers/input/keyboard/gpio_keys.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/keyboard/gpio_keys.c +0 -0
index aa13055..70e89d1 100644

drivers/input/keyboard/gpio_keys.c gpio_keys_get_devtree_pdata(struct device *dev) · line 622

Quoted 5 lines
drivers/input/keyboard/gpio_keys.c +1 -1
@@ -619,7 +619,7 @@ gpio_keys_get_devtree_pdata(struct device *dev)
 	i = 0;
 	for_each_child_of_node(node, pp) {
 		int gpio = -1;
-		int irq;
+		int irq = -EINVAL;

No, this is not good as we'll end up with button->irq, which is unsigned int, having nonsense value.

I'd rather move assignment into the proper branch.

Thanks.

Signature · 1 line
Dmitry