All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Staging: rtl8723au: rtw_xmit: Remove extra NULL tests
@ 2015-10-14  0:51 Shivani Bhardwaj
  2015-10-14  5:48 ` [Outreachy kernel] " Julia Lawall
  0 siblings, 1 reply; 10+ messages in thread
From: Shivani Bhardwaj @ 2015-10-14  0:51 UTC (permalink / raw)
  To: outreachy-kernel

Variables already tested for NULL value are checked again so, the extra
NULL tests should be removed.
Semantic patch used:

@@ expression E; @@
if(E==NULL) {... return...;}
- if(E)

Signed-off-by: Shivani Bhardwaj <shivanib134@gmail.com>
---
 drivers/staging/rtl8723au/core/rtw_xmit.c | 9 ---------
 1 file changed, 9 deletions(-)

diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c
index a4b6bb6..0ea521b 100644
--- a/drivers/staging/rtl8723au/core/rtw_xmit.c
+++ b/drivers/staging/rtl8723au/core/rtw_xmit.c
@@ -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);
 
-- 
2.1.0



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

* Re: [Outreachy kernel] [PATCH] Staging: rtl8723au: rtw_xmit: Remove extra NULL tests
  2015-10-14  0:51 [PATCH] Staging: rtl8723au: rtw_xmit: Remove extra NULL tests Shivani Bhardwaj
@ 2015-10-14  5:48 ` Julia Lawall
  2015-10-14  9:08   ` Shivani Bhardwaj
  0 siblings, 1 reply; 10+ messages in thread
From: Julia Lawall @ 2015-10-14  5:48 UTC (permalink / raw)
  To: Shivani Bhardwaj; +Cc: outreachy-kernel

On Wed, 14 Oct 2015, Shivani Bhardwaj wrote:

> Variables already tested for NULL value are checked again so, the extra
> NULL tests should be removed.
> Semantic patch used:
> 
> @@ expression E; @@
> if(E==NULL) {... return...;}
> - if(E)

This is not a valid semantic patch.  The if needs at least a then branch.

julia


> 
> Signed-off-by: Shivani Bhardwaj <shivanib134@gmail.com>
> ---
>  drivers/staging/rtl8723au/core/rtw_xmit.c | 9 ---------
>  1 file changed, 9 deletions(-)
> 
> diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c
> index a4b6bb6..0ea521b 100644
> --- a/drivers/staging/rtl8723au/core/rtw_xmit.c
> +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c
> @@ -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);
>  
> -- 
> 2.1.0
> 
> -- 
> 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 outreachy-kernel+unsubscribe@googlegroups.com.
> To post to this group, send email to outreachy-kernel@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20151014005112.GA26569%40ubuntu.
> For more options, visit https://groups.google.com/d/optout.
> 


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

* Re: [Outreachy kernel] [PATCH] Staging: rtl8723au: rtw_xmit: Remove extra NULL tests
  2015-10-14  5:48 ` [Outreachy kernel] " Julia Lawall
@ 2015-10-14  9:08   ` Shivani Bhardwaj
  2015-10-14  9:09     ` Shivani Bhardwaj
  0 siblings, 1 reply; 10+ messages in thread
From: Shivani Bhardwaj @ 2015-10-14  9:08 UTC (permalink / raw)
  To: Julia Lawall; +Cc: outreachy-kernel

On Wed, Oct 14, 2015 at 11:18 AM, Julia Lawall <julia.lawall@lip6.fr> wrote:
> On Wed, 14 Oct 2015, Shivani Bhardwaj wrote:
>
>> Variables already tested for NULL value are checked again so, the extra
>> NULL tests should be removed.
>> Semantic patch used:
>>
>> @@ expression E; @@
>> if(E==NULL) {... return...;}
>> - if(E)
>
> This is not a valid semantic patch.  The if needs at least a then branch.
>
> julia
>
>

@@ expression E; @@
if(E==NULL) {... return ...;}
else S
-if(E==NULL){
+{
...
}
-else S

Can you check this one, Julia?

>>
>> Signed-off-by: Shivani Bhardwaj <shivanib134@gmail.com>
>> ---
>>  drivers/staging/rtl8723au/core/rtw_xmit.c | 9 ---------
>>  1 file changed, 9 deletions(-)
>>
>> diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c
>> index a4b6bb6..0ea521b 100644
>> --- a/drivers/staging/rtl8723au/core/rtw_xmit.c
>> +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c
>> @@ -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);
>>
>> --
>> 2.1.0
>>
>> --
>> 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 outreachy-kernel+unsubscribe@googlegroups.com.
>> To post to this group, send email to outreachy-kernel@googlegroups.com.
>> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20151014005112.GA26569%40ubuntu.
>> For more options, visit https://groups.google.com/d/optout.
>>


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

* Re: [Outreachy kernel] [PATCH] Staging: rtl8723au: rtw_xmit: Remove extra NULL tests
  2015-10-14  9:08   ` Shivani Bhardwaj
@ 2015-10-14  9:09     ` Shivani Bhardwaj
  2015-10-14  9:14       ` Julia Lawall
  0 siblings, 1 reply; 10+ messages in thread
From: Shivani Bhardwaj @ 2015-10-14  9:09 UTC (permalink / raw)
  To: Julia Lawall; +Cc: outreachy-kernel

On Wed, Oct 14, 2015 at 2:38 PM, Shivani Bhardwaj <shivanib134@gmail.com> wrote:
> On Wed, Oct 14, 2015 at 11:18 AM, Julia Lawall <julia.lawall@lip6.fr> wrote:
>> On Wed, 14 Oct 2015, Shivani Bhardwaj wrote:
>>
>>> Variables already tested for NULL value are checked again so, the extra
>>> NULL tests should be removed.
>>> Semantic patch used:
>>>
>>> @@ expression E; @@
>>> if(E==NULL) {... return...;}
>>> - if(E)
>>
>> This is not a valid semantic patch.  The if needs at least a then branch.
>>
>> julia
>>
>>
>
> @@ expression E;
statement S; @@
> if(E==NULL) {... return ...;}
> else S
> -if(E==NULL){
> +{
> ...
> }
> -else S
>
> Can you check this one, Julia?
>
>>>
>>> Signed-off-by: Shivani Bhardwaj <shivanib134@gmail.com>
>>> ---
>>>  drivers/staging/rtl8723au/core/rtw_xmit.c | 9 ---------
>>>  1 file changed, 9 deletions(-)
>>>
>>> diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c
>>> index a4b6bb6..0ea521b 100644
>>> --- a/drivers/staging/rtl8723au/core/rtw_xmit.c
>>> +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c
>>> @@ -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);
>>>
>>> --
>>> 2.1.0
>>>
>>> --
>>> 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 outreachy-kernel+unsubscribe@googlegroups.com.
>>> To post to this group, send email to outreachy-kernel@googlegroups.com.
>>> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20151014005112.GA26569%40ubuntu.
>>> For more options, visit https://groups.google.com/d/optout.
>>>


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

* Re: [Outreachy kernel] [PATCH] Staging: rtl8723au: rtw_xmit: Remove extra NULL tests
  2015-10-14  9:09     ` Shivani Bhardwaj
@ 2015-10-14  9:14       ` Julia Lawall
  2015-10-14  9:17         ` Shivani Bhardwaj
  0 siblings, 1 reply; 10+ messages in thread
From: Julia Lawall @ 2015-10-14  9:14 UTC (permalink / raw)
  To: Shivani Bhardwaj; +Cc: outreachy-kernel



On Wed, 14 Oct 2015, Shivani Bhardwaj wrote:

> On Wed, Oct 14, 2015 at 2:38 PM, Shivani Bhardwaj <shivanib134@gmail.com> wrote:
> > On Wed, Oct 14, 2015 at 11:18 AM, Julia Lawall <julia.lawall@lip6.fr> wrote:
> >> On Wed, 14 Oct 2015, Shivani Bhardwaj wrote:
> >>
> >>> Variables already tested for NULL value are checked again so, the extra
> >>> NULL tests should be removed.
> >>> Semantic patch used:
> >>>
> >>> @@ expression E; @@
> >>> if(E==NULL) {... return...;}
> >>> - if(E)
> >>
> >> This is not a valid semantic patch.  The if needs at least a then branch.
> >>
> >> julia
> >>
> >>
> >
> > @@ expression E;
> statement S; @@
> > if(E==NULL) {... return ...;}
> > else S
> > -if(E==NULL){
> > +{
> > ...
> > }
> > -else S

It is strange to remove the { and add it back.  Your semantic patch can
have more newlines than the actual C code, so you don't have to put the {
on the same line as the if.

julia

> >
> > Can you check this one, Julia?
> >
> >>>
> >>> Signed-off-by: Shivani Bhardwaj <shivanib134@gmail.com>
> >>> ---
> >>>  drivers/staging/rtl8723au/core/rtw_xmit.c | 9 ---------
> >>>  1 file changed, 9 deletions(-)
> >>>
> >>> diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c
> >>> index a4b6bb6..0ea521b 100644
> >>> --- a/drivers/staging/rtl8723au/core/rtw_xmit.c
> >>> +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c
> >>> @@ -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);
> >>>
> >>> --
> >>> 2.1.0
> >>>
> >>> --
> >>> 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 outreachy-kernel+unsubscribe@googlegroups.com.
> >>> To post to this group, send email to outreachy-kernel@googlegroups.com.
> >>> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20151014005112.GA26569%40ubuntu.
> >>> For more options, visit https://groups.google.com/d/optout.
> >>>
>


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

* Re: [Outreachy kernel] [PATCH] Staging: rtl8723au: rtw_xmit: Remove extra NULL tests
  2015-10-14  9:14       ` Julia Lawall
@ 2015-10-14  9:17         ` Shivani Bhardwaj
  2015-10-14  9:51           ` Julia Lawall
  0 siblings, 1 reply; 10+ messages in thread
From: Shivani Bhardwaj @ 2015-10-14  9:17 UTC (permalink / raw)
  To: Julia Lawall; +Cc: outreachy-kernel

On Wed, Oct 14, 2015 at 2:44 PM, Julia Lawall <julia.lawall@lip6.fr> wrote:
>
>
> On Wed, 14 Oct 2015, Shivani Bhardwaj wrote:
>
>> On Wed, Oct 14, 2015 at 2:38 PM, Shivani Bhardwaj <shivanib134@gmail.com> wrote:
>> > On Wed, Oct 14, 2015 at 11:18 AM, Julia Lawall <julia.lawall@lip6.fr> wrote:
>> >> On Wed, 14 Oct 2015, Shivani Bhardwaj wrote:
>> >>
>> >>> Variables already tested for NULL value are checked again so, the extra
>> >>> NULL tests should be removed.
>> >>> Semantic patch used:
>> >>>
>> >>> @@ expression E; @@
>> >>> if(E==NULL) {... return...;}
>> >>> - if(E)
>> >>
>> >> This is not a valid semantic patch.  The if needs at least a then branch.
>> >>
>> >> julia
>> >>
>> >>
>> >
>> > @@ expression E;
>> statement S; @@
>> > if(E==NULL) {... return ...;}
>> > else S
>> > -if(E==NULL){
>> > +{
>> > ...
>> > }
>> > -else S
>
> It is strange to remove the { and add it back.  Your semantic patch can
> have more newlines than the actual C code, so you don't have to put the {
> on the same line as the if.
>
> julia
>

@@ expression E;
 statement S; @@
 if(E==NULL) {... return ...;}
 else S
 - if(E==NULL)
 {
 ...
 }
 - else S

How about this?

>> >
>> > Can you check this one, Julia?
>> >
>> >>>
>> >>> Signed-off-by: Shivani Bhardwaj <shivanib134@gmail.com>
>> >>> ---
>> >>>  drivers/staging/rtl8723au/core/rtw_xmit.c | 9 ---------
>> >>>  1 file changed, 9 deletions(-)
>> >>>
>> >>> diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c
>> >>> index a4b6bb6..0ea521b 100644
>> >>> --- a/drivers/staging/rtl8723au/core/rtw_xmit.c
>> >>> +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c
>> >>> @@ -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);
>> >>>
>> >>> --
>> >>> 2.1.0
>> >>>
>> >>> --
>> >>> 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 outreachy-kernel+unsubscribe@googlegroups.com.
>> >>> To post to this group, send email to outreachy-kernel@googlegroups.com.
>> >>> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20151014005112.GA26569%40ubuntu.
>> >>> For more options, visit https://groups.google.com/d/optout.
>> >>>
>>


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

* Re: [Outreachy kernel] [PATCH] Staging: rtl8723au: rtw_xmit: Remove extra NULL tests
  2015-10-14  9:17         ` Shivani Bhardwaj
@ 2015-10-14  9:51           ` Julia Lawall
  2015-10-14  9:54             ` Shivani Bhardwaj
  0 siblings, 1 reply; 10+ messages in thread
From: Julia Lawall @ 2015-10-14  9:51 UTC (permalink / raw)
  To: Shivani Bhardwaj; +Cc: outreachy-kernel

> @@ expression E;
>  statement S; @@
>  if(E==NULL) {... return ...;}
>  else S
>  - if(E==NULL)
>  {
>  ...
>  }
>  - else S
>
> How about this?

That's better.  But actually, you don't care about whether there are
braces, so you could just put S1.

Actually, there is also no need to require that the else of the second if
is the same as the else of the first one.  So you should have a different
statement metavariable in each case.

julia

>
> >> >
> >> > Can you check this one, Julia?
> >> >
> >> >>>
> >> >>> Signed-off-by: Shivani Bhardwaj <shivanib134@gmail.com>
> >> >>> ---
> >> >>>  drivers/staging/rtl8723au/core/rtw_xmit.c | 9 ---------
> >> >>>  1 file changed, 9 deletions(-)
> >> >>>
> >> >>> diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c
> >> >>> index a4b6bb6..0ea521b 100644
> >> >>> --- a/drivers/staging/rtl8723au/core/rtw_xmit.c
> >> >>> +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c
> >> >>> @@ -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);
> >> >>>
> >> >>> --
> >> >>> 2.1.0
> >> >>>
> >> >>> --
> >> >>> 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 outreachy-kernel+unsubscribe@googlegroups.com.
> >> >>> To post to this group, send email to outreachy-kernel@googlegroups.com.
> >> >>> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20151014005112.GA26569%40ubuntu.
> >> >>> For more options, visit https://groups.google.com/d/optout.
> >> >>>
> >>
>


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

* Re: [Outreachy kernel] [PATCH] Staging: rtl8723au: rtw_xmit: Remove extra NULL tests
  2015-10-14  9:51           ` Julia Lawall
@ 2015-10-14  9:54             ` Shivani Bhardwaj
  2015-10-14 10:00               ` Julia Lawall
  0 siblings, 1 reply; 10+ messages in thread
From: Shivani Bhardwaj @ 2015-10-14  9:54 UTC (permalink / raw)
  To: Julia Lawall; +Cc: outreachy-kernel

On Wed, Oct 14, 2015 at 3:21 PM, Julia Lawall <julia.lawall@lip6.fr> wrote:
>> @@ expression E;
>>  statement S; @@
>>  if(E==NULL) {... return ...;}
>>  else S
>>  - if(E==NULL)
>>  {
>>  ...
>>  }
>>  - else S
>>
>> How about this?
>
> That's better.  But actually, you don't care about whether there are
> braces, so you could just put S1.
>
> Actually, there is also no need to require that the else of the second if
> is the same as the else of the first one.  So you should have a different
> statement metavariable in each case.
>
> julia
>
@@ expression E;
 statement S1, S2; @@
 if(E==NULL) {... return ...;}
 else S1
- if(E==NULL)
- else S2

This should be fine, I think?

>>
>> >> >
>> >> > Can you check this one, Julia?
>> >> >
>> >> >>>
>> >> >>> Signed-off-by: Shivani Bhardwaj <shivanib134@gmail.com>
>> >> >>> ---
>> >> >>>  drivers/staging/rtl8723au/core/rtw_xmit.c | 9 ---------
>> >> >>>  1 file changed, 9 deletions(-)
>> >> >>>
>> >> >>> diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c
>> >> >>> index a4b6bb6..0ea521b 100644
>> >> >>> --- a/drivers/staging/rtl8723au/core/rtw_xmit.c
>> >> >>> +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c
>> >> >>> @@ -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);
>> >> >>>
>> >> >>> --
>> >> >>> 2.1.0
>> >> >>>
>> >> >>> --
>> >> >>> 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 outreachy-kernel+unsubscribe@googlegroups.com.
>> >> >>> To post to this group, send email to outreachy-kernel@googlegroups.com.
>> >> >>> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20151014005112.GA26569%40ubuntu.
>> >> >>> For more options, visit https://groups.google.com/d/optout.
>> >> >>>
>> >>
>>


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

* Re: [Outreachy kernel] [PATCH] Staging: rtl8723au: rtw_xmit: Remove extra NULL tests
  2015-10-14  9:54             ` Shivani Bhardwaj
@ 2015-10-14 10:00               ` Julia Lawall
  2015-10-14 10:02                 ` Shivani Bhardwaj
  0 siblings, 1 reply; 10+ messages in thread
From: Julia Lawall @ 2015-10-14 10:00 UTC (permalink / raw)
  To: Shivani Bhardwaj; +Cc: outreachy-kernel



On Wed, 14 Oct 2015, Shivani Bhardwaj wrote:

> On Wed, Oct 14, 2015 at 3:21 PM, Julia Lawall <julia.lawall@lip6.fr> wrote:
> >> @@ expression E;
> >>  statement S; @@
> >>  if(E==NULL) {... return ...;}
> >>  else S
> >>  - if(E==NULL)
> >>  {
> >>  ...
> >>  }
> >>  - else S
> >>
> >> How about this?
> >
> > That's better.  But actually, you don't care about whether there are
> > braces, so you could just put S1.
> >
> > Actually, there is also no need to require that the else of the second if
> > is the same as the else of the first one.  So you should have a different
> > statement metavariable in each case.
> >
> > julia
> >
> @@ expression E;
>  statement S1, S2; @@
>  if(E==NULL) {... return ...;}
>  else S1
> - if(E==NULL)
> - else S2
>
> This should be fine, I think?

No, an if has two branches, then an else.  You can omit the else, but here
you have omitted the then, so it doesn't work.

Actually, you can check your semantic patch by putting it in a file
file.cocci, and then running spatch --parse-cocci file.cocci

julia

>
> >>
> >> >> >
> >> >> > Can you check this one, Julia?
> >> >> >
> >> >> >>>
> >> >> >>> Signed-off-by: Shivani Bhardwaj <shivanib134@gmail.com>
> >> >> >>> ---
> >> >> >>>  drivers/staging/rtl8723au/core/rtw_xmit.c | 9 ---------
> >> >> >>>  1 file changed, 9 deletions(-)
> >> >> >>>
> >> >> >>> diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c
> >> >> >>> index a4b6bb6..0ea521b 100644
> >> >> >>> --- a/drivers/staging/rtl8723au/core/rtw_xmit.c
> >> >> >>> +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c
> >> >> >>> @@ -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);
> >> >> >>>
> >> >> >>> --
> >> >> >>> 2.1.0
> >> >> >>>
> >> >> >>> --
> >> >> >>> 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 outreachy-kernel+unsubscribe@googlegroups.com.
> >> >> >>> To post to this group, send email to outreachy-kernel@googlegroups.com.
> >> >> >>> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20151014005112.GA26569%40ubuntu.
> >> >> >>> For more options, visit https://groups.google.com/d/optout.
> >> >> >>>
> >> >>
> >>
>


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

* Re: [Outreachy kernel] [PATCH] Staging: rtl8723au: rtw_xmit: Remove extra NULL tests
  2015-10-14 10:00               ` Julia Lawall
@ 2015-10-14 10:02                 ` Shivani Bhardwaj
  0 siblings, 0 replies; 10+ messages in thread
From: Shivani Bhardwaj @ 2015-10-14 10:02 UTC (permalink / raw)
  To: Julia Lawall; +Cc: outreachy-kernel

On Wed, Oct 14, 2015 at 3:30 PM, Julia Lawall <julia.lawall@lip6.fr> wrote:
>
>
> On Wed, 14 Oct 2015, Shivani Bhardwaj wrote:
>
>> On Wed, Oct 14, 2015 at 3:21 PM, Julia Lawall <julia.lawall@lip6.fr> wrote:
>> >> @@ expression E;
>> >>  statement S; @@
>> >>  if(E==NULL) {... return ...;}
>> >>  else S
>> >>  - if(E==NULL)
>> >>  {
>> >>  ...
>> >>  }
>> >>  - else S
>> >>
>> >> How about this?
>> >
>> > That's better.  But actually, you don't care about whether there are
>> > braces, so you could just put S1.
>> >
>> > Actually, there is also no need to require that the else of the second if
>> > is the same as the else of the first one.  So you should have a different
>> > statement metavariable in each case.
>> >
>> > julia
>> >
>> @@ expression E;
>>  statement S1, S2; @@
>>  if(E==NULL) {... return ...;}
>>  else S1
>> - if(E==NULL)
>> - else S2
>>
>> This should be fine, I think?
>
> No, an if has two branches, then an else.  You can omit the else, but here
> you have omitted the then, so it doesn't work.
>
> Actually, you can check your semantic patch by putting it in a file
> file.cocci, and then running spatch --parse-cocci file.cocci
>
> julia
>

Right! I omitted the content inside if, which should not happen. I get
it now. Thanks, Julia! :)

>>
>> >>
>> >> >> >
>> >> >> > Can you check this one, Julia?
>> >> >> >
>> >> >> >>>
>> >> >> >>> Signed-off-by: Shivani Bhardwaj <shivanib134@gmail.com>
>> >> >> >>> ---
>> >> >> >>>  drivers/staging/rtl8723au/core/rtw_xmit.c | 9 ---------
>> >> >> >>>  1 file changed, 9 deletions(-)
>> >> >> >>>
>> >> >> >>> diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c
>> >> >> >>> index a4b6bb6..0ea521b 100644
>> >> >> >>> --- a/drivers/staging/rtl8723au/core/rtw_xmit.c
>> >> >> >>> +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c
>> >> >> >>> @@ -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);
>> >> >> >>>
>> >> >> >>> --
>> >> >> >>> 2.1.0
>> >> >> >>>
>> >> >> >>> --
>> >> >> >>> 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 outreachy-kernel+unsubscribe@googlegroups.com.
>> >> >> >>> To post to this group, send email to outreachy-kernel@googlegroups.com.
>> >> >> >>> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20151014005112.GA26569%40ubuntu.
>> >> >> >>> For more options, visit https://groups.google.com/d/optout.
>> >> >> >>>
>> >> >>
>> >>
>>


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

end of thread, other threads:[~2015-10-14 10:02 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-14  0:51 [PATCH] Staging: rtl8723au: rtw_xmit: Remove extra NULL tests Shivani Bhardwaj
2015-10-14  5:48 ` [Outreachy kernel] " Julia Lawall
2015-10-14  9:08   ` Shivani Bhardwaj
2015-10-14  9:09     ` Shivani Bhardwaj
2015-10-14  9:14       ` Julia Lawall
2015-10-14  9:17         ` Shivani Bhardwaj
2015-10-14  9:51           ` Julia Lawall
2015-10-14  9:54             ` Shivani Bhardwaj
2015-10-14 10:00               ` Julia Lawall
2015-10-14 10:02                 ` Shivani Bhardwaj

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.