Re: [PATCH] Input: gpio_keys - initialize the 'irq' variable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Fabio,

On Sat, Dec 06, 2014 at 01:43:52PM -0200, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.estevam@xxxxxxxxxxxxx>
> 
> 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@xxxxxxxxx>
> Signed-off-by: Fabio Estevam <fabio.estevam@xxxxxxxxxxxxx>
> ---
>  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.

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux