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 396BC45C7A; Tue, 12 Nov 2024 18:39:02 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 19A864065C; Tue, 12 Nov 2024 18:38:50 +0100 (CET) Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) by mails.dpdk.org (Postfix) with ESMTP id B7345402E8 for ; Tue, 12 Nov 2024 18:38:46 +0100 (CET) Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-71e8235f0b6so5013771b3a.3 for ; Tue, 12 Nov 2024 09:38:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1731433126; x=1732037926; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fJNMrOrWyzlIM3HiZWi4/+3NHsxzuCZiUzKdosbb7f4=; b=eNK7HxFwv7I1wLBYdFi7hWSrYE5wCTfQo7LPL2RqjbNl4pf3ZfyNPpqdos0ePaxoXA 7ZiOZjfdmdpTxZ/kvst51cAICIYJX8wgobK0JvHHaxCpXSUAoQUxe+NT2m8zE+PG+4cw 64jPzsHr0Em9T2srYsRdHDe3cqGaJYAn7HEBf/rBpz9EdpgOBVm28Wbu12KzaWUhEHhc fZZXa4D1t+sgV7whO6/qRf4oym5a6SKVjahUd5UBiZ/romoSAQhmOScv6WKYFQm7AVTM 5rAK+CsnPn2FJZ3G+8HCjfQqjHUtvxjmbuGHs+Jf4i2wiv3wB0QFSGEbOzwIxZmKrT8y usWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731433126; x=1732037926; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fJNMrOrWyzlIM3HiZWi4/+3NHsxzuCZiUzKdosbb7f4=; b=c5l5O7/LG9NkD8oRXclVvgHAPDDYbvycTTReceqjw+OzaSJ+WV639tMoQF22qpauKe kR43rWg5OY44yoskX78U6cnluEoImS5/Sllr625aFWJ/mPnbQoMur4IKZ7gf2iUhkl7A VqlA/StVer7jRhej7DavN5SERiY8bxBlkEnabMRkQQbursm6Ouy/q9ThMCHyJhLPv51Q C37rRppetPiD0XnHIk85wteqUh6wdxAB8eMHkQ1tfvXxxO3mhfDS+RcyLKVSs+LXzzyA RiJHkZJZRDJ4j+6pJg4WYwS+H7NUwbOeQDf+kSKdhb+KgqO3suloGiCmRdvWEoisofbH dZwQ== X-Gm-Message-State: AOJu0YzqSJ+YL2yma0PmI6AJgULQZyw3fYXH0idcGvx/YjAJ3B+NXuQJ t9pswm5S5nbTP1qO/EN/xOFKT4aDXRRczdXggny6c6RhFXx3wXTNO+2GoZZATIe2YVooU1kFHtT QJfc= X-Google-Smtp-Source: AGHT+IHrYZdmAMkTWbc04hiBlAnpCsnNuQzoSdBrmRIAigopSNp9icV4SEU48Hf3r7Vix5OOyrxzRw== X-Received: by 2002:a05:6a00:1901:b0:71e:744a:3fbc with SMTP id d2e1a72fcca58-72413386f01mr23540549b3a.21.1731433125938; Tue, 12 Nov 2024 09:38:45 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-724078641a2sm11836727b3a.20.2024.11.12.09.38.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Nov 2024 09:38:45 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , okl-plv@napatech.com, Christian Koue Muf , Serhii Iliushyk Subject: [PATCH 3/3] net/ntnic: remove unnecessary check for null before free Date: Tue, 12 Nov 2024 09:38:03 -0800 Message-ID: <20241112173833.323934-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241112173833.323934-1-stephen@networkplumber.org> References: <20241112173833.323934-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 It is unnecessary to check for NULL pointer before calling free. Found by nullfree.cocci Fixes: 1d3f62a0c4f1 ("net/ntnic: add base init and deinit of flow API") Cc: okl-plv@napatech.com Signed-off-by: Stephen Hemminger --- drivers/net/ntnic/nthw/flow_api/flow_api.c | 6 ++---- .../net/ntnic/nthw/flow_api/profile_inline/flm_age_queue.c | 3 +-- .../net/ntnic/nthw/flow_api/profile_inline/flm_evt_queue.c | 3 +-- .../net/ntnic/nthw/flow_api/profile_inline/flm_lrn_queue.c | 3 +-- drivers/net/ntnic/nthw/stat/nthw_stat.c | 3 +-- 5 files changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/net/ntnic/nthw/flow_api/flow_api.c b/drivers/net/ntnic/nthw/flow_api/flow_api.c index 5aaf3c2f23..d4993eb58a 100644 --- a/drivers/net/ntnic/nthw/flow_api/flow_api.c +++ b/drivers/net/ntnic/nthw/flow_api/flow_api.c @@ -473,8 +473,7 @@ static void done_resource_elements(struct flow_nic_dev *ndev, enum res_type_e re { assert(ndev); - if (ndev->res[res_type].alloc_bm) - free(ndev->res[res_type].alloc_bm); + free(ndev->res[res_type].alloc_bm); } static void list_insert_flow_nic(struct flow_nic_dev *ndev) @@ -653,8 +652,7 @@ static struct flow_eth_dev *flow_get_eth_dev(uint8_t adapter_no, uint8_t port_no rte_spinlock_unlock(&ndev->mtx); rte_spinlock_unlock(&base_mtx); - if (eth_dev) - free(eth_dev); + free(eth_dev); #ifdef FLOW_DEBUG ndev->be.iface->set_debug_mode(ndev->be.be_dev, FLOW_BACKEND_DEBUG_MODE_NONE); diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_age_queue.c b/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_age_queue.c index d916eccec7..c7522516d1 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_age_queue.c +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_age_queue.c @@ -40,8 +40,7 @@ void flm_age_queue_free(uint8_t port, uint16_t caller_id) age_queue[caller_id] = NULL; } - if (q != NULL) - rte_ring_free(q); + rte_ring_free(q); } void flm_age_queue_free_all(void) diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_evt_queue.c b/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_evt_queue.c index d76c7da568..7c825009ad 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_evt_queue.c +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_evt_queue.c @@ -68,8 +68,7 @@ static void flm_inf_sta_queue_free(uint8_t port, uint8_t caller) break; } - if (q) - rte_ring_free(q); + rte_ring_free(q); } void flm_inf_sta_queue_free_all(uint8_t caller) diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_lrn_queue.c b/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_lrn_queue.c index 6e77c28f93..992b1659a8 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_lrn_queue.c +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_lrn_queue.c @@ -31,8 +31,7 @@ void *flm_lrn_queue_create(void) void flm_lrn_queue_free(void *q) { - if (q) - rte_ring_free(q); + rte_ring_free(q); } uint32_t *flm_lrn_queue_get_write_buffer(void *q) diff --git a/drivers/net/ntnic/nthw/stat/nthw_stat.c b/drivers/net/ntnic/nthw/stat/nthw_stat.c index 078eec5e1f..b0db7b1984 100644 --- a/drivers/net/ntnic/nthw/stat/nthw_stat.c +++ b/drivers/net/ntnic/nthw/stat/nthw_stat.c @@ -25,8 +25,7 @@ nthw_stat_t *nthw_stat_new(void) void nthw_stat_delete(nthw_stat_t *p) { - if (p) - free(p); + free(p); } int nthw_stat_init(nthw_stat_t *p, nthw_fpga_t *p_fpga, int n_instance) -- 2.45.2