From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0B404A034E; Wed, 9 Feb 2022 20:20:33 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0B463426F9; Wed, 9 Feb 2022 20:18:21 +0100 (CET) Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) by mails.dpdk.org (Postfix) with ESMTP id 2B760426ED for ; Wed, 9 Feb 2022 20:18:19 +0100 (CET) Received: by mail-pl1-f179.google.com with SMTP id c3so3078014pls.5 for ; Wed, 09 Feb 2022 11:18:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1PjndN3aiGxePH9sDfUlk/dbV9reDiQ138rNUWXQYBU=; b=SqWVXy7Rc35iHPO0gA6KGE7GFnSiE3cjHjAOvguLu/rPKH8ZsFB07B9RQ6vCpFcgdQ Z4Zkma/5TyQ+3mj+Hf3Q54m/iEdgYKkm8j97LkwoiNa0lvSUjklULEKw6noSikBDjbzN IXtyadTf7nVB9/UmCMCpGLSfHXmoZlmOmoVGFopvsT+u9w3gTmtB2NF5YZ8nEjW20kOc o8KwEp40Zqm6J79mR9YGI56s/xyDQ4z7fndsN7FTPVQcCovx6IUohRVftgMs/Fqvwo2Q KQTr2N9+ol4pKkavDNAoQv56UcLDqQvK+gSkMrVuQ6o9zilHmsK1X57CWuGN8wfZYPS6 lBPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1PjndN3aiGxePH9sDfUlk/dbV9reDiQ138rNUWXQYBU=; b=d5c2WNLn7zeldSHV1uexYD7vP4gcq4Dogx5QoMgIkoPxvTw0bNAbZIC9bljBwkGANa j600ckXJDskHwEseRN6VZhT9/PNlyMvW31YVNr/e3ZukEDXeG79Ma0ciaY/clyGAkN2E rb02T5nZ1iEVj3kQxB3/w3p4qbkC8SQI+9mQISFaI8BgLX/p3cdLaleUwWVrZS9va8o4 104wrC8uWAakONCaUHTMBDUZwsPAiEBzDaW/oL+ibW7unJM9SRiEGc2TS8JvpVOWRhxT ItOSxD4Rsdb5kC5S/MKZZnu/JWCAXch/A4tWezohk7WeWiwWo8/nAxHFeNXpO++L+0kL 0nNA== X-Gm-Message-State: AOAM532grnojfCtPjMjG92LW94YqN93SgFkA8laJWG6ME8cQ0yldGYL2 +k7utgh8I7E7qQY6be5901X9xmQvahj1clW71QM= X-Google-Smtp-Source: ABdhPJxfwdg/2TH7vIunjaWyh2nG4kqeklgf9gQ+W9R7tx9ZsXHyzNBXffMwv2O7tTNQRR82uHkbMg== X-Received: by 2002:a17:903:2487:: with SMTP id p7mr912318plw.108.1644434297985; Wed, 09 Feb 2022 11:18:17 -0800 (PST) Received: from hermes.local (204-195-112-199.wavecable.com. [204.195.112.199]) by smtp.gmail.com with ESMTPSA id u16sm14378401pgh.54.2022.02.09.11.18.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 11:18:17 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Haiyue Wang , Beilei Xing , Jingjing Wu , Qiming Yang , Qi Zhang Subject: [PATCH v3 22/36] net/i*: remove unnecessary NULL checks Date: Wed, 9 Feb 2022 11:17:34 -0800 Message-Id: <20220209191748.377729-23-stephen@networkplumber.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220209191748.377729-1-stephen@networkplumber.org> References: <20220124000518.319850-1-stephen@networkplumber.org> <20220209191748.377729-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Remove redundant NULL pointer checks before free functions found by nullfree.cocci Signed-off-by: Stephen Hemminger Acked-by: Haiyue Wang --- drivers/net/i40e/i40e_ethdev.c | 27 +++++++++------------------ drivers/net/i40e/i40e_rxtx.c | 3 +-- drivers/net/iavf/iavf_rxtx.c | 3 +-- drivers/net/ice/ice_fdir_filter.c | 6 ++---- drivers/net/igc/igc_flow.c | 5 +---- drivers/net/ixgbe/ixgbe_ethdev.c | 12 ++++-------- drivers/net/ixgbe/ixgbe_rxtx.c | 3 +-- 7 files changed, 19 insertions(+), 40 deletions(-) diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index 1d417dbf8ad7..ecfa3c94db44 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -1781,10 +1781,8 @@ i40e_rm_ethtype_filter_list(struct i40e_pf *pf) ethertype_rule = &pf->ethertype; /* Remove all ethertype filter rules and hash */ - if (ethertype_rule->hash_map) - rte_free(ethertype_rule->hash_map); - if (ethertype_rule->hash_table) - rte_hash_free(ethertype_rule->hash_table); + rte_free(ethertype_rule->hash_map); + rte_hash_free(ethertype_rule->hash_table); while ((p_ethertype = TAILQ_FIRST(ðertype_rule->ethertype_list))) { TAILQ_REMOVE(ðertype_rule->ethertype_list, @@ -1801,10 +1799,8 @@ i40e_rm_tunnel_filter_list(struct i40e_pf *pf) tunnel_rule = &pf->tunnel; /* Remove all tunnel director rules and hash */ - if (tunnel_rule->hash_map) - rte_free(tunnel_rule->hash_map); - if (tunnel_rule->hash_table) - rte_hash_free(tunnel_rule->hash_table); + rte_free(tunnel_rule->hash_map); + rte_hash_free(tunnel_rule->hash_table); while ((p_tunnel = TAILQ_FIRST(&tunnel_rule->tunnel_list))) { TAILQ_REMOVE(&tunnel_rule->tunnel_list, p_tunnel, rules); @@ -1833,16 +1829,11 @@ i40e_fdir_memory_cleanup(struct i40e_pf *pf) fdir_info = &pf->fdir; /* flow director memory cleanup */ - if (fdir_info->hash_map) - rte_free(fdir_info->hash_map); - if (fdir_info->hash_table) - rte_hash_free(fdir_info->hash_table); - if (fdir_info->fdir_flow_pool.bitmap) - rte_free(fdir_info->fdir_flow_pool.bitmap); - if (fdir_info->fdir_flow_pool.pool) - rte_free(fdir_info->fdir_flow_pool.pool); - if (fdir_info->fdir_filter_array) - rte_free(fdir_info->fdir_filter_array); + rte_free(fdir_info->hash_map); + rte_hash_free(fdir_info->hash_table); + rte_free(fdir_info->fdir_flow_pool.bitmap); + rte_free(fdir_info->fdir_flow_pool.pool); + rte_free(fdir_info->fdir_filter_array); } void i40e_flex_payload_reg_set_default(struct i40e_hw *hw) diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c index 9a00a9b71e2c..25a28ecea22c 100644 --- a/drivers/net/i40e/i40e_rxtx.c +++ b/drivers/net/i40e/i40e_rxtx.c @@ -2573,8 +2573,7 @@ i40e_reset_rx_queue(struct i40e_rx_queue *rxq) rxq->rx_tail = 0; rxq->nb_rx_hold = 0; - if (rxq->pkt_first_seg != NULL) - rte_pktmbuf_free(rxq->pkt_first_seg); + rte_pktmbuf_free(rxq->pkt_first_seg); rxq->pkt_first_seg = NULL; rxq->pkt_last_seg = NULL; diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c index 94819e59b220..715893864349 100644 --- a/drivers/net/iavf/iavf_rxtx.c +++ b/drivers/net/iavf/iavf_rxtx.c @@ -230,8 +230,7 @@ reset_rx_queue(struct iavf_rx_queue *rxq) rxq->rx_tail = 0; rxq->nb_rx_hold = 0; - if (rxq->pkt_first_seg != NULL) - rte_pktmbuf_free(rxq->pkt_first_seg); + rte_pktmbuf_free(rxq->pkt_first_seg); rxq->pkt_first_seg = NULL; rxq->pkt_last_seg = NULL; diff --git a/drivers/net/ice/ice_fdir_filter.c b/drivers/net/ice/ice_fdir_filter.c index 287032a6a739..b8728fb1be0b 100644 --- a/drivers/net/ice/ice_fdir_filter.c +++ b/drivers/net/ice/ice_fdir_filter.c @@ -421,10 +421,8 @@ ice_fdir_release_filter_list(struct ice_pf *pf) { struct ice_fdir_info *fdir_info = &pf->fdir; - if (fdir_info->hash_map) - rte_free(fdir_info->hash_map); - if (fdir_info->hash_table) - rte_hash_free(fdir_info->hash_table); + rte_free(fdir_info->hash_map); + rte_hash_free(fdir_info->hash_table); fdir_info->hash_map = NULL; fdir_info->hash_table = NULL; diff --git a/drivers/net/igc/igc_flow.c b/drivers/net/igc/igc_flow.c index 66053060af5a..58a6a8a539c6 100644 --- a/drivers/net/igc/igc_flow.c +++ b/drivers/net/igc/igc_flow.c @@ -775,10 +775,7 @@ igc_flow_create(struct rte_eth_dev *dev, } if (ret) { - /* check and free the memory */ - if (flow) - rte_free(flow); - + rte_free(flow); rte_flow_error_set(error, -ret, RTE_FLOW_ERROR_TYPE_HANDLE, NULL, "Failed to create flow."); diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index c8f0460440c0..d7efe5c6d753 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -1322,10 +1322,8 @@ static int ixgbe_fdir_filter_uninit(struct rte_eth_dev *eth_dev) IXGBE_DEV_PRIVATE_TO_FDIR_INFO(eth_dev->data->dev_private); struct ixgbe_fdir_filter *fdir_filter; - if (fdir_info->hash_map) - rte_free(fdir_info->hash_map); - if (fdir_info->hash_handle) - rte_hash_free(fdir_info->hash_handle); + rte_free(fdir_info->hash_map); + rte_hash_free(fdir_info->hash_handle); while ((fdir_filter = TAILQ_FIRST(&fdir_info->fdir_list))) { TAILQ_REMOVE(&fdir_info->fdir_list, @@ -1343,10 +1341,8 @@ static int ixgbe_l2_tn_filter_uninit(struct rte_eth_dev *eth_dev) IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(eth_dev->data->dev_private); struct ixgbe_l2_tn_filter *l2_tn_filter; - if (l2_tn_info->hash_map) - rte_free(l2_tn_info->hash_map); - if (l2_tn_info->hash_handle) - rte_hash_free(l2_tn_info->hash_handle); + rte_free(l2_tn_info->hash_map); + rte_hash_free(l2_tn_info->hash_handle); while ((l2_tn_filter = TAILQ_FIRST(&l2_tn_info->l2_tn_list))) { TAILQ_REMOVE(&l2_tn_info->l2_tn_list, diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c index 99e928a2a971..9e8ea366a506 100644 --- a/drivers/net/ixgbe/ixgbe_rxtx.c +++ b/drivers/net/ixgbe/ixgbe_rxtx.c @@ -2983,8 +2983,7 @@ ixgbe_reset_rx_queue(struct ixgbe_adapter *adapter, struct ixgbe_rx_queue *rxq) rxq->rx_tail = 0; rxq->nb_rx_hold = 0; - if (rxq->pkt_first_seg != NULL) - rte_pktmbuf_free(rxq->pkt_first_seg); + rte_pktmbuf_free(rxq->pkt_first_seg); rxq->pkt_first_seg = NULL; rxq->pkt_last_seg = NULL; -- 2.34.1