Skip to contentSkip to conversation

staging: vt6655: Merge three statements into one

PATCH In review Amitoj Kaur Chawla 2 participants 2 messages Feb 19, 2016 – Feb 20, 2016 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: vt6655: Merge three statements into one

This patch merges three lines into one, removing if branch.

A simplified version of the Coccinelle semantic patch used to find this is as follows:

//<smpl>
@@
expression e;
@@
- if(e)
- return false;
- return true;
+ return !e;
//</smpl>

---
 drivers/staging/vt6655/rf.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/staging/vt6655/rf.c +1 -4
index ae10da2..f32d18e 100644
@@ -518,10 +518,7 @@ bool IFRFbWriteEmbedded(struct vnt_private *priv, unsigned long dwData)
 			break;
 	}
 
-	if (ww == W_MAX_TIMEOUT)
-		return false;
-
-	return true;
+	return !(ww == W_MAX_TIMEOUT);
 }
 
 /*
Signature · 1 line
1.9.1
maintainer
#1 lore raw
Quoted 25 lines · Amitoj Kaur Chawla

This patch merges three lines into one, removing if branch.

A simplified version of the Coccinelle semantic patch used to find this is as follows:

//<smpl>
@@
expression e;
@@
- if(e)
- return false;
- return true;
+ return !e;
//</smpl>

---
 drivers/staging/vt6655/rf.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/staging/vt6655/rf.c +0 -0
index ae10da2..f32d18e 100644

drivers/staging/vt6655/rf.c bool IFRFbWriteEmbedded(struct vnt_private *priv, unsigned long dwData) · line 521

Quoted 8 lines
drivers/staging/vt6655/rf.c +1 -4
@@ -518,10 +518,7 @@ bool IFRFbWriteEmbedded(struct vnt_private *priv, unsigned long dwData)
 			break;
 	}
 
-	if (ww == W_MAX_TIMEOUT)
-		return false;
-
-	return true;
+	return !(ww == W_MAX_TIMEOUT);

That's crazy, that's much less readable than before.

Remember, kernel code is ment for people to read it and instantly know what is going on, don't force us to think :)

thanks,

greg k-h