diff mbox

Input: gpio_keys - initialize the 'irq' variable

Message ID 1417880632-13559-1-git-send-email-festevam@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Fabio Estevam Dec. 6, 2014, 3:43 p.m. UTC
From: Fabio Estevam <fabio.estevam@freescale.com>

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.

Reported-by: Olof's autobuilder <build@lixom.net>
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
 drivers/input/keyboard/gpio_keys.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Dmitry Torokhov Dec. 8, 2014, 6:48 a.m. UTC | #1
Hi Fabio,

On Sat, Dec 06, 2014 at 01:43:52PM -0200, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.estevam@freescale.com>
> 
> 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.
> 
> Reported-by: Olof's autobuilder <build@lixom.net>
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> ---
>  drivers/input/keyboard/gpio_keys.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
> index aa13055..70e89d1 100644
> --- a/drivers/input/keyboard/gpio_keys.c
> +++ b/drivers/input/keyboard/gpio_keys.c
> @@ -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.
diff mbox

Patch

diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index aa13055..70e89d1 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -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)) {