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

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

From: Joe Perches <joe@perches.com>
Date: 2020-09-11 04:19:55
Also in: 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 Thu, 2020-09-10 at 15:21 +0100, Robin Murphy wrote:
On 2020-09-09 21:06, Joe Perches wrote:
quoted
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>
---

Compiled allyesconfig x86-64 only.
A few files for other arches were not compiled.
[...]
quoted
diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
index c192544e874b..743db1abec40 100644
--- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
+++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
@@ -3777,7 +3777,7 @@ static int arm_smmu_device_hw_probe(struct arm_smmu_device *smmu)
  	switch (FIELD_GET(IDR0_TTF, reg)) {
  	case IDR0_TTF_AARCH32_64:
  		smmu->ias = 40;
-		fallthrough;
+		break;
  	case IDR0_TTF_AARCH64:
  		break;
  	default:
I have to say I don't really agree with the readability argument for 
this one - a fallthrough is semantically correct here, since the first 
case is a superset of the second. It just happens that anything we would 
do for the common subset is implicitly assumed (there are other 
potential cases we simply haven't added support for at the moment), thus 
the second case is currently empty.
This change actively obfuscates that distinction.
Then perhaps comments should be added to usefully
describe the mechanisms.

	case IDR0_TTF_AARCH32_64:
		smmu->ias = 40;
		fallthrough;	/* and still do the 64 bit processing */
	case IDR0_TTF_AARCH64:
		/* Nothing specific yet */
		break;
Robin.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help