Skip to contentSkip to conversation

staging: xgifb: compress return logic

PATCH In review Gargi Sharma 2 participants 2 messages Sep 24, 2016 – Sep 25, 2016 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: xgifb: compress return logic

compress return logic into a single statement, using semantic patch:
@@
local idexpression ret;
expression e;
@@

-ret =
+return

     e;

-return ret;

---
 drivers/staging/xgifb/vb_init.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/xgifb/vb_init.c +1 -2
index 062ece2..661dd98 100644
@@ -576,8 +576,7 @@ static unsigned char XGINew_CheckFrequence(struct vb_device_info *pVBInfo)
 
 	if ((data & 0x10) == 0) {
 		data = xgifb_reg_get(pVBInfo->P3c4, 0x39);
-		data = (data & 0x02) >> 1;
-		return data;
+		return (data & 0x02) >> 1;
 	}
 	return data & 0x01;
 }
Signature · 1 line
2.9.2
maintainer
#1 lore raw
Quoted 22 lines · Gargi Sharma

compress return logic into a single statement, using semantic patch:
@@
local idexpression ret;
expression e;
@@

(quoted diff) +1 -2
-ret =
+return
     e;
-return ret;
---
 drivers/staging/xgifb/vb_init.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/xgifb/vb_init.c +0 -0
index 062ece2..661dd98 100644

drivers/staging/xgifb/vb_init.c static unsigned char XGINew_CheckFrequence(struct vb_device_info *pVBInfo) · line 579

Quoted 6 lines
drivers/staging/xgifb/vb_init.c +1 -2
@@ -576,8 +576,7 @@ static unsigned char XGINew_CheckFrequence(struct vb_device_info *pVBInfo)
 
 	if ((data & 0x10) == 0) {
 		data = xgifb_reg_get(pVBInfo->P3c4, 0x39);
-		data = (data & 0x02) >> 1;
-		return data;
+		return (data & 0x02) >> 1;

I'm going to argue that the original code is easier to read and understand. The output of the compiler will be the same, so can we leave this as-is?

thanks,

gre k-h