Skip to contentSkip to conversation

can: mark expected switch fall-throughs

PATCH In review Gustavo A. R. Silva 4 participants 13 messages Jan 29, 2019 – May 21, 2019

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 can: 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/net/can/peak_canfd/peak_pciefd_main.c:668:3: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/spi/mcp251x.c:875:7: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/usb/peak_usb/pcan_usb.c:422:6: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/at91_can.c:895:6: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/at91_can.c:953:15: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/usb/peak_usb/pcan_usb.c: In function ‘pcan_usb_decode_error’:
drivers/net/can/usb/peak_usb/pcan_usb.c:422:6: warning: this statement may fall through [-Wimplicit-fallthrough=]

   if (n & PCAN_USB_ERROR_BUS_LIGHT) {
      ^

drivers/net/can/usb/peak_usb/pcan_usb.c:428:2: note: here
case CAN_STATE_ERROR_WARNING:
^~~~

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

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

Notice that in some cases spelling mistakes were fixed. In other cases, the /* fall through */ comment is placed at the bottom of the case statement, which is what GCC is expecting to find.

---
 drivers/net/can/at91_can.c                    | 6 ++++--
 drivers/net/can/peak_canfd/peak_pciefd_main.c | 2 +-
 drivers/net/can/spi/mcp251x.c                 | 3 ++-
 drivers/net/can/usb/peak_usb/pcan_usb.c       | 2 +-
 4 files changed, 8 insertions(+), 5 deletions(-)
drivers/net/can/at91_can.c +4 -2
index d98c69045b17..1718c20f9c99 100644
@@ -902,7 +902,8 @@ static void at91_irq_err_state(struct net_device *dev,
 				CAN_ERR_CRTL_TX_WARNING :
 				CAN_ERR_CRTL_RX_WARNING;
 		}
-	case CAN_STATE_ERROR_WARNING:	/* fallthrough */
+		/* fall through */
+	case CAN_STATE_ERROR_WARNING:
 		/*
 		 * from: ERROR_ACTIVE, ERROR_WARNING
 		 * to  : ERROR_PASSIVE, BUS_OFF
@@ -951,7 +952,8 @@ static void at91_irq_err_state(struct net_device *dev,
 		netdev_dbg(dev, "Error Active\n");
 		cf->can_id |= CAN_ERR_PROT;
 		cf->data[2] = CAN_ERR_PROT_ACTIVE;
-	case CAN_STATE_ERROR_WARNING:	/* fallthrough */
+		/* fall through */
+	case CAN_STATE_ERROR_WARNING:
 		reg_idr = AT91_IRQ_ERRA | AT91_IRQ_WARN | AT91_IRQ_BOFF;
 		reg_ier = AT91_IRQ_ERRP;
 		break;
drivers/net/can/peak_canfd/peak_pciefd_main.c +1 -1
index c458d5fdc8d3..e4f4d65a76b4 100644
@@ -668,7 +668,7 @@ static int pciefd_can_probe(struct pciefd_board *pciefd)
 		pciefd_can_writereg(priv, CANFD_CLK_SEL_80MHZ,
 				    PCIEFD_REG_CAN_CLK_SEL);
 
-		/* fallthough */
+		/* fall through */
 	case CANFD_CLK_SEL_80MHZ:
 		priv->ucan.can.clock.freq = 80 * 1000 * 1000;
 		break;
drivers/net/can/spi/mcp251x.c +2 -1
index e90817608645..17257c73c302 100644
@@ -875,7 +875,8 @@ static irqreturn_t mcp251x_can_ist(int irq, void *dev_id)
 			if (new_state >= CAN_STATE_ERROR_WARNING &&
 			    new_state <= CAN_STATE_BUS_OFF)
 				priv->can.can_stats.error_warning++;
-		case CAN_STATE_ERROR_WARNING:	/* fallthrough */
+			/* fall through */
+		case CAN_STATE_ERROR_WARNING:
 			if (new_state >= CAN_STATE_ERROR_PASSIVE &&
 			    new_state <= CAN_STATE_BUS_OFF)
 				priv->can.can_stats.error_passive++;
drivers/net/can/usb/peak_usb/pcan_usb.c +1 -1
index 13238a72a338..eca785532b6b 100644
@@ -423,7 +423,7 @@ static int pcan_usb_decode_error(struct pcan_usb_msg_context *mc, u8 n,
 			new_state = CAN_STATE_ERROR_WARNING;
 			break;
 		}
-		/* else: fall through */
+		/* fall through */
 
 	case CAN_STATE_ERROR_WARNING:
 		if (n & PCAN_USB_ERROR_BUS_HEAVY) {
Signature · 1 line
2.20.1
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 23 lines · Gustavo A. R. Silva

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

This patch fixes the following warnings:

drivers/net/can/peak_canfd/peak_pciefd_main.c:668:3: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/spi/mcp251x.c:875:7: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/usb/peak_usb/pcan_usb.c:422:6: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/at91_can.c:895:6: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/at91_can.c:953:15: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/usb/peak_usb/pcan_usb.c: In function ‘pcan_usb_decode_error’:
drivers/net/can/usb/peak_usb/pcan_usb.c:422:6: warning: this statement may fall through [-Wimplicit-fallthrough=]

    if (n & PCAN_USB_ERROR_BUS_LIGHT) {
       ^
drivers/net/can/usb/peak_usb/pcan_usb.c:428:2: note: here
   case CAN_STATE_ERROR_WARNING:
   ^~~~

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

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

Quoted 8 lines

Notice that in some cases spelling mistakes were fixed. In other cases, the /* fall through */ comment is placed at the bottom of the case statement, which is what GCC is expecting to find.

---
  drivers/net/can/at91_can.c                    | 6 ++++--

For this one:

Quoted 70 lines
  drivers/net/can/peak_canfd/peak_pciefd_main.c | 2 +-
  drivers/net/can/spi/mcp251x.c                 | 3 ++-
  drivers/net/can/usb/peak_usb/pcan_usb.c       | 2 +-
  4 files changed, 8 insertions(+), 5 deletions(-)
drivers/net/can/at91_can.c +4 -2
index d98c69045b17..1718c20f9c99 100644
@@ -902,7 +902,8 @@ static void at91_irq_err_state(struct net_device *dev,
  				CAN_ERR_CRTL_TX_WARNING :
  				CAN_ERR_CRTL_RX_WARNING;
  		}
-	case CAN_STATE_ERROR_WARNING:	/* fallthrough */
+		/* fall through */
+	case CAN_STATE_ERROR_WARNING:
  		/*
  		 * from: ERROR_ACTIVE, ERROR_WARNING
  		 * to  : ERROR_PASSIVE, BUS_OFF
@@ -951,7 +952,8 @@ static void at91_irq_err_state(struct net_device *dev,
  		netdev_dbg(dev, "Error Active\n");
  		cf->can_id |= CAN_ERR_PROT;
  		cf->data[2] = CAN_ERR_PROT_ACTIVE;
-	case CAN_STATE_ERROR_WARNING:	/* fallthrough */
+		/* fall through */
+	case CAN_STATE_ERROR_WARNING:
  		reg_idr = AT91_IRQ_ERRA | AT91_IRQ_WARN | AT91_IRQ_BOFF;
  		reg_ier = AT91_IRQ_ERRP;
  		break;
drivers/net/can/peak_canfd/peak_pciefd_main.c +1 -1
index c458d5fdc8d3..e4f4d65a76b4 100644
@@ -668,7 +668,7 @@ static int pciefd_can_probe(struct pciefd_board *pciefd)
  		pciefd_can_writereg(priv, CANFD_CLK_SEL_80MHZ,
  				    PCIEFD_REG_CAN_CLK_SEL);
 
-		/* fallthough */
+		/* fall through */
  	case CANFD_CLK_SEL_80MHZ:
  		priv->ucan.can.clock.freq = 80 * 1000 * 1000;
  		break;
drivers/net/can/spi/mcp251x.c +2 -1
index e90817608645..17257c73c302 100644
@@ -875,7 +875,8 @@ static irqreturn_t mcp251x_can_ist(int irq, void *dev_id)
  			if (new_state >= CAN_STATE_ERROR_WARNING &&
  			    new_state <= CAN_STATE_BUS_OFF)
  				priv->can.can_stats.error_warning++;
-		case CAN_STATE_ERROR_WARNING:	/* fallthrough */
+			/* fall through */
+		case CAN_STATE_ERROR_WARNING:
  			if (new_state >= CAN_STATE_ERROR_PASSIVE &&
  			    new_state <= CAN_STATE_BUS_OFF)
  				priv->can.can_stats.error_passive++;
drivers/net/can/usb/peak_usb/pcan_usb.c +1 -1
index 13238a72a338..eca785532b6b 100644
@@ -423,7 +423,7 @@ static int pcan_usb_decode_error(struct pcan_usb_msg_context *mc, u8 n,
  			new_state = CAN_STATE_ERROR_WARNING;
  			break;
  		}
-		/* else: fall through */
+		/* fall through */
 
  	case CAN_STATE_ERROR_WARNING:
  		if (n & PCAN_USB_ERROR_BUS_HEAVY) {
Signature · 1 line
Nicolas Ferre
#2 lore raw
Quoted 29 lines · On 1/30/19 2:11 AM, [email protected] wrote:
Quoted 28 lines · Gustavo A. R. Silva

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

This patch fixes the following warnings:

drivers/net/can/peak_canfd/peak_pciefd_main.c:668:3: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/spi/mcp251x.c:875:7: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/usb/peak_usb/pcan_usb.c:422:6: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/at91_can.c:895:6: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/at91_can.c:953:15: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/usb/peak_usb/pcan_usb.c: In function ‘pcan_usb_decode_error’:
drivers/net/can/usb/peak_usb/pcan_usb.c:422:6: warning: this statement may fall through [-Wimplicit-fallthrough=]

    if (n & PCAN_USB_ERROR_BUS_LIGHT) {
       ^
drivers/net/can/usb/peak_usb/pcan_usb.c:428:2: note: here
   case CAN_STATE_ERROR_WARNING:
   ^~~~

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

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

Notice that in some cases spelling mistakes were fixed. In other cases, the /* fall through */ comment is placed at the bottom of the case statement, which is what GCC is expecting to find.

Quoted 7 lines
Quoted 3 lines
---
  drivers/net/can/at91_can.c                    | 6 ++++--

For this one:

Thanks, Nicolas.

Dave:

I wonder if you can take this patch.

Thanks
--
Gustavo

Quoted 72 lines
Quoted 70 lines
  drivers/net/can/peak_canfd/peak_pciefd_main.c | 2 +-
  drivers/net/can/spi/mcp251x.c                 | 3 ++-
  drivers/net/can/usb/peak_usb/pcan_usb.c       | 2 +-
  4 files changed, 8 insertions(+), 5 deletions(-)
drivers/net/can/at91_can.c +4 -2
index d98c69045b17..1718c20f9c99 100644
@@ -902,7 +902,8 @@ static void at91_irq_err_state(struct net_device *dev,
  				CAN_ERR_CRTL_TX_WARNING :
  				CAN_ERR_CRTL_RX_WARNING;
  		}
-	case CAN_STATE_ERROR_WARNING:	/* fallthrough */
+		/* fall through */
+	case CAN_STATE_ERROR_WARNING:
  		/*
  		 * from: ERROR_ACTIVE, ERROR_WARNING
  		 * to  : ERROR_PASSIVE, BUS_OFF
@@ -951,7 +952,8 @@ static void at91_irq_err_state(struct net_device *dev,
  		netdev_dbg(dev, "Error Active\n");
  		cf->can_id |= CAN_ERR_PROT;
  		cf->data[2] = CAN_ERR_PROT_ACTIVE;
-	case CAN_STATE_ERROR_WARNING:	/* fallthrough */
+		/* fall through */
+	case CAN_STATE_ERROR_WARNING:
  		reg_idr = AT91_IRQ_ERRA | AT91_IRQ_WARN | AT91_IRQ_BOFF;
  		reg_ier = AT91_IRQ_ERRP;
  		break;
drivers/net/can/peak_canfd/peak_pciefd_main.c +1 -1
index c458d5fdc8d3..e4f4d65a76b4 100644
@@ -668,7 +668,7 @@ static int pciefd_can_probe(struct pciefd_board *pciefd)
  		pciefd_can_writereg(priv, CANFD_CLK_SEL_80MHZ,
  				    PCIEFD_REG_CAN_CLK_SEL);
 
-		/* fallthough */
+		/* fall through */
  	case CANFD_CLK_SEL_80MHZ:
  		priv->ucan.can.clock.freq = 80 * 1000 * 1000;
  		break;
drivers/net/can/spi/mcp251x.c +2 -1
index e90817608645..17257c73c302 100644
@@ -875,7 +875,8 @@ static irqreturn_t mcp251x_can_ist(int irq, void *dev_id)
  			if (new_state >= CAN_STATE_ERROR_WARNING &&
  			    new_state <= CAN_STATE_BUS_OFF)
  				priv->can.can_stats.error_warning++;
-		case CAN_STATE_ERROR_WARNING:	/* fallthrough */
+			/* fall through */
+		case CAN_STATE_ERROR_WARNING:
  			if (new_state >= CAN_STATE_ERROR_PASSIVE &&
  			    new_state <= CAN_STATE_BUS_OFF)
  				priv->can.can_stats.error_passive++;
drivers/net/can/usb/peak_usb/pcan_usb.c +1 -1
index 13238a72a338..eca785532b6b 100644
@@ -423,7 +423,7 @@ static int pcan_usb_decode_error(struct pcan_usb_msg_context *mc, u8 n,
  			new_state = CAN_STATE_ERROR_WARNING;
  			break;
  		}
-		/* else: fall through */
+		/* fall through */
 
  	case CAN_STATE_ERROR_WARNING:
  		if (n & PCAN_USB_ERROR_BUS_HEAVY) {
#3 lore raw

Hi,

Quoted 36 lines · Gustavo A. R. Silva
Quoted 33 lines · On 1/30/19 2:11 AM, [email protected] wrote:
Quoted 31 lines · Gustavo A. R. Silva

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

This patch fixes the following warnings:

drivers/net/can/peak_canfd/peak_pciefd_main.c:668:3: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/spi/mcp251x.c:875:7: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/usb/peak_usb/pcan_usb.c:422:6: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/at91_can.c:895:6: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/at91_can.c:953:15: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/usb/peak_usb/pcan_usb.c: In function ‘pcan_usb_decode_error’:
drivers/net/can/usb/peak_usb/pcan_usb.c:422:6: warning: this statement may fall through [-Wimplicit-fallthrough=]

    if (n & PCAN_USB_ERROR_BUS_LIGHT) {
       ^
drivers/net/can/usb/peak_usb/pcan_usb.c:428:2: note: here
   case CAN_STATE_ERROR_WARNING:
   ^~~~

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

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

Notice that in some cases spelling mistakes were fixed. In other cases, the /* fall through */ comment is placed at the bottom of the case statement, which is what GCC is expecting to find.

---
  drivers/net/can/at91_can.c                    | 6 ++++--
Quoted 6 lines
Quoted 3 lines

For this one:

Thanks, Nicolas.

I though I had a déjà vu but you actually sent the at91 part twice.

Quoted 24 lines

Dave:

I wonder if you can take this patch.

Thanks
--
Gustavo

Quoted 16 lines
Quoted 16 lines
  drivers/net/can/peak_canfd/peak_pciefd_main.c | 2 +-
  drivers/net/can/spi/mcp251x.c                 | 3 ++-
  drivers/net/can/usb/peak_usb/pcan_usb.c       | 2 +-
  4 files changed, 8 insertions(+), 5 deletions(-)
drivers/net/can/at91_can.c +2 -1
index d98c69045b17..1718c20f9c99 100644
@@ -902,7 +902,8 @@ static void at91_irq_err_state(struct net_device *dev,
  				CAN_ERR_CRTL_TX_WARNING :
  				CAN_ERR_CRTL_RX_WARNING;
  		}
-	case CAN_STATE_ERROR_WARNING:	/* fallthrough */
+		/* fall through */
+	case CAN_STATE_ERROR_WARNING:
Quoted 8 lines
Quoted 8 lines

drivers/net/can/at91_can.c static void at91_irq_err_state(struct net_device *dev, · line 954

Quoted 8 lines
drivers/net/can/at91_can.c +0 -1
  		/*
  		 * from: ERROR_ACTIVE, ERROR_WARNING
  		 * to  : ERROR_PASSIVE, BUS_OFF
@@ -951,7 +952,8 @@ static void at91_irq_err_state(struct net_device *dev,
  		netdev_dbg(dev, "Error Active\n");
  		cf->can_id |= CAN_ERR_PROT;
  		cf->data[2] = CAN_ERR_PROT_ACTIVE;
-	case CAN_STATE_ERROR_WARNING:	/* fallthrough */

Seriously, for that one, you should fix the compiler. The fall through is not implicit, it is actually quite explicit and the warning is simply wrong.

Also, the gcc documentation says that -Wimplicit-fallthrough=3 recognizes /* fallthrough */ as a proper fall through comment (and I tested with gcc 8.2).

The matching regex is [ \t.!]*([Ee]lse,? |[Ii]ntentional(ly)? )? fall(s | |-)?thr(ough|u)[ \t.!]*(-[^\n\r]*)?

Signature · 8 lines
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#4 lore raw
Quoted 39 lines · Alexandre Belloni

Hi,

Quoted 36 lines · Gustavo A. R. Silva
Quoted 33 lines · On 1/30/19 2:11 AM, [email protected] wrote:
Quoted 31 lines · Gustavo A. R. Silva

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

This patch fixes the following warnings:

drivers/net/can/peak_canfd/peak_pciefd_main.c:668:3: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/spi/mcp251x.c:875:7: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/usb/peak_usb/pcan_usb.c:422:6: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/at91_can.c:895:6: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/at91_can.c:953:15: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/usb/peak_usb/pcan_usb.c: In function ‘pcan_usb_decode_error’:
drivers/net/can/usb/peak_usb/pcan_usb.c:422:6: warning: this statement may fall through [-Wimplicit-fallthrough=]

    if (n & PCAN_USB_ERROR_BUS_LIGHT) {
       ^
drivers/net/can/usb/peak_usb/pcan_usb.c:428:2: note: here
   case CAN_STATE_ERROR_WARNING:
   ^~~~

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

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

Notice that in some cases spelling mistakes were fixed. In other cases, the /* fall through */ comment is placed at the bottom of the case statement, which is what GCC is expecting to find.

---
  drivers/net/can/at91_can.c                    | 6 ++++--
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines

For this one:

Thanks, Nicolas.

I though I had a déjà vu but you actually sent the at91 part twice.

It wasn't intentional.

Quoted 26 lines
Quoted 26 lines

Dave:

I wonder if you can take this patch.

Thanks
--
Gustavo

Quoted 18 lines
Quoted 18 lines
  drivers/net/can/peak_canfd/peak_pciefd_main.c | 2 +-
  drivers/net/can/spi/mcp251x.c                 | 3 ++-
  drivers/net/can/usb/peak_usb/pcan_usb.c       | 2 +-
  4 files changed, 8 insertions(+), 5 deletions(-)
drivers/net/can/at91_can.c +2 -1
index d98c69045b17..1718c20f9c99 100644
@@ -902,7 +902,8 @@ static void at91_irq_err_state(struct net_device *dev,
  				CAN_ERR_CRTL_TX_WARNING :
  				CAN_ERR_CRTL_RX_WARNING;
  		}
-	case CAN_STATE_ERROR_WARNING:	/* fallthrough */
+		/* fall through */
+	case CAN_STATE_ERROR_WARNING:
  		/*
  		 * from: ERROR_ACTIVE, ERROR_WARNING
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines

drivers/net/can/at91_can.c static void at91_irq_err_state(struct net_device *dev, · line 954

Quoted 6 lines
drivers/net/can/at91_can.c +0 -1
  		 * to  : ERROR_PASSIVE, BUS_OFF
@@ -951,7 +952,8 @@ static void at91_irq_err_state(struct net_device *dev,
  		netdev_dbg(dev, "Error Active\n");
  		cf->can_id |= CAN_ERR_PROT;
  		cf->data[2] = CAN_ERR_PROT_ACTIVE;
-	case CAN_STATE_ERROR_WARNING:	/* fallthrough */

Seriously, for that one, you should fix the compiler. The fall through

I'll pass your feedback on to the GCC guys.

Quoted 7 lines

is not implicit, it is actually quite explicit and the warning is simply wrong.

Also, the gcc documentation says that -Wimplicit-fallthrough=3 recognizes /* fallthrough */ as a proper fall through comment (and I tested with gcc 8.2).

Yeah. But that's not the relevant change in this case. Notice that the comment was moved to the very bottom of the previous case.

Thanks
--
Gustavo

#5 lore raw
Quoted 94 lines · Gustavo A. R. Silva
Quoted 39 lines · Alexandre Belloni

Hi,

Quoted 36 lines · Gustavo A. R. Silva
Quoted 33 lines · On 1/30/19 2:11 AM, [email protected] wrote:
Quoted 31 lines · Gustavo A. R. Silva

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

This patch fixes the following warnings:

drivers/net/can/peak_canfd/peak_pciefd_main.c:668:3: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/spi/mcp251x.c:875:7: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/usb/peak_usb/pcan_usb.c:422:6: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/at91_can.c:895:6: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/at91_can.c:953:15: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/usb/peak_usb/pcan_usb.c: In function ‘pcan_usb_decode_error’:
drivers/net/can/usb/peak_usb/pcan_usb.c:422:6: warning: this statement may fall through [-Wimplicit-fallthrough=]

    if (n & PCAN_USB_ERROR_BUS_LIGHT) {
       ^
drivers/net/can/usb/peak_usb/pcan_usb.c:428:2: note: here
   case CAN_STATE_ERROR_WARNING:
   ^~~~

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

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

Notice that in some cases spelling mistakes were fixed. In other cases, the /* fall through */ comment is placed at the bottom of the case statement, which is what GCC is expecting to find.

---
  drivers/net/can/at91_can.c                    | 6 ++++--
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines

For this one:

Thanks, Nicolas.

I though I had a déjà vu but you actually sent the at91 part twice.

It wasn't intentional.

Quoted 26 lines
Quoted 26 lines

Dave:

I wonder if you can take this patch.

Thanks
--
Gustavo

Quoted 18 lines
Quoted 18 lines
  drivers/net/can/peak_canfd/peak_pciefd_main.c | 2 +-
  drivers/net/can/spi/mcp251x.c                 | 3 ++-
  drivers/net/can/usb/peak_usb/pcan_usb.c       | 2 +-
  4 files changed, 8 insertions(+), 5 deletions(-)
drivers/net/can/at91_can.c +2 -1
index d98c69045b17..1718c20f9c99 100644
@@ -902,7 +902,8 @@ static void at91_irq_err_state(struct net_device *dev,
  				CAN_ERR_CRTL_TX_WARNING :
  				CAN_ERR_CRTL_RX_WARNING;
  		}
-	case CAN_STATE_ERROR_WARNING:	/* fallthrough */
+		/* fall through */
+	case CAN_STATE_ERROR_WARNING:
  		/*
  		 * from: ERROR_ACTIVE, ERROR_WARNING
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines

drivers/net/can/at91_can.c static void at91_irq_err_state(struct net_device *dev, · line 954

Quoted 6 lines
drivers/net/can/at91_can.c +0 -1
  		 * to  : ERROR_PASSIVE, BUS_OFF
@@ -951,7 +952,8 @@ static void at91_irq_err_state(struct net_device *dev,
  		netdev_dbg(dev, "Error Active\n");
  		cf->can_id |= CAN_ERR_PROT;
  		cf->data[2] = CAN_ERR_PROT_ACTIVE;
-	case CAN_STATE_ERROR_WARNING:	/* fallthrough */

Seriously, for that one, you should fix the compiler. The fall through

I'll pass your feedback on to the GCC guys.

Quoted 3 lines

is not implicit, it is actually quite explicit and the warning is simply wrong.

Quoted 8 lines
Quoted 4 lines

Also, the gcc documentation says that -Wimplicit-fallthrough=3 recognizes /* fallthrough */ as a proper fall through comment (and I tested with gcc 8.2).

Yeah. But that's not the relevant change in this case. Notice that the comment was moved to the very bottom of the previous case.

Yes and it doesn't matter for gcc, I tested with gcc 8.2.

Signature · 3 lines
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#6 lore raw
Quoted 100 lines · Alexandre Belloni
Quoted 99 lines · Gustavo A. R. Silva
Quoted 39 lines · Alexandre Belloni

Hi,

Quoted 36 lines · Gustavo A. R. Silva
Quoted 33 lines · On 1/30/19 2:11 AM, [email protected] wrote:
Quoted 31 lines · Gustavo A. R. Silva

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

This patch fixes the following warnings:

drivers/net/can/peak_canfd/peak_pciefd_main.c:668:3: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/spi/mcp251x.c:875:7: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/usb/peak_usb/pcan_usb.c:422:6: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/at91_can.c:895:6: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/at91_can.c:953:15: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/usb/peak_usb/pcan_usb.c: In function ‘pcan_usb_decode_error’:
drivers/net/can/usb/peak_usb/pcan_usb.c:422:6: warning: this statement may fall through [-Wimplicit-fallthrough=]

    if (n & PCAN_USB_ERROR_BUS_LIGHT) {
       ^
drivers/net/can/usb/peak_usb/pcan_usb.c:428:2: note: here
   case CAN_STATE_ERROR_WARNING:
   ^~~~

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

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

Notice that in some cases spelling mistakes were fixed. In other cases, the /* fall through */ comment is placed at the bottom of the case statement, which is what GCC is expecting to find.

---
  drivers/net/can/at91_can.c                    | 6 ++++--
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines

For this one:

Thanks, Nicolas.

I though I had a déjà vu but you actually sent the at91 part twice.

It wasn't intentional.

Quoted 26 lines
Quoted 26 lines

Dave:

I wonder if you can take this patch.

Thanks
--
Gustavo

Quoted 18 lines
Quoted 18 lines
  drivers/net/can/peak_canfd/peak_pciefd_main.c | 2 +-
  drivers/net/can/spi/mcp251x.c                 | 3 ++-
  drivers/net/can/usb/peak_usb/pcan_usb.c       | 2 +-
  4 files changed, 8 insertions(+), 5 deletions(-)
drivers/net/can/at91_can.c +2 -1
index d98c69045b17..1718c20f9c99 100644
@@ -902,7 +902,8 @@ static void at91_irq_err_state(struct net_device *dev,
  				CAN_ERR_CRTL_TX_WARNING :
  				CAN_ERR_CRTL_RX_WARNING;
  		}
-	case CAN_STATE_ERROR_WARNING:	/* fallthrough */
+		/* fall through */
+	case CAN_STATE_ERROR_WARNING:
  		/*
  		 * from: ERROR_ACTIVE, ERROR_WARNING
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines

drivers/net/can/at91_can.c static void at91_irq_err_state(struct net_device *dev, · line 954

Quoted 6 lines
drivers/net/can/at91_can.c +0 -1
  		 * to  : ERROR_PASSIVE, BUS_OFF
@@ -951,7 +952,8 @@ static void at91_irq_err_state(struct net_device *dev,
  		netdev_dbg(dev, "Error Active\n");
  		cf->can_id |= CAN_ERR_PROT;
  		cf->data[2] = CAN_ERR_PROT_ACTIVE;
-	case CAN_STATE_ERROR_WARNING:	/* fallthrough */

Seriously, for that one, you should fix the compiler. The fall through

I'll pass your feedback on to the GCC guys.

Quoted 7 lines

is not implicit, it is actually quite explicit and the warning is simply wrong.

Also, the gcc documentation says that -Wimplicit-fallthrough=3 recognizes /* fallthrough */ as a proper fall through comment (and I tested with gcc 8.2).

Quoted 6 lines
Quoted 3 lines

Yeah. But that's not the relevant change in this case. Notice that the comment was moved to the very bottom of the previous case.

Yes and it doesn't matter for gcc, I tested with gcc 8.2.

Yeah. But, again, you are missing the relevant part of the patch.

#7 lore raw
Quoted 5 lines · Gustavo A. R. Silva
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

Also, the gcc documentation says that -Wimplicit-fallthrough=3 recognizes /* fallthrough */ as a proper fall through comment (and I tested with gcc 8.2).

Quoted 9 lines
Quoted 6 lines
Quoted 3 lines

Yeah. But that's not the relevant change in this case. Notice that the comment was moved to the very bottom of the previous case.

Yes and it doesn't matter for gcc, I tested with gcc 8.2.

Yeah. But, again, you are missing the relevant part of the patch.

Right, I misread the patch and though you were moving the comment after the case statement.

Signature · 3 lines
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#8 lore raw
In reply to Gustavo A. R. Silva

Hi,

Friendly ping:

Dave, I wonder if you can take this.

Thanks
--
Gustavo

Quoted 122 lines · Gustavo A. R. Silva
Quoted 29 lines · On 1/30/19 2:11 AM, [email protected] wrote:
Quoted 28 lines · Gustavo A. R. Silva

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

This patch fixes the following warnings:

drivers/net/can/peak_canfd/peak_pciefd_main.c:668:3: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/spi/mcp251x.c:875:7: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/usb/peak_usb/pcan_usb.c:422:6: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/at91_can.c:895:6: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/at91_can.c:953:15: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/usb/peak_usb/pcan_usb.c: In function ‘pcan_usb_decode_error’:
drivers/net/can/usb/peak_usb/pcan_usb.c:422:6: warning: this statement may fall through [-Wimplicit-fallthrough=]

    if (n & PCAN_USB_ERROR_BUS_LIGHT) {
       ^
drivers/net/can/usb/peak_usb/pcan_usb.c:428:2: note: here
   case CAN_STATE_ERROR_WARNING:
   ^~~~

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

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

Notice that in some cases spelling mistakes were fixed. In other cases, the /* fall through */ comment is placed at the bottom of the case statement, which is what GCC is expecting to find.

Quoted 7 lines
Quoted 3 lines
---
  drivers/net/can/at91_can.c                    | 6 ++++--

For this one:

Thanks, Nicolas.

Dave:

I wonder if you can take this patch.

Thanks
--
Gustavo

Quoted 72 lines
Quoted 70 lines
  drivers/net/can/peak_canfd/peak_pciefd_main.c | 2 +-
  drivers/net/can/spi/mcp251x.c                 | 3 ++-
  drivers/net/can/usb/peak_usb/pcan_usb.c       | 2 +-
  4 files changed, 8 insertions(+), 5 deletions(-)
drivers/net/can/at91_can.c +4 -2
index d98c69045b17..1718c20f9c99 100644
@@ -902,7 +902,8 @@ static void at91_irq_err_state(struct net_device *dev,
  				CAN_ERR_CRTL_TX_WARNING :
  				CAN_ERR_CRTL_RX_WARNING;
  		}
-	case CAN_STATE_ERROR_WARNING:	/* fallthrough */
+		/* fall through */
+	case CAN_STATE_ERROR_WARNING:
  		/*
  		 * from: ERROR_ACTIVE, ERROR_WARNING
  		 * to  : ERROR_PASSIVE, BUS_OFF
@@ -951,7 +952,8 @@ static void at91_irq_err_state(struct net_device *dev,
  		netdev_dbg(dev, "Error Active\n");
  		cf->can_id |= CAN_ERR_PROT;
  		cf->data[2] = CAN_ERR_PROT_ACTIVE;
-	case CAN_STATE_ERROR_WARNING:	/* fallthrough */
+		/* fall through */
+	case CAN_STATE_ERROR_WARNING:
  		reg_idr = AT91_IRQ_ERRA | AT91_IRQ_WARN | AT91_IRQ_BOFF;
  		reg_ier = AT91_IRQ_ERRP;
  		break;
drivers/net/can/peak_canfd/peak_pciefd_main.c +1 -1
index c458d5fdc8d3..e4f4d65a76b4 100644
@@ -668,7 +668,7 @@ static int pciefd_can_probe(struct pciefd_board *pciefd)
  		pciefd_can_writereg(priv, CANFD_CLK_SEL_80MHZ,
  				    PCIEFD_REG_CAN_CLK_SEL);
 
-		/* fallthough */
+		/* fall through */
  	case CANFD_CLK_SEL_80MHZ:
  		priv->ucan.can.clock.freq = 80 * 1000 * 1000;
  		break;
drivers/net/can/spi/mcp251x.c +2 -1
index e90817608645..17257c73c302 100644
@@ -875,7 +875,8 @@ static irqreturn_t mcp251x_can_ist(int irq, void *dev_id)
  			if (new_state >= CAN_STATE_ERROR_WARNING &&
  			    new_state <= CAN_STATE_BUS_OFF)
  				priv->can.can_stats.error_warning++;
-		case CAN_STATE_ERROR_WARNING:	/* fallthrough */
+			/* fall through */
+		case CAN_STATE_ERROR_WARNING:
  			if (new_state >= CAN_STATE_ERROR_PASSIVE &&
  			    new_state <= CAN_STATE_BUS_OFF)
  				priv->can.can_stats.error_passive++;
drivers/net/can/usb/peak_usb/pcan_usb.c +1 -1
index 13238a72a338..eca785532b6b 100644
@@ -423,7 +423,7 @@ static int pcan_usb_decode_error(struct pcan_usb_msg_context *mc, u8 n,
  			new_state = CAN_STATE_ERROR_WARNING;
  			break;
  		}
-		/* else: fall through */
+		/* fall through */
 
  	case CAN_STATE_ERROR_WARNING:
  		if (n & PCAN_USB_ERROR_BUS_HEAVY) {
#9 lore raw
In reply to Gustavo A. R. Silva
Quoted 23 lines · Gustavo A. R. Silva

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

This patch fixes the following warnings:

drivers/net/can/peak_canfd/peak_pciefd_main.c:668:3: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/spi/mcp251x.c:875:7: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/usb/peak_usb/pcan_usb.c:422:6: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/at91_can.c:895:6: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/at91_can.c:953:15: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/usb/peak_usb/pcan_usb.c: In function ‘pcan_usb_decode_error’:
drivers/net/can/usb/peak_usb/pcan_usb.c:422:6: warning: this statement may fall through [-Wimplicit-fallthrough=]

   if (n & PCAN_USB_ERROR_BUS_LIGHT) {
      ^

drivers/net/can/usb/peak_usb/pcan_usb.c:428:2: note: here
case CAN_STATE_ERROR_WARNING:
^~~~

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

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

Quoted 6 lines

Notice that in some cases spelling mistakes were fixed. In other cases, the /* fall through */ comment is placed at the bottom of the case statement, which is what GCC is expecting to find.

Added to linux-can-next.

Tnx
Marc

Signature · 9 lines
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#10 lore raw
Quoted 24 lines · Marc Kleine-Budde
Quoted 23 lines · Gustavo A. R. Silva

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

This patch fixes the following warnings:

drivers/net/can/peak_canfd/peak_pciefd_main.c:668:3: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/spi/mcp251x.c:875:7: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/usb/peak_usb/pcan_usb.c:422:6: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/at91_can.c:895:6: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/at91_can.c:953:15: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/usb/peak_usb/pcan_usb.c: In function ‘pcan_usb_decode_error’:
drivers/net/can/usb/peak_usb/pcan_usb.c:422:6: warning: this statement may fall through [-Wimplicit-fallthrough=]

   if (n & PCAN_USB_ERROR_BUS_LIGHT) {
      ^

drivers/net/can/usb/peak_usb/pcan_usb.c:428:2: note: here
case CAN_STATE_ERROR_WARNING:
^~~~

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

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

Quoted 9 lines
Quoted 6 lines

Notice that in some cases spelling mistakes were fixed. In other cases, the /* fall through */ comment is placed at the bottom of the case statement, which is what GCC is expecting to find.

Added to linux-can-next.

Thanks, Marc.

--
Gustavo

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#11 lore raw
In reply to Marc Kleine-Budde

Hi Marc,

Quoted 24 lines · Marc Kleine-Budde
Quoted 23 lines · Gustavo A. R. Silva

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

This patch fixes the following warnings:

drivers/net/can/peak_canfd/peak_pciefd_main.c:668:3: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/spi/mcp251x.c:875:7: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/usb/peak_usb/pcan_usb.c:422:6: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/at91_can.c:895:6: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/at91_can.c:953:15: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/usb/peak_usb/pcan_usb.c: In function ‘pcan_usb_decode_error’:
drivers/net/can/usb/peak_usb/pcan_usb.c:422:6: warning: this statement may fall through [-Wimplicit-fallthrough=]

   if (n & PCAN_USB_ERROR_BUS_LIGHT) {
      ^

drivers/net/can/usb/peak_usb/pcan_usb.c:428:2: note: here
case CAN_STATE_ERROR_WARNING:
^~~~

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

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

Quoted 9 lines
Quoted 6 lines

Notice that in some cases spelling mistakes were fixed. In other cases, the /* fall through */ comment is placed at the bottom of the case statement, which is what GCC is expecting to find.

Added to linux-can-next.

I wonder if there is any chance for this patch to be queued up for 5.2-rc1.

Thanks

#12 lore raw

Hi Marc,

This patch has been in linux-can-next since February, but for some reason it hasn't been merged into net yet, not even once into linux-next.

I can add it to my tree if you don't mind.

Thanks
--
Gustavo

Quoted 43 lines · Gustavo A. R. Silva

Hi Marc,

Quoted 24 lines · Marc Kleine-Budde
Quoted 23 lines · Gustavo A. R. Silva

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

This patch fixes the following warnings:

drivers/net/can/peak_canfd/peak_pciefd_main.c:668:3: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/spi/mcp251x.c:875:7: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/usb/peak_usb/pcan_usb.c:422:6: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/at91_can.c:895:6: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/at91_can.c:953:15: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/net/can/usb/peak_usb/pcan_usb.c: In function ‘pcan_usb_decode_error’:
drivers/net/can/usb/peak_usb/pcan_usb.c:422:6: warning: this statement may fall through [-Wimplicit-fallthrough=]

   if (n & PCAN_USB_ERROR_BUS_LIGHT) {
      ^

drivers/net/can/usb/peak_usb/pcan_usb.c:428:2: note: here
case CAN_STATE_ERROR_WARNING:
^~~~

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

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

Quoted 9 lines
Quoted 6 lines

Notice that in some cases spelling mistakes were fixed. In other cases, the /* fall through */ comment is placed at the bottom of the case statement, which is what GCC is expecting to find.

Added to linux-can-next.

I wonder if there is any chance for this patch to be queued up for 5.2-rc1.

Thanks
--
Gustavo