Skip to contentSkip to conversation

staging: rtl8188eu: core: rtw_wlan_util.c: Modify return type suggested by Coccinelle.

PATCH In review Sanjana Sanikommu 4 participants 6 messages Mar 21, 2019 – Mar 24, 2019 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: rtl8188eu: core: rtw_wlan_util.c: Modify return type suggested by Coccinelle.

The last two lines in the function could
be compressed into one. Avoid usage of local variable. Challenge suggested by Coccinelle using ret.cocci. The below is the script for ret.cocci:
@@
local idexpression res;
expression e;
@@

-res =
+return

     e;

-return res;

---
 drivers/staging/rtl8188eu/core/rtw_wlan_util.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/staging/rtl8188eu/core/rtw_wlan_util.c +1 -3
index 4480deef95a1..70776f8e19a6 100644
@@ -1182,10 +1182,8 @@ unsigned int update_MSC_rate(struct ieee80211_ht_cap *pHT_caps)
 {
 	unsigned int mask = 0;
 
-	mask = (pHT_caps->mcs.rx_mask[0] << 12) |
+	return (pHT_caps->mcs.rx_mask[0] << 12) |
 	       (pHT_caps->mcs.rx_mask[1] << 20);
-
-	return mask;
 }
 
 int support_short_GI(struct adapter *padapter, struct ieee80211_ht_cap *pHT_caps)
Signature · 1 line
2.17.1
maintainer
#1 lore raw
Quoted 24 lines · Sanjana Sanikommu

The last two lines in the function could
be compressed into one. Avoid usage of local variable. Challenge suggested by Coccinelle using ret.cocci. The below is the script for ret.cocci:
@@
local idexpression res;
expression e;
@@

(quoted diff) +1 -2
-res =
+return
     e;
-return res;
---
 drivers/staging/rtl8188eu/core/rtw_wlan_util.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/staging/rtl8188eu/core/rtw_wlan_util.c +0 -0
index 4480deef95a1..70776f8e19a6 100644

drivers/staging/rtl8188eu/core/rtw_wlan_util.c unsigned int update_MSC_rate(struct ieee80211_ht_cap *pHT_caps) · line 1187

Quoted 9 lines
drivers/staging/rtl8188eu/core/rtw_wlan_util.c +1 -3
@@ -1182,10 +1182,8 @@ unsigned int update_MSC_rate(struct ieee80211_ht_cap *pHT_caps)
 {
 	unsigned int mask = 0;
 
-	mask = (pHT_caps->mcs.rx_mask[0] << 12) |
+	return (pHT_caps->mcs.rx_mask[0] << 12) |
 	       (pHT_caps->mcs.rx_mask[1] << 20);
-
-	return mask;
 }

Did you build this patch?

Just looking at it I can see the compiler warning that it will emit...

Please always test-build your patches, otherwise it just makes people grumpy :)

thanks,

greg k-h

#2 lore raw
Quoted 38 lines · gregkh
Quoted 14 lines · Sanjana Sanikommu

The last two lines in the function could
be compressed into one. Avoid usage of local variable. Challenge suggested by Coccinelle using ret.cocci. The below is the script for ret.cocci:
@@
local idexpression res;
expression e;
@@

(quoted diff) +1 -2
-res = 
+return 
     e; 
-return res; 

Review

Quoted 6 lines
Signed-off-by Sanjana Sanikommu <[email protected] <javascript:>>

---

 drivers/staging/rtl8188eu/core/rtw_wlan_util.c | 4 +--- 
 1 file changed, 1 insertion(+), 3 deletions(-) 
(quoted diff) +0 -0

b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c

drivers/staging/rtl8188eu/core/rtw_wlan_util.c unsigned int update_MSC_rate(struct

Quoted 4 lines

index 4480deef95a1..70776f8e19a6 100644

drivers/staging/rtl8188eu/core/rtw_wlan_util.c +0 -0
@@ -1182,10 +1182,8 @@ unsigned int update_MSC_rate(struct 

ieee80211_ht_cap *pHT_caps)

drivers/staging/rtl8188eu/core/rtw_wlan_util.c unsigned int update_MSC_rate(struct ieee80211_ht_cap *pHT_caps) · line 1187

Quoted 9 lines
drivers/staging/rtl8188eu/core/rtw_wlan_util.c +1 -3
 { 
         unsigned int mask = 0; 
 
-        mask = (pHT_caps->mcs.rx_mask[0] << 12) | 
+        return (pHT_caps->mcs.rx_mask[0] << 12) | 
                (pHT_caps->mcs.rx_mask[1] << 20); 
- 
-        return mask; 
 } 
Quoted 7 lines

Did you build this patch?

Just looking at it I can see the compiler warning that it will emit...

Please always test-build your patches, otherwise it just makes people grumpy :)

I apologise for what happened regarding this patch. I submitted this patch after
0 errors, 0 warnings, 0 checks i.e after post commit hooks.
I would like to know where I went wrong. I will correct them :)

Sanjana

Quoted 5 lines

thanks,

greg k-h

#3 lore raw
Quoted 51 lines · On Fri, 22 Mar 2019, [email protected] wrote:

On Friday, March 22, 2019 at 12:31:06 AM UTC+5:30, gregkh wrote:

      On Thu, Mar 21, 2019 at 04:42:22PM +0530, Sanjana Sanikommu
      wrote:
      > The last two lines in the function could
      > be compressed into one. Avoid usage of local variable.
      > Challenge suggested by Coccinelle using ret.cocci.
      > The below is the script for ret.cocci:
      > @@
      > local idexpression res;
      > expression e;
      > @@
      >
      > -res =
      > +return
      > ᅵ ᅵ ᅵe;
      > -return res;
      >
      > Signed-off-by: Sanjana Sanikommu <[email protected]>
      > ---
      > ᅵdrivers/staging/rtl8188eu/core/rtw_wlan_util.c | 4 +---
      > ᅵ1 file changed, 1 insertion(+), 3 deletions(-)
      >
      > diff --git a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c
      b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c
      > index 4480deef95a1..70776f8e19a6 100644
      > --- a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c
      > +++ b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c
      > @@ -1182,10 +1182,8 @@ unsigned int update_MSC_rate(struct
      ieee80211_ht_cap *pHT_caps)
      > ᅵ{
      > ᅵᅵᅵᅵᅵᅵᅵᅵᅵunsigned int mask = 0;
      > ᅵ
      > -ᅵᅵᅵᅵᅵᅵᅵᅵmask = (pHT_caps->mcs.rx_mask[0] << 12) |
      > +ᅵᅵᅵᅵᅵᅵᅵᅵreturn (pHT_caps->mcs.rx_mask[0] << 12) |
      > ᅵᅵᅵᅵᅵᅵᅵᅵᅵ ᅵ ᅵ ᅵ (pHT_caps->mcs.rx_mask[1] << 20);
      > -
      > -ᅵᅵᅵᅵᅵᅵᅵᅵreturn mask;
      > ᅵ}

      Did you build this patch?

      Just looking at it I can see the compiler warning that it will
      emit...

      Please always test-build your patches, otherwise it just makes
      people
      grumpy :)
Quoted 4 lines

I apologise for what happened regarding this patch. I submitted this patch after
0 errors, 0 warnings, 0 checks i.e after post commit hooks.
I would like to know where I went wrong. I will correct them :)

I don't know what is in your post commit hooks. But the question is about compilation (make), not checkpatch.

julia

Quoted 19 lines

Sanjanaᅵ
ᅵᅵᅵ

thanks,

greg k-h

--
You received this message because you are subscribed to the Google Groups
"outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visithttps://groups.google.com/d/msgid/outreachy-kernel/dcd4eaa9-83e8-448e-ac97- 00555572ac62%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

#4 lore raw
In reply to [email protected]
Quoted 45 lines · On Fri, Mar 22, 2019 at 08:27:09AM -0700, [email protected] wrote:
Quoted 42 lines · gregkh
Quoted 14 lines · Sanjana Sanikommu

The last two lines in the function could
be compressed into one. Avoid usage of local variable. Challenge suggested by Coccinelle using ret.cocci. The below is the script for ret.cocci:
@@
local idexpression res;
expression e;
@@

(quoted diff) +1 -2
-res = 
+return 
     e; 
-return res; 

Review

Quoted 6 lines
Signed-off-by Sanjana Sanikommu <[email protected] <javascript:>>

---

 drivers/staging/rtl8188eu/core/rtw_wlan_util.c | 4 +--- 
 1 file changed, 1 insertion(+), 3 deletions(-) 
(quoted diff) +0 -0

b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c

drivers/staging/rtl8188eu/core/rtw_wlan_util.c unsigned int update_MSC_rate(struct

Quoted 4 lines

index 4480deef95a1..70776f8e19a6 100644

drivers/staging/rtl8188eu/core/rtw_wlan_util.c +0 -0
@@ -1182,10 +1182,8 @@ unsigned int update_MSC_rate(struct 

ieee80211_ht_cap *pHT_caps)

drivers/staging/rtl8188eu/core/rtw_wlan_util.c unsigned int update_MSC_rate(struct ieee80211_ht_cap *pHT_caps) · line 1187

Quoted 9 lines
drivers/staging/rtl8188eu/core/rtw_wlan_util.c +1 -3
 { 
         unsigned int mask = 0; 
 
-        mask = (pHT_caps->mcs.rx_mask[0] << 12) | 
+        return (pHT_caps->mcs.rx_mask[0] << 12) | 
                (pHT_caps->mcs.rx_mask[1] << 20); 
- 
-        return mask; 
 } 

Did you build this patch?

Just looking at it I can see the compiler warning that it will emit...

Quoted 8 lines
Quoted 3 lines

Please always test-build your patches, otherwise it just makes people grumpy :)

I apologise for what happened regarding this patch. I submitted this patch after
0 errors, 0 warnings, 0 checks i.e after post commit hooks.
I would like to know where I went wrong. I will correct them :)

Did you build the code after making the change? That's the most important part :)

thanks,

greg k-h

#5 lore raw
Quoted 55 lines · Greg Kroah-Hartman
Quoted 14 lines · On Fri, Mar 22, 2019 at 08:27:09AM -0700, [email protected] <javascript:>…
Quoted 11 lines · gregkh
Quoted 9 lines · Sanjana Sanikommu

The last two lines in the function could
be compressed into one. Avoid usage of local variable. Challenge suggested by Coccinelle using ret.cocci. The below is the script for ret.cocci:
@@
local idexpression res;
expression e;
@@

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
(quoted diff) +1 -2
-res = 
+return 
     e; 
-return res; 

<javascript:>>

Quoted 23 lines
Quoted 23 lines

Review

Quoted 5 lines

---

 drivers/staging/rtl8188eu/core/rtw_wlan_util.c | 4 +--- 
 1 file changed, 1 insertion(+), 3 deletions(-) 
(quoted diff) +0 -0

b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c

drivers/staging/rtl8188eu/core/rtw_wlan_util.c unsigned int update_MSC_rate(struct

Quoted 4 lines

index 4480deef95a1..70776f8e19a6 100644

drivers/staging/rtl8188eu/core/rtw_wlan_util.c +0 -0
@@ -1182,10 +1182,8 @@ unsigned int update_MSC_rate(struct 

ieee80211_ht_cap *pHT_caps)

drivers/staging/rtl8188eu/core/rtw_wlan_util.c unsigned int update_MSC_rate(struct ieee80211_ht_cap *pHT_caps) · line 1187

Quoted 9 lines
drivers/staging/rtl8188eu/core/rtw_wlan_util.c +1 -3
 { 
         unsigned int mask = 0; 
 
-        mask = (pHT_caps->mcs.rx_mask[0] << 12) | 
+        return (pHT_caps->mcs.rx_mask[0] << 12) | 
                (pHT_caps->mcs.rx_mask[1] << 20); 
- 
-        return mask; 
 } 

Did you build this patch?

Quoted 7 lines
Quoted 5 lines

Just looking at it I can see the compiler warning that it will emit...

Please always test-build your patches, otherwise it just makes people grumpy :)

I apologise for what happened regarding this patch. I submitted this

patch

Quoted 8 lines
Quoted 3 lines

after
0 errors, 0 warnings, 0 checks i.e after post commit hooks. I would like to know where I went wrong. I will correct them :)

Did you build the code after making the change? That's the most important part :)

I would resend the patch.

sanjana

thanks,

Quoted 3 lines

greg k-h