Input: gpio_keys - fix warning regarding uninitialized 'button' variable
authorFabio Estevam <fabio.estevam@freescale.com>
Sat, 13 Dec 2014 19:02:08 +0000 (11:02 -0800)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Sun, 14 Dec 2014 19:51:36 +0000 (11:51 -0800)
Commit af906faabcf91eb1 ("Input: gpio_keys - fix warning regarding uninitialized
'irq' variable") introduced the following build warning:

drivers/input/keyboard/gpio_keys.c:625:16: warning: 'button' may be used uninitialized in this function [-Wmaybe-uninitialized]

Move the 'button' initialization to a proper location to avoid such warning.

Reported-by: Olof's autobuilder <build@lixom.net>
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/keyboard/gpio_keys.c

index b8b4876ac8d3151211984264e599f73b46e5c63c..f44f05b70ee0172603304c22f76f713ae82fdc5c 100644 (file)
@@ -621,9 +621,12 @@ gpio_keys_get_devtree_pdata(struct device *dev)
                int gpio = -1;
                enum of_gpio_flags flags;
 
+               button = &pdata->buttons[i++];
+
                if (!of_find_property(pp, "gpios", NULL)) {
                        button->irq = irq_of_parse_and_map(pp, 0);
                        if (button->irq == 0) {
+                               i--;
                                pdata->nbuttons--;
                                dev_warn(dev, "Found button without gpios or irqs\n");
                                continue;
@@ -640,8 +643,6 @@ gpio_keys_get_devtree_pdata(struct device *dev)
                        }
                }
 
-               button = &pdata->buttons[i++];
-
                button->gpio = gpio;
                button->active_low = flags & OF_GPIO_ACTIVE_LOW;