Skip to contentSkip to conversation

Staging: rtl8723au: rtw_xmit: Remove unnecessary tests

PATCH In review Shivani Bhardwaj 3 participants 8 messages Oct 14, 2015 – Oct 15, 2015 Staging

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 Staging: rtl8723au: rtw_xmit: Remove unnecessary tests

The variables which are preceded by NULL tests on them should not be checked again.
Semantic patch used:
@@ expression E;
statement S1, S2, S3; @@
if(E==NULL) {... return ...;}
else S1
- if(E==NULL)
S2
- else S3

---
Changes in v2:
-Correct the semantic patch and make commit message better.

 drivers/staging/rtl8723au/core/rtw_xmit.c | 9 ---------
 1 file changed, 9 deletions(-)
drivers/staging/rtl8723au/core/rtw_xmit.c +0 -9
index a4b6bb6..0ea521b 100644
@@ -667,7 +667,6 @@ static int xmitframe_addmic(struct rtw_adapter *padapter,
 
 	if (pattrib->encrypt == WLAN_CIPHER_SUITE_TKIP) {
 		/* encode mic code */
-		if (stainfo) {
 			u8 null_key[16]={0x0, 0x0, 0x0, 0x0,
 					 0x0, 0x0, 0x0, 0x0,
 					 0x0, 0x0, 0x0, 0x0,
@@ -792,10 +791,6 @@ static int xmitframe_addmic(struct rtw_adapter *padapter,
 					 *(payload + curfragnum + 6),
 					 *(payload + curfragnum + 7));
 			}
-		} else {
-			RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_,
-				 "xmitframe_addmic: rtw_get_stainfo23a ==NULL!!!\n");
-		}
 	}
 
 	return _SUCCESS;
@@ -934,7 +929,6 @@ static int rtw_make_wlanhdr(struct rtw_adapter *padapter, u8 *hdr,
 		/* TODO: fill HT Control Field */
 
 		/* Update Seq Num will be handled by f/w */
-		if (psta) {
 			psta->sta_xmitpriv.txseq_tid[pattrib->priority]++;
 			psta->sta_xmitpriv.txseq_tid[pattrib->priority] &= 0xFFF;
 			pattrib->seqnum = psta->sta_xmitpriv.txseq_tid[pattrib->priority];
@@ -970,7 +964,6 @@ static int rtw_make_wlanhdr(struct rtw_adapter *padapter, u8 *hdr,
 					pattrib->ampdu_en = true;/* AGG EN */
 				}
 			}
-		}
 	}
 exit:
 	return res;
@@ -1132,7 +1125,6 @@ int rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *skb,
 
 		/* adding icv, if necessary... */
 		if (pattrib->iv_len) {
-			if (psta) {
 				switch (pattrib->encrypt) {
 				case WLAN_CIPHER_SUITE_WEP40:
 				case WLAN_CIPHER_SUITE_WEP104:
@@ -1158,7 +1150,6 @@ int rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *skb,
 						       psta->dot11txpn, 0);
 					break;
 				}
-			}
 
 			memcpy(pframe, pattrib->iv, pattrib->iv_len);
 
Signature · 1 line
2.1.0
#1 lore raw
Quoted 24 lines · Shivani Bhardwaj

The variables which are preceded by NULL tests on them should not be checked again.
Semantic patch used:
@@ expression E;
statement S1, S2, S3; @@
if(E==NULL) {... return ...;}
else S1
- if(E==NULL)
S2
- else S3

---
Changes in v2:
-Correct the semantic patch and make commit message better.

 drivers/staging/rtl8723au/core/rtw_xmit.c | 9 ---------
 1 file changed, 9 deletions(-)
drivers/staging/rtl8723au/core/rtw_xmit.c +0 -0
index a4b6bb6..0ea521b 100644

drivers/staging/rtl8723au/core/rtw_xmit.c static int xmitframe_addmic(struct rtw_adapter *padapter, · line 672

Quoted 7 lines
drivers/staging/rtl8723au/core/rtw_xmit.c +0 -1
@@ -667,7 +667,6 @@ static int xmitframe_addmic(struct rtw_adapter *padapter,
 
 	if (pattrib->encrypt == WLAN_CIPHER_SUITE_TKIP) {
 		/* encode mic code */
-		if (stainfo) {
 			u8 null_key[16]={0x0, 0x0, 0x0, 0x0,
 					 0x0, 0x0, 0x0, 0x0,
 					 0x0, 0x0, 0x0, 0x0,

Now this indention is looking wrong.

regards
sudip

#2 lore raw
Quoted 35 lines · Sudip Mukherjee
Quoted 24 lines · Shivani Bhardwaj

The variables which are preceded by NULL tests on them should not be checked again.
Semantic patch used:
@@ expression E;
statement S1, S2, S3; @@
if(E==NULL) {... return ...;}
else S1
- if(E==NULL)
S2
- else S3

---
Changes in v2:
-Correct the semantic patch and make commit message better.

 drivers/staging/rtl8723au/core/rtw_xmit.c | 9 ---------
 1 file changed, 9 deletions(-)
drivers/staging/rtl8723au/core/rtw_xmit.c +0 -0
index a4b6bb6..0ea521b 100644

drivers/staging/rtl8723au/core/rtw_xmit.c static int xmitframe_addmic(struct rtw_adapter *padapter, · line 672

Quoted 7 lines
drivers/staging/rtl8723au/core/rtw_xmit.c +0 -1
@@ -667,7 +667,6 @@ static int xmitframe_addmic(struct rtw_adapter *padapter,
 
      if (pattrib->encrypt == WLAN_CIPHER_SUITE_TKIP) {
              /* encode mic code */
-             if (stainfo) {
                      u8 null_key[16]={0x0, 0x0, 0x0, 0x0,
                                       0x0, 0x0, 0x0, 0x0,
                                       0x0, 0x0, 0x0, 0x0,

Now this indention is looking wrong.

Quoted 2 lines

regards
sudip

Is it also supposed to be a part of the same patch or a series should be made?

#3 lore raw
Quoted 37 lines · Shivani Bhardwaj
Quoted 35 lines · Sudip Mukherjee
Quoted 24 lines · Shivani Bhardwaj

The variables which are preceded by NULL tests on them should not be checked again.
Semantic patch used:
@@ expression E;
statement S1, S2, S3; @@
if(E==NULL) {... return ...;}
else S1
- if(E==NULL)
S2
- else S3

---
Changes in v2:
-Correct the semantic patch and make commit message better.

 drivers/staging/rtl8723au/core/rtw_xmit.c | 9 ---------
 1 file changed, 9 deletions(-)
drivers/staging/rtl8723au/core/rtw_xmit.c +0 -0
index a4b6bb6..0ea521b 100644

drivers/staging/rtl8723au/core/rtw_xmit.c static int xmitframe_addmic(struct rtw_adapter *padapter, · line 672

Quoted 7 lines
drivers/staging/rtl8723au/core/rtw_xmit.c +0 -1
@@ -667,7 +667,6 @@ static int xmitframe_addmic(struct rtw_adapter *padapter,
 
      if (pattrib->encrypt == WLAN_CIPHER_SUITE_TKIP) {
              /* encode mic code */
-             if (stainfo) {
                      u8 null_key[16]={0x0, 0x0, 0x0, 0x0,
                                       0x0, 0x0, 0x0, 0x0,
                                       0x0, 0x0, 0x0, 0x0,

Now this indention is looking wrong.

Quoted 3 lines
Quoted 2 lines

regards
sudip

Is it also supposed to be a part of the same patch or a series should be made?

same patch as that indention problem is caused as "if (stainfo) {" is removed. But can the cocci script handle that? maybe you need to modify the indention by hand, and mention that in the commit message.

regards
sudip

#4 lore raw
Quoted 40 lines · Sudip Mukherjee
Quoted 39 lines · Shivani Bhardwaj
Quoted 37 lines · Sudip Mukherjee
Quoted 24 lines · Shivani Bhardwaj

The variables which are preceded by NULL tests on them should not be checked again.
Semantic patch used:
@@ expression E;
statement S1, S2, S3; @@
if(E==NULL) {... return ...;}
else S1
- if(E==NULL)
S2
- else S3

---
Changes in v2:
-Correct the semantic patch and make commit message better.

 drivers/staging/rtl8723au/core/rtw_xmit.c | 9 ---------
 1 file changed, 9 deletions(-)
drivers/staging/rtl8723au/core/rtw_xmit.c +0 -0
index a4b6bb6..0ea521b 100644

drivers/staging/rtl8723au/core/rtw_xmit.c static int xmitframe_addmic(struct rtw_adapter *padapter, · line 672

Quoted 7 lines
drivers/staging/rtl8723au/core/rtw_xmit.c +0 -1
@@ -667,7 +667,6 @@ static int xmitframe_addmic(struct rtw_adapter *padapter,
 
      if (pattrib->encrypt == WLAN_CIPHER_SUITE_TKIP) {
              /* encode mic code */
-             if (stainfo) {
                      u8 null_key[16]={0x0, 0x0, 0x0, 0x0,
                                       0x0, 0x0, 0x0, 0x0,
                                       0x0, 0x0, 0x0, 0x0,

Now this indention is looking wrong.

regards
sudip

Quoted 8 lines
Quoted 1 line

Is it also supposed to be a part of the same patch or a series should be made?

same patch as that indention problem is caused as "if (stainfo) {" is removed. But can the cocci script handle that? maybe you need to modify the indention by hand, and mention that in the commit message.

regards
sudip

I don't know if cocci script can do that. I'll have to ask Julia. Anyway, I'll make the changes by hand.

#5 lore raw
Quoted 48 lines · Shivani Bhardwaj
Quoted 46 lines · Sudip Mukherjee
Quoted 37 lines · Shivani Bhardwaj
Quoted 35 lines · Sudip Mukherjee
Quoted 24 lines · Shivani Bhardwaj

The variables which are preceded by NULL tests on them should not be checked again.
Semantic patch used:
@@ expression E;
statement S1, S2, S3; @@
if(E==NULL) {... return ...;}
else S1
- if(E==NULL)
S2
- else S3

---
Changes in v2:
-Correct the semantic patch and make commit message better.

 drivers/staging/rtl8723au/core/rtw_xmit.c | 9 ---------
 1 file changed, 9 deletions(-)
drivers/staging/rtl8723au/core/rtw_xmit.c +0 -0
index a4b6bb6..0ea521b 100644

drivers/staging/rtl8723au/core/rtw_xmit.c static int xmitframe_addmic(struct rtw_adapter *padapter, · line 672

Quoted 7 lines
drivers/staging/rtl8723au/core/rtw_xmit.c +0 -1
@@ -667,7 +667,6 @@ static int xmitframe_addmic(struct rtw_adapter *padapter,
 
      if (pattrib->encrypt == WLAN_CIPHER_SUITE_TKIP) {
              /* encode mic code */
-             if (stainfo) {
                      u8 null_key[16]={0x0, 0x0, 0x0, 0x0,
                                       0x0, 0x0, 0x0, 0x0,
                                       0x0, 0x0, 0x0, 0x0,

Now this indention is looking wrong.

Quoted 3 lines
Quoted 2 lines

regards
sudip

Is it also supposed to be a part of the same patch or a series should be made?

same patch as that indention problem is caused as "if (stainfo) {" is removed. But can the cocci script handle that? maybe you need to modify the indention by hand, and mention that in the commit message.

Quoted 5 lines
Quoted 2 lines

regards
sudip

I don't know if cocci script can do that. I'll have to ask Julia. Anyway, I'll make the changes by hand.

Coccinelle is supposed to clean up the indentation, but it seems that it is not. Could you send me your semantic patch, and I will check on it.

thanks,
julia

#6 lore raw
Quoted 55 lines · Julia Lawall
Quoted 51 lines · Shivani Bhardwaj
Quoted 48 lines · Sudip Mukherjee
Quoted 37 lines · Shivani Bhardwaj
Quoted 35 lines · Sudip Mukherjee
Quoted 24 lines · Shivani Bhardwaj

The variables which are preceded by NULL tests on them should not be checked again.
Semantic patch used:
@@ expression E;
statement S1, S2, S3; @@
if(E==NULL) {... return ...;}
else S1
- if(E==NULL)
S2
- else S3

---
Changes in v2:
-Correct the semantic patch and make commit message better.

 drivers/staging/rtl8723au/core/rtw_xmit.c | 9 ---------
 1 file changed, 9 deletions(-)
drivers/staging/rtl8723au/core/rtw_xmit.c +0 -0
index a4b6bb6..0ea521b 100644

drivers/staging/rtl8723au/core/rtw_xmit.c static int xmitframe_addmic(struct rtw_adapter *padapter, · line 672

Quoted 7 lines
drivers/staging/rtl8723au/core/rtw_xmit.c +0 -1
@@ -667,7 +667,6 @@ static int xmitframe_addmic(struct rtw_adapter *padapter,
 
      if (pattrib->encrypt == WLAN_CIPHER_SUITE_TKIP) {
              /* encode mic code */
-             if (stainfo) {
                      u8 null_key[16]={0x0, 0x0, 0x0, 0x0,
                                       0x0, 0x0, 0x0, 0x0,
                                       0x0, 0x0, 0x0, 0x0,

Now this indention is looking wrong.

Quoted 3 lines
Quoted 2 lines

regards
sudip

Is it also supposed to be a part of the same patch or a series should be made?

same patch as that indention problem is caused as "if (stainfo) {" is removed. But can the cocci script handle that? maybe you need to modify the indention by hand, and mention that in the commit message.

regards
sudip

Quoted 8 lines
Quoted 2 lines

I don't know if cocci script can do that. I'll have to ask Julia. Anyway, I'll make the changes by hand.

Coccinelle is supposed to clean up the indentation, but it seems that it is not. Could you send me your semantic patch, and I will check on it.

thanks,
julia

I just used the script to detect null tests. I used
http://coccinelle.lip6.fr/rules/notnull.cocci .
I still don't know well about making changes to cocci scripts. :(

#7 lore raw
In reply to Shivani Bhardwaj
Quoted 37 lines · Shivani Bhardwaj
Quoted 35 lines · Sudip Mukherjee
Quoted 24 lines · Shivani Bhardwaj

The variables which are preceded by NULL tests on them should not be checked again.
Semantic patch used:
@@ expression E;
statement S1, S2, S3; @@
if(E==NULL) {... return ...;}
else S1
- if(E==NULL)
S2
- else S3

---
Changes in v2:
-Correct the semantic patch and make commit message better.

 drivers/staging/rtl8723au/core/rtw_xmit.c | 9 ---------
 1 file changed, 9 deletions(-)
drivers/staging/rtl8723au/core/rtw_xmit.c +0 -0
index a4b6bb6..0ea521b 100644

drivers/staging/rtl8723au/core/rtw_xmit.c static int xmitframe_addmic(struct rtw_adapter *padapter, · line 672

Quoted 7 lines
drivers/staging/rtl8723au/core/rtw_xmit.c +0 -1
@@ -667,7 +667,6 @@ static int xmitframe_addmic(struct rtw_adapter *padapter,
 
      if (pattrib->encrypt == WLAN_CIPHER_SUITE_TKIP) {
              /* encode mic code */
-             if (stainfo) {
                      u8 null_key[16]={0x0, 0x0, 0x0, 0x0,
                                       0x0, 0x0, 0x0, 0x0,
                                       0x0, 0x0, 0x0, 0x0,

Now this indention is looking wrong.

Quoted 3 lines
Quoted 2 lines

regards
sudip

Is it also supposed to be a part of the same patch or a series should be made?

Same. The removal caused the indentation problem, so the same patch should fix it up.

julia

Quoted 8 lines

--
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 visit https://groups.google.com/d/msgid/outreachy-kernel/CAKHNQQGOs9OPBZi6Eoy3t7R1ybZf5kmnTUJx9JRxGTmhAhmCjg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.