staging: rtl8192e: clean up comparisons to NULL
PATCH 1/1 staging: rtl8192e: clean up comparisons to NULL
Clean up comparisons to NULL to improve readability. Reported by checkpatch.
if (x == NULL) -> if (!x)
if (x != NULL) -> if (x)
Signed-off-by Michael Straube <[email protected]>
---
Compile tested only, due to missing hardware.
.../staging/rtl8192e/rtl8192e/r8192E_phy.c | 2 +- drivers/staging/rtl8192e/rtl8192e/rtl_cam.c | 2 +- drivers/staging/rtl8192e/rtl8192e/rtl_wx.c | 2 +- drivers/staging/rtl8192e/rtllib_crypt_ccmp.c | 2 +- drivers/staging/rtl8192e/rtllib_crypt_wep.c | 2 +- drivers/staging/rtl8192e/rtllib_rx.c | 24 +++++++++---------- drivers/staging/rtl8192e/rtllib_softmac.c | 2 +- 7 files changed, 17 insertions(+), 19 deletions(-)
drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c +1 -1
@@ -513,7 +513,7 @@ static u8 _rtl92e_phy_set_sw_chnl_cmd_array(struct net_device *dev, {struct sw_chnl_cmd *pCmd; -if (CmdTable ==NULL ) { +if (!CmdTable) {netdev_err (dev,"%s(): CmdTable cannot be NULL.\n" , __func__);return false; }
drivers/staging/rtl8192e/rtl8192e/rtl_cam.c +1 -1
@@ -112,7 +112,7 @@ void rtl92e_set_key(struct net_device *dev, u8 EntryNo, u8 KeyIndex,rtl92e_writel (dev,WCAMI , TargetContent);rtl92e_writel (dev,RWCAM , TargetCommand); }else { -if (KeyContent !=NULL ) { +if (KeyContent) {rtl92e_writel (dev,WCAMI , (u32)(*(KeyContent + i -2 )));rtl92e_writel (dev,RWCAM , TargetCommand);
drivers/staging/rtl8192e/rtl8192e/rtl_wx.c +1 -1
@@ -805,7 +805,7 @@ static int _rtl92e_wx_get_gen_ie(struct net_device *dev,struct r8192_priv *priv =rtllib_priv (dev);struct rtllib_device *ieee = priv->rtllib; -if (ieee->wpa_ie_len ==0 || ieee->wpa_ie ==NULL ) { +if (ieee->wpa_ie_len ==0 || !ieee->wpa_ie) { data->data.length =0 ;return 0 ; }
drivers/staging/rtl8192e/rtllib_crypt_ccmp.c +1 -1
@@ -52,7 +52,7 @@ static void *rtllib_ccmp_init(int key_idx)struct rtllib_ccmp_data *priv; priv =kzalloc (sizeof (*priv),GFP_ATOMIC ); -if (priv ==NULL ) +if (!priv) goto fail; priv->key_idx = key_idx;
drivers/staging/rtl8192e/rtllib_crypt_wep.c +1 -1
@@ -35,7 +35,7 @@ static void *prism2_wep_init(int keyidx)return NULL ; priv =kzalloc (sizeof (*priv),GFP_ATOMIC ); -if (priv ==NULL ) +if (!priv)return NULL ; priv->key_idx = keyidx;
drivers/staging/rtl8192e/rtllib_rx.c +11 -13
@@ -63,7 +63,7 @@ rtllib_frag_cache_find(struct rtllib_device *ieee, unsigned int seq,for (i =0 ; i <RTLLIB_FRAG_CACHE_LEN ; i++) { entry = &ieee->frag_cache[tid][i]; -if (entry->skb !=NULL && +if (entry->skb &&time_after (jiffies, entry->first_frag_time +2 *HZ )) { netdev_dbg(ieee->dev, "expiring fragment cache entry seq=%u last_frag=%u\n",
@@ -72,7 +72,7 @@ rtllib_frag_cache_find(struct rtllib_device *ieee, unsigned int seq, entry->skb =NULL ; } -if (entry->skb !=NULL && entry->seq == seq && +if (entry->skb && entry->seq == seq && (entry->last_frag +1 == frag || frag ==-1 ) &&memcmp (entry->src_addr, src,ETH_ALEN ) ==0 &&memcmp (entry->dst_addr, dst,ETH_ALEN ) ==0 )
@@ -130,7 +130,7 @@ rtllib_frag_cache_get(struct rtllib_device *ieee,if (ieee->frag_next_idx[tid] >=RTLLIB_FRAG_CACHE_LEN ) ieee->frag_next_idx[tid] =0 ; -if (entry->skb !=NULL ) +if (entry->skb)dev_kfree_skb_any (entry->skb); entry->first_frag_time = jiffies;
@@ -145,7 +145,7 @@ rtllib_frag_cache_get(struct rtllib_device *ieee,*/ entry =rtllib_frag_cache_find (ieee, seq, frag, tid, hdr->addr2, hdr->addr1); -if (entry !=NULL ) { +if (entry) { entry->last_frag = frag; skb = entry->skb; }
@@ -184,7 +184,7 @@ static int rtllib_frag_cache_invalidate(struct rtllib_device *ieee, entry =rtllib_frag_cache_find (ieee, seq,-1 , tid, hdr->addr2, hdr->addr1); -if (entry ==NULL ) { +if (!entry) {netdev_dbg (ieee->dev,"Couldn't invalidate fragment cache entry (seq=%u)\n" , seq);
@@ -276,7 +276,7 @@ rtllib_rx_frame_decrypt(struct rtllib_device *ieee, struct sk_buff *skb,struct ieee80211_hdr *hdr;int res, hdrlen; -if (crypt ==NULL || crypt->ops->decrypt_mpdu ==NULL ) +if (!crypt || !crypt->ops->decrypt_mpdu)return 0 ;if (ieee->hwsec_active) {
@@ -316,7 +316,7 @@ rtllib_rx_frame_decrypt_msdu(struct rtllib_device *ieee, struct sk_buff *skb,struct ieee80211_hdr *hdr;int res, hdrlen; -if (crypt ==NULL || crypt->ops->decrypt_msdu ==NULL ) +if (!crypt || !crypt->ops->decrypt_msdu)return 0 ;if (ieee->hwsec_active) { struct cb_desc *tcb_desc = (struct cb_desc *)
@@ -998,8 +998,7 @@ static int rtllib_rx_get_crypt(struct rtllib_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_PROTECTED )) {
@@ -1171,7 +1170,7 @@ static void rtllib_rx_indicate_pkt_legacy(struct rtllib_device *ieee,u16 ethertype;int i =0 ; -if (rxb ==NULL ) { +if (!rxb) {netdev_info (dev,"%s: rxb is NULL!!\n" , __func__);return ; }
@@ -1369,7 +1368,7 @@ static int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb,rtllib_rx_check_leave_lps (ieee, unicast, nr_subframes);/* Indicate packets to upper layer or Rx Reorder */ -if (!ieee->ht_info->cur_rx_reorder_enable || ts ==NULL ) +if (!ieee->ht_info->cur_rx_reorder_enable || !ts)rtllib_rx_indicate_pkt_legacy (ieee, rx_stats, rxb, dst, src);else RxReorderIndicatePacket (ieee, rxb, ts, SeqNum);
@@ -2510,8 +2509,7 @@ static inline void rtllib_process_probe_response(if (is_same_network (target, network, (target->ssid_len ?1 :0 )))break ; -if ((oldest ==NULL ) || - (target->last_scanned < oldest->last_scanned)) +if (!oldest || (target->last_scanned < oldest->last_scanned)) oldest = target; }
drivers/staging/rtl8192e/rtllib_softmac.c +1 -1
@@ -918,7 +918,7 @@ rtllib_association_req(struct rtllib_network *beacon,int len =0 ; crypt = ieee->crypt_info.crypt[ieee->crypt_info.tx_keyidx]; -if (crypt !=NULL ) +if (crypt) encrypt = crypt && crypt->ops && ((strcmp (crypt->ops->name,"R-WEP" ) ==0 || wpa_ie_len));
Signature · 1 line
2.42.0
Quoted 194 lines · Michael Straube
Clean up comparisons to NULL to improve readability. Reported by checkpatch.
if (x == NULL) -> if (!x)
if (x != NULL) -> if (x)Signed-off-by Michael Straube <[email protected]>---
Compile tested only, due to missing hardware..../staging/rtl8192e/rtl8192e/r8192E_phy.c | 2 +- drivers/staging/rtl8192e/rtl8192e/rtl_cam.c | 2 +- drivers/staging/rtl8192e/rtl8192e/rtl_wx.c | 2 +- drivers/staging/rtl8192e/rtllib_crypt_ccmp.c | 2 +- drivers/staging/rtl8192e/rtllib_crypt_wep.c | 2 +- drivers/staging/rtl8192e/rtllib_rx.c | 24 +++++++++---------- drivers/staging/rtl8192e/rtllib_softmac.c | 2 +- 7 files changed, 17 insertions(+), 19 deletions(-)drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c +1
-1@@ -513,7 +513,7 @@ static u8 _rtl92e_phy_set_sw_chnl_cmd_array(struct net_device *dev, {struct sw_chnl_cmd *pCmd; -if (CmdTable ==NULL ) { +if (!CmdTable) {netdev_err (dev,"%s(): CmdTable cannot be NULL.\n" , __func__);return false; }drivers/staging/rtl8192e/rtl8192e/rtl_cam.c +1
-1@@ -112,7 +112,7 @@ void rtl92e_set_key(struct net_device *dev, u8 EntryNo, u8 KeyIndex,rtl92e_writel (dev,WCAMI , TargetContent);rtl92e_writel (dev,RWCAM , TargetCommand); }else { -if (KeyContent !=NULL ) { +if (KeyContent) {rtl92e_writel (dev,WCAMI , (u32)(*(KeyContent + i -2 )));rtl92e_writel (dev,RWCAM , TargetCommand);drivers/staging/rtl8192e/rtl8192e/rtl_wx.c +1
-1@@ -805,7 +805,7 @@ static int _rtl92e_wx_get_gen_ie(struct net_device *dev,struct r8192_priv *priv =rtllib_priv (dev);struct rtllib_device *ieee = priv->rtllib; -if (ieee->wpa_ie_len ==0 || ieee->wpa_ie ==NULL ) { +if (ieee->wpa_ie_len ==0 || !ieee->wpa_ie) { data->data.length =0 ;return 0 ; }drivers/staging/rtl8192e/rtllib_crypt_ccmp.c +1
-1@@ -52,7 +52,7 @@ static void *rtllib_ccmp_init(int key_idx)struct rtllib_ccmp_data *priv; priv =kzalloc (sizeof (*priv),GFP_ATOMIC ); -if (priv ==NULL ) +if (!priv) goto fail; priv->key_idx = key_idx;drivers/staging/rtl8192e/rtllib_crypt_wep.c +1
-1@@ -35,7 +35,7 @@ static void *prism2_wep_init(int keyidx)return NULL ; priv =kzalloc (sizeof (*priv),GFP_ATOMIC ); -if (priv ==NULL ) +if (!priv)return NULL ; priv->key_idx = keyidx;drivers/staging/rtl8192e/rtllib_rx.c +11
-13@@ -63,7 +63,7 @@ rtllib_frag_cache_find(struct rtllib_device *ieee, unsigned int seq,for (i =0 ; i <RTLLIB_FRAG_CACHE_LEN ; i++) { entry = &ieee->frag_cache[tid][i]; -if (entry->skb !=NULL && +if (entry->skb &&time_after (jiffies, entry->first_frag_time +2 *HZ )) { netdev_dbg(ieee->dev, "expiring fragment cache entry seq=%u last_frag=%u\n",@@ -72,7 +72,7 @@ rtllib_frag_cache_find(struct rtllib_device *ieee, unsigned int seq, entry->skb =NULL ; } -if (entry->skb !=NULL && entry->seq == seq && +if (entry->skb && entry->seq == seq && (entry->last_frag +1 == frag || frag ==-1 ) &&memcmp (entry->src_addr, src,ETH_ALEN ) ==0 &&memcmp (entry->dst_addr, dst,ETH_ALEN ) ==0 )@@ -130,7 +130,7 @@ rtllib_frag_cache_get(struct rtllib_device *ieee,if (ieee->frag_next_idx[tid] >=RTLLIB_FRAG_CACHE_LEN ) ieee->frag_next_idx[tid] =0 ; -if (entry->skb !=NULL ) +if (entry->skb)dev_kfree_skb_any (entry->skb); entry->first_frag_time = jiffies;@@ -145,7 +145,7 @@ rtllib_frag_cache_get(struct rtllib_device *ieee,*/ entry =rtllib_frag_cache_find (ieee, seq, frag, tid, hdr->addr2, hdr->addr1); -if (entry !=NULL ) { +if (entry) { entry->last_frag = frag; skb = entry->skb; }@@ -184,7 +184,7 @@ static int rtllib_frag_cache_invalidate(struct rtllib_device *ieee, entry =rtllib_frag_cache_find (ieee, seq,-1 , tid, hdr->addr2, hdr->addr1); -if (entry ==NULL ) { +if (!entry) {netdev_dbg (ieee->dev,"Couldn't invalidate fragment cache entry (seq=%u)\n" , seq);@@ -276,7 +276,7 @@ rtllib_rx_frame_decrypt(struct rtllib_device *ieee, struct sk_buff *skb,struct ieee80211_hdr *hdr;int res, hdrlen; -if (crypt ==NULL || crypt->ops->decrypt_mpdu ==NULL ) +if (!crypt || !crypt->ops->decrypt_mpdu)return 0 ;if (ieee->hwsec_active) {@@ -316,7 +316,7 @@ rtllib_rx_frame_decrypt_msdu(struct rtllib_device *ieee, struct sk_buff *skb,struct ieee80211_hdr *hdr;int res, hdrlen; -if (crypt ==NULL || crypt->ops->decrypt_msdu ==NULL ) +if (!crypt || !crypt->ops->decrypt_msdu)return 0 ;if (ieee->hwsec_active) { struct cb_desc *tcb_desc = (struct cb_desc *)@@ -998,8 +998,7 @@ static int rtllib_rx_get_crypt(struct rtllib_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_PROTECTED )) {@@ -1171,7 +1170,7 @@ static void rtllib_rx_indicate_pkt_legacy(struct rtllib_device *ieee,u16 ethertype;int i =0 ; -if (rxb ==NULL ) { +if (!rxb) {netdev_info (dev,"%s: rxb is NULL!!\n" , __func__);return ; }@@ -1369,7 +1368,7 @@ static int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb,rtllib_rx_check_leave_lps (ieee, unicast, nr_subframes);/* Indicate packets to upper layer or Rx Reorder */ -if (!ieee->ht_info->cur_rx_reorder_enable || ts ==NULL ) +if (!ieee->ht_info->cur_rx_reorder_enable || !ts)rtllib_rx_indicate_pkt_legacy (ieee, rx_stats, rxb, dst, src);else RxReorderIndicatePacket (ieee, rxb, ts, SeqNum);@@ -2510,8 +2509,7 @@ static inline void rtllib_process_probe_response(if (is_same_network (target, network, (target->ssid_len ?1 :0 )))break ; -if ((oldest ==NULL ) || - (target->last_scanned < oldest->last_scanned)) +if (!oldest || (target->last_scanned < oldest->last_scanned)) oldest = target; }drivers/staging/rtl8192e/rtllib_softmac.c +0
-0
drivers/staging/rtl8192e/rtllib_softmac.c rtllib_association_req(struct rtllib_network *beacon, · line 924
Quoted 8 lines
drivers/staging/rtl8192e/rtllib_softmac.c +1
-1@@ -918,7 +918,7 @@ rtllib_association_req(struct rtllib_network *beacon,int len =0 ; crypt = ieee->crypt_info.crypt[ieee->crypt_info.tx_keyidx]; -if (crypt !=NULL ) +if (crypt) encrypt = crypt && crypt->ops && ((strcmp (crypt->ops->name,"R-WEP" ) ==0 || wpa_ie_len));
Tested-by Philipp Hortmann <[email protected]>