* [PATCH] usb: gadget: goku_udc: mark expected switch fall-throughs
@ 2017-10-24 3:45 Gustavo A. R. Silva
2017-10-24 14:21 ` David Laight
0 siblings, 1 reply; 2+ messages in thread
From: Gustavo A. R. Silva @ 2017-10-24 3:45 UTC (permalink / raw)
To: Felipe Balbi, Greg Kroah-Hartman
Cc: linux-usb, 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: 145713
Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
---
drivers/usb/gadget/udc/goku_udc.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/drivers/usb/gadget/udc/goku_udc.c b/drivers/usb/gadget/udc/goku_udc.c
index 8433c22..a85407e 100644
--- a/drivers/usb/gadget/udc/goku_udc.c
+++ b/drivers/usb/gadget/udc/goku_udc.c
@@ -127,11 +127,15 @@ goku_ep_enable(struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
mode = 0;
max = get_unaligned_le16(&desc->wMaxPacketSize);
switch (max) {
- case 64: mode++;
- case 32: mode++;
- case 16: mode++;
- case 8: mode <<= 3;
- break;
+ case 64:
+ mode++; /* fall through */
+ case 32:
+ mode++; /* fall through */
+ case 16:
+ mode++; /* fall through */
+ case 8:
+ mode <<= 3;
+ break;
default:
return -EINVAL;
}
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* RE: [PATCH] usb: gadget: goku_udc: mark expected switch fall-throughs
2017-10-24 3:45 [PATCH] usb: gadget: goku_udc: mark expected switch fall-throughs Gustavo A. R. Silva
@ 2017-10-24 14:21 ` David Laight
0 siblings, 0 replies; 2+ messages in thread
From: David Laight @ 2017-10-24 14:21 UTC (permalink / raw)
To: 'Gustavo A. R. Silva', Felipe Balbi, Greg Kroah-Hartman
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
From: Gustavo A. R. Silva
> Sent: 24 October 2017 04:46
> In preparation to enabling -Wimplicit-fallthrough, mark switch cases
> where we are expecting to fall through.
>
> Addresses-Coverity-ID: 145713
> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
> ---
> drivers/usb/gadget/udc/goku_udc.c | 14 +++++++++-----
> 1 file changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/usb/gadget/udc/goku_udc.c b/drivers/usb/gadget/udc/goku_udc.c
> index 8433c22..a85407e 100644
> --- a/drivers/usb/gadget/udc/goku_udc.c
> +++ b/drivers/usb/gadget/udc/goku_udc.c
> @@ -127,11 +127,15 @@ goku_ep_enable(struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
> mode = 0;
> max = get_unaligned_le16(&desc->wMaxPacketSize);
> switch (max) {
> - case 64: mode++;
> - case 32: mode++;
> - case 16: mode++;
> - case 8: mode <<= 3;
> - break;
> + case 64:
> + mode++; /* fall through */
> + case 32:
> + mode++; /* fall through */
> + case 16:
> + mode++; /* fall through */
> + case 8:
> + mode <<= 3;
> + break;
> default:
> return -EINVAL;
I can't help feeling this could be the more obvious:
switch (max) {
case 8: mode = 0; break;
case 16: mode = 8; break;
case 32: mode = 16; break;
case 64: mode = 24; break;
default: return -EINVAL;
}
(with a few more blank lines)
David
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-10-24 14:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-24 3:45 [PATCH] usb: gadget: goku_udc: mark expected switch fall-throughs Gustavo A. R. Silva
2017-10-24 14:21 ` David Laight
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.