Browse Source

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
Pragaspathi Thilagaraj 6 years ago
parent
commit
b11dbe4531

+ 4 - 2
core/sap/src/sap_api_link_cntl.c

@@ -91,10 +91,12 @@ QDF_STATUS wlansap_scan_callback(tHalHandle hal_handle,
 	uint8_t operChannel = 0;
 	QDF_STATUS sap_sm_status;
 	uint32_t event;
-	tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
+	tpAniSirGlobal mac_ctx;
 
 
-	if (NULL == hal_handle) {
+	if (NULL != hal_handle) {
+		mac_ctx = PMAC_STRUCT(hal_handle);
+	} else {
 		QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR,
 					"In %s invalid hHal", __func__);
 		return QDF_STATUS_E_FAILURE;

+ 0 - 5
core/sap/src/sap_ch_select.c

@@ -421,11 +421,6 @@ void sap_update_unsafe_channel_list(tHalHandle hal, struct sap_context *sap_ctx)
 		return;
 	}
 	mac_ctx = PMAC_STRUCT(hal);
-	if (!mac_ctx) {
-		QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_FATAL,
-			  "mac_ctx is NULL");
-		return;
-	}
 
 	/* Flush, default set all channel safe */
 	for (i = 0; i < NUM_CHANNELS; i++) {

+ 0 - 20
core/sap/src/sap_fsm.c

@@ -234,11 +234,6 @@ static uint8_t sap_random_channel_sel(struct sap_context *sap_ctx)
 	}
 
 	mac_ctx = PMAC_STRUCT(hal);
-	if (!mac_ctx) {
-		QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR,
-			  FL("null mac_ctx"));
-		return 0;
-	}
 
 	pdev = mac_ctx->pdev;
 	if (!pdev) {
@@ -866,11 +861,6 @@ QDF_STATUS sap_goto_channel_sel(struct sap_context *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 (policy_mgr_concurrent_beaconing_sessions_running(mac_ctx->psoc) ||
 	   ((sap_context->cc_switch_mode ==
 		QDF_MCC_TO_SCC_SWITCH_FORCE_PREFERRED_WITHOUT_DISCONNECTION) &&
@@ -1502,11 +1492,6 @@ QDF_STATUS sap_signal_hdd_event(struct sap_context *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;
-	}
 	QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_HIGH,
 		  FL("SAP event callback event = %s"),
 		  sap_hdd_event_to_string(sap_hddevent));
@@ -2821,11 +2806,6 @@ QDF_STATUS sap_fsm(struct sap_context *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"),

+ 2 - 2
core/sap/src/sap_module.c

@@ -2038,9 +2038,9 @@ 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"));

+ 17 - 27
core/sme/src/common/sme_api.c

@@ -116,11 +116,6 @@ tpAniSirGlobal sme_get_mac_context(void)
 	}
 
 	mac_ctx = PMAC_STRUCT(h_hal);
-	if (NULL == mac_ctx) {
-		QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
-		FL("Invalid MAC context"));
-		return NULL;
-	}
 
 	return mac_ctx;
 }
@@ -485,9 +480,10 @@ QDF_STATUS sme_ser_handle_active_cmd(struct wlan_serialization_command *cmd)
 	}
 
 	hal = cds_get_context(QDF_MODULE_ID_SME);
-	mac_ctx = PMAC_STRUCT(hal);
-	if (!mac_ctx) {
-		sme_err("No mac_ctx found");
+	if (NULL != hal) {
+		mac_ctx = PMAC_STRUCT(hal);
+	} else {
+		sme_err("No hal found");
 		return QDF_STATUS_E_FAILURE;
 	}
 	sme_cmd = cmd->umac_cmd;
@@ -543,9 +539,10 @@ QDF_STATUS sme_ser_cmd_callback(void *buf,
 	tSmeCmd *sme_cmd;
 
 	hal = cds_get_context(QDF_MODULE_ID_SME);
-	mac_ctx = PMAC_STRUCT(hal);
-	if (!mac_ctx) {
-		sme_err("mac_ctx is null");
+	if (hal != NULL) {
+		mac_ctx = PMAC_STRUCT(hal);
+	} else {
+		sme_err("hal is null");
 		return QDF_STATUS_E_FAILURE;
 	}
 	/*
@@ -3149,12 +3146,6 @@ 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,
@@ -8714,14 +8705,15 @@ void sme_get_command_q_status(tHalHandle hHal)
 {
 	tSmeCmd *pTempCmd = NULL;
 	tListElem *pEntry;
-	tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
+	tpAniSirGlobal pMac;
 
-	if (NULL == pMac) {
+	if (NULL != hHal) {
+		pMac = PMAC_STRUCT(hHal);
+	} else {
 		QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
-			  "%s: pMac is NULL", __func__);
+			  "%s: Invalid hHal pointer", __func__);
 		return;
 	}
-
 	pEntry = csr_nonscan_active_ll_peek_head(pMac, LL_ACCESS_LOCK);
 	if (pEntry)
 		pTempCmd = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
@@ -12257,10 +12249,6 @@ QDF_STATUS sme_enable_dfs_chan_scan(tHalHandle h_hal, uint8_t dfs_flag)
 	}
 
 	mac = PMAC_STRUCT(h_hal);
-	if (!mac) {
-		sme_err("mac is NULL");
-		return QDF_STATUS_E_INVAL;
-	}
 
 	mac->scan.fEnableDFSChnlScan = dfs_flag;
 
@@ -13639,9 +13627,11 @@ void sme_update_tgt_services(tHalHandle hal, struct wma_tgt_services *cfg)
  */
 bool sme_is_session_id_valid(tHalHandle hal, uint32_t session_id)
 {
-	tpAniSirGlobal mac = PMAC_STRUCT(hal);
+	tpAniSirGlobal mac;
 
-	if (!mac) {
+	if (NULL != hal) {
+		mac = PMAC_STRUCT(hal);
+	} else {
 		QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
 			"%s: null mac pointer", __func__);
 		return false;