Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Input: gpio_keys - fix warning regarding uninitialized 'button' variable

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>

authored by

Fabio Estevam and committed by
Dmitry Torokhov
1d6a0136 66aee900

+3 -2
+3 -2
drivers/input/keyboard/gpio_keys.c
··· 621 621 int gpio = -1; 622 622 enum of_gpio_flags flags; 623 623 624 + button = &pdata->buttons[i++]; 625 + 624 626 if (!of_find_property(pp, "gpios", NULL)) { 625 627 button->irq = irq_of_parse_and_map(pp, 0); 626 628 if (button->irq == 0) { 629 + i--; 627 630 pdata->nbuttons--; 628 631 dev_warn(dev, "Found button without gpios or irqs\n"); 629 632 continue; ··· 642 639 return ERR_PTR(error); 643 640 } 644 641 } 645 - 646 - button = &pdata->buttons[i++]; 647 642 648 643 button->gpio = gpio; 649 644 button->active_low = flags & OF_GPIO_ACTIVE_LOW;