linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] watchdog: pcwd_pci: mark expected switch fall-through
@ 2017-11-03 14:49 Gustavo A. R. Silva
  2017-11-03 15:04 ` Wim Van Sebroeck
  0 siblings, 1 reply; 9+ messages in thread
From: Gustavo A. R. Silva @ 2017-11-03 14:49 UTC (permalink / raw)
  To: Wim Van Sebroeck, Guenter Roeck
  Cc: linux-watchdog, linux-kernel, Gustavo A. R. Silva

In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.

Notice that in this particular case I replaced "Fall" with a proper
"fall through" comment, which is what GCC is expecting to find.

Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
---
 drivers/watchdog/pcwd_pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/watchdog/pcwd_pci.c b/drivers/watchdog/pcwd_pci.c
index c0d07ee..c882252 100644
--- a/drivers/watchdog/pcwd_pci.c
+++ b/drivers/watchdog/pcwd_pci.c
@@ -545,7 +545,7 @@ static long pcipcwd_ioctl(struct file *file, unsigned int cmd,
 			return -EINVAL;
 
 		pcipcwd_keepalive();
-		/* Fall */
+		/* fall through */
 	}
 
 	case WDIOC_GETTIMEOUT:
-- 
2.7.4

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

* Re: [PATCH] watchdog: pcwd_pci: mark expected switch fall-through
  2017-11-03 14:49 [PATCH] watchdog: pcwd_pci: mark expected switch fall-through Gustavo A. R. Silva
@ 2017-11-03 15:04 ` Wim Van Sebroeck
  2017-11-03 15:47   ` Gustavo A. R. Silva
  2017-11-03 15:54   ` [PATCH] " Guenter Roeck
  0 siblings, 2 replies; 9+ messages in thread
From: Wim Van Sebroeck @ 2017-11-03 15:04 UTC (permalink / raw)
  To: Gustavo A. R. Silva; +Cc: Guenter Roeck, linux-watchdog, linux-kernel

Hi Gustavo,

> In preparation to enabling -Wimplicit-fallthrough, mark switch cases
> where we are expecting to fall through.
> 
> Notice that in this particular case I replaced "Fall" with a proper
> "fall through" comment, which is what GCC is expecting to find.
> 
> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
> ---
>  drivers/watchdog/pcwd_pci.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/watchdog/pcwd_pci.c b/drivers/watchdog/pcwd_pci.c
> index c0d07ee..c882252 100644
> --- a/drivers/watchdog/pcwd_pci.c
> +++ b/drivers/watchdog/pcwd_pci.c
> @@ -545,7 +545,7 @@ static long pcipcwd_ioctl(struct file *file, unsigned int cmd,
>  			return -EINVAL;
>  
>  		pcipcwd_keepalive();
> -		/* Fall */
> +		/* fall through */
>  	}
>  
>  	case WDIOC_GETTIMEOUT:
> -- 
> 2.7.4
> 

Shouldn't the /* fall through */ come after the } ?

Kind regards,
Wim.

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

* Re: [PATCH] watchdog: pcwd_pci: mark expected switch fall-through
  2017-11-03 15:04 ` Wim Van Sebroeck
@ 2017-11-03 15:47   ` Gustavo A. R. Silva
  2017-11-03 16:02     ` [PATCH v2] " Gustavo A. R. Silva
  2017-11-03 15:54   ` [PATCH] " Guenter Roeck
  1 sibling, 1 reply; 9+ messages in thread
From: Gustavo A. R. Silva @ 2017-11-03 15:47 UTC (permalink / raw)
  To: Wim Van Sebroeck; +Cc: Guenter Roeck, linux-watchdog, linux-kernel

Hi Wim,

Quoting Wim Van Sebroeck <wim@iguana.be>:

> Hi Gustavo,
>
>> In preparation to enabling -Wimplicit-fallthrough, mark switch cases
>> where we are expecting to fall through.
>>
>> Notice that in this particular case I replaced "Fall" with a proper
>> "fall through" comment, which is what GCC is expecting to find.
>>
>> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
>> ---
>>  drivers/watchdog/pcwd_pci.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/watchdog/pcwd_pci.c b/drivers/watchdog/pcwd_pci.c
>> index c0d07ee..c882252 100644
>> --- a/drivers/watchdog/pcwd_pci.c
>> +++ b/drivers/watchdog/pcwd_pci.c
>> @@ -545,7 +545,7 @@ static long pcipcwd_ioctl(struct file *file,  
>> unsigned int cmd,
>>  			return -EINVAL;
>>
>>  		pcipcwd_keepalive();
>> -		/* Fall */
>> +		/* fall through */
>>  	}
>>
>>  	case WDIOC_GETTIMEOUT:
>> --
>> 2.7.4
>>
>
> Shouldn't the /* fall through */ come after the } ?
>

Yep, you are right.

I'll fix that.

Thank you!
--
Gustavo A. R. Silva

> Kind regards,
> Wim.

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

* Re: [PATCH] watchdog: pcwd_pci: mark expected switch fall-through
  2017-11-03 15:04 ` Wim Van Sebroeck
  2017-11-03 15:47   ` Gustavo A. R. Silva
@ 2017-11-03 15:54   ` Guenter Roeck
  2017-11-03 15:57     ` Gustavo A. R. Silva
  2017-11-03 16:02     ` Joe Perches
  1 sibling, 2 replies; 9+ messages in thread
From: Guenter Roeck @ 2017-11-03 15:54 UTC (permalink / raw)
  To: Wim Van Sebroeck; +Cc: Gustavo A. R. Silva, linux-watchdog, linux-kernel

On Fri, Nov 03, 2017 at 04:04:23PM +0100, Wim Van Sebroeck wrote:
> Hi Gustavo,
> 
> > In preparation to enabling -Wimplicit-fallthrough, mark switch cases
> > where we are expecting to fall through.
> > 
> > Notice that in this particular case I replaced "Fall" with a proper
> > "fall through" comment, which is what GCC is expecting to find.
> > 
> > Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
> > ---
> >  drivers/watchdog/pcwd_pci.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/watchdog/pcwd_pci.c b/drivers/watchdog/pcwd_pci.c
> > index c0d07ee..c882252 100644
> > --- a/drivers/watchdog/pcwd_pci.c
> > +++ b/drivers/watchdog/pcwd_pci.c
> > @@ -545,7 +545,7 @@ static long pcipcwd_ioctl(struct file *file, unsigned int cmd,
> >  			return -EINVAL;
> >  
> >  		pcipcwd_keepalive();
> > -		/* Fall */
> > +		/* fall through */
> >  	}
> >  
> >  	case WDIOC_GETTIMEOUT:
> > -- 
> > 2.7.4
> > 
> 
> Shouldn't the /* fall through */ come after the } ?
> 
Good question. This is an unconditional code block needed to declare
a local variable within the case statement. What is correct in that
situation ?

Guenter

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

* Re: [PATCH] watchdog: pcwd_pci: mark expected switch fall-through
  2017-11-03 15:54   ` [PATCH] " Guenter Roeck
@ 2017-11-03 15:57     ` Gustavo A. R. Silva
  2017-11-03 16:02     ` Joe Perches
  1 sibling, 0 replies; 9+ messages in thread
From: Gustavo A. R. Silva @ 2017-11-03 15:57 UTC (permalink / raw)
  To: Guenter Roeck; +Cc: Wim Van Sebroeck, linux-watchdog, linux-kernel


Quoting Guenter Roeck <linux@roeck-us.net>:

> On Fri, Nov 03, 2017 at 04:04:23PM +0100, Wim Van Sebroeck wrote:
>> Hi Gustavo,
>>
>> > In preparation to enabling -Wimplicit-fallthrough, mark switch cases
>> > where we are expecting to fall through.
>> >
>> > Notice that in this particular case I replaced "Fall" with a proper
>> > "fall through" comment, which is what GCC is expecting to find.
>> >
>> > Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
>> > ---
>> >  drivers/watchdog/pcwd_pci.c | 2 +-
>> >  1 file changed, 1 insertion(+), 1 deletion(-)
>> >
>> > diff --git a/drivers/watchdog/pcwd_pci.c b/drivers/watchdog/pcwd_pci.c
>> > index c0d07ee..c882252 100644
>> > --- a/drivers/watchdog/pcwd_pci.c
>> > +++ b/drivers/watchdog/pcwd_pci.c
>> > @@ -545,7 +545,7 @@ static long pcipcwd_ioctl(struct file *file,  
>> unsigned int cmd,
>> >  			return -EINVAL;
>> >
>> >  		pcipcwd_keepalive();
>> > -		/* Fall */
>> > +		/* fall through */
>> >  	}
>> >
>> >  	case WDIOC_GETTIMEOUT:
>> > --
>> > 2.7.4
>> >
>>
>> Shouldn't the /* fall through */ come after the } ?
>>
> Good question. This is an unconditional code block needed to declare
> a local variable within the case statement. What is correct in that
> situation ?
>

I think it is correct to place the comment outside the code block.

I'll send a patch shortly.

Thanks
--
Gustavo A. R. Silva

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

* [PATCH v2] watchdog: pcwd_pci: mark expected switch fall-through
  2017-11-03 15:47   ` Gustavo A. R. Silva
@ 2017-11-03 16:02     ` Gustavo A. R. Silva
  2017-11-05 15:11       ` [v2] " Guenter Roeck
  0 siblings, 1 reply; 9+ messages in thread
From: Gustavo A. R. Silva @ 2017-11-03 16:02 UTC (permalink / raw)
  To: Wim Van Sebroeck, Guenter Roeck
  Cc: linux-watchdog, linux-kernel, Gustavo A. R. Silva

In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.

Notice that in this particular case I replaced "Fall" with a proper
"fall through" comment, which is what GCC is expecting to find.

Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
---
Changes in v2:
 Place the "fall through" comment outside the unconditional code block.

 drivers/watchdog/pcwd_pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/watchdog/pcwd_pci.c b/drivers/watchdog/pcwd_pci.c
index c0d07ee..1f78f09 100644
--- a/drivers/watchdog/pcwd_pci.c
+++ b/drivers/watchdog/pcwd_pci.c
@@ -545,8 +545,8 @@ static long pcipcwd_ioctl(struct file *file, unsigned int cmd,
 			return -EINVAL;
 
 		pcipcwd_keepalive();
-		/* Fall */
 	}
+		/* fall through */
 
 	case WDIOC_GETTIMEOUT:
 		return put_user(heartbeat, p);
-- 
2.7.4

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

* Re: [PATCH] watchdog: pcwd_pci: mark expected switch fall-through
  2017-11-03 15:54   ` [PATCH] " Guenter Roeck
  2017-11-03 15:57     ` Gustavo A. R. Silva
@ 2017-11-03 16:02     ` Joe Perches
  2017-11-03 16:15       ` Guenter Roeck
  1 sibling, 1 reply; 9+ messages in thread
From: Joe Perches @ 2017-11-03 16:02 UTC (permalink / raw)
  To: Guenter Roeck, Wim Van Sebroeck
  Cc: Gustavo A. R. Silva, linux-watchdog, linux-kernel

On Fri, 2017-11-03 at 08:54 -0700, Guenter Roeck wrote:
> On Fri, Nov 03, 2017 at 04:04:23PM +0100, Wim Van Sebroeck wrote:
> > Hi Gustavo,
> > 
> > > In preparation to enabling -Wimplicit-fallthrough, mark switch cases
> > > where we are expecting to fall through.
> > > 
> > > Notice that in this particular case I replaced "Fall" with a proper
> > > "fall through" comment, which is what GCC is expecting to find.
> > > 
> > > Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
> > > ---
> > >  drivers/watchdog/pcwd_pci.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/watchdog/pcwd_pci.c b/drivers/watchdog/pcwd_pci.c
> > > index c0d07ee..c882252 100644
> > > --- a/drivers/watchdog/pcwd_pci.c
> > > +++ b/drivers/watchdog/pcwd_pci.c
> > > @@ -545,7 +545,7 @@ static long pcipcwd_ioctl(struct file *file, unsigned int cmd,
> > >  			return -EINVAL;
> > >  
> > >  		pcipcwd_keepalive();
> > > -		/* Fall */
> > > +		/* fall through */
> > >  	}
> > >  
> > >  	case WDIOC_GETTIMEOUT:
> > > -- 
> > > 2.7.4
> > > 
> > 
> > Shouldn't the /* fall through */ come after the } ?
> > 
> 
> Good question. This is an unconditional code block needed to declare
> a local variable within the case statement. What is correct in that
> situation ?

I think it'd be clearer to avoid the trivial fallthrough
optimization/complexity and just directly use

		return put_user(new_heartbeat, p);

as heartbeat and new_heartbeat are now the same value here.

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

* Re: [PATCH] watchdog: pcwd_pci: mark expected switch fall-through
  2017-11-03 16:02     ` Joe Perches
@ 2017-11-03 16:15       ` Guenter Roeck
  0 siblings, 0 replies; 9+ messages in thread
From: Guenter Roeck @ 2017-11-03 16:15 UTC (permalink / raw)
  To: Joe Perches
  Cc: Wim Van Sebroeck, Gustavo A. R. Silva, linux-watchdog, linux-kernel

On Fri, Nov 03, 2017 at 09:02:33AM -0700, Joe Perches wrote:
> On Fri, 2017-11-03 at 08:54 -0700, Guenter Roeck wrote:
> > On Fri, Nov 03, 2017 at 04:04:23PM +0100, Wim Van Sebroeck wrote:
> > > Hi Gustavo,
> > > 
> > > > In preparation to enabling -Wimplicit-fallthrough, mark switch cases
> > > > where we are expecting to fall through.
> > > > 
> > > > Notice that in this particular case I replaced "Fall" with a proper
> > > > "fall through" comment, which is what GCC is expecting to find.
> > > > 
> > > > Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
> > > > ---
> > > >  drivers/watchdog/pcwd_pci.c | 2 +-
> > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > > 
> > > > diff --git a/drivers/watchdog/pcwd_pci.c b/drivers/watchdog/pcwd_pci.c
> > > > index c0d07ee..c882252 100644
> > > > --- a/drivers/watchdog/pcwd_pci.c
> > > > +++ b/drivers/watchdog/pcwd_pci.c
> > > > @@ -545,7 +545,7 @@ static long pcipcwd_ioctl(struct file *file, unsigned int cmd,
> > > >  			return -EINVAL;
> > > >  
> > > >  		pcipcwd_keepalive();
> > > > -		/* Fall */
> > > > +		/* fall through */
> > > >  	}
> > > >  
> > > >  	case WDIOC_GETTIMEOUT:
> > > > -- 
> > > > 2.7.4
> > > > 
> > > 
> > > Shouldn't the /* fall through */ come after the } ?
> > > 
> > 
> > Good question. This is an unconditional code block needed to declare
> > a local variable within the case statement. What is correct in that
> > situation ?
> 
> I think it'd be clearer to avoid the trivial fallthrough
> optimization/complexity and just directly use
> 
> 		return put_user(new_heartbeat, p);
> 
> as heartbeat and new_heartbeat are now the same value here.
> 
I don't think it really matters. What would matter would be for someone
to convert he driver to use the watchdog subsystem.

Guenter

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

* Re: [v2] watchdog: pcwd_pci: mark expected switch fall-through
  2017-11-03 16:02     ` [PATCH v2] " Gustavo A. R. Silva
@ 2017-11-05 15:11       ` Guenter Roeck
  0 siblings, 0 replies; 9+ messages in thread
From: Guenter Roeck @ 2017-11-05 15:11 UTC (permalink / raw)
  To: Gustavo A. R. Silva; +Cc: Wim Van Sebroeck, linux-watchdog, linux-kernel

On Fri, Nov 03, 2017 at 11:02:30AM -0500, Gustavo A. R. Silva wrote:
> In preparation to enabling -Wimplicit-fallthrough, mark switch cases
> where we are expecting to fall through.
> 
> Notice that in this particular case I replaced "Fall" with a proper
> "fall through" comment, which is what GCC is expecting to find.
> 
> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>

Reviewed-by: Guenter Roeck <linux@roeck-us.net>

> ---
> Changes in v2:
>  Place the "fall through" comment outside the unconditional code block.
> 
>  drivers/watchdog/pcwd_pci.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/watchdog/pcwd_pci.c b/drivers/watchdog/pcwd_pci.c
> index c0d07ee..1f78f09 100644
> --- a/drivers/watchdog/pcwd_pci.c
> +++ b/drivers/watchdog/pcwd_pci.c
> @@ -545,8 +545,8 @@ static long pcipcwd_ioctl(struct file *file, unsigned int cmd,
>  			return -EINVAL;
>  
>  		pcipcwd_keepalive();
> -		/* Fall */
>  	}
> +		/* fall through */
>  
>  	case WDIOC_GETTIMEOUT:
>  		return put_user(heartbeat, p);

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

end of thread, other threads:[~2017-11-05 15:11 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-03 14:49 [PATCH] watchdog: pcwd_pci: mark expected switch fall-through Gustavo A. R. Silva
2017-11-03 15:04 ` Wim Van Sebroeck
2017-11-03 15:47   ` Gustavo A. R. Silva
2017-11-03 16:02     ` [PATCH v2] " Gustavo A. R. Silva
2017-11-05 15:11       ` [v2] " Guenter Roeck
2017-11-03 15:54   ` [PATCH] " Guenter Roeck
2017-11-03 15:57     ` Gustavo A. R. Silva
2017-11-03 16:02     ` Joe Perches
2017-11-03 16:15       ` Guenter Roeck

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