Skip to contentSkip to conversation

USB: serial: io_edgeport: fix up switch fall-through comments

PATCH Greg Kroah-Hartman 3 participants 4 messages May 2, 2019 – May 3, 2019

Subsystems (2)
lore
Share & tools
lore

Greg Kroah-Hartman

author maintainer
#0 lore raw

Gustavo has been working to fix up all of the switch statements that "fall through" such that we can eventually turn on -Wimplicit-fallthrough. As part of that, the io_edgeport.c driver is a bit "messy" with the parsing logic of a data packet. Clean that logic up a bit by unindenting one level of the logic, and properly label /* Fall through */ to make gcc happy.

drivers/usb/serial/io_edgeport.c +14 -23
index 4ca31c0e4174..48a439298a68 100644
@@ -1751,7 +1751,7 @@ static void process_rcvd_data(struct edgeport_serial *edge_serial,
 				edge_serial->rxState = EXPECT_HDR2;
 				break;
 			}
-			/* otherwise, drop on through */
+			/* Fall through */
 		case EXPECT_HDR2:
 			edge_serial->rxHeader2 = *buffer;
 			++buffer;
@@ -1790,29 +1790,20 @@ static void process_rcvd_data(struct edgeport_serial *edge_serial,
 						edge_serial->rxHeader2, 0);
 				edge_serial->rxState = EXPECT_HDR1;
 				break;
-			} else {
-				edge_serial->rxPort =
-				    IOSP_GET_HDR_PORT(edge_serial->rxHeader1);
-				edge_serial->rxBytesRemaining =
-				    IOSP_GET_HDR_DATA_LEN(
-						edge_serial->rxHeader1,
-						edge_serial->rxHeader2);
-				dev_dbg(dev, "%s - Data for Port %u Len %u\n",
-					__func__,
-					edge_serial->rxPort,
-					edge_serial->rxBytesRemaining);
-
-				/* ASSERT(DevExt->RxPort < DevExt->NumPorts);
-				 * ASSERT(DevExt->RxBytesRemaining <
-				 *		IOSP_MAX_DATA_LENGTH);
-				 */
-
-				if (bufferLength == 0) {
-					edge_serial->rxState = EXPECT_DATA;
-					break;
-				}
-				/* Else, drop through */
 			}
+
+			edge_serial->rxPort = IOSP_GET_HDR_PORT(edge_serial->rxHeader1);
+			edge_serial->rxBytesRemaining = IOSP_GET_HDR_DATA_LEN(edge_serial->rxHeader1,
+									      edge_serial->rxHeader2);
+			dev_dbg(dev, "%s - Data for Port %u Len %u\n", __func__,
+				edge_serial->rxPort,
+				edge_serial->rxBytesRemaining);
+
+			if (bufferLength == 0) {
+				edge_serial->rxState = EXPECT_DATA;
+				break;
+			}
+			/* Fall through */
 		case EXPECT_DATA: /* Expect data */
 			if (bufferLength < edge_serial->rxBytesRemaining) {
 				rxLen = bufferLength;
maintainer
#1 lore raw
Quoted 9 lines · Greg Kroah-Hartman

Gustavo has been working to fix up all of the switch statements that "fall through" such that we can eventually turn on -Wimplicit-fallthrough. As part of that, the io_edgeport.c driver is a bit "messy" with the parsing logic of a data packet. Clean that logic up a bit by unindenting one level of the logic, and properly label /* Fall through */ to make gcc happy.

Now applied, thanks.

Gustavo, how many of these warnings are there left in the kernel now that the last one in USB is gone? :)

Johan

#2 lore raw
Quoted 8 lines · Johan Hovold
Quoted 7 lines · Greg Kroah-Hartman

Gustavo has been working to fix up all of the switch statements that "fall through" such that we can eventually turn on -Wimplicit-fallthrough. As part of that, the io_edgeport.c driver is a bit "messy" with the parsing logic of a data packet. Clean that logic up a bit by unindenting one level of the logic, and properly label /* Fall through */ to make gcc happy.

Quoted 8 lines
Quoted 2 lines

Now applied, thanks.

Gustavo, how many of these warnings are there left in the kernel now that the last one in USB is gone? :)

Today, we woke up with 37 of these warnings left in linux-next. :)

There were more than 2000 when I first started auditing them.

Thanks
---
Gustavo

maintainer
#3 lore raw
Quoted 9 lines · Gustavo A. R. Silva
Quoted 3 lines · Johan Hovold

Gustavo, how many of these warnings are there left in the kernel now that the last one in USB is gone? :)

Today, we woke up with 37 of these warnings left in linux-next. :)

There were more than 2000 when I first started auditing them.

Nice work! Hope the remaining ones aren't all super tricky to address.

Johan