Thread (21 messages) 21 messages, 17 authors, 2020-09-17

Re: [oss-drivers] [trivial PATCH] treewide: Convert switch/case fallthrough; to break;

From: Simon Horman <hidden>
Date: 2020-09-17 08:10:21
Also in: alsa-devel, bpf, ceph-devel, dm-devel, dri-devel, intel-gfx, intel-wired-lan, kvmarm, linux-arm-kernel, linux-crypto, linux-fbdev, linux-i2c, linux-ide, linux-input, linux-iommu, linux-media, linux-mediatek, linux-mips, linux-mmc, linux-nfs, linux-pm, linux-rdma, linux-rtc, linux-scsi, linux-sctp, linux-serial, linux-usb, linux-wireless, linuxppc-dev, lkml, netdev, netfilter-devel, nouveau, sparclinux

On Wed, Sep 09, 2020 at 01:06:39PM -0700, Joe Perches wrote:
fallthrough to a separate case/default label break; isn't very readable.

Convert pseudo-keyword fallthrough; statements to a simple break; when
the next label is case or default and the only statement in the next
label block is break;

Found using:

$ grep-2.5.4 -rP --include=*.[ch] -n "fallthrough;(\s*(case\s+\w+|default)\s*:\s*){1,7}break;" *

Miscellanea:

o Move or coalesce a couple label blocks above a default: block.

Signed-off-by: Joe Perches <joe@perches.com>
...
quoted hunk ↗ jump to hunk
diff --git a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp6000_pcie.c b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp6000_pcie.c
index 252fe06f58aa..1d5b87079104 100644
--- a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp6000_pcie.c
+++ b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp6000_pcie.c
@@ -345,7 +345,7 @@ static int matching_bar(struct nfp_bar *bar, u32 tgt, u32 act, u32 tok,
 		baract = NFP_CPP_ACTION_RW;
 		if (act == 0)
 			act = NFP_CPP_ACTION_RW;
-		fallthrough;
+		break;
 	case NFP_PCIE_BAR_PCIE2CPP_MapType_FIXED:
 		break;
 	default:
This is a cascading fall-through handling all map types.
I don't think this change improves readability.

...
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help