* [PATCH] Input: gpio_keys - initialize the 'irq' variable
@ 2014-12-06 15:43 Fabio Estevam
2014-12-08 6:48 ` Dmitry Torokhov
0 siblings, 1 reply; 2+ messages in thread
From: Fabio Estevam @ 2014-12-06 15:43 UTC (permalink / raw)
To: dmitry.torokhov; +Cc: alexander.stein, linux-input, Fabio Estevam
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;
enum of_gpio_flags flags;
if (!of_find_property(pp, "gpios", NULL)) {
--
1.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Input: gpio_keys - initialize the 'irq' variable
2014-12-06 15:43 [PATCH] Input: gpio_keys - initialize the 'irq' variable Fabio Estevam
@ 2014-12-08 6:48 ` Dmitry Torokhov
0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2014-12-08 6:48 UTC (permalink / raw)
To: Fabio Estevam; +Cc: alexander.stein, linux-input, Fabio Estevam
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.
--
Dmitry
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-12-08 6:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-06 15:43 [PATCH] Input: gpio_keys - initialize the 'irq' variable Fabio Estevam
2014-12-08 6:48 ` Dmitry Torokhov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).