From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
okl-plv@napatech.com, Christian Koue Muf <ckm@napatech.com>,
Serhii Iliushyk <sil-plv@napatech.com>
Subject: [PATCH 3/3] net/ntnic: remove unnecessary check for null before free
Date: Tue, 12 Nov 2024 09:38:03 -0800 [thread overview]
Message-ID: <20241112173833.323934-4-stephen@networkplumber.org> (raw)
In-Reply-To: <20241112173833.323934-1-stephen@networkplumber.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 <stephen@networkplumber.org>
---
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
next prev parent reply other threads:[~2024-11-12 17:39 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-12 17:38 [PATCH 0/3] unnecessary checks for null Stephen Hemminger
2024-11-12 17:38 ` [PATCH 1/3] bus/fslmc: remove unnecessary null check Stephen Hemminger
2024-11-13 5:01 ` Hemant Agrawal
2024-11-12 17:38 ` [PATCH 2/3] net/dpaa2: remove unnecessary check for null before rte_free Stephen Hemminger
2024-11-13 5:01 ` Hemant Agrawal
2024-11-12 17:38 ` Stephen Hemminger [this message]
2024-11-13 1:25 ` [PATCH 0/3] unnecessary checks for null Ferruh Yigit
2024-11-13 4:56 ` Stephen Hemminger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241112173833.323934-4-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=ckm@napatech.com \
--cc=dev@dpdk.org \
--cc=okl-plv@napatech.com \
--cc=sil-plv@napatech.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).