Skip to contentSkip to conversation

firewire: mark expected switch fall-throughs

PATCH In review Gustavo A. R. Silva 2 participants 3 messages Feb 11, 2019 – Mar 14, 2019 Firewire

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 firewire: mark expected switch fall-throughs

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

This patch fixes the following warnings:

drivers/firewire/core-device.c: In function ‘set_broadcast_channel’:
drivers/firewire/core-device.c:969:7: warning: this statement may fall through [-Wimplicit-fallthrough=]

    if (data & cpu_to_be32(1 << 31)) {
       ^

drivers/firewire/core-device.c:974:3: note: here
case RCODE_ADDRESS_ERROR:
^~~~
drivers/firewire/core-iso.c: In function ‘manage_channel’:
drivers/firewire/core-iso.c:308:7: warning: this statement may fall through [-Wimplicit-fallthrough=]

    if ((data[0] & bit) == (data[1] & bit))
       ^

drivers/firewire/core-iso.c:312:3: note: here
default:
^~~~~~~
drivers/firewire/core-topology.c: In function ‘count_ports’:
drivers/firewire/core-topology.c:69:23: warning: this statement may fall through [-Wimplicit-fallthrough=]

    (*child_port_count)++;
    ~~~~~~~~~~~~~~~~~~~^~

drivers/firewire/core-topology.c:70:3: note: here
case SELFID_PORT_PARENT:
^~~~

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

Notice that in some cases, the code comment is modified in accordance with what GCC is expecting to find.

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

---
 drivers/firewire/core-device.c   | 2 +-
 drivers/firewire/core-iso.c      | 2 +-
 drivers/firewire/core-topology.c | 1 +
 3 files changed, 3 insertions(+), 2 deletions(-)
drivers/firewire/core-device.c +1 -1
index 7c2eed76011e..0c86548fa4a7 100644
@@ -970,7 +970,7 @@ static void set_broadcast_channel(struct fw_device *device, int generation)
 				device->bc_implemented = BC_IMPLEMENTED;
 				break;
 			}
-			/* else fall through to case address error */
+			/* else, fall through - to case address error */
 		case RCODE_ADDRESS_ERROR:
 			device->bc_implemented = BC_UNIMPLEMENTED;
 		}
drivers/firewire/core-iso.c +1 -1
index 35e784cffc23..7e5c98840b80 100644
@@ -308,7 +308,7 @@ static int manage_channel(struct fw_card *card, int irm_id, int generation,
 			if ((data[0] & bit) == (data[1] & bit))
 				continue;
 
-			/* 1394-1995 IRM, fall through to retry. */
+			/* fall through - to retry for 1394-1995 IRM */
 		default:
 			if (retry) {
 				retry--;
drivers/firewire/core-topology.c +1 -0
index 7db234d3fbdd..82c67e900aad 100644
@@ -67,6 +67,7 @@ static u32 *count_ports(u32 *sid, int *total_port_count, int *child_port_count)
 		switch (port_type) {
 		case SELFID_PORT_CHILD:
 			(*child_port_count)++;
+			/* fall through */
 		case SELFID_PORT_PARENT:
 		case SELFID_PORT_NCONN:
 			(*total_port_count)++;
Signature · 1 line
2.20.1
#1 lore raw

(added Cc: Mathieu Malaterre, who sent a patch which is a subset of this)

Quoted 27 lines · On Feb 11 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/firewire/core-device.c: In function ‘set_broadcast_channel’:
drivers/firewire/core-device.c:969:7: warning: this statement may fall through [-Wimplicit-fallthrough=]

    if (data & cpu_to_be32(1 << 31)) {
       ^
drivers/firewire/core-device.c:974:3: note: here
   case RCODE_ADDRESS_ERROR:
   ^~~~
drivers/firewire/core-iso.c: In function ‘manage_channel’:
drivers/firewire/core-iso.c:308:7: warning: this statement may fall through [-Wimplicit-fallthrough=]
    if ((data[0] & bit) == (data[1] & bit))
       ^
drivers/firewire/core-iso.c:312:3: note: here
   default:
   ^~~~~~~
drivers/firewire/core-topology.c: In function ‘count_ports’:
drivers/firewire/core-topology.c:69:23: warning: this statement may fall through [-Wimplicit-fallthrough=]
    (*child_port_count)++;
    ~~~~~~~~~~~~~~~~~~~^~
drivers/firewire/core-topology.c:70:3: note: here
   case SELFID_PORT_PARENT:
   ^~~~
Quoted 4 lines

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

Notice that in some cases, the code comment is modified in accordance with what GCC is expecting to find.

OK, I looked up
https://gcc.gnu.org/onlinedocs/gcc-8.3.0/gcc/Warning-Options.html#index-Wimplicit-fallthrough
now. I am loudly sighing and rolling my eyes... Anyway; the last regex listed at the Wimplicit-fallthrough=3 bullet point is obviously the one you are wanting to match.

Quoted 28 lines

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

---
 drivers/firewire/core-device.c   | 2 +-
 drivers/firewire/core-iso.c      | 2 +-
 drivers/firewire/core-topology.c | 1 +
 3 files changed, 3 insertions(+), 2 deletions(-)
drivers/firewire/core-device.c +1 -1
index 7c2eed76011e..0c86548fa4a7 100644
@@ -970,7 +970,7 @@ static void set_broadcast_channel(struct fw_device *device, int generation)
 				device->bc_implemented = BC_IMPLEMENTED;
 				break;
 			}
-			/* else fall through to case address error */
+			/* else, fall through - to case address error */
 		case RCODE_ADDRESS_ERROR:
 			device->bc_implemented = BC_UNIMPLEMENTED;
 		}
drivers/firewire/core-iso.c +0 -0
index 35e784cffc23..7e5c98840b80 100644

drivers/firewire/core-iso.c static int manage_channel(struct fw_card *card, int irm_id, int generation, · line 311

Quoted 5 lines
drivers/firewire/core-iso.c +1 -1
@@ -308,7 +308,7 @@ static int manage_channel(struct fw_card *card, int irm_id, int generation,
 			if ((data[0] & bit) == (data[1] & bit))
 				continue;
 
-			/* 1394-1995 IRM, fall through to retry. */
+			/* fall through - to retry for 1394-1995 IRM */

If you don't mind, I will apply your patch with a different wording of this comment:

			/* fall through - It's an 1394-1995 IRM, retry. */

I'll mark my modification to your patch in the signed-off-by-tag.

Quoted 15 lines
drivers/firewire/core-iso.c +0 -0
 		default:
 			if (retry) {
 				retry--;
drivers/firewire/core-topology.c +1 -0
index 7db234d3fbdd..82c67e900aad 100644
@@ -67,6 +67,7 @@ static u32 *count_ports(u32 *sid, int *total_port_count, int *child_port_count)
 		switch (port_type) {
 		case SELFID_PORT_CHILD:
 			(*child_port_count)++;
+			/* fall through */
 		case SELFID_PORT_PARENT:
 		case SELFID_PORT_NCONN:
 			(*total_port_count)++;
Signature · 3 lines
Stefan Richter
-======---== --== -===-
http://arcgraph.de/sr/
#2 lore raw

On 3/14/19 5:00 AM, Stefan Richter wrote:

[..]

Quoted 14 lines

drivers/firewire/core-iso.c static int manage_channel(struct fw_card *card, int irm_id, int generation, · line 311

Quoted 10 lines
drivers/firewire/core-iso.c +1 -1
index 35e784cffc23..7e5c98840b80 100644
@@ -308,7 +308,7 @@ static int manage_channel(struct fw_card *card, int irm_id, int generation,
 			if ((data[0] & bit) == (data[1] & bit))
 				continue;
 
-			/* 1394-1995 IRM, fall through to retry. */
+			/* fall through - to retry for 1394-1995 IRM */

If you don't mind, I will apply your patch with a different wording of this comment:

Quoted 4 lines
			/* fall through - It's an 1394-1995 IRM, retry. */

I'll mark my modification to your patch in the signed-off-by-tag.

Sure. That's fine with me.

Thank you.
--
Gustavo