linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] PCI: Mark expected switch fall-throughs
@ 2019-03-20 18:27 Gustavo A. R. Silva
  2019-03-20 19:24 ` Bjorn Helgaas
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Gustavo A. R. Silva @ 2019-03-20 18:27 UTC (permalink / raw)
  To: Bjorn Helgaas, Boris Ostrovsky, Juergen Gross,
	Stefano Stabellini, Konrad Rzeszutek Wilk
  Cc: linux-pci, linux-kernel, xen-devel, Gustavo A. R. Silva, Kees Cook

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

This patch fixes the following warnings:

drivers/pci/proc.c: In function ‘proc_bus_pci_ioctl’:
drivers/pci/proc.c:216:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
   if (arch_can_pci_mmap_wc()) {
      ^
drivers/pci/proc.c:225:2: note: here
  default:
  ^~~~~~~

drivers/pci/xen-pcifront.c: In function ‘pcifront_backend_changed’:
drivers/pci/xen-pcifront.c:1105:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
   if (xdev->state == XenbusStateClosed)
      ^
drivers/pci/xen-pcifront.c:1108:2: note: here
  case XenbusStateClosing:
  ^~~~

Notice that, in this particular case, the /* fall through */
comment is placed at the very bottom of the case statement,
which is what GCC is expecting to find.

Warning level 3 was used: -Wimplicit-fallthrough=3

This patch is part of the ongoing efforts to enable
-Wimplicit-fallthrough.

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
 drivers/pci/proc.c         | 1 +
 drivers/pci/xen-pcifront.c | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
index 6fa1627ce08d..445b51db75b0 100644
--- a/drivers/pci/proc.c
+++ b/drivers/pci/proc.c
@@ -222,6 +222,7 @@ static long proc_bus_pci_ioctl(struct file *file, unsigned int cmd,
 		}
 		/* If arch decided it can't, fall through... */
 #endif /* HAVE_PCI_MMAP */
+		/* fall through */
 	default:
 		ret = -EINVAL;
 		break;
diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
index eba6e33147a2..14cf0f41ecf0 100644
--- a/drivers/pci/xen-pcifront.c
+++ b/drivers/pci/xen-pcifront.c
@@ -1104,7 +1104,7 @@ static void __ref pcifront_backend_changed(struct xenbus_device *xdev,
 	case XenbusStateClosed:
 		if (xdev->state == XenbusStateClosed)
 			break;
-		/* Missed the backend's CLOSING state -- fallthrough */
+		/* fall through - Missed the backend's CLOSING state. */
 	case XenbusStateClosing:
 		dev_warn(&xdev->dev, "backend going away!\n");
 		pcifront_try_disconnect(pdev);
-- 
2.21.0


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

* Re: [PATCH] PCI: Mark expected switch fall-throughs
  2019-03-20 18:27 [PATCH] PCI: Mark expected switch fall-throughs Gustavo A. R. Silva
@ 2019-03-20 19:24 ` Bjorn Helgaas
  2019-03-20 19:33   ` Gustavo A. R. Silva
  2019-03-20 19:27 ` [Xen-devel] " Andrew Cooper
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 10+ messages in thread
From: Bjorn Helgaas @ 2019-03-20 19:24 UTC (permalink / raw)
  To: Gustavo A. R. Silva
  Cc: Boris Ostrovsky, Juergen Gross, Stefano Stabellini,
	Konrad Rzeszutek Wilk, linux-pci, linux-kernel, xen-devel,
	Kees Cook

On Wed, Mar 20, 2019 at 01:27:15PM -0500, Gustavo A. R. Silva wrote:
> In preparation to enabling -Wimplicit-fallthrough, mark switch
> cases where we are expecting to fall through.

Does this fix all the remaining cases in drivers/pci?  I'd like to fix
them all at once.

What's the best way to watch for new warnings being added?  I fiddled
with "make W=2" etc but it didn't seem useful.  Does the 0-day robot
warn when -Wimplicit-fallthrough warnings are added?

Bjorn

> This patch fixes the following warnings:
> 
> drivers/pci/proc.c: In function ‘proc_bus_pci_ioctl’:
> drivers/pci/proc.c:216:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
>    if (arch_can_pci_mmap_wc()) {
>       ^
> drivers/pci/proc.c:225:2: note: here
>   default:
>   ^~~~~~~
> 
> drivers/pci/xen-pcifront.c: In function ‘pcifront_backend_changed’:
> drivers/pci/xen-pcifront.c:1105:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
>    if (xdev->state == XenbusStateClosed)
>       ^
> drivers/pci/xen-pcifront.c:1108:2: note: here
>   case XenbusStateClosing:
>   ^~~~
> 
> Notice that, in this particular case, the /* fall through */
> comment is placed at the very bottom of the case statement,
> which is what GCC is expecting to find.
> 
> Warning level 3 was used: -Wimplicit-fallthrough=3
> 
> This patch is part of the ongoing efforts to enable
> -Wimplicit-fallthrough.
> 
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> ---
>  drivers/pci/proc.c         | 1 +
>  drivers/pci/xen-pcifront.c | 2 +-
>  2 files changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
> index 6fa1627ce08d..445b51db75b0 100644
> --- a/drivers/pci/proc.c
> +++ b/drivers/pci/proc.c
> @@ -222,6 +222,7 @@ static long proc_bus_pci_ioctl(struct file *file, unsigned int cmd,
>  		}
>  		/* If arch decided it can't, fall through... */
>  #endif /* HAVE_PCI_MMAP */
> +		/* fall through */
>  	default:
>  		ret = -EINVAL;
>  		break;
> diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
> index eba6e33147a2..14cf0f41ecf0 100644
> --- a/drivers/pci/xen-pcifront.c
> +++ b/drivers/pci/xen-pcifront.c
> @@ -1104,7 +1104,7 @@ static void __ref pcifront_backend_changed(struct xenbus_device *xdev,
>  	case XenbusStateClosed:
>  		if (xdev->state == XenbusStateClosed)
>  			break;
> -		/* Missed the backend's CLOSING state -- fallthrough */
> +		/* fall through - Missed the backend's CLOSING state. */
>  	case XenbusStateClosing:
>  		dev_warn(&xdev->dev, "backend going away!\n");
>  		pcifront_try_disconnect(pdev);
> -- 
> 2.21.0
> 

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

* Re: [Xen-devel] [PATCH] PCI: Mark expected switch fall-throughs
  2019-03-20 18:27 [PATCH] PCI: Mark expected switch fall-throughs Gustavo A. R. Silva
  2019-03-20 19:24 ` Bjorn Helgaas
@ 2019-03-20 19:27 ` Andrew Cooper
  2019-03-20 19:41   ` Gustavo A. R. Silva
  2019-03-20 20:13 ` Bjorn Helgaas
  2019-03-25 13:25 ` [Xen-devel] " Jan Beulich
  3 siblings, 1 reply; 10+ messages in thread
From: Andrew Cooper @ 2019-03-20 19:27 UTC (permalink / raw)
  To: Gustavo A. R. Silva, Bjorn Helgaas, Boris Ostrovsky,
	Juergen Gross, Stefano Stabellini, Konrad Rzeszutek Wilk
  Cc: linux-pci, linux-kernel, Kees Cook, xen-devel

On 20/03/2019 18:27, Gustavo A. R. Silva wrote:
> diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
> index 6fa1627ce08d..445b51db75b0 100644
> --- a/drivers/pci/proc.c
> +++ b/drivers/pci/proc.c
> @@ -222,6 +222,7 @@ static long proc_bus_pci_ioctl(struct file *file, unsigned int cmd,
>  		}
>  		/* If arch decided it can't, fall through... */
>  #endif /* HAVE_PCI_MMAP */
> +		/* fall through */

Surely it would be better to transpose the #endif and its previous line,
than to add a second fallthrough ?

~Andrew

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

* Re: [PATCH] PCI: Mark expected switch fall-throughs
  2019-03-20 19:24 ` Bjorn Helgaas
@ 2019-03-20 19:33   ` Gustavo A. R. Silva
  0 siblings, 0 replies; 10+ messages in thread
From: Gustavo A. R. Silva @ 2019-03-20 19:33 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Boris Ostrovsky, Juergen Gross, Stefano Stabellini,
	Konrad Rzeszutek Wilk, linux-pci, linux-kernel, xen-devel,
	Kees Cook



On 3/20/19 2:24 PM, Bjorn Helgaas wrote:
> On Wed, Mar 20, 2019 at 01:27:15PM -0500, Gustavo A. R. Silva wrote:
>> In preparation to enabling -Wimplicit-fallthrough, mark switch
>> cases where we are expecting to fall through.
> 
> Does this fix all the remaining cases in drivers/pci?  I'd like to fix
> them all at once.
> 

These are actually the last ones.

> What's the best way to watch for new warnings being added?  I fiddled
> with "make W=2" etc but it didn't seem useful.  Does the 0-day robot
> warn when -Wimplicit-fallthrough warnings are added?
> 

0-day robot doesn't know about these warnings yet.  But it certainly
will once we finally enable -Wimplicit-fallthrough.

Add this to your Makefile to see the warnings:

KBUILD_CFLAGS  += $(call cc-option,-Wimplicit-fallthrough=3,)

Thanks
--
Gustavo

> Bjorn
> 
>> This patch fixes the following warnings:
>>
>> drivers/pci/proc.c: In function ‘proc_bus_pci_ioctl’:
>> drivers/pci/proc.c:216:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
>>    if (arch_can_pci_mmap_wc()) {
>>       ^
>> drivers/pci/proc.c:225:2: note: here
>>   default:
>>   ^~~~~~~
>>
>> drivers/pci/xen-pcifront.c: In function ‘pcifront_backend_changed’:
>> drivers/pci/xen-pcifront.c:1105:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
>>    if (xdev->state == XenbusStateClosed)
>>       ^
>> drivers/pci/xen-pcifront.c:1108:2: note: here
>>   case XenbusStateClosing:
>>   ^~~~
>>
>> Notice that, in this particular case, the /* fall through */
>> comment is placed at the very bottom of the case statement,
>> which is what GCC is expecting to find.
>>
>> Warning level 3 was used: -Wimplicit-fallthrough=3
>>
>> This patch is part of the ongoing efforts to enable
>> -Wimplicit-fallthrough.
>>
>> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
>> ---
>>  drivers/pci/proc.c         | 1 +
>>  drivers/pci/xen-pcifront.c | 2 +-
>>  2 files changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
>> index 6fa1627ce08d..445b51db75b0 100644
>> --- a/drivers/pci/proc.c
>> +++ b/drivers/pci/proc.c
>> @@ -222,6 +222,7 @@ static long proc_bus_pci_ioctl(struct file *file, unsigned int cmd,
>>  		}
>>  		/* If arch decided it can't, fall through... */
>>  #endif /* HAVE_PCI_MMAP */
>> +		/* fall through */
>>  	default:
>>  		ret = -EINVAL;
>>  		break;
>> diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
>> index eba6e33147a2..14cf0f41ecf0 100644
>> --- a/drivers/pci/xen-pcifront.c
>> +++ b/drivers/pci/xen-pcifront.c
>> @@ -1104,7 +1104,7 @@ static void __ref pcifront_backend_changed(struct xenbus_device *xdev,
>>  	case XenbusStateClosed:
>>  		if (xdev->state == XenbusStateClosed)
>>  			break;
>> -		/* Missed the backend's CLOSING state -- fallthrough */
>> +		/* fall through - Missed the backend's CLOSING state. */
>>  	case XenbusStateClosing:
>>  		dev_warn(&xdev->dev, "backend going away!\n");
>>  		pcifront_try_disconnect(pdev);
>> -- 
>> 2.21.0
>>

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

* Re: [Xen-devel] [PATCH] PCI: Mark expected switch fall-throughs
  2019-03-20 19:27 ` [Xen-devel] " Andrew Cooper
@ 2019-03-20 19:41   ` Gustavo A. R. Silva
  0 siblings, 0 replies; 10+ messages in thread
From: Gustavo A. R. Silva @ 2019-03-20 19:41 UTC (permalink / raw)
  To: Andrew Cooper, Bjorn Helgaas, Boris Ostrovsky, Juergen Gross,
	Stefano Stabellini, Konrad Rzeszutek Wilk
  Cc: linux-pci, linux-kernel, Kees Cook, xen-devel



On 3/20/19 2:27 PM, Andrew Cooper wrote:
> On 20/03/2019 18:27, Gustavo A. R. Silva wrote:
>> diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
>> index 6fa1627ce08d..445b51db75b0 100644
>> --- a/drivers/pci/proc.c
>> +++ b/drivers/pci/proc.c
>> @@ -222,6 +222,7 @@ static long proc_bus_pci_ioctl(struct file *file, unsigned int cmd,
>>  		}
>>  		/* If arch decided it can't, fall through... */
>>  #endif /* HAVE_PCI_MMAP */
>> +		/* fall through */
> 
> Surely it would be better to transpose the #endif and its previous line,
> than to add a second fallthrough ?
> 

I agree.  The thing is that, currently, GCC is expecting to find the
fall-through "annotations" at the very bottom of the case statement,
as I mentioned it in the changelog text.

That's the reason why I decided to left in place the original comment.

Thanks
--
Gustavo

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

* Re: [PATCH] PCI: Mark expected switch fall-throughs
  2019-03-20 18:27 [PATCH] PCI: Mark expected switch fall-throughs Gustavo A. R. Silva
  2019-03-20 19:24 ` Bjorn Helgaas
  2019-03-20 19:27 ` [Xen-devel] " Andrew Cooper
@ 2019-03-20 20:13 ` Bjorn Helgaas
  2019-03-20 20:23   ` Gustavo A. R. Silva
  2019-03-25 13:25 ` [Xen-devel] " Jan Beulich
  3 siblings, 1 reply; 10+ messages in thread
From: Bjorn Helgaas @ 2019-03-20 20:13 UTC (permalink / raw)
  To: Gustavo A. R. Silva
  Cc: Boris Ostrovsky, Juergen Gross, Stefano Stabellini,
	Konrad Rzeszutek Wilk, linux-pci, linux-kernel, xen-devel,
	Kees Cook

On Wed, Mar 20, 2019 at 01:27:15PM -0500, Gustavo A. R. Silva wrote:
> In preparation to enabling -Wimplicit-fallthrough, mark switch
> cases where we are expecting to fall through.
> 
> This patch fixes the following warnings:
> 
> drivers/pci/proc.c: In function ‘proc_bus_pci_ioctl’:
> drivers/pci/proc.c:216:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
>    if (arch_can_pci_mmap_wc()) {
>       ^
> drivers/pci/proc.c:225:2: note: here
>   default:
>   ^~~~~~~
> 
> drivers/pci/xen-pcifront.c: In function ‘pcifront_backend_changed’:
> drivers/pci/xen-pcifront.c:1105:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
>    if (xdev->state == XenbusStateClosed)
>       ^
> drivers/pci/xen-pcifront.c:1108:2: note: here
>   case XenbusStateClosing:
>   ^~~~
> 
> Notice that, in this particular case, the /* fall through */
> comment is placed at the very bottom of the case statement,
> which is what GCC is expecting to find.
> 
> Warning level 3 was used: -Wimplicit-fallthrough=3
> 
> This patch is part of the ongoing efforts to enable
> -Wimplicit-fallthrough.
> 
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>

Applied to pci/misc for v5.2, thanks!

> ---
>  drivers/pci/proc.c         | 1 +
>  drivers/pci/xen-pcifront.c | 2 +-
>  2 files changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
> index 6fa1627ce08d..445b51db75b0 100644
> --- a/drivers/pci/proc.c
> +++ b/drivers/pci/proc.c
> @@ -222,6 +222,7 @@ static long proc_bus_pci_ioctl(struct file *file, unsigned int cmd,
>  		}
>  		/* If arch decided it can't, fall through... */
>  #endif /* HAVE_PCI_MMAP */
> +		/* fall through */
>  	default:
>  		ret = -EINVAL;
>  		break;
> diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
> index eba6e33147a2..14cf0f41ecf0 100644
> --- a/drivers/pci/xen-pcifront.c
> +++ b/drivers/pci/xen-pcifront.c
> @@ -1104,7 +1104,7 @@ static void __ref pcifront_backend_changed(struct xenbus_device *xdev,
>  	case XenbusStateClosed:
>  		if (xdev->state == XenbusStateClosed)
>  			break;
> -		/* Missed the backend's CLOSING state -- fallthrough */
> +		/* fall through - Missed the backend's CLOSING state. */
>  	case XenbusStateClosing:
>  		dev_warn(&xdev->dev, "backend going away!\n");
>  		pcifront_try_disconnect(pdev);
> -- 
> 2.21.0
> 

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

* Re: [PATCH] PCI: Mark expected switch fall-throughs
  2019-03-20 20:13 ` Bjorn Helgaas
@ 2019-03-20 20:23   ` Gustavo A. R. Silva
  0 siblings, 0 replies; 10+ messages in thread
From: Gustavo A. R. Silva @ 2019-03-20 20:23 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Boris Ostrovsky, Juergen Gross, Stefano Stabellini,
	Konrad Rzeszutek Wilk, linux-pci, linux-kernel, xen-devel,
	Kees Cook



On 3/20/19 3:13 PM, Bjorn Helgaas wrote:
> On Wed, Mar 20, 2019 at 01:27:15PM -0500, Gustavo A. R. Silva wrote:

[..]

>>
>> Warning level 3 was used: -Wimplicit-fallthrough=3
>>
>> This patch is part of the ongoing efforts to enable
>> -Wimplicit-fallthrough.
>>
>> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> 
> Applied to pci/misc for v5.2, thanks!
> 

Awesome!

Thanks
--
Gustavo

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

* Re: [Xen-devel] [PATCH] PCI: Mark expected switch fall-throughs
  2019-03-20 18:27 [PATCH] PCI: Mark expected switch fall-throughs Gustavo A. R. Silva
                   ` (2 preceding siblings ...)
  2019-03-20 20:13 ` Bjorn Helgaas
@ 2019-03-25 13:25 ` Jan Beulich
  3 siblings, 0 replies; 10+ messages in thread
From: Jan Beulich @ 2019-03-25 13:25 UTC (permalink / raw)
  To: Gustavo A.R.Silva
  Cc: keescook, Bjorn Helgaas, Stefano Stabellini, xen-devel,
	Boris Ostrovsky, Konrad Rzeszutek Wilk, Juergen Gross,
	linux-kernel, linux-pci

>>> On 20.03.19 at 19:27, <gustavo@embeddedor.com> wrote:
> In preparation to enabling -Wimplicit-fallthrough, mark switch
> cases where we are expecting to fall through.
> 
> This patch fixes the following warnings:
> 
> drivers/pci/proc.c: In function ‘proc_bus_pci_ioctl’:
> drivers/pci/proc.c:216:6: warning: this statement may fall through 
> [-Wimplicit-fallthrough=]
>    if (arch_can_pci_mmap_wc()) {
>       ^
> drivers/pci/proc.c:225:2: note: here
>   default:
>   ^~~~~~~
> 
> drivers/pci/xen-pcifront.c: In function ‘pcifront_backend_changed’:
> drivers/pci/xen-pcifront.c:1105:6: warning: this statement may fall through 
> [-Wimplicit-fallthrough=]
>    if (xdev->state == XenbusStateClosed)
>       ^
> drivers/pci/xen-pcifront.c:1108:2: note: here
>   case XenbusStateClosing:
>   ^~~~
> 
> Notice that, in this particular case, the /* fall through */
> comment is placed at the very bottom of the case statement,
> which is what GCC is expecting to find.
> 
> Warning level 3 was used: -Wimplicit-fallthrough=3
> 
> This patch is part of the ongoing efforts to enable
> -Wimplicit-fallthrough.

None of the above explains why ...

> --- a/drivers/pci/xen-pcifront.c
> +++ b/drivers/pci/xen-pcifront.c
> @@ -1104,7 +1104,7 @@ static void __ref pcifront_backend_changed(struct xenbus_device *xdev,
>  	case XenbusStateClosed:
>  		if (xdev->state == XenbusStateClosed)
>  			break;
> -		/* Missed the backend's CLOSING state -- fallthrough */
> +		/* fall through - Missed the backend's CLOSING state. */

... the original comment here wasn't good enough.

Jan


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

* Re: [PATCH] PCI: Mark expected switch fall-throughs
  2018-07-05 14:56 Gustavo A. R. Silva
@ 2018-07-10 17:09 ` Bjorn Helgaas
  0 siblings, 0 replies; 10+ messages in thread
From: Bjorn Helgaas @ 2018-07-10 17:09 UTC (permalink / raw)
  To: Gustavo A. R. Silva; +Cc: Bjorn Helgaas, linux-pci, linux-kernel

On Thu, Jul 05, 2018 at 09:56:00AM -0500, Gustavo A. R. Silva wrote:
> In preparation to enabling -Wimplicit-fallthrough, mark switch cases
> where we are expecting to fall through.
> 
> Warning level 2 was used: -Wimplicit-fallthrough=2
> 
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>

Applied to pci/misc for v4.19, thanks!

If you'd like to apply this elsewhere as part of a larger series, feel
free to do that.  Just add my ack and let me know to drop it.

Acked-by: Bjorn Helgaas <bhelgaas@google.com>

> ---
>  drivers/pci/hotplug/pciehp_ctrl.c | 2 ++
>  drivers/pci/hotplug/shpchp_ctrl.c | 2 ++
>  drivers/pci/pci.c                 | 1 +
>  drivers/pci/quirks.c              | 1 +
>  4 files changed, 6 insertions(+)
> 
> diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c
> index c684faa..cfc46e8 100644
> --- a/drivers/pci/hotplug/pciehp_ctrl.c
> +++ b/drivers/pci/hotplug/pciehp_ctrl.c
> @@ -436,6 +436,7 @@ int pciehp_sysfs_enable_slot(struct slot *p_slot)
>  	switch (p_slot->state) {
>  	case BLINKINGON_STATE:
>  		cancel_delayed_work(&p_slot->work);
> +		/* fall through */
>  	case STATIC_STATE:
>  		p_slot->state = POWERON_STATE;
>  		mutex_unlock(&p_slot->lock);
> @@ -473,6 +474,7 @@ int pciehp_sysfs_disable_slot(struct slot *p_slot)
>  	switch (p_slot->state) {
>  	case BLINKINGOFF_STATE:
>  		cancel_delayed_work(&p_slot->work);
> +		/* fall through */
>  	case STATIC_STATE:
>  		p_slot->state = POWEROFF_STATE;
>  		mutex_unlock(&p_slot->lock);
> diff --git a/drivers/pci/hotplug/shpchp_ctrl.c b/drivers/pci/hotplug/shpchp_ctrl.c
> index 1047b56..1267dcc 100644
> --- a/drivers/pci/hotplug/shpchp_ctrl.c
> +++ b/drivers/pci/hotplug/shpchp_ctrl.c
> @@ -654,6 +654,7 @@ int shpchp_sysfs_enable_slot(struct slot *p_slot)
>  	switch (p_slot->state) {
>  	case BLINKINGON_STATE:
>  		cancel_delayed_work(&p_slot->work);
> +		/* fall through */
>  	case STATIC_STATE:
>  		p_slot->state = POWERON_STATE;
>  		mutex_unlock(&p_slot->lock);
> @@ -689,6 +690,7 @@ int shpchp_sysfs_disable_slot(struct slot *p_slot)
>  	switch (p_slot->state) {
>  	case BLINKINGOFF_STATE:
>  		cancel_delayed_work(&p_slot->work);
> +		/* fall through */
>  	case STATIC_STATE:
>  		p_slot->state = POWEROFF_STATE;
>  		mutex_unlock(&p_slot->lock);
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index 97acba7..f5c6ab1 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -2045,6 +2045,7 @@ static pci_power_t pci_target_state(struct pci_dev *dev, bool wakeup)
>  		case PCI_D2:
>  			if (pci_no_d1d2(dev))
>  				break;
> +			/* else: fall through */
>  		default:
>  			target_state = state;
>  		}
> diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
> index f439de8..502275c 100644
> --- a/drivers/pci/quirks.c
> +++ b/drivers/pci/quirks.c
> @@ -2105,6 +2105,7 @@ static void quirk_netmos(struct pci_dev *dev)
>  		if (dev->subsystem_vendor == PCI_VENDOR_ID_IBM &&
>  				dev->subsystem_device == 0x0299)
>  			return;
> +		/* else: fall through */
>  	case PCI_DEVICE_ID_NETMOS_9735:
>  	case PCI_DEVICE_ID_NETMOS_9745:
>  	case PCI_DEVICE_ID_NETMOS_9845:
> -- 
> 2.7.4
> 

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

* [PATCH] PCI: Mark expected switch fall-throughs
@ 2018-07-05 14:56 Gustavo A. R. Silva
  2018-07-10 17:09 ` Bjorn Helgaas
  0 siblings, 1 reply; 10+ messages in thread
From: Gustavo A. R. Silva @ 2018-07-05 14:56 UTC (permalink / raw)
  To: Bjorn Helgaas; +Cc: linux-pci, linux-kernel, Gustavo A. R. Silva

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

Warning level 2 was used: -Wimplicit-fallthrough=2

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
 drivers/pci/hotplug/pciehp_ctrl.c | 2 ++
 drivers/pci/hotplug/shpchp_ctrl.c | 2 ++
 drivers/pci/pci.c                 | 1 +
 drivers/pci/quirks.c              | 1 +
 4 files changed, 6 insertions(+)

diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c
index c684faa..cfc46e8 100644
--- a/drivers/pci/hotplug/pciehp_ctrl.c
+++ b/drivers/pci/hotplug/pciehp_ctrl.c
@@ -436,6 +436,7 @@ int pciehp_sysfs_enable_slot(struct slot *p_slot)
 	switch (p_slot->state) {
 	case BLINKINGON_STATE:
 		cancel_delayed_work(&p_slot->work);
+		/* fall through */
 	case STATIC_STATE:
 		p_slot->state = POWERON_STATE;
 		mutex_unlock(&p_slot->lock);
@@ -473,6 +474,7 @@ int pciehp_sysfs_disable_slot(struct slot *p_slot)
 	switch (p_slot->state) {
 	case BLINKINGOFF_STATE:
 		cancel_delayed_work(&p_slot->work);
+		/* fall through */
 	case STATIC_STATE:
 		p_slot->state = POWEROFF_STATE;
 		mutex_unlock(&p_slot->lock);
diff --git a/drivers/pci/hotplug/shpchp_ctrl.c b/drivers/pci/hotplug/shpchp_ctrl.c
index 1047b56..1267dcc 100644
--- a/drivers/pci/hotplug/shpchp_ctrl.c
+++ b/drivers/pci/hotplug/shpchp_ctrl.c
@@ -654,6 +654,7 @@ int shpchp_sysfs_enable_slot(struct slot *p_slot)
 	switch (p_slot->state) {
 	case BLINKINGON_STATE:
 		cancel_delayed_work(&p_slot->work);
+		/* fall through */
 	case STATIC_STATE:
 		p_slot->state = POWERON_STATE;
 		mutex_unlock(&p_slot->lock);
@@ -689,6 +690,7 @@ int shpchp_sysfs_disable_slot(struct slot *p_slot)
 	switch (p_slot->state) {
 	case BLINKINGOFF_STATE:
 		cancel_delayed_work(&p_slot->work);
+		/* fall through */
 	case STATIC_STATE:
 		p_slot->state = POWEROFF_STATE;
 		mutex_unlock(&p_slot->lock);
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 97acba7..f5c6ab1 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -2045,6 +2045,7 @@ static pci_power_t pci_target_state(struct pci_dev *dev, bool wakeup)
 		case PCI_D2:
 			if (pci_no_d1d2(dev))
 				break;
+			/* else: fall through */
 		default:
 			target_state = state;
 		}
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index f439de8..502275c 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -2105,6 +2105,7 @@ static void quirk_netmos(struct pci_dev *dev)
 		if (dev->subsystem_vendor == PCI_VENDOR_ID_IBM &&
 				dev->subsystem_device == 0x0299)
 			return;
+		/* else: fall through */
 	case PCI_DEVICE_ID_NETMOS_9735:
 	case PCI_DEVICE_ID_NETMOS_9745:
 	case PCI_DEVICE_ID_NETMOS_9845:
-- 
2.7.4

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

end of thread, other threads:[~2019-03-25 13:25 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-20 18:27 [PATCH] PCI: Mark expected switch fall-throughs Gustavo A. R. Silva
2019-03-20 19:24 ` Bjorn Helgaas
2019-03-20 19:33   ` Gustavo A. R. Silva
2019-03-20 19:27 ` [Xen-devel] " Andrew Cooper
2019-03-20 19:41   ` Gustavo A. R. Silva
2019-03-20 20:13 ` Bjorn Helgaas
2019-03-20 20:23   ` Gustavo A. R. Silva
2019-03-25 13:25 ` [Xen-devel] " Jan Beulich
  -- strict thread matches above, loose matches on Subject: below --
2018-07-05 14:56 Gustavo A. R. Silva
2018-07-10 17:09 ` Bjorn Helgaas

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