All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Staging: xgifb: Compress return logic
@ 2016-09-18  9:05 Bhumika Goyal
  0 siblings, 0 replies; 3+ messages in thread
From: Bhumika Goyal @ 2016-09-18  9:05 UTC (permalink / raw)
  To: outreachy-kernel, gregkh, arnaud.patard; +Cc: Bhumika Goyal

This patch compresses the  return logic into a single statement
and removes the now unused return variable.
Done using coccinelle:
@@
type T;
identifier r;
@@
- T r;
... when !=r
- r =
+ return
     ...;
- return r;

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
---
 drivers/staging/xgifb/XGI_main_26.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c
index d56ef14..cc69233 100644
--- a/drivers/staging/xgifb/XGI_main_26.c
+++ b/drivers/staging/xgifb/XGI_main_26.c
@@ -62,7 +62,6 @@ static int XGIfb_mode_rate_to_dclock(struct vb_device_info *XGI_Pr,
 	unsigned short ModeNo = modeno;
 	unsigned short ModeIdIndex = 0, ClockIndex = 0;
 	unsigned short RefreshRateTableIndex = 0;
-	int Clock;
 
 	InitTo330Pointer(HwDeviceExtension->jChipType, XGI_Pr);
 
@@ -73,9 +72,7 @@ static int XGIfb_mode_rate_to_dclock(struct vb_device_info *XGI_Pr,
 
 	ClockIndex = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
 
-	Clock = XGI_VCLKData[ClockIndex].CLOCK * 1000;
-
-	return Clock;
+	return XGI_VCLKData[ClockIndex].CLOCK * 1000;
 }
 
 static int XGIfb_mode_rate_to_ddata(struct vb_device_info *XGI_Pr,
-- 
1.9.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] staging: xgifb: compress return logic
  2016-09-24 19:38 [PATCH] staging: xgifb: compress " Gargi Sharma
@ 2016-09-25 10:42 ` Greg KH
  0 siblings, 0 replies; 3+ messages in thread
From: Greg KH @ 2016-09-25 10:42 UTC (permalink / raw)
  To: Gargi Sharma; +Cc: outreachy-kernel, arnaud.patard

On Sun, Sep 25, 2016 at 01:08:36AM +0530, Gargi Sharma wrote:
> compress return logic into a single statement, using
> semantic patch:
> @@
> local idexpression ret;
> expression e;
> @@
> 
> -ret =
> +return
>      e;
> -return ret;
> 
> Signed-off-by: Gargi Sharma <gs051095@gmail.com>
> ---
>  drivers/staging/xgifb/vb_init.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/xgifb/vb_init.c b/drivers/staging/xgifb/vb_init.c
> index 062ece2..661dd98 100644
> --- a/drivers/staging/xgifb/vb_init.c
> +++ b/drivers/staging/xgifb/vb_init.c
> @@ -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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] staging: xgifb: compress return logic
@ 2016-09-24 19:38 Gargi Sharma
  2016-09-25 10:42 ` Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: Gargi Sharma @ 2016-09-24 19:38 UTC (permalink / raw)
  To: outreachy-kernel; +Cc: gregkh, arnaud.patard, Gargi Sharma

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

-ret =
+return
     e;
-return ret;

Signed-off-by: Gargi Sharma <gs051095@gmail.com>
---
 drivers/staging/xgifb/vb_init.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/xgifb/vb_init.c b/drivers/staging/xgifb/vb_init.c
index 062ece2..661dd98 100644
--- a/drivers/staging/xgifb/vb_init.c
+++ b/drivers/staging/xgifb/vb_init.c
@@ -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;
 }
-- 
2.9.2



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-09-25 10:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-18  9:05 [PATCH] Staging: xgifb: Compress return logic Bhumika Goyal
2016-09-24 19:38 [PATCH] staging: xgifb: compress " Gargi Sharma
2016-09-25 10:42 ` Greg KH

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.