Commit 409e8332 authored by Wambui Karuga's avatar Wambui Karuga Committed by Greg Kroah-Hartman

staging: rtl8723bs: Remove comparisons to NULL in conditionals

Remove most comparisons to NULL in conditionals in
drivers/staging/rtl8723bs/core/rtw_mlme.c
Issues reported by checkpatch.pl as:
CHECK: Comparison to NULL could be written
Signed-off-by: default avatarWambui Karuga <wambui.karugax@gmail.com>
Link: https://lore.kernel.org/r/f4752d3a49e02193ed7b47a353e18e56d94b5a68.1570712632.git.wambui.karugax@gmail.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent d13cf9ea
...@@ -40,7 +40,7 @@ int rtw_init_mlme_priv(struct adapter *padapter) ...@@ -40,7 +40,7 @@ int rtw_init_mlme_priv(struct adapter *padapter)
pbuf = vzalloc(array_size(MAX_BSS_CNT, sizeof(struct wlan_network))); pbuf = vzalloc(array_size(MAX_BSS_CNT, sizeof(struct wlan_network)));
if (pbuf == NULL) { if (!pbuf) {
res = _FAIL; res = _FAIL;
goto exit; goto exit;
} }
...@@ -185,7 +185,7 @@ void _rtw_free_network(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwor ...@@ -185,7 +185,7 @@ void _rtw_free_network(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwor
/* _irqL irqL; */ /* _irqL irqL; */
struct __queue *free_queue = &(pmlmepriv->free_bss_pool); struct __queue *free_queue = &(pmlmepriv->free_bss_pool);
if (pnetwork == NULL) if (!pnetwork)
return; return;
if (pnetwork->fixed == true) if (pnetwork->fixed == true)
...@@ -220,7 +220,7 @@ void _rtw_free_network_nolock(struct mlme_priv *pmlmepriv, struct wlan_network * ...@@ -220,7 +220,7 @@ void _rtw_free_network_nolock(struct mlme_priv *pmlmepriv, struct wlan_network *
struct __queue *free_queue = &(pmlmepriv->free_bss_pool); struct __queue *free_queue = &(pmlmepriv->free_bss_pool);
if (pnetwork == NULL) if (!pnetwork)
return; return;
if (pnetwork->fixed == true) if (pnetwork->fixed == true)
...@@ -633,7 +633,7 @@ void rtw_update_scanned_network(struct adapter *adapter, struct wlan_bssid_ex *t ...@@ -633,7 +633,7 @@ void rtw_update_scanned_network(struct adapter *adapter, struct wlan_bssid_ex *t
/* If there are no more slots, expire the oldest */ /* If there are no more slots, expire the oldest */
/* list_del_init(&oldest->list); */ /* list_del_init(&oldest->list); */
pnetwork = oldest; pnetwork = oldest;
if (pnetwork == NULL) { if (!pnetwork) {
RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("\n\n\nsomething wrong here\n\n\n")); RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("\n\n\nsomething wrong here\n\n\n"));
goto exit; goto exit;
} }
...@@ -654,7 +654,7 @@ void rtw_update_scanned_network(struct adapter *adapter, struct wlan_bssid_ex *t ...@@ -654,7 +654,7 @@ void rtw_update_scanned_network(struct adapter *adapter, struct wlan_bssid_ex *t
pnetwork = rtw_alloc_network(pmlmepriv); /* will update scan_time */ pnetwork = rtw_alloc_network(pmlmepriv); /* will update scan_time */
if (pnetwork == NULL) { if (!pnetwork) {
RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("\n\n\nsomething wrong here\n\n\n")); RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("\n\n\nsomething wrong here\n\n\n"));
goto exit; goto exit;
} }
...@@ -738,7 +738,7 @@ int rtw_is_desired_network(struct adapter *adapter, struct wlan_network *pnetwor ...@@ -738,7 +738,7 @@ int rtw_is_desired_network(struct adapter *adapter, struct wlan_network *pnetwor
privacy = pnetwork->network.Privacy; privacy = pnetwork->network.Privacy;
if (check_fwstate(pmlmepriv, WIFI_UNDER_WPS)) { if (check_fwstate(pmlmepriv, WIFI_UNDER_WPS)) {
if (rtw_get_wps_ie(pnetwork->network.IEs+_FIXED_IE_LENGTH_, pnetwork->network.IELength-_FIXED_IE_LENGTH_, NULL, &wps_ielen) != NULL) if (rtw_get_wps_ie(pnetwork->network.IEs+_FIXED_IE_LENGTH_, pnetwork->network.IELength-_FIXED_IE_LENGTH_, NULL, &wps_ielen))
return true; return true;
else else
return false; return false;
...@@ -1166,7 +1166,7 @@ static struct sta_info *rtw_joinbss_update_stainfo(struct adapter *padapter, str ...@@ -1166,7 +1166,7 @@ static struct sta_info *rtw_joinbss_update_stainfo(struct adapter *padapter, str
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
psta = rtw_get_stainfo(pstapriv, pnetwork->network.MacAddress); psta = rtw_get_stainfo(pstapriv, pnetwork->network.MacAddress);
if (psta == NULL) { if (!psta) {
psta = rtw_alloc_stainfo(pstapriv, pnetwork->network.MacAddress); psta = rtw_alloc_stainfo(pstapriv, pnetwork->network.MacAddress);
} }
...@@ -1413,7 +1413,7 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf) ...@@ -1413,7 +1413,7 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf)
/* s3. find ptarget_sta & update ptarget_sta after update cur_network only for station mode */ /* s3. find ptarget_sta & update ptarget_sta after update cur_network only for station mode */
if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) { if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) {
ptarget_sta = rtw_joinbss_update_stainfo(adapter, pnetwork); ptarget_sta = rtw_joinbss_update_stainfo(adapter, pnetwork);
if (ptarget_sta == NULL) { if (!ptarget_sta) {
RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Can't update stainfo when joinbss_event callback\n")); RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Can't update stainfo when joinbss_event callback\n"));
spin_unlock_bh(&(pmlmepriv->scanned_queue.lock)); spin_unlock_bh(&(pmlmepriv->scanned_queue.lock));
goto ignore_joinbss_callback; goto ignore_joinbss_callback;
...@@ -1503,7 +1503,7 @@ void rtw_sta_media_status_rpt(struct adapter *adapter, struct sta_info *psta, u3 ...@@ -1503,7 +1503,7 @@ void rtw_sta_media_status_rpt(struct adapter *adapter, struct sta_info *psta, u3
{ {
u16 media_status_rpt; u16 media_status_rpt;
if (psta == NULL) if (!psta)
return; return;
media_status_rpt = (u16)((psta->mac_id<<8)|mstatus); /* MACID|OPMODE:1 connect */ media_status_rpt = (u16)((psta->mac_id<<8)|mstatus); /* MACID|OPMODE:1 connect */
...@@ -1561,7 +1561,7 @@ void rtw_stassoc_event_callback(struct adapter *adapter, u8 *pbuf) ...@@ -1561,7 +1561,7 @@ void rtw_stassoc_event_callback(struct adapter *adapter, u8 *pbuf)
/* for AD-HOC mode */ /* for AD-HOC mode */
psta = rtw_get_stainfo(&adapter->stapriv, pstassoc->macaddr); psta = rtw_get_stainfo(&adapter->stapriv, pstassoc->macaddr);
if (psta != NULL) { if (psta) {
/* the sta have been in sta_info_queue => do nothing */ /* the sta have been in sta_info_queue => do nothing */
RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Error: rtw_stassoc_event_callback: sta has been in sta_hash_queue\n")); RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Error: rtw_stassoc_event_callback: sta has been in sta_hash_queue\n"));
...@@ -1570,7 +1570,7 @@ void rtw_stassoc_event_callback(struct adapter *adapter, u8 *pbuf) ...@@ -1570,7 +1570,7 @@ void rtw_stassoc_event_callback(struct adapter *adapter, u8 *pbuf)
} }
psta = rtw_alloc_stainfo(&adapter->stapriv, pstassoc->macaddr); psta = rtw_alloc_stainfo(&adapter->stapriv, pstassoc->macaddr);
if (psta == NULL) { if (!psta) {
RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Can't alloc sta_info when rtw_stassoc_event_callback\n")); RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Can't alloc sta_info when rtw_stassoc_event_callback\n"));
return; return;
} }
...@@ -1993,7 +1993,7 @@ int rtw_select_roaming_candidate(struct mlme_priv *mlme) ...@@ -1993,7 +1993,7 @@ int rtw_select_roaming_candidate(struct mlme_priv *mlme)
struct wlan_network *pnetwork = NULL; struct wlan_network *pnetwork = NULL;
struct wlan_network *candidate = NULL; struct wlan_network *candidate = NULL;
if (mlme->cur_network_scanned == NULL) { if (!mlme->cur_network_scanned) {
rtw_warn_on(1); rtw_warn_on(1);
return ret; return ret;
} }
...@@ -2006,7 +2006,7 @@ int rtw_select_roaming_candidate(struct mlme_priv *mlme) ...@@ -2006,7 +2006,7 @@ int rtw_select_roaming_candidate(struct mlme_priv *mlme)
while (phead != mlme->pscanned) { while (phead != mlme->pscanned) {
pnetwork = LIST_CONTAINOR(mlme->pscanned, struct wlan_network, list); pnetwork = LIST_CONTAINOR(mlme->pscanned, struct wlan_network, list);
if (pnetwork == NULL) { if (!pnetwork) {
RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("%s return _FAIL:(pnetwork == NULL)\n", __func__)); RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("%s return _FAIL:(pnetwork == NULL)\n", __func__));
ret = _FAIL; ret = _FAIL;
goto exit; goto exit;
...@@ -2024,7 +2024,7 @@ int rtw_select_roaming_candidate(struct mlme_priv *mlme) ...@@ -2024,7 +2024,7 @@ int rtw_select_roaming_candidate(struct mlme_priv *mlme)
} }
if (candidate == NULL) { if (!candidate) {
DBG_871X("%s: return _FAIL(candidate == NULL)\n", __func__); DBG_871X("%s: return _FAIL(candidate == NULL)\n", __func__);
ret = _FAIL; ret = _FAIL;
goto exit; goto exit;
...@@ -2141,7 +2141,7 @@ int rtw_select_and_join_from_scanned_queue(struct mlme_priv *pmlmepriv) ...@@ -2141,7 +2141,7 @@ int rtw_select_and_join_from_scanned_queue(struct mlme_priv *pmlmepriv)
while (phead != pmlmepriv->pscanned) { while (phead != pmlmepriv->pscanned) {
pnetwork = LIST_CONTAINOR(pmlmepriv->pscanned, struct wlan_network, list); pnetwork = LIST_CONTAINOR(pmlmepriv->pscanned, struct wlan_network, list);
if (pnetwork == NULL) { if (!pnetwork) {
RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("%s return _FAIL:(pnetwork == NULL)\n", __func__)); RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("%s return _FAIL:(pnetwork == NULL)\n", __func__));
ret = _FAIL; ret = _FAIL;
goto exit; goto exit;
...@@ -2159,7 +2159,7 @@ int rtw_select_and_join_from_scanned_queue(struct mlme_priv *pmlmepriv) ...@@ -2159,7 +2159,7 @@ int rtw_select_and_join_from_scanned_queue(struct mlme_priv *pmlmepriv)
} }
if (candidate == NULL) { if (!candidate) {
DBG_871X("%s: return _FAIL(candidate == NULL)\n", __func__); DBG_871X("%s: return _FAIL(candidate == NULL)\n", __func__);
#ifdef CONFIG_WOWLAN #ifdef CONFIG_WOWLAN
_clr_fwstate_(pmlmepriv, _FW_LINKED|_FW_UNDER_LINKING); _clr_fwstate_(pmlmepriv, _FW_LINKED|_FW_UNDER_LINKING);
...@@ -2200,14 +2200,14 @@ sint rtw_set_auth(struct adapter *adapter, struct security_priv *psecuritypriv) ...@@ -2200,14 +2200,14 @@ sint rtw_set_auth(struct adapter *adapter, struct security_priv *psecuritypriv)
sint res = _SUCCESS; sint res = _SUCCESS;
pcmd = rtw_zmalloc(sizeof(struct cmd_obj)); pcmd = rtw_zmalloc(sizeof(struct cmd_obj));
if (pcmd == NULL) { if (!pcmd) {
res = _FAIL; /* try again */ res = _FAIL; /* try again */
goto exit; goto exit;
} }
psetauthparm = rtw_zmalloc(sizeof(struct setauth_parm)); psetauthparm = rtw_zmalloc(sizeof(struct setauth_parm));
if (psetauthparm == NULL) { if (!psetauthparm) {
kfree(pcmd); kfree((unsigned char *)pcmd);
res = _FAIL; res = _FAIL;
goto exit; goto exit;
} }
...@@ -2240,7 +2240,7 @@ sint rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, s ...@@ -2240,7 +2240,7 @@ sint rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, s
sint res = _SUCCESS; sint res = _SUCCESS;
psetkeyparm = rtw_zmalloc(sizeof(struct setkey_parm)); psetkeyparm = rtw_zmalloc(sizeof(struct setkey_parm));
if (psetkeyparm == NULL) { if (!psetkeyparm) {
res = _FAIL; res = _FAIL;
goto exit; goto exit;
} }
...@@ -2291,8 +2291,8 @@ sint rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, s ...@@ -2291,8 +2291,8 @@ sint rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, s
if (enqueue) { if (enqueue) {
pcmd = rtw_zmalloc(sizeof(struct cmd_obj)); pcmd = rtw_zmalloc(sizeof(struct cmd_obj));
if (pcmd == NULL) { if (!pcmd) {
kfree(psetkeyparm); kfree((unsigned char *)psetkeyparm);
res = _FAIL; /* try again */ res = _FAIL; /* try again */
goto exit; goto exit;
} }
...@@ -2672,7 +2672,7 @@ unsigned int rtw_restructure_ht_ie(struct adapter *padapter, u8 *in_ie, u8 *out_ ...@@ -2672,7 +2672,7 @@ unsigned int rtw_restructure_ht_ie(struct adapter *padapter, u8 *in_ie, u8 *out_
ht_capie.cap_info |= cpu_to_le16(IEEE80211_HT_CAP_SGI_20); ht_capie.cap_info |= cpu_to_le16(IEEE80211_HT_CAP_SGI_20);
/* Get HT BW */ /* Get HT BW */
if (in_ie == NULL) { if (!in_ie) {
/* TDLS: TODO 20/40 issue */ /* TDLS: TODO 20/40 issue */
if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) {
operation_bw = padapter->mlmeextpriv.cur_bwmode; operation_bw = padapter->mlmeextpriv.cur_bwmode;
...@@ -2787,7 +2787,7 @@ unsigned int rtw_restructure_ht_ie(struct adapter *padapter, u8 *in_ie, u8 *out_ ...@@ -2787,7 +2787,7 @@ unsigned int rtw_restructure_ht_ie(struct adapter *padapter, u8 *in_ie, u8 *out_
phtpriv->ht_option = true; phtpriv->ht_option = true;
if (in_ie != NULL) { if (in_ie) {
p = rtw_get_ie(in_ie, _HT_ADD_INFO_IE_, &ielen, in_len); p = rtw_get_ie(in_ie, _HT_ADD_INFO_IE_, &ielen, in_len);
if (p && (ielen == sizeof(struct ieee80211_ht_addt_info))) { if (p && (ielen == sizeof(struct ieee80211_ht_addt_info))) {
out_len = *pout_len; out_len = *pout_len;
...@@ -2954,7 +2954,7 @@ void rtw_issue_addbareq_cmd(struct adapter *padapter, struct xmit_frame *pxmitfr ...@@ -2954,7 +2954,7 @@ void rtw_issue_addbareq_cmd(struct adapter *padapter, struct xmit_frame *pxmitfr
return; return;
} }
if (psta == NULL) { if (!psta) {
DBG_871X("%s, psta ==NUL\n", __func__); DBG_871X("%s, psta ==NUL\n", __func__);
return; return;
} }
......
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