linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pinctrl: amd: avoid maybe-uninitalized warning
@ 2017-01-11 14:36 Arnd Bergmann
  2017-01-12  7:49 ` Linus Walleij
  0 siblings, 1 reply; 3+ messages in thread
From: Arnd Bergmann @ 2017-01-11 14:36 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Arnd Bergmann, Agrawal, Nitesh-kumar, Pankaj Sen, Shah,
	Nehal-bakulchandra, Shyam-sundar S-k, linux-gpio, linux-kernel

Since gpio_dev->hwbank_num is now a variable, the compiler cannot
figure out if pin_num is initialized at all:

drivers/pinctrl/pinctrl-amd.c: In function 'amd_gpio_dbg_show':
drivers/pinctrl/pinctrl-amd.c:210:3: warning: 'pin_num' may be used uninitialized in this function [-Wmaybe-uninitialized]
   for (; i < pin_num; i++) {
   ^~~
drivers/pinctrl/pinctrl-amd.c:172:21: warning: 'i' may be used uninitialized in this function [-Wmaybe-uninitialized]

This adds a 'default' statement to make that case well-defined.

Fixes: 3bfd44306c65 ("pinctrl: amd: Add support for additional GPIO")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/pinctrl/pinctrl-amd.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/pinctrl/pinctrl-amd.c b/drivers/pinctrl/pinctrl-amd.c
index 7b95c1886f7b..9495e6eb76d1 100644
--- a/drivers/pinctrl/pinctrl-amd.c
+++ b/drivers/pinctrl/pinctrl-amd.c
@@ -206,6 +206,8 @@ static void amd_gpio_dbg_show(struct seq_file *s, struct gpio_chip *gc)
 			i = 192;
 			pin_num = AMD_GPIO_PINS_BANK3 + i;
 			break;
+		default:
+			return;
 		}
 		for (; i < pin_num; i++) {
 			seq_printf(s, "pin%d\t", i);
-- 
2.9.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] pinctrl: amd: avoid maybe-uninitalized warning
  2017-01-11 14:36 [PATCH] pinctrl: amd: avoid maybe-uninitalized warning Arnd Bergmann
@ 2017-01-12  7:49 ` Linus Walleij
  2017-01-12  8:15   ` Shyam Sundar S K
  0 siblings, 1 reply; 3+ messages in thread
From: Linus Walleij @ 2017-01-12  7:49 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Agrawal, Nitesh-kumar, Pankaj Sen, Shah, Nehal-bakulchandra,
	Shyam-sundar S-k, linux-gpio, linux-kernel

On Wed, Jan 11, 2017 at 3:36 PM, Arnd Bergmann <arnd@arndb.de> wrote:

> Since gpio_dev->hwbank_num is now a variable, the compiler cannot
> figure out if pin_num is initialized at all:
>
> drivers/pinctrl/pinctrl-amd.c: In function 'amd_gpio_dbg_show':
> drivers/pinctrl/pinctrl-amd.c:210:3: warning: 'pin_num' may be used uninitialized in this function [-Wmaybe-uninitialized]
>    for (; i < pin_num; i++) {
>    ^~~
> drivers/pinctrl/pinctrl-amd.c:172:21: warning: 'i' may be used uninitialized in this function [-Wmaybe-uninitialized]
>
> This adds a 'default' statement to make that case well-defined.
>
> Fixes: 3bfd44306c65 ("pinctrl: amd: Add support for additional GPIO")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Patch applied.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] pinctrl: amd: avoid maybe-uninitalized warning
  2017-01-12  7:49 ` Linus Walleij
@ 2017-01-12  8:15   ` Shyam Sundar S K
  0 siblings, 0 replies; 3+ messages in thread
From: Shyam Sundar S K @ 2017-01-12  8:15 UTC (permalink / raw)
  To: Linus Walleij, Arnd Bergmann
  Cc: Agrawal, Nitesh-kumar, Pankaj Sen, Shah, Nehal-bakulchandra,
	Shyam-sundar S-k, linux-gpio, linux-kernel

Hi Linus,

You have already added patch for the same "[PATCH] pinctrl: amd: fix compilation warning" and applied to one of your fixed branch.

Do you feel this patch needs to be taken ?

Thanks,
Shyam

On 1/12/2017 1:19 PM, Linus Walleij wrote:
> On Wed, Jan 11, 2017 at 3:36 PM, Arnd Bergmann <arnd@arndb.de> wrote:
> 
>> Since gpio_dev->hwbank_num is now a variable, the compiler cannot
>> figure out if pin_num is initialized at all:
>>
>> drivers/pinctrl/pinctrl-amd.c: In function 'amd_gpio_dbg_show':
>> drivers/pinctrl/pinctrl-amd.c:210:3: warning: 'pin_num' may be used uninitialized in this function [-Wmaybe-uninitialized]
>>    for (; i < pin_num; i++) {
>>    ^~~
>> drivers/pinctrl/pinctrl-amd.c:172:21: warning: 'i' may be used uninitialized in this function [-Wmaybe-uninitialized]
>>
>> This adds a 'default' statement to make that case well-defined.
>>
>> Fixes: 3bfd44306c65 ("pinctrl: amd: Add support for additional GPIO")
>> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> 
> Patch applied.
> 
> Yours,
> Linus Walleij
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-01-12  8:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-11 14:36 [PATCH] pinctrl: amd: avoid maybe-uninitalized warning Arnd Bergmann
2017-01-12  7:49 ` Linus Walleij
2017-01-12  8:15   ` Shyam Sundar S K

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).