Skip to contentSkip to conversation

usb: gadget: goku_udc: mark expected switch fall-throughs

PATCH In review Gustavo A. R. Silva 2 participants 2 messages Oct 24, 2017 USB

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: gadget: goku_udc: mark expected switch fall-throughs

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

Addresses-Coverity-ID: 145713

---
 drivers/usb/gadget/udc/goku_udc.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
drivers/usb/gadget/udc/goku_udc.c +9 -5
index 8433c22..a85407e 100644
@@ -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;
 	}
Signature · 1 line
2.7.4
#1 lore raw

From: Gustavo A. R. Silva

Quoted 24 lines

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

---
 drivers/usb/gadget/udc/goku_udc.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
drivers/usb/gadget/udc/goku_udc.c +1 -5
index 8433c22..a85407e 100644
@@ -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:

drivers/usb/gadget/udc/goku_udc.c goku_ep_enable(struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc) · line 140

Quoted 10 lines
drivers/usb/gadget/udc/goku_udc.c +8 -0
+		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