linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] spi: pxa2xx: Mark expected switch fall-through
@ 2018-10-03 12:12 Gustavo A. R. Silva
  2018-10-03 15:22 ` Mark Brown
  0 siblings, 1 reply; 4+ messages in thread
From: Gustavo A. R. Silva @ 2018-10-03 12:12 UTC (permalink / raw)
  To: Daniel Mack, Haojian Zhuang, Robert Jarzmik, Mark Brown
  Cc: linux-arm-kernel, linux-spi, linux-kernel, Gustavo A. R. Silva

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

Addresses-Coverity-ID: 1056539 ("Missing break in switch")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
 drivers/spi/spi-pxa2xx.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c
index fc9aac2..728b5f3 100644
--- a/drivers/spi/spi-pxa2xx.c
+++ b/drivers/spi/spi-pxa2xx.c
@@ -666,6 +666,7 @@ static irqreturn_t interrupt_transfer(struct driver_data *drv_data)
 			switch (drv_data->n_bytes) {
 			case 4:
 				bytes_left >>= 1;
+				/* Fall through */
 			case 2:
 				bytes_left >>= 1;
 			}
-- 
2.7.4


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

* Re: [PATCH] spi: pxa2xx: Mark expected switch fall-through
  2018-10-03 12:12 [PATCH] spi: pxa2xx: Mark expected switch fall-through Gustavo A. R. Silva
@ 2018-10-03 15:22 ` Mark Brown
  2018-10-03 15:27   ` Gustavo A. R. Silva
  0 siblings, 1 reply; 4+ messages in thread
From: Mark Brown @ 2018-10-03 15:22 UTC (permalink / raw)
  To: Gustavo A. R. Silva
  Cc: Daniel Mack, Haojian Zhuang, Robert Jarzmik, linux-arm-kernel,
	linux-spi, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 453 bytes --]

On Wed, Oct 03, 2018 at 02:12:11PM +0200, Gustavo A. R. Silva wrote:

>  			switch (drv_data->n_bytes) {
>  			case 4:
>  				bytes_left >>= 1;
> +				/* Fall through */
>  			case 2:
>  				bytes_left >>= 1;
>  			}

I think this code is just being too cute and it'd be better to just
rewrite it to directly do the expected number of shifts directly in each
case and have break statements; your fix is good but still not ideal for
readability I think.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH] spi: pxa2xx: Mark expected switch fall-through
  2018-10-03 15:22 ` Mark Brown
@ 2018-10-03 15:27   ` Gustavo A. R. Silva
  2018-10-03 15:53     ` Gustavo A. R. Silva
  0 siblings, 1 reply; 4+ messages in thread
From: Gustavo A. R. Silva @ 2018-10-03 15:27 UTC (permalink / raw)
  To: Mark Brown
  Cc: Daniel Mack, Haojian Zhuang, Robert Jarzmik, linux-arm-kernel,
	linux-spi, linux-kernel



On 10/3/18 5:22 PM, Mark Brown wrote:
> On Wed, Oct 03, 2018 at 02:12:11PM +0200, Gustavo A. R. Silva wrote:
> 
>>  			switch (drv_data->n_bytes) {
>>  			case 4:
>>  				bytes_left >>= 1;
>> +				/* Fall through */
>>  			case 2:
>>  				bytes_left >>= 1;
>>  			}
> 
> I think this code is just being too cute and it'd be better to just
> rewrite it to directly do the expected number of shifts directly in each
> case and have break statements; your fix is good but still not ideal for
> readability I think.
> 

Okay. I agree. I'll rewrite and send v2.

Thanks
--
Gustavo

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

* Re: [PATCH] spi: pxa2xx: Mark expected switch fall-through
  2018-10-03 15:27   ` Gustavo A. R. Silva
@ 2018-10-03 15:53     ` Gustavo A. R. Silva
  0 siblings, 0 replies; 4+ messages in thread
From: Gustavo A. R. Silva @ 2018-10-03 15:53 UTC (permalink / raw)
  To: Mark Brown
  Cc: Daniel Mack, Haojian Zhuang, Robert Jarzmik, linux-arm-kernel,
	linux-spi, linux-kernel



On 10/3/18 5:27 PM, Gustavo A. R. Silva wrote:
> 
> 
> On 10/3/18 5:22 PM, Mark Brown wrote:
>> On Wed, Oct 03, 2018 at 02:12:11PM +0200, Gustavo A. R. Silva wrote:
>>
>>>  			switch (drv_data->n_bytes) {
>>>  			case 4:
>>>  				bytes_left >>= 1;
>>> +				/* Fall through */
>>>  			case 2:
>>>  				bytes_left >>= 1;
>>>  			}
>>
>> I think this code is just being too cute and it'd be better to just
>> rewrite it to directly do the expected number of shifts directly in each
>> case and have break statements; your fix is good but still not ideal for
>> readability I think.
>>
> 
> Okay. I agree. I'll rewrite and send v2.
> 

I'll actually send a completely new patch for this.

Thanks
--
Gustavo

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

end of thread, other threads:[~2018-10-03 15:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-03 12:12 [PATCH] spi: pxa2xx: Mark expected switch fall-through Gustavo A. R. Silva
2018-10-03 15:22 ` Mark Brown
2018-10-03 15:27   ` Gustavo A. R. Silva
2018-10-03 15:53     ` Gustavo A. R. Silva

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