From a507601be7c85b4a8356af690b0ec9cca04ca569 Mon Sep 17 00:00:00 2001 From: Ankit Gupta Date: Wed, 14 Sep 2016 11:32:19 -0700 Subject: qcacld-3.0: Align return value check for qdf_mem_cmp qdf_mem_cmp api returns zero when comparison string matches else returns non zero. Checking return value with true/false can cause confusion and errors. Replace the return value check from true/false to zero/non-zero values. Change-Id: I485d69a4bf85d1e6273ea780af6d0423c3910686 CRs-Fixed: 1066946 --- core/bmi/src/ol_fw.c | 2 +- core/cds/src/cds_regdomain.c | 12 ++++++------ core/dp/txrx/ol_rx.c | 4 +--- core/dp/txrx/ol_rx_fwd.c | 4 ++-- core/dp/txrx/ol_txrx.c | 10 ++++------ core/hdd/src/wlan_hdd_ioctl.c | 2 +- core/mac/src/pe/lim/lim_process_action_frame.c | 2 +- core/mac/src/pe/lim/lim_process_assoc_req_frame.c | 9 ++++----- core/mac/src/pe/lim/lim_scan_result_utils.c | 2 +- core/sme/src/common/sme_api.c | 3 +-- core/sme/src/csr/csr_api_scan.c | 8 ++++---- core/sme/src/csr/csr_neighbor_roam.c | 2 +- core/wma/src/wma_main.c | 8 ++++---- 13 files changed, 31 insertions(+), 37 deletions(-) diff --git a/core/bmi/src/ol_fw.c b/core/bmi/src/ol_fw.c index 2babdcfa918e..429ae5f848d1 100644 --- a/core/bmi/src/ol_fw.c +++ b/core/bmi/src/ol_fw.c @@ -127,7 +127,7 @@ static int ol_check_fw_hash(struct device *dev, goto end; } - if (qdf_mem_cmp(hash, digest, SHA256_DIGEST_SIZE) == 0) { + if (qdf_mem_cmp(hash, digest, SHA256_DIGEST_SIZE)) { BMI_ERR("Hash Mismatch"); qdf_trace_hex_dump(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_FATAL, digest, SHA256_DIGEST_SIZE); diff --git a/core/cds/src/cds_regdomain.c b/core/cds/src/cds_regdomain.c index 3d4c38e0e1fa..e798389a5dd7 100644 --- a/core/cds/src/cds_regdomain.c +++ b/core/cds/src/cds_regdomain.c @@ -819,11 +819,11 @@ uint16_t cds_reg_dmn_get_chanwidth_from_opclass(uint8_t *country, const struct reg_dmn_op_class_map_t *class; uint16_t i; - if (true != qdf_mem_cmp(country, "US", 2)) + if (!qdf_mem_cmp(country, "US", 2)) class = us_op_class; - else if (true != qdf_mem_cmp(country, "EU", 2)) + else if (!qdf_mem_cmp(country, "EU", 2)) class = euro_op_class; - else if (true != qdf_mem_cmp(country, "JP", 2)) + else if (!qdf_mem_cmp(country, "JP", 2)) class = japan_op_class; else class = global_op_class; @@ -859,11 +859,11 @@ uint16_t cds_reg_dmn_get_opclass_from_channel(uint8_t *country, uint8_t channel, const struct reg_dmn_op_class_map_t *class = NULL; uint16_t i = 0; - if (true != qdf_mem_cmp(country, "US", 2)) { + if (!qdf_mem_cmp(country, "US", 2)) { class = us_op_class; - } else if (true != qdf_mem_cmp(country, "EU", 2)) { + } else if (!qdf_mem_cmp(country, "EU", 2)) { class = euro_op_class; - } else if (true != qdf_mem_cmp(country, "JP", 2)) { + } else if (!qdf_mem_cmp(country, "JP", 2)) { class = japan_op_class; } else { class = global_op_class; diff --git a/core/dp/txrx/ol_rx.c b/core/dp/txrx/ol_rx.c index 760500c71642..4d9dc4aac1a9 100644 --- a/core/dp/txrx/ol_rx.c +++ b/core/dp/txrx/ol_rx.c @@ -214,10 +214,8 @@ static void ol_rx_process_inv_peer(ol_txrx_pdev_handle pdev, /* ignore frames for non-existent bssids */ qdf_mem_copy(a1, wh->i_addr1, IEEE80211_ADDR_LEN); TAILQ_FOREACH(vdev, &pdev->vdev_list, vdev_list_elem) { - if (qdf_mem_cmp(a1, vdev->mac_addr.raw, IEEE80211_ADDR_LEN) - != 0) { + if (qdf_mem_cmp(a1, vdev->mac_addr.raw, IEEE80211_ADDR_LEN)) break; - } } if (!vdev) return; diff --git a/core/dp/txrx/ol_rx_fwd.c b/core/dp/txrx/ol_rx_fwd.c index 589f9d2e8e1f..65af905ee306 100644 --- a/core/dp/txrx/ol_rx_fwd.c +++ b/core/dp/txrx/ol_rx_fwd.c @@ -76,9 +76,9 @@ static inline void ol_ap_fwd_check(struct ol_txrx_vdev_t *vdev, qdf_nbuf_t msdu) if (type != IEEE80211_FC0_TYPE_DATA || subtype != 0x0 || ((tods != 1) || (fromds != 0)) || - (qdf_mem_cmp + qdf_mem_cmp (mac_header->i_addr3, vdev->mac_addr.raw, - IEEE80211_ADDR_LEN) != 0)) { + IEEE80211_ADDR_LEN)) { #ifdef DEBUG_HOST_RC TXRX_PRINT(TXRX_PRINT_LEVEL_INFO1, "Exit: %s | Unnecessary to adjust mac header\n", diff --git a/core/dp/txrx/ol_txrx.c b/core/dp/txrx/ol_txrx.c index c43ea2b82182..82c2b116b580 100644 --- a/core/dp/txrx/ol_txrx.c +++ b/core/dp/txrx/ol_txrx.c @@ -95,9 +95,9 @@ void ol_txrx_copy_mac_addr_raw(ol_txrx_vdev_handle vdev, uint8_t *bss_addr) { if (bss_addr && vdev->last_real_peer && - (qdf_mem_cmp((u8 *)bss_addr, + !qdf_mem_cmp((u8 *)bss_addr, vdev->last_real_peer->mac_addr.raw, - IEEE80211_ADDR_LEN) == 0)) + IEEE80211_ADDR_LEN)) qdf_mem_copy(vdev->hl_tdls_ap_mac_addr.raw, vdev->last_real_peer->mac_addr.raw, OL_TXRX_MAC_ADDR_LEN); @@ -2087,7 +2087,6 @@ ol_txrx_peer_attach(ol_txrx_vdev_handle vdev, uint8_t *peer_mac_addr) struct ol_txrx_peer_t *peer; struct ol_txrx_peer_t *temp_peer; uint8_t i; - int differs; bool wait_on_deletion = false; unsigned long rc; struct ol_txrx_pdev_t *pdev; @@ -2191,9 +2190,8 @@ ol_txrx_peer_attach(ol_txrx_vdev_handle vdev, uint8_t *peer_mac_addr) /* * For every peer MAp message search and set if bss_peer */ - differs = qdf_mem_cmp(peer->mac_addr.raw, vdev->mac_addr.raw, - OL_TXRX_MAC_ADDR_LEN); - if (differs) + if (qdf_mem_cmp(peer->mac_addr.raw, vdev->mac_addr.raw, + OL_TXRX_MAC_ADDR_LEN)) peer->bss_peer = 1; /* diff --git a/core/hdd/src/wlan_hdd_ioctl.c b/core/hdd/src/wlan_hdd_ioctl.c index 27a7f5f80fca..91b0ebef9027 100644 --- a/core/hdd/src/wlan_hdd_ioctl.c +++ b/core/hdd/src/wlan_hdd_ioctl.c @@ -4439,7 +4439,7 @@ static int drv_cmd_fast_reassoc(hdd_adapter_t *adapter, * if the target bssid is same as currently associated AP, * issue reassoc to same AP */ - if (true != qdf_mem_cmp(targetApBssid, + if (!qdf_mem_cmp(targetApBssid, pHddStaCtx->conn_info.bssId.bytes, QDF_MAC_ADDR_SIZE)) { hdd_info("Reassoc BSSID is same as currently associated AP bssid"); diff --git a/core/mac/src/pe/lim/lim_process_action_frame.c b/core/mac/src/pe/lim/lim_process_action_frame.c index d35e447dc8d8..7b8e00944635 100644 --- a/core/mac/src/pe/lim/lim_process_action_frame.c +++ b/core/mac/src/pe/lim/lim_process_action_frame.c @@ -1946,7 +1946,7 @@ void lim_process_action_frame(tpAniSirGlobal mac_ctx, /* Check if it is a vendor specific action frame. */ if (LIM_IS_STA_ROLE(session) && - (true != qdf_mem_cmp(session->selfMacAddr, + (!qdf_mem_cmp(session->selfMacAddr, &mac_hdr->da[0], sizeof(tSirMacAddr))) && IS_WES_MODE_ENABLED(mac_ctx) && !qdf_mem_cmp(vendor_specific->Oui, oui, 3)) { diff --git a/core/mac/src/pe/lim/lim_process_assoc_req_frame.c b/core/mac/src/pe/lim/lim_process_assoc_req_frame.c index eb660e6bb0d9..f60e43231eed 100644 --- a/core/mac/src/pe/lim/lim_process_assoc_req_frame.c +++ b/core/mac/src/pe/lim/lim_process_assoc_req_frame.c @@ -203,15 +203,14 @@ static bool lim_check_sta_in_pe_entries(tpAniSirGlobal mac_ctx, tpSirMacMgmtHdr * * Checks source addr to destination addr of assoc req frame * - * Return: true of no error, false otherwise + * Return: true if source and destination address are different */ static bool lim_chk_sa_da(tpAniSirGlobal mac_ctx, tpSirMacMgmtHdr hdr, tpPESession session, uint8_t sub_type) { - int result = qdf_mem_cmp((uint8_t *) hdr->sa, + if (qdf_mem_cmp((uint8_t *) hdr->sa, (uint8_t *) hdr->da, - (uint8_t) (sizeof(tSirMacAddr))); - if (0 != result) + (uint8_t) (sizeof(tSirMacAddr)))) return true; lim_log(mac_ctx, LOGE, FL("Assoc Req rejected: wlan.sa = wlan.da")); @@ -1103,7 +1102,7 @@ static bool lim_process_assoc_req_sta_ctx(tpAniSirGlobal mac_ctx, /* no change in the capability so drop the frame */ if ((sub_type == LIM_ASSOC) && - (0 == qdf_mem_cmp(&sta_ds->mlmStaContext.capabilityInfo, + (!qdf_mem_cmp(&sta_ds->mlmStaContext.capabilityInfo, &assoc_req->capabilityInfo, sizeof(tSirMacCapabilityInfo)))) { lim_log(mac_ctx, LOGE, diff --git a/core/mac/src/pe/lim/lim_scan_result_utils.c b/core/mac/src/pe/lim/lim_scan_result_utils.c index 64413251b181..58b43db3e6b6 100644 --- a/core/mac/src/pe/lim/lim_scan_result_utils.c +++ b/core/mac/src/pe/lim/lim_scan_result_utils.c @@ -261,7 +261,7 @@ bool lim_is_scan_requested_ssid(tpAniSirGlobal pMac, tSirMacSSid *ssId) uint8_t i = 0; for (i = 0; i < pMac->lim.gpLimMlmScanReq->numSsid; i++) { - if (true != qdf_mem_cmp((uint8_t *) ssId, + if (!qdf_mem_cmp((uint8_t *) ssId, (uint8_t *) &pMac->lim. gpLimMlmScanReq->ssId[i], (uint8_t) (pMac->lim. diff --git a/core/sme/src/common/sme_api.c b/core/sme/src/common/sme_api.c index cf838f0b41da..2baf673cda0f 100644 --- a/core/sme/src/common/sme_api.c +++ b/core/sme/src/common/sme_api.c @@ -7626,8 +7626,7 @@ QDF_STATUS sme_handle_change_country_code(tpAniSirGlobal pMac, void *pMsgBuf) * if the reset Supplicant country code command is triggered, * enable 11D, reset the country code and return */ - if (false == - qdf_mem_cmp(pMsg->countryCode, SME_INVALID_COUNTRY_CODE, 2)) { + if (!qdf_mem_cmp(pMsg->countryCode, SME_INVALID_COUNTRY_CODE, 2)) { pMac->roam.configParam.Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabledOriginal; diff --git a/core/sme/src/csr/csr_api_scan.c b/core/sme/src/csr/csr_api_scan.c index 386326e2c6a6..b33ccace5a31 100644 --- a/core/sme/src/csr/csr_api_scan.c +++ b/core/sme/src/csr/csr_api_scan.c @@ -2197,7 +2197,7 @@ QDF_STATUS csr_scan_flush_selective_result(tpAniSirGlobal pMac, bool flushP2P) pEntry = csr_ll_peek_head(pList, LL_ACCESS_NOLOCK); while (pEntry != NULL) { pBssDesc = GET_BASE_ADDR(pEntry, tCsrScanResult, Link); - if (flushP2P != qdf_mem_cmp(pBssDesc->Result.ssId.ssId, + if (flushP2P && !qdf_mem_cmp(pBssDesc->Result.ssId.ssId, "DIRECT-", 7)) { pFreeElem = pEntry; pEntry = csr_ll_next(pList, pEntry, LL_ACCESS_NOLOCK); @@ -4676,13 +4676,13 @@ QDF_STATUS csr_scan_process_single_bssdescr(tpAniSirGlobal mac_ctx, bool csr_scan_is_wild_card_scan(tpAniSirGlobal pMac, tSmeCmd *pCommand) { uint8_t bssid[QDF_MAC_ADDR_SIZE] = {0}; - bool f = qdf_mem_cmp(pCommand->u.scanCmd.u.scanRequest.bssid.bytes, - bssid, sizeof(struct qdf_mac_addr)); /* * It is not a wild card scan if the bssid is not broadcast and * the number of SSID is 1. */ - return ((!f) || (0xff == pCommand->u.scanCmd.u.scanRequest.bssid.bytes[0])) + return ((!qdf_mem_cmp(pCommand->u.scanCmd.u.scanRequest.bssid.bytes, + bssid, sizeof(struct qdf_mac_addr))) + || (0xff == pCommand->u.scanCmd.u.scanRequest.bssid.bytes[0])) && (pCommand->u.scanCmd.u.scanRequest.SSIDs.numOfSSIDs != 1); } diff --git a/core/sme/src/csr/csr_neighbor_roam.c b/core/sme/src/csr/csr_neighbor_roam.c index 4884cfd2cc4b..5a04fcedb69c 100644 --- a/core/sme/src/csr/csr_neighbor_roam.c +++ b/core/sme/src/csr/csr_neighbor_roam.c @@ -1695,7 +1695,7 @@ QDF_STATUS csr_neighbor_roam_handoff_req_hdlr( } /* sanity check */ - if (true != qdf_mem_cmp(handoff_req->bssid, + if (!qdf_mem_cmp(handoff_req->bssid, roam_ctrl_info->currAPbssid.bytes, sizeof(tSirMacAddr))) { sms_log(mac_ctx, LOGE, diff --git a/core/wma/src/wma_main.c b/core/wma/src/wma_main.c index aa47d07de511..6ccb25c744fb 100644 --- a/core/wma/src/wma_main.c +++ b/core/wma/src/wma_main.c @@ -3649,7 +3649,7 @@ static void wma_derive_ext_ht_cap(tp_wma_handle wma_handle, if (NULL == wma_handle || NULL == ht_cap) return; - if (0 == qdf_mem_cmp(ht_cap, &tmp, sizeof(struct wma_tgt_ht_cap))) { + if (!qdf_mem_cmp(ht_cap, &tmp, sizeof(struct wma_tgt_ht_cap))) { ht_cap->ht_rx_stbc = (!!(value & WMI_HT_CAP_RX_STBC)); ht_cap->ht_tx_stbc = (!!(value & WMI_HT_CAP_TX_STBC)); ht_cap->mpdu_density = (!!(value & WMI_HT_CAP_MPDU_DENSITY)); @@ -3733,7 +3733,7 @@ static void wma_update_target_ext_ht_cap(tp_wma_handle wma_handle, } } - if (0 != qdf_mem_cmp(&tmp_cap, &tmp_ht_cap, + if (qdf_mem_cmp(&tmp_cap, &tmp_ht_cap, sizeof(struct wma_tgt_ht_cap))) { qdf_mem_copy(ht_cap, &tmp_ht_cap, sizeof(struct wma_tgt_ht_cap)); @@ -3770,7 +3770,7 @@ static void wma_derive_ext_vht_cap(t_wma_handle *wma_handle, if (NULL == wma_handle || NULL == vht_cap) return; - if (0 == qdf_mem_cmp(vht_cap, &tmp_cap, + if (!qdf_mem_cmp(vht_cap, &tmp_cap, sizeof(struct wma_tgt_vht_cap))) { if (value & WMI_VHT_CAP_MAX_MPDU_LEN_11454) vht_cap->vht_max_mpdu = WMI_VHT_CAP_MAX_MPDU_LEN_11454; @@ -3904,7 +3904,7 @@ static void wma_update_target_ext_vht_cap(t_wma_handle *wma_handle, } } - if (0 != qdf_mem_cmp(&tmp_cap, &tmp_vht_cap, + if (qdf_mem_cmp(&tmp_cap, &tmp_vht_cap, sizeof(struct wma_tgt_vht_cap))) { qdf_mem_copy(vht_cap, &tmp_vht_cap, sizeof(struct wma_tgt_vht_cap)); -- cgit v1.2.3