Commit deabe035 authored by Puranjay Mohan's avatar Puranjay Mohan Committed by Greg Kroah-Hartman

Staging: rtl8192u: ieee80211: Use !x in place of NULL comparisons

Fix the following checkpatch.pl warning :
CHECK: Comparison to NULL could be written "!x"
by changing (x == NULL) to !x and (x != NULL) to x.
Signed-off-by: default avatarPuranjay Mohan <puranjay12@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 63a9c3ed
...@@ -155,7 +155,7 @@ struct net_device *alloc_ieee80211(int sizeof_priv) ...@@ -155,7 +155,7 @@ struct net_device *alloc_ieee80211(int sizeof_priv)
ieee80211_softmac_init(ieee); ieee80211_softmac_init(ieee);
ieee->pHTInfo = kzalloc(sizeof(RT_HIGH_THROUGHPUT), GFP_KERNEL); ieee->pHTInfo = kzalloc(sizeof(RT_HIGH_THROUGHPUT), GFP_KERNEL);
if (ieee->pHTInfo == NULL) { if (!ieee->pHTInfo) {
IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't alloc memory for HTInfo\n"); IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't alloc memory for HTInfo\n");
/* By this point in code ieee80211_networks_allocate() has been /* By this point in code ieee80211_networks_allocate() has been
......
...@@ -67,7 +67,7 @@ ieee80211_frag_cache_find(struct ieee80211_device *ieee, unsigned int seq, ...@@ -67,7 +67,7 @@ ieee80211_frag_cache_find(struct ieee80211_device *ieee, unsigned int seq,
for (i = 0; i < IEEE80211_FRAG_CACHE_LEN; i++) { for (i = 0; i < IEEE80211_FRAG_CACHE_LEN; i++) {
entry = &ieee->frag_cache[tid][i]; entry = &ieee->frag_cache[tid][i];
if (entry->skb != NULL && if (entry->skb &&
time_after(jiffies, entry->first_frag_time + 2 * HZ)) { time_after(jiffies, entry->first_frag_time + 2 * HZ)) {
IEEE80211_DEBUG_FRAG( IEEE80211_DEBUG_FRAG(
"expiring fragment cache entry " "expiring fragment cache entry "
...@@ -77,7 +77,7 @@ ieee80211_frag_cache_find(struct ieee80211_device *ieee, unsigned int seq, ...@@ -77,7 +77,7 @@ ieee80211_frag_cache_find(struct ieee80211_device *ieee, unsigned int seq,
entry->skb = NULL; entry->skb = NULL;
} }
if (entry->skb != NULL && entry->seq == seq && if (entry->skb && entry->seq == seq &&
(entry->last_frag + 1 == frag || frag == -1) && (entry->last_frag + 1 == frag || frag == -1) &&
memcmp(entry->src_addr, src, ETH_ALEN) == 0 && memcmp(entry->src_addr, src, ETH_ALEN) == 0 &&
memcmp(entry->dst_addr, dst, ETH_ALEN) == 0) memcmp(entry->dst_addr, dst, ETH_ALEN) == 0)
...@@ -133,7 +133,7 @@ ieee80211_frag_cache_get(struct ieee80211_device *ieee, ...@@ -133,7 +133,7 @@ ieee80211_frag_cache_get(struct ieee80211_device *ieee,
if (ieee->frag_next_idx[tid] >= IEEE80211_FRAG_CACHE_LEN) if (ieee->frag_next_idx[tid] >= IEEE80211_FRAG_CACHE_LEN)
ieee->frag_next_idx[tid] = 0; ieee->frag_next_idx[tid] = 0;
if (entry->skb != NULL) if (entry->skb)
dev_kfree_skb_any(entry->skb); dev_kfree_skb_any(entry->skb);
entry->first_frag_time = jiffies; entry->first_frag_time = jiffies;
...@@ -1092,7 +1092,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, ...@@ -1092,7 +1092,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
ieee->iw_mode == IW_MODE_REPEAT) && ieee->iw_mode == IW_MODE_REPEAT) &&
!from_assoc_ap) { !from_assoc_ap) {
switch (hostap_handle_sta_rx(ieee, dev, skb, rx_stats, switch (hostap_handle_sta_rx(ieee, dev, skb, rx_stats,
wds != NULL)) { wds)) {
case AP_RX_CONTINUE_NOT_AUTHORIZED: case AP_RX_CONTINUE_NOT_AUTHORIZED:
case AP_RX_CONTINUE: case AP_RX_CONTINUE:
break; break;
...@@ -1388,7 +1388,7 @@ static int ieee80211_read_qos_param_element(struct ieee80211_qos_parameter_info ...@@ -1388,7 +1388,7 @@ static int ieee80211_read_qos_param_element(struct ieee80211_qos_parameter_info
int ret = 0; int ret = 0;
u16 size = sizeof(struct ieee80211_qos_parameter_info) - 2; u16 size = sizeof(struct ieee80211_qos_parameter_info) - 2;
if ((info_element == NULL) || (element_param == NULL)) if (!info_element || !element_param)
return -1; return -1;
if (info_element->id == QOS_ELEMENT_ID && info_element->len == size) { if (info_element->id == QOS_ELEMENT_ID && info_element->len == size) {
...@@ -2508,7 +2508,7 @@ static inline void ieee80211_process_probe_response( ...@@ -2508,7 +2508,7 @@ static inline void ieee80211_process_probe_response(
list_for_each_entry(target, &ieee->network_list, list) { list_for_each_entry(target, &ieee->network_list, list) {
if (is_same_network(target, network, ieee)) if (is_same_network(target, network, ieee))
break; break;
if ((oldest == NULL) || if (!oldest ||
(target->last_scanned < oldest->last_scanned)) (target->last_scanned < oldest->last_scanned))
oldest = target; oldest = target;
} }
...@@ -2577,7 +2577,7 @@ static inline void ieee80211_process_probe_response( ...@@ -2577,7 +2577,7 @@ static inline void ieee80211_process_probe_response(
spin_unlock_irqrestore(&ieee->lock, flags); spin_unlock_irqrestore(&ieee->lock, flags);
if (is_beacon(beacon->header.frame_ctl) && is_same_network(&ieee->current_network, network, ieee) && \ if (is_beacon(beacon->header.frame_ctl) && is_same_network(&ieee->current_network, network, ieee) && \
(ieee->state == IEEE80211_LINKED)) { (ieee->state == IEEE80211_LINKED)) {
if (ieee->handle_beacon != NULL) if (ieee->handle_beacon)
ieee->handle_beacon(ieee->dev,beacon,&ieee->current_network); ieee->handle_beacon(ieee->dev,beacon,&ieee->current_network);
} }
......
...@@ -2660,13 +2660,13 @@ static int ieee80211_wpa_set_wpa_ie(struct ieee80211_device *ieee, ...@@ -2660,13 +2660,13 @@ static int ieee80211_wpa_set_wpa_ie(struct ieee80211_device *ieee,
u8 *buf; u8 *buf;
if (param->u.wpa_ie.len > MAX_WPA_IE_LEN || if (param->u.wpa_ie.len > MAX_WPA_IE_LEN ||
(param->u.wpa_ie.len && param->u.wpa_ie.data == NULL)) (param->u.wpa_ie.len && !param->u.wpa_ie.data))
return -EINVAL; return -EINVAL;
if (param->u.wpa_ie.len) { if (param->u.wpa_ie.len) {
buf = kmemdup(param->u.wpa_ie.data, param->u.wpa_ie.len, buf = kmemdup(param->u.wpa_ie.data, param->u.wpa_ie.len,
GFP_KERNEL); GFP_KERNEL);
if (buf == NULL) if (!buf)
return -ENOMEM; return -ENOMEM;
kfree(ieee->wpa_ie); kfree(ieee->wpa_ie);
......
...@@ -311,7 +311,7 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee, ...@@ -311,7 +311,7 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
/* Check all the keys to see if any are still configured, /* Check all the keys to see if any are still configured,
* and if no key index was provided, de-init them all */ * and if no key index was provided, de-init them all */
for (i = 0; i < WEP_KEYS; i++) { for (i = 0; i < WEP_KEYS; i++) {
if (ieee->crypt[i] != NULL) { if (ieee->crypt[i]) {
if (key_provided) if (key_provided)
break; break;
ieee80211_crypt_delayed_deinit( ieee80211_crypt_delayed_deinit(
...@@ -333,14 +333,14 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee, ...@@ -333,14 +333,14 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
sec.enabled = 1; sec.enabled = 1;
sec.flags |= SEC_ENABLED; sec.flags |= SEC_ENABLED;
if (*crypt != NULL && (*crypt)->ops != NULL && if (*crypt && (*crypt)->ops &&
strcmp((*crypt)->ops->name, "WEP") != 0) { strcmp((*crypt)->ops->name, "WEP") != 0) {
/* changing to use WEP; deinit previously used algorithm /* changing to use WEP; deinit previously used algorithm
* on this key */ * on this key */
ieee80211_crypt_delayed_deinit(ieee, crypt); ieee80211_crypt_delayed_deinit(ieee, crypt);
} }
if (*crypt == NULL) { if (!*crypt) {
struct ieee80211_crypt_data *new_crypt; struct ieee80211_crypt_data *new_crypt;
/* take WEP into use */ /* take WEP into use */
...@@ -468,7 +468,7 @@ int ieee80211_wx_get_encode(struct ieee80211_device *ieee, ...@@ -468,7 +468,7 @@ int ieee80211_wx_get_encode(struct ieee80211_device *ieee,
crypt = ieee->crypt[key]; crypt = ieee->crypt[key];
erq->flags = key + 1; erq->flags = key + 1;
if (crypt == NULL || crypt->ops == NULL) { if (!crypt || !crypt->ops) {
erq->length = 0; erq->length = 0;
erq->flags |= IW_ENCODE_DISABLED; erq->flags |= IW_ENCODE_DISABLED;
return 0; return 0;
...@@ -537,7 +537,7 @@ int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee, ...@@ -537,7 +537,7 @@ int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee,
for (i = 0; i < WEP_KEYS; i++) for (i = 0; i < WEP_KEYS; i++)
if (ieee->crypt[i] != NULL) if (ieee->crypt[i])
break; break;
...@@ -582,7 +582,7 @@ int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee, ...@@ -582,7 +582,7 @@ int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee,
goto done; goto done;
} }
if (*crypt == NULL || (*crypt)->ops != ops) { if (!*crypt || (*crypt)->ops != ops) {
struct ieee80211_crypt_data *new_crypt; struct ieee80211_crypt_data *new_crypt;
ieee80211_crypt_delayed_deinit(ieee, crypt); ieee80211_crypt_delayed_deinit(ieee, crypt);
...@@ -595,7 +595,7 @@ int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee, ...@@ -595,7 +595,7 @@ int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee,
new_crypt->ops = ops; new_crypt->ops = ops;
if (new_crypt->ops && try_module_get(new_crypt->ops->owner)) if (new_crypt->ops && try_module_get(new_crypt->ops->owner))
new_crypt->priv = new_crypt->ops->init(idx); new_crypt->priv = new_crypt->ops->init(idx);
if (new_crypt->priv == NULL) { if (!new_crypt->priv) {
kfree(new_crypt); kfree(new_crypt);
ret = -EINVAL; ret = -EINVAL;
goto done; goto done;
...@@ -683,7 +683,7 @@ int ieee80211_wx_get_encode_ext(struct ieee80211_device *ieee, ...@@ -683,7 +683,7 @@ int ieee80211_wx_get_encode_ext(struct ieee80211_device *ieee,
encoding->flags = idx + 1; encoding->flags = idx + 1;
memset(ext, 0, sizeof(*ext)); memset(ext, 0, sizeof(*ext));
if (crypt == NULL || crypt->ops == NULL ) { if (!crypt || !crypt->ops) {
ext->alg = IW_ENCODE_ALG_NONE; ext->alg = IW_ENCODE_ALG_NONE;
ext->key_len = 0; ext->key_len = 0;
encoding->flags |= IW_ENCODE_DISABLED; encoding->flags |= IW_ENCODE_DISABLED;
...@@ -785,7 +785,7 @@ int ieee80211_wx_set_gen_ie(struct ieee80211_device *ieee, u8 *ie, size_t len) ...@@ -785,7 +785,7 @@ int ieee80211_wx_set_gen_ie(struct ieee80211_device *ieee, u8 *ie, size_t len)
{ {
u8 *buf; u8 *buf;
if (len>MAX_WPA_IE_LEN || (len && ie == NULL)) { if (len>MAX_WPA_IE_LEN || (len && !ie)) {
// printk("return error out, len:%d\n", len); // printk("return error out, len:%d\n", len);
return -EINVAL; return -EINVAL;
} }
...@@ -797,7 +797,7 @@ int ieee80211_wx_set_gen_ie(struct ieee80211_device *ieee, u8 *ie, size_t len) ...@@ -797,7 +797,7 @@ int ieee80211_wx_set_gen_ie(struct ieee80211_device *ieee, u8 *ie, size_t len)
return -EINVAL; return -EINVAL;
} }
buf = kmemdup(ie, len, GFP_KERNEL); buf = kmemdup(ie, len, GFP_KERNEL);
if (buf == NULL) if (!buf)
return -ENOMEM; return -ENOMEM;
kfree(ieee->wpa_ie); kfree(ieee->wpa_ie);
ieee->wpa_ie = buf; ieee->wpa_ie = buf;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment