Skip to contentSkip to conversation

mark expected switch fall-throughs

PATCH In review Gustavo A. R. Silva 3 participants 33 messages Oct 12, 2017 – Oct 23, 2017

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

cover mark expected switch fall-throughs

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

In Kees Cook words:
"This is an unfortunate omission in the C language, and thankfully both gcc and clang have stepped up to solve this the same way static analyzers have solved it. It does both document the intention for humans and provide a way for analyzers to report issues.

Having the compiler help us not make mistakes is quite handy."

In some cases there were "no break" or "fall thru" comments already in place. So I replaced them with proper "fall through" comments, which is what GCC is expecting to find.

For the rest of the cases, please double check if the actual intention of the code is to fall through.

Thanks!

Gustavo A. R. Silva (20):
staging: ks7010: ks_wlan_net: mark expected switch fall-throughs
staging: lustre: lnet: socklnd: mark expected switch fall-through
staging: rtl8192e: mark expected switch fall-through
staging: rtl8723bs: rtw_mlme_ext: mark expected switch fall-through
staging: lustre: lnet: net_fault: mark expected switch fall-through
staging: comedi: s526: mark expected switch fall-through
staging: rtl8188eu: usb_halinit: mark expected switch fall-through
staging: vc04_services: vchiq_core: mark expected switch fall-through
staging: vt6656: card: mark expected switch fall-throughs
staging: rtl8188eu: usb_ops_linux: mark expected switch fall-through
staging: r8822be: mark expected switch fall-throughs
staging: lustre: lnet: selftest: mark expected switch fall-through
staging: rtlwifi: halmac: mark expected switch fall-through
staging: lustre: lnet: selftest: mark expected switch fall-throughs
staging: lustre: llite: mark expected switch fall-through
staging: lustre: lprocfs: mark expected switch fall-throughs
staging: lustre: ldlm: mark expected switch fall-through
staging: lustre: osc: mark expected switch fall-through
staging: lustre: ptlrpc: mark expected switch fall-throughs
staging: lustre: rpc: mark expected switch fall-throughs

 drivers/staging/comedi/drivers/s526.c                       |  5 ++---
 drivers/staging/ks7010/ks_wlan_net.c                        | 10 ++++++++++
 drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c         |  2 +-
 drivers/staging/lustre/lnet/lnet/net_fault.c                |  1 +
 drivers/staging/lustre/lnet/selftest/conctl.c               |  1 +
 drivers/staging/lustre/lnet/selftest/module.c               |  5 ++++-
 drivers/staging/lustre/lnet/selftest/rpc.c                  | 13 +++++++++----
 drivers/staging/lustre/lustre/ldlm/ldlm_request.c           |  1 +
 drivers/staging/lustre/lustre/llite/namei.c                 |  4 +++-
 drivers/staging/lustre/lustre/obdclass/lprocfs_status.c     |  4 ++++
 drivers/staging/lustre/lustre/osc/osc_cache.c               |  1 +
 drivers/staging/lustre/lustre/ptlrpc/pack_generic.c         |  6 +++---
 drivers/staging/rtl8188eu/hal/usb_halinit.c                 |  1 +
 drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c            |  1 +
 drivers/staging/rtl8192e/rtllib_wx.c                        |  3 +--
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c               |  2 +-
 .../staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx.c    |  2 ++
 drivers/staging/rtlwifi/halmac/rtl_halmac.c                 |  2 +-
 .../staging/vc04_services/interface/vchiq_arm/vchiq_core.c  |  3 +--
 drivers/staging/vt6656/card.c                               |  2 ++
 20 files changed, 50 insertions(+), 19 deletions(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/20 staging: ks7010: ks_wlan_net: mark expected switch fall-throughs

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

Addresses-Coverity-ID: 1364489

---
 drivers/staging/ks7010/ks_wlan_net.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/staging/ks7010/ks_wlan_net.c +10 -0
index 0f9348b..b82b515 100644
@@ -473,13 +473,16 @@ static int ks_wlan_set_rate(struct net_device *dev,
 					priv->reg.rate_set.body[3] =
 					    TX_RATE_11M;
 					i++;
+					/* fall through */
 				case 5500000:
 					priv->reg.rate_set.body[2] = TX_RATE_5M;
 					i++;
+					/* fall through */
 				case 2000000:
 					priv->reg.rate_set.body[1] =
 					    TX_RATE_2M | BASIC_RATE;
 					i++;
+					/* fall through */
 				case 1000000:
 					priv->reg.rate_set.body[0] =
 					    TX_RATE_1M | BASIC_RATE;
@@ -535,14 +538,17 @@ static int ks_wlan_set_rate(struct net_device *dev,
 					priv->reg.rate_set.body[11] =
 					    TX_RATE_54M;
 					i++;
+					/* fall through */
 				case 48000000:
 					priv->reg.rate_set.body[10] =
 					    TX_RATE_48M;
 					i++;
+					/* fall through */
 				case 36000000:
 					priv->reg.rate_set.body[9] =
 					    TX_RATE_36M;
 					i++;
+					/* fall through */
 				case 24000000:
 				case 18000000:
 				case 12000000:
@@ -619,14 +625,17 @@ static int ks_wlan_set_rate(struct net_device *dev,
 						    TX_RATE_6M | BASIC_RATE;
 						i++;
 					}
+					/* fall through */
 				case 5500000:
 					priv->reg.rate_set.body[2] =
 					    TX_RATE_5M | BASIC_RATE;
 					i++;
+					/* fall through */
 				case 2000000:
 					priv->reg.rate_set.body[1] =
 					    TX_RATE_2M | BASIC_RATE;
 					i++;
+					/* fall through */
 				case 1000000:
 					priv->reg.rate_set.body[0] =
 					    TX_RATE_1M | BASIC_RATE;
@@ -2010,6 +2019,7 @@ static int ks_wlan_set_mlme(struct net_device *dev,
 	case IW_MLME_DEAUTH:
 		if (mlme->reason_code == WLAN_REASON_MIC_FAILURE)
 			return 0;
+		/* fall through */
 	case IW_MLME_DISASSOC:
 		mode = 1;
 		return ks_wlan_set_stop_request(dev, NULL, &mode, NULL);
Signature · 1 line
2.7.4
#2 lore raw

PATCH 2/20 staging: lustre: lnet: socklnd: mark expected switch fall-through

In reply to Gustavo A. R. Silva

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

---
 drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c +1 -1
index d0ee58d..7b014ca 100644
@@ -2308,7 +2308,7 @@ ksocknal_base_shutdown(void)
 	switch (ksocknal_data.ksnd_init) {
 	default:
 		LASSERT(0);
-
+		/* fall through */
 	case SOCKNAL_INIT_ALL:
 	case SOCKNAL_INIT_DATA:
 		LASSERT(ksocknal_data.ksnd_peers);
Signature · 1 line
2.7.4
Reviewed-by on v1 2/20
#3 lore raw

Re: [PATCH 02/20] staging: lustre: lnet: socklnd: mark expected switch fall-through

Quoted 5 lines · Gustavo A. R. Silva

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

This isn't strictly necessary, since LASSERT() never returns, but not harmful either.

Quoted 20 lines

---
drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c +1 -1
index d0ee58d..7b014ca 100644
@@ -2308,7 +2308,7 @@ ksocknal_base_shutdown(void)
 	switch (ksocknal_data.ksnd_init) {
 	default:
 		LASSERT(0);
-
+		/* fall through */
 	case SOCKNAL_INIT_ALL:
 	case SOCKNAL_INIT_DATA:
 		LASSERT(ksocknal_data.ksnd_peers);
Signature · 1 line
2.7.4

Cheers, Andreas
--
Andreas Dilger
Lustre Principal Architect
Intel Corporation

#4 lore raw

PATCH 3/20 staging: rtl8192e: mark expected switch fall-through

In reply to Gustavo A. R. Silva

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

---
 drivers/staging/rtl8192e/rtllib_wx.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/rtl8192e/rtllib_wx.c +1 -2
index f7eba01..03fbff0 100644
@@ -694,8 +694,7 @@ int rtllib_wx_set_mlme(struct rtllib_device *ieee,
 	switch (mlme->cmd) {
 	case IW_MLME_DEAUTH:
 		deauth = true;
-		/* leave break out intentionly */
-
+		/* fall through */
 	case IW_MLME_DISASSOC:
 		if (deauth)
 			netdev_info(ieee->dev, "disauth packet !\n");
Signature · 1 line
2.7.4
#5 lore raw

PATCH 4/20 staging: rtl8723bs: rtw_mlme_ext: mark expected switch fall-through

In reply to Gustavo A. R. Silva

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

---
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +1 -1
index 355ce9b..66127d1 100644
@@ -584,7 +584,7 @@ void mgt_dispatcher(struct adapter *padapter, union recv_frame *precv_frame)
 			ptable->func = &OnAuth;
 		else
 			ptable->func = &OnAuthClient;
-		/* pass through */
+		/* fall through */
 	case WIFI_ASSOCREQ:
 	case WIFI_REASSOCREQ:
 		_mgt_dispatcher(padapter, ptable, precv_frame);
Signature · 1 line
2.7.4
#6 lore raw

PATCH 5/20 staging: lustre: lnet: net_fault: mark expected switch fall-through

In reply to Gustavo A. R. Silva

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

---
 drivers/staging/lustre/lnet/lnet/net_fault.c | 1 +
 1 file changed, 1 insertion(+)
drivers/staging/lustre/lnet/lnet/net_fault.c +1 -0
index 03f3d18..7391e16 100644
@@ -629,6 +629,7 @@ delayed_msg_process(struct list_head *msg_list, bool drop)
 			case LNET_CREDIT_OK:
 				lnet_ni_recv(ni, msg->msg_private, msg, 0,
 					     0, msg->msg_len, msg->msg_len);
+				/* fall through */
 			case LNET_CREDIT_WAIT:
 				continue;
 			default: /* failures */
Signature · 1 line
2.7.4
Reviewed-by on v1 5/20
#7 lore raw

Re: [PATCH 05/20] staging: lustre: lnet: net_fault: mark expected switch fall-through

Quoted 5 lines · Gustavo A. R. Silva

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

This could also just be "continue;", but doesn't appear harmful.

Quoted 19 lines

---
drivers/staging/lustre/lnet/lnet/net_fault.c | 1 +

1 file changed, 1 insertion(+)
drivers/staging/lustre/lnet/lnet/net_fault.c +1 -0
index 03f3d18..7391e16 100644
@@ -629,6 +629,7 @@ delayed_msg_process(struct list_head *msg_list, bool drop)
 			case LNET_CREDIT_OK:
 				lnet_ni_recv(ni, msg->msg_private, msg, 0,
 					     0, msg->msg_len, msg->msg_len);
+				/* fall through */
 			case LNET_CREDIT_WAIT:
 				continue;
 			default: /* failures */
Signature · 1 line
2.7.4

Cheers, Andreas
--
Andreas Dilger
Lustre Principal Architect
Intel Corporation

#8 lore raw

PATCH 6/20 staging: comedi: s526: mark expected switch fall-through

In reply to Gustavo A. R. Silva

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

---
 drivers/staging/comedi/drivers/s526.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/staging/comedi/drivers/s526.c +2 -3
index c80527d..e620f6a 100644
@@ -408,9 +408,8 @@ static int s526_gpct_winsn(struct comedi_device *dev,
 		 */
 		if ((data[1] <= data[0]) || !data[0])
 			return -EINVAL;
-
-		/* Fall thru to write the PULSE_WIDTH */
-
+		/* to write the PULSE_WIDTH */
+		/* fall through */
 	case INSN_CONFIG_GPCT_QUADRATURE_ENCODER:
 	case INSN_CONFIG_GPCT_SINGLE_PULSE_GENERATOR:
 		s526_gpct_write(dev, chan, data[0]);
Signature · 1 line
2.7.4
#9 lore raw

PATCH 7/20 staging: rtl8188eu: usb_halinit: mark expected switch fall-through

In reply to Gustavo A. R. Silva

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

Addresses-Coverity-ID: 1373894

---
 drivers/staging/rtl8188eu/hal/usb_halinit.c | 1 +
 1 file changed, 1 insertion(+)
drivers/staging/rtl8188eu/hal/usb_halinit.c +1 -0
index 674ac53..17967c9 100644
@@ -1745,6 +1745,7 @@ void rtw_hal_get_hwreg(struct adapter *Adapter, u8 variable, u8 *val)
 	switch (variable) {
 	case HW_VAR_BASIC_RATE:
 		*((u16 *)(val)) = Adapter->HalData->BasicRateSet;
+		/* fall through */
 	case HW_VAR_TXPAUSE:
 		val[0] = usb_read8(Adapter, REG_TXPAUSE);
 		break;
Signature · 1 line
2.7.4
#10 lore raw

PATCH 8/20 staging: vc04_services: vchiq_core: mark expected switch fall-through

In reply to Gustavo A. R. Silva

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

---
 drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +1 -2
index c3bb8e0..ecff92b 100644
@@ -2951,8 +2951,7 @@ vchiq_close_service_internal(VCHIQ_SERVICE_T *service, int close_recvd)
 
 	case VCHIQ_SRVSTATE_OPENSYNC:
 		mutex_lock(&state->sync_mutex);
-		/* Drop through */
-
+		/* fall through */
 	case VCHIQ_SRVSTATE_OPEN:
 		if (state->is_master || close_recvd) {
 			if (!do_abort_bulks(service))
Signature · 1 line
2.7.4
Acked-by on v1 8/20
#11 lore raw

Re: [PATCH 08/20] staging: vc04_services: vchiq_core: mark expected switch fall-through

Quoted 11 lines

"Gustavo A. R. Silva" <[email protected]> hat am 12. Oktober 2017 um 18:16 geschrieben:

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

---
 drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
#12 lore raw

PATCH 9/20 staging: vt6656: card: mark expected switch fall-throughs

In reply to Gustavo A. R. Silva

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

---
 drivers/staging/vt6656/card.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/staging/vt6656/card.c +2 -0
index c61422e..4fd9cd6 100644
@@ -382,11 +382,13 @@ void vnt_update_ifs(struct vnt_private *priv)
 			priv->difs -= 1;
 			break;
 		}
+		/* fall through */
 	case RF_AIROHA7230:
 	case RF_AL2230:
 	case RF_AL2230S:
 		if (priv->bb_type != BB_TYPE_11B)
 			break;
+		/* fall through */
 	case RF_RFMD2959:
 	case RF_VT3226:
 	case RF_VT3342A0:
Signature · 1 line
2.7.4
#13 lore raw

PATCH 10/20 staging: rtl8188eu: usb_ops_linux: mark expected switch fall-through

In reply to Gustavo A. R. Silva

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

Addresses-Coverity-ID: 1077613

---
 drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c | 1 +
 1 file changed, 1 insertion(+)
drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c +1 -0
index 64397b6..7e75030 100644
@@ -407,6 +407,7 @@ static void usb_read_port_complete(struct urb *purb, struct pt_regs *regs)
 		case -ENODEV:
 		case -ESHUTDOWN:
 			adapt->bSurpriseRemoved = true;
+			/* fall through */
 		case -ENOENT:
 			adapt->bDriverStopped = true;
 			RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_read_port_complete:bDriverStopped=true\n"));
Signature · 1 line
2.7.4
#14 lore raw

PATCH 11/20 staging: r8822be: mark expected switch fall-throughs

In reply to Gustavo A. R. Silva

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

---
 drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx.c +2 -0
index edbf6af..448b137 100644
@@ -3391,8 +3391,10 @@ halmac_cfg_txbf_88xx(struct halmac_adapter *halmac_adapter, u8 userid,
 		switch (bw) {
 		case HALMAC_BW_80:
 			temp42C |= BIT_R_TXBF0_80M;
+			/* fall through */
 		case HALMAC_BW_40:
 			temp42C |= BIT_R_TXBF0_40M;
+			/* fall through */
 		case HALMAC_BW_20:
 			temp42C |= BIT_R_TXBF0_20M;
 			break;
Signature · 1 line
2.7.4
#15 lore raw

PATCH 12/20 staging: lustre: lnet: selftest: mark expected switch fall-through

In reply to Gustavo A. R. Silva

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

---
 drivers/staging/lustre/lnet/selftest/conctl.c | 1 +
 1 file changed, 1 insertion(+)
drivers/staging/lustre/lnet/selftest/conctl.c +1 -0
index 9619ecb..551e921 100644
@@ -151,6 +151,7 @@ lst_debug_ioctl(struct lstio_debug_args *args)
 
 	case LST_OPC_BATCHSRV:
 		client = 0;
+		/* fall through */
 	case LST_OPC_BATCHCLI:
 		if (!name)
 			goto out;
Signature · 1 line
2.7.4
Reviewed-by on v1 12/20
#16 lore raw

Re: [PATCH 12/20] staging: lustre: lnet: selftest: mark expected switch fall-through

Quoted 5 lines · Gustavo A. R. Silva

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

Quoted 19 lines

---
drivers/staging/lustre/lnet/selftest/conctl.c | 1 +

1 file changed, 1 insertion(+)
drivers/staging/lustre/lnet/selftest/conctl.c +1 -0
index 9619ecb..551e921 100644
@@ -151,6 +151,7 @@ lst_debug_ioctl(struct lstio_debug_args *args)
 
 	case LST_OPC_BATCHSRV:
 		client = 0;
+		/* fall through */
 	case LST_OPC_BATCHCLI:
 		if (!name)
 			goto out;
Signature · 1 line
2.7.4

Cheers, Andreas
--
Andreas Dilger
Lustre Principal Architect
Intel Corporation

#17 lore raw

PATCH 13/20 staging: rtlwifi: halmac: mark expected switch fall-through

In reply to Gustavo A. R. Silva

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

---
 drivers/staging/rtlwifi/halmac/rtl_halmac.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtlwifi/halmac/rtl_halmac.c +1 -1
index 6448a8b..66f0a6d 100644
@@ -617,7 +617,7 @@ static int _send_general_info(struct rtl_priv *rtlpriv)
 		RT_TRACE(rtlpriv, COMP_HALMAC, DBG_WARNING,
 			 "%s: halmac_send_general_info() fail because fw not dl!\n",
 			 __func__);
-	/* fallthrough here */
+	/* fall through */
 	default:
 		return -1;
 	}
Signature · 1 line
2.7.4
#18 lore raw

PATCH 14/20 staging: lustre: lnet: selftest: mark expected switch fall-throughs

In reply to Gustavo A. R. Silva

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

---
 drivers/staging/lustre/lnet/selftest/module.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/staging/lustre/lnet/selftest/module.c +4 -1
index b5d556f..fa1bccc 100644
@@ -57,10 +57,13 @@ lnet_selftest_exit(void)
 	switch (lst_init_step) {
 	case LST_INIT_CONSOLE:
 		lstcon_console_fini();
+		/* fall through */
 	case LST_INIT_FW:
 		sfw_shutdown();
+		/* fall through */
 	case LST_INIT_RPC:
 		srpc_shutdown();
+		/* fall through */
 	case LST_INIT_WI_TEST:
 		for (i = 0;
 		     i < cfs_cpt_number(lnet_cpt_table()); i++) {
@@ -72,7 +75,7 @@ lnet_selftest_exit(void)
 			    sizeof(lst_sched_test[0]) *
 			    cfs_cpt_number(lnet_cpt_table()));
 		lst_sched_test = NULL;
-
+		/* fall through */
 	case LST_INIT_WI_SERIAL:
 		cfs_wi_sched_destroy(lst_sched_serial);
 		lst_sched_serial = NULL;
Signature · 1 line
2.7.4
Reviewed-by on v1 14/20
#19 lore raw

Re: [PATCH 14/20] staging: lustre: lnet: selftest: mark expected switch fall-throughs

Quoted 6 lines · Gustavo A. R. Silva

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

Quoted 34 lines

---
drivers/staging/lustre/lnet/selftest/module.c | 5 ++++-

1 file changed, 4 insertions(+), 1 deletion(-)
drivers/staging/lustre/lnet/selftest/module.c +4 -1
index b5d556f..fa1bccc 100644
@@ -57,10 +57,13 @@ lnet_selftest_exit(void)
 	switch (lst_init_step) {
 	case LST_INIT_CONSOLE:
 		lstcon_console_fini();
+		/* fall through */
 	case LST_INIT_FW:
 		sfw_shutdown();
+		/* fall through */
 	case LST_INIT_RPC:
 		srpc_shutdown();
+		/* fall through */
 	case LST_INIT_WI_TEST:
 		for (i = 0;
 		     i < cfs_cpt_number(lnet_cpt_table()); i++) {
@@ -72,7 +75,7 @@ lnet_selftest_exit(void)
 			    sizeof(lst_sched_test[0]) *
 			    cfs_cpt_number(lnet_cpt_table()));
 		lst_sched_test = NULL;
-
+		/* fall through */
 	case LST_INIT_WI_SERIAL:
 		cfs_wi_sched_destroy(lst_sched_serial);
 		lst_sched_serial = NULL;
Signature · 1 line
2.7.4

Cheers, Andreas
--
Andreas Dilger
Lustre Principal Architect
Intel Corporation

#20 lore raw

PATCH 15/20 staging: lustre: llite: mark expected switch fall-through

In reply to Gustavo A. R. Silva

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

---
 drivers/staging/lustre/lustre/llite/namei.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/staging/lustre/lustre/llite/namei.c +3 -1
index 5cc2b32..55e0d03 100644
@@ -949,7 +949,9 @@ static int ll_mknod(struct inode *dir, struct dentry *dchild,
 
 	switch (mode & S_IFMT) {
 	case 0:
-		mode |= S_IFREG; /* for mode = 0 case, fallthrough */
+		mode |= S_IFREG;
+		/* for mode = 0 case */
+		/* fall through */
 	case S_IFREG:
 	case S_IFCHR:
 	case S_IFBLK:
Signature · 1 line
2.7.4
Reviewed-by on v1 15/20
#21 lore raw

Re: [PATCH 15/20] staging: lustre: llite: mark expected switch fall-through

Quoted 7 lines · Gustavo A. R. Silva

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

Not sure why you moved the "for mode = 0" comment to a separate line? Not the end of the world though.

Quoted 22 lines

---
drivers/staging/lustre/lustre/llite/namei.c | 4 +++-

1 file changed, 3 insertions(+), 1 deletion(-)
drivers/staging/lustre/lustre/llite/namei.c +3 -1
index 5cc2b32..55e0d03 100644
@@ -949,7 +949,9 @@ static int ll_mknod(struct inode *dir, struct dentry *dchild,
 
 	switch (mode & S_IFMT) {
 	case 0:
-		mode |= S_IFREG; /* for mode = 0 case, fallthrough */
+		mode |= S_IFREG;
+		/* for mode = 0 case */
+		/* fall through */
 	case S_IFREG:
 	case S_IFCHR:
 	case S_IFBLK:
Signature · 1 line
2.7.4

Cheers, Andreas
--
Andreas Dilger
Lustre Principal Architect
Intel Corporation

#22 lore raw

PATCH 16/20 staging: lustre: lprocfs: mark expected switch fall-throughs

In reply to Gustavo A. R. Silva

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

Addresses-Coverity-ID: 1271166
Addresses-Coverity-ID: 1271167
Addresses-Coverity-ID: 1271168
Addresses-Coverity-ID: 1271169

---
 drivers/staging/lustre/lustre/obdclass/lprocfs_status.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +4 -0
index e79485b..4ec582f 100644
@@ -1507,12 +1507,16 @@ int lprocfs_write_frac_u64_helper(const char __user *buffer,
 		switch (tolower(*end)) {
 		case 'p':
 			units <<= 10;
+			/* fall through */
 		case 't':
 			units <<= 10;
+			/* fall through */
 		case 'g':
 			units <<= 10;
+			/* fall through */
 		case 'm':
 			units <<= 10;
+			/* fall through */
 		case 'k':
 			units <<= 10;
 		}
Signature · 1 line
2.7.4
Reviewed-by on v1 16/20
#23 lore raw

Re: [PATCH 16/20] staging: lustre: lprocfs: mark expected switch fall-throughs

Quoted 9 lines · Gustavo A. R. Silva

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

Addresses-Coverity-ID: 1271166
Addresses-Coverity-ID: 1271167
Addresses-Coverity-ID: 1271168
Addresses-Coverity-ID: 1271169

Quoted 28 lines

---
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c | 4 ++++

1 file changed, 4 insertions(+)
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +4 -0
index e79485b..4ec582f 100644
@@ -1507,12 +1507,16 @@ int lprocfs_write_frac_u64_helper(const char __user *buffer,
 		switch (tolower(*end)) {
 		case 'p':
 			units <<= 10;
+			/* fall through */
 		case 't':
 			units <<= 10;
+			/* fall through */
 		case 'g':
 			units <<= 10;
+			/* fall through */
 		case 'm':
 			units <<= 10;
+			/* fall through */
 		case 'k':
 			units <<= 10;
 		}
Signature · 1 line
2.7.4

Cheers, Andreas
--
Andreas Dilger
Lustre Principal Architect
Intel Corporation

#24 lore raw

PATCH 17/20 staging: lustre: ldlm: mark expected switch fall-through

In reply to Gustavo A. R. Silva

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

---
 drivers/staging/lustre/lustre/ldlm/ldlm_request.c | 1 +
 1 file changed, 1 insertion(+)
drivers/staging/lustre/lustre/ldlm/ldlm_request.c +1 -0
index f3bf238..6943987 100644
@@ -1175,6 +1175,7 @@ ldlm_cancel_no_wait_policy(struct ldlm_namespace *ns, struct ldlm_lock *lock,
 	case LDLM_IBITS:
 		if (ns->ns_cancel && ns->ns_cancel(lock) != 0)
 			break;
+		/* fall through */
 	default:
 		result = LDLM_POLICY_SKIP_LOCK;
 		lock_res_and_lock(lock);
Signature · 1 line
2.7.4
Reviewed-by on v1 17/20
#25 lore raw

Re: [PATCH 17/20] staging: lustre: ldlm: mark expected switch fall-through

Quoted 5 lines · Gustavo A. R. Silva

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

Quoted 19 lines

---
drivers/staging/lustre/lustre/ldlm/ldlm_request.c | 1 +

1 file changed, 1 insertion(+)
drivers/staging/lustre/lustre/ldlm/ldlm_request.c +1 -0
index f3bf238..6943987 100644
@@ -1175,6 +1175,7 @@ ldlm_cancel_no_wait_policy(struct ldlm_namespace *ns, struct ldlm_lock *lock,
 	case LDLM_IBITS:
 		if (ns->ns_cancel && ns->ns_cancel(lock) != 0)
 			break;
+		/* fall through */
 	default:
 		result = LDLM_POLICY_SKIP_LOCK;
 		lock_res_and_lock(lock);
Signature · 1 line
2.7.4

Cheers, Andreas
--
Andreas Dilger
Lustre Principal Architect
Intel Corporation

#26 lore raw

PATCH 18/20 staging: lustre: osc: mark expected switch fall-through

In reply to Gustavo A. R. Silva

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

Addresses-Coverity-ID: 1077598

---
 drivers/staging/lustre/lustre/osc/osc_cache.c | 1 +
 1 file changed, 1 insertion(+)
drivers/staging/lustre/lustre/osc/osc_cache.c +1 -0
index e1207c2..eab7759 100644
@@ -227,6 +227,7 @@ static int osc_extent_sanity_check0(struct osc_extent *ext,
 			rc = 65;
 			goto out;
 		}
+		/* fall through */
 	default:
 		if (atomic_read(&ext->oe_users) > 0) {
 			rc = 70;
Signature · 1 line
2.7.4
Reviewed-by on v1 18/20
#27 lore raw

Re: [PATCH 18/20] staging: lustre: osc: mark expected switch fall-through

Quoted 6 lines · Gustavo A. R. Silva

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

Addresses-Coverity-ID: 1077598

Quoted 19 lines

---
drivers/staging/lustre/lustre/osc/osc_cache.c | 1 +

1 file changed, 1 insertion(+)
drivers/staging/lustre/lustre/osc/osc_cache.c +1 -0
index e1207c2..eab7759 100644
@@ -227,6 +227,7 @@ static int osc_extent_sanity_check0(struct osc_extent *ext,
 			rc = 65;
 			goto out;
 		}
+		/* fall through */
 	default:
 		if (atomic_read(&ext->oe_users) > 0) {
 			rc = 70;
Signature · 1 line
2.7.4

Cheers, Andreas
--
Andreas Dilger
Lustre Principal Architect
Intel Corporation

#28 lore raw

PATCH 19/20 staging: lustre: ptlrpc: mark expected switch fall-throughs

In reply to Gustavo A. R. Silva

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

---
 drivers/staging/lustre/lustre/ptlrpc/pack_generic.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/lustre/lustre/ptlrpc/pack_generic.c +3 -3
index aad4ff1..a3664c1 100644
@@ -786,7 +786,7 @@ __u32 lustre_msg_get_flags(struct lustre_msg *msg)
 
 		CERROR("invalid msg %p: no ptlrpc body!\n", msg);
 	}
-	/* no break */
+	/* fall through */
 	default:
 		/* flags might be printed in debug code while message
 		 * uninitialized
@@ -854,7 +854,7 @@ __u32 lustre_msg_get_op_flags(struct lustre_msg *msg)
 
 		CERROR("invalid msg %p: no ptlrpc body!\n", msg);
 	}
-	/* no break */
+	/* fall through */
 	default:
 		return 0;
 	}
@@ -1035,7 +1035,7 @@ int lustre_msg_get_status(struct lustre_msg *msg)
 
 		CERROR("invalid msg %p: no ptlrpc body!\n", msg);
 	}
-	/* no break */
+	/* fall through */
 	default:
 		/* status might be printed in debug code while message
 		 * uninitialized
Signature · 1 line
2.7.4
Reviewed-by on v1 19/20
#29 lore raw

Re: [PATCH 19/20] staging: lustre: ptlrpc: mark expected switch fall-throughs

Quoted 5 lines · Gustavo A. R. Silva

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

Quoted 38 lines

---
drivers/staging/lustre/lustre/ptlrpc/pack_generic.c | 6 +++---

1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/lustre/lustre/ptlrpc/pack_generic.c +3 -3
index aad4ff1..a3664c1 100644
@@ -786,7 +786,7 @@ __u32 lustre_msg_get_flags(struct lustre_msg *msg)
 
 		CERROR("invalid msg %p: no ptlrpc body!\n", msg);
 	}
-	/* no break */
+	/* fall through */
 	default:
 		/* flags might be printed in debug code while message
 		 * uninitialized
@@ -854,7 +854,7 @@ __u32 lustre_msg_get_op_flags(struct lustre_msg *msg)
 
 		CERROR("invalid msg %p: no ptlrpc body!\n", msg);
 	}
-	/* no break */
+	/* fall through */
 	default:
 		return 0;
 	}
@@ -1035,7 +1035,7 @@ int lustre_msg_get_status(struct lustre_msg *msg)
 
 		CERROR("invalid msg %p: no ptlrpc body!\n", msg);
 	}
-	/* no break */
+	/* fall through */
 	default:
 		/* status might be printed in debug code while message
 		 * uninitialized
Signature · 1 line
2.7.4

Cheers, Andreas
--
Andreas Dilger
Lustre Principal Architect
Intel Corporation

#30 lore raw

PATCH 20/20 staging: lustre: rpc: mark expected switch fall-throughs

In reply to Gustavo A. R. Silva

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

Addresses-Coverity-ID: 1077604
Addresses-Coverity-ID: 1077605

---
 drivers/staging/lustre/lnet/selftest/rpc.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/staging/lustre/lnet/selftest/rpc.c +9 -4
index 77c222c..74ef3c3 100644
@@ -1037,6 +1037,7 @@ srpc_handle_rpc(struct swi_workitem *wi)
 			ev->ev_status = rc;
 		}
 	}
+		/* fall through */
 	case SWI_STATE_BULK_STARTED:
 		LASSERT(!rpc->srpc_bulk || ev->ev_fired);
 
@@ -1237,7 +1238,8 @@ srpc_send_rpc(struct swi_workitem *wi)
 			break;
 
 		wi->swi_state = SWI_STATE_REQUEST_SENT;
-		/* perhaps more events, fall thru */
+		/* perhaps more events */
+		/* fall through */
 	case SWI_STATE_REQUEST_SENT: {
 		enum srpc_msg_type type = srpc_service2reply(rpc->crpc_service);
 
@@ -1269,6 +1271,7 @@ srpc_send_rpc(struct swi_workitem *wi)
 
 		wi->swi_state = SWI_STATE_REPLY_RECEIVED;
 	}
+		/* fall through */
 	case SWI_STATE_REPLY_RECEIVED:
 		if (do_bulk && !rpc->crpc_bulkev.ev_fired)
 			break;
@@ -1448,6 +1451,7 @@ srpc_lnet_ev_handler(struct lnet_event *ev)
 			srpc_data.rpc_counters.rpcs_sent++;
 			spin_unlock(&srpc_data.rpc_glock);
 		}
+		/* fall through */
 	case SRPC_REPLY_RCVD:
 	case SRPC_BULK_REQ_RCVD:
 		crpc = rpcev->ev_data;
@@ -1570,7 +1574,7 @@ srpc_lnet_ev_handler(struct lnet_event *ev)
 
 		if (!ev->unlinked)
 			break; /* wait for final event */
-
+		/* fall through */
 	case SRPC_BULK_PUT_SENT:
 		if (!ev->status && ev->type != LNET_EVENT_UNLINK) {
 			spin_lock(&srpc_data.rpc_glock);
@@ -1582,6 +1586,7 @@ srpc_lnet_ev_handler(struct lnet_event *ev)
 
 			spin_unlock(&srpc_data.rpc_glock);
 		}
+		/* fall through */
 	case SRPC_REPLY_SENT:
 		srpc = rpcev->ev_data;
 		scd = srpc->srpc_scd;
@@ -1674,14 +1679,14 @@ srpc_shutdown(void)
 		spin_unlock(&srpc_data.rpc_glock);
 
 		stt_shutdown();
-
+		/* fall through */
 	case SRPC_STATE_EQ_INIT:
 		rc = LNetClearLazyPortal(SRPC_FRAMEWORK_REQUEST_PORTAL);
 		rc = LNetClearLazyPortal(SRPC_REQUEST_PORTAL);
 		LASSERT(!rc);
 		rc = LNetEQFree(srpc_data.rpc_lnet_eq);
 		LASSERT(!rc); /* the EQ should have no user by now */
-
+		/* fall through */
 	case SRPC_STATE_NI_INIT:
 		LNetNIFini();
 	}
Signature · 1 line
2.7.4
Reviewed-by on v1 20/20
#31 lore raw

Re: [PATCH 20/20] staging: lustre: rpc: mark expected switch fall-throughs

Quoted 7 lines · Gustavo A. R. Silva

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

Addresses-Coverity-ID: 1077604
Addresses-Coverity-ID: 1077605

Quoted 79 lines

---
drivers/staging/lustre/lnet/selftest/rpc.c | 13 +++++++++----

1 file changed, 9 insertions(+), 4 deletions(-)
drivers/staging/lustre/lnet/selftest/rpc.c +9 -4
index 77c222c..74ef3c3 100644
@@ -1037,6 +1037,7 @@ srpc_handle_rpc(struct swi_workitem *wi)
 			ev->ev_status = rc;
 		}
 	}
+		/* fall through */
 	case SWI_STATE_BULK_STARTED:
 		LASSERT(!rpc->srpc_bulk || ev->ev_fired);
 
@@ -1237,7 +1238,8 @@ srpc_send_rpc(struct swi_workitem *wi)
 			break;
 
 		wi->swi_state = SWI_STATE_REQUEST_SENT;
-		/* perhaps more events, fall thru */
+		/* perhaps more events */
+		/* fall through */
 	case SWI_STATE_REQUEST_SENT: {
 		enum srpc_msg_type type = srpc_service2reply(rpc->crpc_service);
 
@@ -1269,6 +1271,7 @@ srpc_send_rpc(struct swi_workitem *wi)
 
 		wi->swi_state = SWI_STATE_REPLY_RECEIVED;
 	}
+		/* fall through */
 	case SWI_STATE_REPLY_RECEIVED:
 		if (do_bulk && !rpc->crpc_bulkev.ev_fired)
 			break;
@@ -1448,6 +1451,7 @@ srpc_lnet_ev_handler(struct lnet_event *ev)
 			srpc_data.rpc_counters.rpcs_sent++;
 			spin_unlock(&srpc_data.rpc_glock);
 		}
+		/* fall through */
 	case SRPC_REPLY_RCVD:
 	case SRPC_BULK_REQ_RCVD:
 		crpc = rpcev->ev_data;
@@ -1570,7 +1574,7 @@ srpc_lnet_ev_handler(struct lnet_event *ev)
 
 		if (!ev->unlinked)
 			break; /* wait for final event */
-
+		/* fall through */
 	case SRPC_BULK_PUT_SENT:
 		if (!ev->status && ev->type != LNET_EVENT_UNLINK) {
 			spin_lock(&srpc_data.rpc_glock);
@@ -1582,6 +1586,7 @@ srpc_lnet_ev_handler(struct lnet_event *ev)
 
 			spin_unlock(&srpc_data.rpc_glock);
 		}
+		/* fall through */
 	case SRPC_REPLY_SENT:
 		srpc = rpcev->ev_data;
 		scd = srpc->srpc_scd;
@@ -1674,14 +1679,14 @@ srpc_shutdown(void)
 		spin_unlock(&srpc_data.rpc_glock);
 
 		stt_shutdown();
-
+		/* fall through */
 	case SRPC_STATE_EQ_INIT:
 		rc = LNetClearLazyPortal(SRPC_FRAMEWORK_REQUEST_PORTAL);
 		rc = LNetClearLazyPortal(SRPC_REQUEST_PORTAL);
 		LASSERT(!rc);
 		rc = LNetEQFree(srpc_data.rpc_lnet_eq);
 		LASSERT(!rc); /* the EQ should have no user by now */
-
+		/* fall through */
 	case SRPC_STATE_NI_INIT:
 		LNetNIFini();
 	}
Signature · 1 line
2.7.4

Cheers, Andreas
--
Andreas Dilger
Lustre Principal Architect
Intel Corporation

#32 lore raw
In reply to Gustavo A. R. Silva

Quoting "Gustavo A. R. Silva" <[email protected]>:

Quoted 65 lines

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

In Kees Cook words:
"This is an unfortunate omission in the C language, and thankfully both gcc and clang have stepped up to solve this the same way static analyzers have solved it. It does both document the intention for humans and provide a way for analyzers to report issues.

Having the compiler help us not make mistakes is quite handy."

In some cases there were "no break" or "fall thru" comments already in place. So I replaced them with proper "fall through" comments, which is what GCC is expecting to find.

For the rest of the cases, please double check if the actual intention of the code is to fall through.

Thanks!

Gustavo A. R. Silva (20):
staging: ks7010: ks_wlan_net: mark expected switch fall-throughs
staging: lustre: lnet: socklnd: mark expected switch fall-through
staging: rtl8192e: mark expected switch fall-through
staging: rtl8723bs: rtw_mlme_ext: mark expected switch fall-through
staging: lustre: lnet: net_fault: mark expected switch fall-through
staging: comedi: s526: mark expected switch fall-through
staging: rtl8188eu: usb_halinit: mark expected switch fall-through
staging: vc04_services: vchiq_core: mark expected switch fall-through
staging: vt6656: card: mark expected switch fall-throughs
staging: rtl8188eu: usb_ops_linux: mark expected switch fall-through
staging: r8822be: mark expected switch fall-throughs
staging: lustre: lnet: selftest: mark expected switch fall-through
staging: rtlwifi: halmac: mark expected switch fall-through
staging: lustre: lnet: selftest: mark expected switch fall-throughs
staging: lustre: llite: mark expected switch fall-through
staging: lustre: lprocfs: mark expected switch fall-throughs
staging: lustre: ldlm: mark expected switch fall-through
staging: lustre: osc: mark expected switch fall-through
staging: lustre: ptlrpc: mark expected switch fall-throughs
staging: lustre: rpc: mark expected switch fall-throughs

 drivers/staging/comedi/drivers/s526.c                       |  5 ++---
 drivers/staging/ks7010/ks_wlan_net.c                        | 10 ++++++++++
 drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c         |  2 +-
 drivers/staging/lustre/lnet/lnet/net_fault.c                |  1 +
 drivers/staging/lustre/lnet/selftest/conctl.c               |  1 +
 drivers/staging/lustre/lnet/selftest/module.c               |  5 ++++-
 drivers/staging/lustre/lnet/selftest/rpc.c                  | 13  
+++++++++----
 drivers/staging/lustre/lustre/ldlm/ldlm_request.c           |  1 +
 drivers/staging/lustre/lustre/llite/namei.c                 |  4 +++-
 drivers/staging/lustre/lustre/obdclass/lprocfs_status.c     |  4 ++++
 drivers/staging/lustre/lustre/osc/osc_cache.c               |  1 +
 drivers/staging/lustre/lustre/ptlrpc/pack_generic.c         |  6 +++---
 drivers/staging/rtl8188eu/hal/usb_halinit.c                 |  1 +
 drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c            |  1 +
 drivers/staging/rtl8192e/rtllib_wx.c                        |  3 +--
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c               |  2 +-
 .../staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx.c    |  2 ++
 drivers/staging/rtlwifi/halmac/rtl_halmac.c                 |  2 +-
 .../staging/vc04_services/interface/vchiq_arm/vchiq_core.c  |  3 +--
 drivers/staging/vt6656/card.c                               |  2 ++
 20 files changed, 50 insertions(+), 19 deletions(-)
Quoted 2 lines

--
2.7.4

Andreas, Stefan:
Thank you for your reviews and ACKs

Greg:
Thank you for applying the patches.

--
Gustavo A. R. Silva