staging: rtl8192u: ieee80211: Use !x in place of NULL comparison
PATCH 1/1 staging: rtl8192u: ieee80211: Use !x in place of NULL comparison
change NULL comparison to Boolean negation.Issue found using Coccinelle. Semantic patch used to solve the problem is as follow:
@replace_rule@
expression e;
@@
- e == NULL
+ !e
--- drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c +7 -7
@@ -341,7 +341,7 @@ ieee80211_rx_frame_decrypt(struct ieee80211_device *ieee, struct sk_buff *skb,struct rtl_80211_hdr_4addr *hdr;int res, hdrlen; -if (crypt ==NULL || crypt->ops->decrypt_mpdu ==NULL ) +if (!crypt || !crypt->ops->decrypt_mpdu)return 0 ;if (ieee->hwsec_active) {
@@ -388,7 +388,7 @@ ieee80211_rx_frame_decrypt_msdu(struct ieee80211_device *ieee, struct sk_buff *sstruct rtl_80211_hdr_4addr *hdr;int res, hdrlen; -if (crypt ==NULL || crypt->ops->decrypt_msdu ==NULL ) +if (!crypt || !crypt->ops->decrypt_msdu)return 0 ;if (ieee->hwsec_active) {
@@ -983,8 +983,8 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,/* allow NULL decrypt to indicate an station specific override * for default encryption */ -if (crypt && (crypt->ops ==NULL || - crypt->ops->decrypt_mpdu ==NULL )) +if (crypt && (!crypt->ops || + !crypt->ops->decrypt_mpdu)) crypt =NULL ;if (!crypt && (fc &IEEE80211_FCTL_WEP )) {
@@ -1285,7 +1285,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, }//added by amy for reorder -if (!ieee->pHTInfo->bCurRxReorderEnable || pTS ==NULL ){ +if (!ieee->pHTInfo->bCurRxReorderEnable || !pTS){//added by amy for reorder for (i =0 ; i<rxb->nr_subframes; i++) {struct sk_buff *sub_skb = rxb->subframes[i];
@@ -1421,9 +1421,9 @@ static int ieee80211_read_qos_info_element(structint ret =0 ;u16 size =sizeof (struct ieee80211_qos_information_element ) -2 ; -if (element_info ==NULL ) +if (!element_info)return -1 ; -if (info_element ==NULL ) +if (!info_element)return -1 ;if ((info_element->id ==QOS_ELEMENT_ID ) && (info_element->len == size)) {
Signature · 1 line
2.17.1
Quoted 38 lines · Vatsala Narang
change NULL comparison to Boolean negation.Issue found using Coccinelle. Semantic patch used to solve the problem is as follow:
@replace_rule@
expression e;
@@- e == NULL
+ !eSigned-off-by Vatsala Narang <[email protected]>--- drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c +2
-2@@ -341,7 +341,7 @@ ieee80211_rx_frame_decrypt(struct ieee80211_device *ieee, struct sk_buff *skb,struct rtl_80211_hdr_4addr *hdr;int res, hdrlen; -if (crypt ==NULL || crypt->ops->decrypt_mpdu ==NULL ) +if (!crypt || !crypt->ops->decrypt_mpdu)return 0 ;if (ieee->hwsec_active) {@@ -388,7 +388,7 @@ ieee80211_rx_frame_decrypt_msdu(struct ieee80211_device *ieee, struct sk_buff *sstruct rtl_80211_hdr_4addr *hdr;int res, hdrlen; -if (crypt ==NULL || crypt->ops->decrypt_msdu ==NULL ) +if (!crypt || !crypt->ops->decrypt_msdu)return 0 ;if (ieee->hwsec_active) {
drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, · line 987
Quoted 7 lines
drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c +2
-2@@ -983,8 +983,8 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,/* allow NULL decrypt to indicate an station specific override * for default encryption */ -if (crypt && (crypt->ops ==NULL || - crypt->ops->decrypt_mpdu ==NULL )) +if (crypt && (!crypt->ops || + !crypt->ops->decrypt_mpdu))
You could put the two lines into one to improve readability, now that the lines are shorter.
drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, · line 1288
Quoted 9 lines
drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c +1
-1crypt =NULL ;if (!crypt && (fc &IEEE80211_FCTL_WEP )) {@@ -1285,7 +1285,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, }//added by amy for reorder -if (!ieee->pHTInfo->bCurRxReorderEnable || pTS ==NULL ){ +if (!ieee->pHTInfo->bCurRxReorderEnable || !pTS){
You could put a space before the {
julia
Quoted 25 lines
drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c +2
-3//added by amy for reorder for (i =0 ; i<rxb->nr_subframes; i++) {struct sk_buff *sub_skb = rxb->subframes[i];@@ -1421,9 +1421,9 @@ static int ieee80211_read_qos_info_element(structint ret =0 ;u16 size =sizeof (struct ieee80211_qos_information_element ) -2 ; -if (element_info ==NULL ) +if (!element_info)return -1 ; -if (info_element ==NULL ) +if (!info_element)return -1 ;if ((info_element->id ==QOS_ELEMENT_ID ) && (info_element->len == size)) { --2.17.1
--
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/20190328184151.4315-1-vatsalanarang%40gmail.com.
For more options, visit https://groups.google.com/d/optout.
Okay,i will make these changes and keep them in mind from next time. thanks,
Vatsala Narang