From ab5b78df177a29ac5c19d0a627820526617f23a4 Mon Sep 17 00:00:00 2001 From: Jeff Johnson Date: Mon, 18 Mar 2019 09:37:23 -0700 Subject: [PATCH] qcacmn: wmi: Replace explicit comparison to NULL Per the Linux Kernel coding style, as enforced by the kernel checkpatch script, pointers should not be explicitly compared to NULL. Therefore within wmi replace any such comparisons with logical operations performed on the pointer itself. Change-Id: Ida6b1b32330d97392bd879f84929782a64f4fc85 CRs-Fixed: 2418250 --- wmi/src/wmi_tlv_helper.c | 10 +++++----- wmi/src/wmi_unified.c | 12 ++++++------ wmi/src/wmi_unified_tlv.c | 16 ++++++++-------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/wmi/src/wmi_tlv_helper.c b/wmi/src/wmi_tlv_helper.c index f01cbd2d55ac..5414eb168114 100644 --- a/wmi/src/wmi_tlv_helper.c +++ b/wmi/src/wmi_tlv_helper.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2018 The Linux Foundation. All rights reserved. + * Copyright (c) 2013-2019 The Linux Foundation. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -541,7 +541,7 @@ wmitlv_check_and_pad_tlvs(void *os_handle, void *param_struc_ptr, return error; } #endif - if (*wmi_cmd_struct_ptr == NULL) { + if (!*wmi_cmd_struct_ptr) { /* Error: unable to alloc memory */ wmi_tlv_print_error ("%s: Error: unable to alloc memory (size=%d) for TLV\n", @@ -704,7 +704,7 @@ wmitlv_check_and_pad_tlvs(void *os_handle, void *param_struc_ptr, wmi_tlv_os_mem_alloc(os_handle, new_tlv_buf, (num_of_elems * attr_struct_ptr.tag_struct_size)); - if (new_tlv_buf == NULL) { + if (!new_tlv_buf) { /* Error: unable to alloc memory */ wmi_tlv_print_error ("%s: Error: unable to alloc memory (size=%d) for padding the TLV array %d\n", @@ -910,7 +910,7 @@ wmitlv_check_and_pad_tlvs(void *os_handle, void *param_struc_ptr, /* Dynamic memory allocation is supported */ wmi_tlv_os_mem_alloc(os_handle, new_tlv_buf, (curr_tlv_len - tlv_size_diff)); - if (new_tlv_buf == NULL) { + if (!new_tlv_buf) { /* Error: unable to alloc memory */ wmi_tlv_print_error ("%s: Error: unable to alloc memory (size=%d) for padding the TLV %d\n", @@ -1053,7 +1053,7 @@ static void wmitlv_free_allocated_tlvs(uint32_t is_cmd_id, /* macro to free that previously allocated memory for this TLV. When (op==FREE_TLV_ELEM). */ #define WMITLV_OP_FREE_TLV_ELEM_macro(param_ptr, param_len, wmi_cmd_event_id, elem_tlv_tag, elem_struc_type, elem_name, var_len, arr_size) \ if ((((WMITLV_TYPEDEF_STRUCT_PARAMS_TLVS(wmi_cmd_event_id) *)ptr)->WMITLV_FIELD_BUF_IS_ALLOCATED(elem_name)) && \ - (((WMITLV_TYPEDEF_STRUCT_PARAMS_TLVS(wmi_cmd_event_id) *)ptr)->elem_name != NULL)) \ + (((WMITLV_TYPEDEF_STRUCT_PARAMS_TLVS(wmi_cmd_event_id) *)ptr)->elem_name)) \ { \ wmi_tlv_os_mem_free(((WMITLV_TYPEDEF_STRUCT_PARAMS_TLVS(wmi_cmd_event_id) *)ptr)->elem_name); \ } diff --git a/wmi/src/wmi_unified.c b/wmi/src/wmi_unified.c index 46e99d7b88da..5405fe118215 100644 --- a/wmi/src/wmi_unified.c +++ b/wmi/src/wmi_unified.c @@ -1788,7 +1788,7 @@ static int wmi_unified_get_event_handler_ix(wmi_unified_t wmi_handle, for (idx = 0; (idx < soc->max_event_idx && idx < WMI_UNIFIED_MAX_EVENT); ++idx) { if (wmi_handle->event_id[idx] == event_id && - wmi_handle->event_handler[idx] != NULL) { + wmi_handle->event_handler[idx]) { return idx; } } @@ -2102,7 +2102,7 @@ static void wmi_control_rx(void *ctx, HTC_PACKET *htc_packet) evt_buf = (wmi_buf_t) htc_packet->pPktContext; wmi_handle = wmi_get_pdev_ep(soc, htc_packet->Endpoint); - if (wmi_handle == NULL) { + if (!wmi_handle) { WMI_LOGE ("unable to get wmi_handle to Endpoint %d\n", htc_packet->Endpoint); @@ -2411,7 +2411,7 @@ void *wmi_unified_get_pdev_handle(struct wmi_soc *soc, uint32_t pdev_idx) if (pdev_idx >= WMI_MAX_RADIOS) return NULL; - if (soc->wmi_pdev[pdev_idx] == NULL) { + if (!soc->wmi_pdev[pdev_idx]) { wmi_handle = (struct wmi_unified *) qdf_mem_malloc( sizeof(struct wmi_unified)); @@ -2430,7 +2430,7 @@ void *wmi_unified_get_pdev_handle(struct wmi_soc *soc, uint32_t pdev_idx) wmi_rx_event_work, wmi_handle); wmi_handle->wmi_rx_work_queue = qdf_alloc_unbound_workqueue("wmi_rx_event_work_queue"); - if (NULL == wmi_handle->wmi_rx_work_queue) { + if (!wmi_handle->wmi_rx_work_queue) { WMI_LOGE("failed to create wmi_rx_event_work_queue"); goto error; } @@ -2570,7 +2570,7 @@ void *wmi_unified_attach(void *scn_handle, wmi_rx_event_work, wmi_handle); wmi_handle->wmi_rx_work_queue = qdf_alloc_unbound_workqueue("wmi_rx_event_work_queue"); - if (NULL == wmi_handle->wmi_rx_work_queue) { + if (!wmi_handle->wmi_rx_work_queue) { WMI_LOGE("failed to create wmi_rx_event_work_queue"); goto error; } @@ -2742,7 +2742,7 @@ static void wmi_htc_tx_complete(void *ctx, HTC_PACKET *htc_pkt) ASSERT(wmi_cmd_buf); wmi_handle = wmi_get_pdev_ep(soc, htc_pkt->Endpoint); - if (wmi_handle == NULL) { + if (!wmi_handle) { WMI_LOGE("%s: Unable to get wmi handle\n", __func__); QDF_ASSERT(0); return; diff --git a/wmi/src/wmi_unified_tlv.c b/wmi/src/wmi_unified_tlv.c index 7714cd4b3c86..703edee10e40 100644 --- a/wmi/src/wmi_unified_tlv.c +++ b/wmi/src/wmi_unified_tlv.c @@ -1292,7 +1292,7 @@ static QDF_STATUS send_suspend_cmd_tlv(wmi_unified_t wmi_handle, * states are in sync */ wmibuf = wmi_buf_alloc(wmi_handle, len); - if (wmibuf == NULL) + if (!wmibuf) return QDF_STATUS_E_NOMEM; cmd = (wmi_pdev_suspend_cmd_fixed_param *) wmi_buf_data(wmibuf); @@ -1333,7 +1333,7 @@ static QDF_STATUS send_resume_cmd_tlv(wmi_unified_t wmi_handle, QDF_STATUS ret; wmibuf = wmi_buf_alloc(wmi_handle, sizeof(*cmd)); - if (wmibuf == NULL) + if (!wmibuf) return QDF_STATUS_E_NOMEM; cmd = (wmi_pdev_resume_cmd_fixed_param *) wmi_buf_data(wmibuf); WMITLV_SET_HDR(&cmd->tlv_header, @@ -6685,7 +6685,7 @@ static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle, sizeof(u_int8_t)*param->data_len + FIPS_ALIGN); /* Checking if kmalloc is successful to allocate space */ - if (key_unaligned == NULL) + if (!key_unaligned) return QDF_STATUS_SUCCESS; /* Checking if space is aligned */ if (!FIPS_IS_ALIGNED(key_unaligned, FIPS_ALIGN)) { @@ -6708,7 +6708,7 @@ static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle, 16, 1, key_aligned, param->key_len, true); /* Checking if kmalloc is successful to allocate space */ - if (data_unaligned == NULL) + if (!data_unaligned) return QDF_STATUS_SUCCESS; /* Checking of space is aligned */ if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) { @@ -6818,7 +6818,7 @@ send_pdev_fips_cmd_tlv(wmi_unified_t wmi_handle, cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target( param->pdev_id); - if (param->key != NULL && param->data != NULL) { + if (param->key && param->data) { cmd->key_len = param->key_len; cmd->data_len = param->data_len; cmd->fips_cmd = !!(param->op); @@ -8956,7 +8956,7 @@ static QDF_STATUS extract_chainmask_tables_tlv(wmi_unified_t wmi_handle, chainmask_caps = param_buf->mac_phy_chainmask_caps; - if (chainmask_caps == NULL) + if (!chainmask_caps) return QDF_STATUS_E_INVAL; for (i = 0; i < hw_caps->num_chainmask_tables; i++) { @@ -9096,7 +9096,7 @@ static QDF_STATUS extract_service_ready_ext_tlv(wmi_unified_t wmi_handle, } chain_mask_combo = param_buf->mac_phy_chainmask_combo; - if (chain_mask_combo == NULL) + if (!chain_mask_combo) return QDF_STATUS_SUCCESS; wmi_nofl_debug("Dumping chain mask combo data"); @@ -9465,7 +9465,7 @@ static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data) FIPS_ALIGN)); /* Assigning unaligned space to copy the data */ /* Checking if kmalloc does successful allocation */ - if (data_unaligned == NULL) + if (!data_unaligned) return QDF_STATUS_E_FAILURE; /* Checking if space is alligned */