summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPragaspathi Thilagaraj <tpragasp@codeaurora.org>2018-07-10 17:32:26 +0530
committernshrivas <nshrivas@codeaurora.org>2018-07-23 07:45:48 -0700
commit0851e6c550d7db67bdda42a41c5cb00dd0a69c6c (patch)
tree5e0ac742248867b1c5d82ca012663860e2fdd3eb
parent68694049bae7178e20be8ded2cc2385e97e4f23e (diff)
qcacld-3.0: Remove redundant null check for p_mac
In sme and lim, NULL check is available for h_hal. pmac is casted resultant from h_hal and is retrieved using PMAC_STRUCT macro, which is defined as ((tpAniSirGlobal)_hHal). Null check is added for this p_mac also which is redundant. Remove logically dead code to NULL check the p_mac. Change-Id: I7a22de3691b83e8ae04391e43cde82541eaabc23 CRs-Fixed: 2276003
-rw-r--r--core/hdd/src/wlan_hdd_wext.c12
-rw-r--r--core/mac/src/sys/common/src/wlan_qct_sys.c8
-rw-r--r--core/sap/src/sap_fsm.c49
-rw-r--r--core/sap/src/sap_module.c6
-rw-r--r--core/sme/src/common/sme_api.c95
5 files changed, 53 insertions, 117 deletions
diff --git a/core/hdd/src/wlan_hdd_wext.c b/core/hdd/src/wlan_hdd_wext.c
index 641253827e5c..463a351d4fba 100644
--- a/core/hdd/src/wlan_hdd_wext.c
+++ b/core/hdd/src/wlan_hdd_wext.c
@@ -9367,7 +9367,6 @@ static int __iw_get_char_setnone(struct net_device *dev,
int count = 0, check = 1;
tHalHandle hHal = NULL;
- tpAniSirGlobal pMac = NULL;
hdd_station_ctx_t *pHddStaCtx = NULL;
hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
@@ -9424,16 +9423,7 @@ static int __iw_get_char_setnone(struct net_device *dev,
buf =
scnprintf(extra + len,
WE_MAX_STR_LEN - len,
- "\n pMac is NULL");
- len += buf;
- break;
- }
- pMac = PMAC_STRUCT(hHal);
- if (!pMac) {
- buf =
- scnprintf(extra + len,
- WE_MAX_STR_LEN - len,
- "\n pMac is NULL");
+ "\n hHal is NULL");
len += buf;
break;
}
diff --git a/core/mac/src/sys/common/src/wlan_qct_sys.c b/core/mac/src/sys/common/src/wlan_qct_sys.c
index daeed0ee6dd6..d870adc7b0cd 100644
--- a/core/mac/src/sys/common/src/wlan_qct_sys.c
+++ b/core/mac/src/sys/common/src/wlan_qct_sys.c
@@ -212,13 +212,7 @@ QDF_STATUS sys_mc_process_msg(v_CONTEXT_t p_cds_context, cds_msg_t *pMsg)
break;
}
mac_ctx = PMAC_STRUCT(hHal);
- if (NULL == mac_ctx) {
- QDF_TRACE(QDF_MODULE_ID_SYS,
- QDF_TRACE_LEVEL_ERROR,
- FL("Invalid mac context"));
- qdf_mem_free(pMsg->bodyptr);
- break;
- }
+
if (NULL == mac_ctx->ftm_msg_processor_callback) {
QDF_TRACE(QDF_MODULE_ID_SYS,
QDF_TRACE_LEVEL_ERROR,
diff --git a/core/sap/src/sap_fsm.c b/core/sap/src/sap_fsm.c
index e1a204b7aa6e..db481a1fa65b 100644
--- a/core/sap/src/sap_fsm.c
+++ b/core/sap/src/sap_fsm.c
@@ -1183,11 +1183,6 @@ bool sap_dfs_is_w53_invalid(tHalHandle hHal, uint8_t channelID)
tpAniSirGlobal pMac;
pMac = PMAC_STRUCT(hHal);
- if (NULL == pMac) {
- QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR,
- FL("invalid pMac"));
- return false;
- }
/*
* Check for JAPAN W53 Channel operation capability
@@ -1218,14 +1213,8 @@ bool sap_dfs_is_w53_invalid(tHalHandle hHal, uint8_t channelID)
*/
bool sap_dfs_is_channel_in_preferred_location(tHalHandle hHal, uint8_t channelID)
{
- tpAniSirGlobal pMac;
+ tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
- pMac = PMAC_STRUCT(hHal);
- if (NULL == pMac) {
- QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR,
- FL("invalid pMac"));
- return true;
- }
if ((SAP_CHAN_PREFERRED_INDOOR ==
pMac->sap.SapDfsInfo.sap_operating_chan_preferred_location) &&
(true == IS_CHAN_JAPAN_OUTDOOR(channelID))) {
@@ -1338,11 +1327,6 @@ static uint8_t sap_apply_rules(ptSapContext sap_ctx)
}
mac_ctx = PMAC_STRUCT(hal);
- if (NULL == mac_ctx) {
- QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR,
- FL("mac_ctx pointer NULL"));
- return 0;
- }
preferred_location =
mac_ctx->sap.SapDfsInfo.sap_operating_chan_preferred_location;
@@ -1691,11 +1675,6 @@ static uint8_t sap_random_channel_sel(ptSapContext sap_ctx)
}
mac_ctx = PMAC_STRUCT(hal);
- if (NULL == mac_ctx) {
- QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR,
- FL("invalid mac_ctx"));
- return 0;
- }
/*
* Retrieve the original one and store it.
@@ -1837,12 +1816,11 @@ static void sap_mark_dfs_channels(ptSapContext sapContext, uint8_t *channels,
int i, j;
tSapDfsNolInfo *psapDfsChannelNolList = NULL;
uint8_t nRegDomainDfsChannels;
- tHalHandle hHal;
+ tHalHandle hHal = CDS_GET_HAL_CB(sapContext->p_cds_gctx);
tpAniSirGlobal pMac;
uint64_t time_elapsed_since_last_radar;
uint64_t time_when_radar_found;
- hHal = CDS_GET_HAL_CB(sapContext->p_cds_gctx);
if (NULL == channels)
return;
if (NULL == hHal) {
@@ -1851,11 +1829,6 @@ static void sap_mark_dfs_channels(ptSapContext sapContext, uint8_t *channels,
return;
}
pMac = PMAC_STRUCT(hHal);
- if (NULL == pMac) {
- QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR,
- FL("invalid pMac"));
- return;
- }
/*
* Mark the current channel on which Radar is found
@@ -2312,11 +2285,6 @@ QDF_STATUS sap_goto_channel_sel(ptSapContext sap_context,
}
mac_ctx = PMAC_STRUCT(h_hal);
- if (NULL == mac_ctx) {
- QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR,
- FL("Invalid MAC context"));
- return QDF_STATUS_E_FAILURE;
- }
if (cds_concurrent_beaconing_sessions_running()) {
con_ch =
@@ -2938,11 +2906,6 @@ QDF_STATUS sap_signal_hdd_event(ptSapContext sap_ctx,
return QDF_STATUS_E_FAILURE;
}
mac_ctx = PMAC_STRUCT(hal);
- if (NULL == mac_ctx) {
- QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR,
- FL("Invalid MAC context"));
- return QDF_STATUS_E_FAILURE;
- }
if (sap_hddevent != eSAP_UPDATE_SCAN_RESULT)
QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_HIGH,
@@ -4417,11 +4380,6 @@ QDF_STATUS sap_fsm(ptSapContext sap_ctx, ptWLAN_SAPEvent sap_event)
}
mac_ctx = PMAC_STRUCT(hal);
- if (NULL == mac_ctx) {
- QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR,
- FL("Invalid MAC context"));
- return QDF_STATUS_E_FAILURE;
- }
QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_DEBUG,
FL("sap_ctx=%pK, state_var=%d, msg=0x%x"),
@@ -4882,7 +4840,7 @@ static QDF_STATUS sap_get_channel_list(ptSapContext sap_ctx,
#ifdef FEATURE_WLAN_CH_AVOID
uint8_t i;
#endif
- tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
+ tpAniSirGlobal mac_ctx;
tSapChSelSpectInfo spect_info_obj = { NULL, 0 };
uint16_t ch_width;
@@ -4894,6 +4852,7 @@ static QDF_STATUS sap_get_channel_list(ptSapContext sap_ctx,
return QDF_STATUS_E_FAULT;
}
+ mac_ctx = PMAC_STRUCT(hal);
start_ch_num = sap_ctx->acs_cfg->start_ch;
end_ch_num = sap_ctx->acs_cfg->end_ch;
ch_width = sap_ctx->acs_cfg->ch_width;
diff --git a/core/sap/src/sap_module.c b/core/sap/src/sap_module.c
index 58fd382e8f7e..f9a96875e283 100644
--- a/core/sap/src/sap_module.c
+++ b/core/sap/src/sap_module.c
@@ -3039,12 +3039,12 @@ wlan_sap_set_channel_avoidance(tHalHandle hal, bool sap_channel_avoidance)
{
tpAniSirGlobal mac_ctx = NULL;
- if (NULL != hal)
+ if (NULL != hal) {
mac_ctx = PMAC_STRUCT(hal);
- if (mac_ctx == NULL || hal == NULL) {
+ } else {
QDF_TRACE(QDF_MODULE_ID_SAP,
QDF_TRACE_LEVEL_ERROR,
- FL("hal or mac_ctx pointer NULL"));
+ FL("hal pointer NULL"));
return QDF_STATUS_E_FAULT;
}
mac_ctx->sap.sap_channel_avoidance = sap_channel_avoidance;
diff --git a/core/sme/src/common/sme_api.c b/core/sme/src/common/sme_api.c
index d3c16621870c..f834505780cb 100644
--- a/core/sme/src/common/sme_api.c
+++ b/core/sme/src/common/sme_api.c
@@ -1563,24 +1563,17 @@ QDF_STATUS sme_update_roam_params(tHalHandle hal,
}
#ifdef WLAN_FEATURE_GTK_OFFLOAD
-static void sme_process_get_gtk_info_rsp(tHalHandle hHal,
+static void sme_process_get_gtk_info_rsp(tpAniSirGlobal mac_ctx,
tpSirGtkOffloadGetInfoRspParams
pGtkOffloadGetInfoRsp)
{
- tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
-
- if (NULL == pMac) {
- QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
- "%s: pMac is null", __func__);
- return;
- }
- if (pMac->sme.gtk_offload_get_info_cb == NULL) {
+ if (mac_ctx->sme.gtk_offload_get_info_cb == NULL) {
QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
"%s: HDD callback is null", __func__);
return;
}
- pMac->sme.gtk_offload_get_info_cb(
- pMac->sme.gtk_offload_get_info_cb_context,
+ mac_ctx->sme.gtk_offload_get_info_cb(
+ mac_ctx->sme.gtk_offload_get_info_cb_context,
pGtkOffloadGetInfoRsp);
}
#endif
@@ -2308,25 +2301,19 @@ QDF_STATUS sme_set_ese_roam_scan_channel_list(tHalHandle hHal,
#endif /* FEATURE_WLAN_ESE */
static
-QDF_STATUS sme_ibss_peer_info_response_handler(tHalHandle hHal,
+QDF_STATUS sme_ibss_peer_info_response_handler(tpAniSirGlobal mac_ctx,
tpSirIbssGetPeerInfoRspParams
pIbssPeerInfoParams)
{
- tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
- if (NULL == pMac) {
- QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
- "%s: pMac is null", __func__);
- return QDF_STATUS_E_FAILURE;
- }
- if (pMac->sme.peerInfoParams.peerInfoCbk == NULL) {
+ if (mac_ctx->sme.peerInfoParams.peerInfoCbk == NULL) {
QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
"%s: HDD callback is null", __func__);
return QDF_STATUS_E_FAILURE;
}
- pMac->sme.peerInfoParams.peerInfoCbk(pMac->sme.peerInfoParams.pUserData,
- &pIbssPeerInfoParams->
- ibssPeerInfoRspParams);
+ mac_ctx->sme.peerInfoParams.peerInfoCbk(
+ mac_ctx->sme.peerInfoParams.pUserData,
+ &pIbssPeerInfoParams->ibssPeerInfoRspParams);
return QDF_STATUS_SUCCESS;
}
@@ -3230,10 +3217,14 @@ QDF_STATUS sme_close(tHalHandle hHal)
{
QDF_STATUS status = QDF_STATUS_E_FAILURE;
QDF_STATUS fail_status = QDF_STATUS_SUCCESS;
- tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
+ tpAniSirGlobal pMac;
- if (!pMac)
+ if (NULL != hHal) {
+ pMac = PMAC_STRUCT(hHal);
+ } else {
+ sme_err(" Invalid hHal");
return QDF_STATUS_E_FAILURE;
+ }
/* Note: pSession will be invalid from here on, do not access */
status = csr_close(pMac);
@@ -3451,14 +3442,16 @@ QDF_STATUS sme_get_ap_channel_from_scan_cache(tHalHandle hal_handle,
uint8_t *ap_chnl_id)
{
QDF_STATUS status = QDF_STATUS_E_FAILURE;
- tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
+ tpAniSirGlobal mac_ctx;
tCsrScanResultFilter *scan_filter = NULL;
tScanResultHandle filtered_scan_result = NULL;
tSirBssDescription first_ap_profile;
- if (NULL == mac_ctx) {
+ if (NULL != hal_handle) {
+ mac_ctx = PMAC_STRUCT(hal_handle);
+ } else {
QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
- FL("mac_ctx is NULL"));
+ FL("hal_handle is NULL"));
return QDF_STATUS_E_FAILURE;
}
scan_filter = qdf_mem_malloc(sizeof(tCsrScanResultFilter));
@@ -3943,10 +3936,14 @@ QDF_STATUS sme_roam_connect(tHalHandle hHal, uint8_t sessionId,
tCsrRoamProfile *pProfile, uint32_t *pRoamId)
{
QDF_STATUS status = QDF_STATUS_E_FAILURE;
- tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
+ tpAniSirGlobal pMac;
- if (!pMac)
+ if (NULL != hHal) {
+ pMac = PMAC_STRUCT(hHal);
+ } else {
+ sme_err("Invalid hHal");
return QDF_STATUS_E_FAILURE;
+ }
MTRACE(qdf_trace(QDF_MODULE_ID_SME,
TRACE_CODE_SME_RX_HDD_MSG_CONNECT, sessionId, 0));
@@ -3979,19 +3976,12 @@ QDF_STATUS sme_set_phy_mode(tHalHandle hHal, eCsrPhyMode phyMode)
{
tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
- if (NULL == pMac) {
- QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
- "%s: invalid context", __func__);
- return QDF_STATUS_E_FAILURE;
- }
-
pMac->roam.configParam.phyMode = phyMode;
pMac->roam.configParam.uCfgDot11Mode =
csr_get_cfg_dot11_mode_from_csr_phy_mode(NULL,
pMac->roam.configParam.phyMode,
pMac->roam.configParam.
ProprietaryRatesEnabled);
-
return QDF_STATUS_SUCCESS;
}
@@ -4111,12 +4101,15 @@ QDF_STATUS sme_roam_disconnect(tHalHandle hHal, uint8_t sessionId,
*/
void sme_dhcp_done_ind(tHalHandle hal, uint8_t session_id)
{
- tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
+ tpAniSirGlobal mac_ctx;
tCsrRoamSession *session;
- if (!mac_ctx)
+ if (NULL != hal) {
+ mac_ctx = PMAC_STRUCT(hal);
+ } else {
+ sme_err("Invalid hal");
return;
-
+ }
session = CSR_GET_SESSION(mac_ctx, session_id);
if (!session) {
sme_err("Session: %d not found", session_id);
@@ -4169,7 +4162,10 @@ QDF_STATUS sme_roam_disconnect_sta(tHalHandle hHal, uint8_t sessionId,
QDF_STATUS status = QDF_STATUS_E_FAILURE;
tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
- if (NULL == pMac) {
+ if (NULL != hHal) {
+ pMac = PMAC_STRUCT(hHal);
+ } else {
+ sme_err("Invalid hHal");
QDF_ASSERT(0);
return status;
}
@@ -4241,9 +4237,11 @@ QDF_STATUS sme_roam_tkip_counter_measures(tHalHandle hHal, uint8_t sessionId,
bool bEnable)
{
QDF_STATUS status = QDF_STATUS_E_FAILURE;
- tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
+ tpAniSirGlobal pMac;
- if (NULL == pMac) {
+ if (NULL != hHal) {
+ pMac = PMAC_STRUCT(hHal);
+ } else {
QDF_ASSERT(0);
return status;
}
@@ -4285,9 +4283,11 @@ QDF_STATUS sme_roam_get_associated_stas(tHalHandle hHal, uint8_t sessionId,
uint8_t *pAssocStasBuf)
{
QDF_STATUS status = QDF_STATUS_E_FAILURE;
- tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
+ tpAniSirGlobal pMac;
- if (NULL == pMac) {
+ if (NULL != hHal) {
+ pMac = PMAC_STRUCT(hHal);
+ } else {
QDF_ASSERT(0);
return status;
}
@@ -5014,13 +5014,6 @@ void sme_register_ftm_msg_processor(tHalHandle hal,
hdd_ftm_msg_processor callback)
{
tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
-
- if (mac_ctx == NULL) {
- QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
- FL("mac ctx is NULL"));
- return;
- }
-
mac_ctx->ftm_msg_processor_callback = callback;
}