DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH 00/82] remove unnecessary null checks
@ 2022-01-24  0:03 Stephen Hemminger
  2022-01-24  0:03 ` [PATCH 01/82] devtools/cocci: add script to fix " Stephen Hemminger
                   ` (83 more replies)
  0 siblings, 84 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:03 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

While working on a new driver, noticed that some drivers always call
free routines (correct) and others conditionally call free routines
if not null (redundant check).  The extra if(e != NULL) type check
is unneeded and adds extra code.  Better to have all the code
consistent.

The Linux kernel has automated this kind of fixup using coccinelle,
and this patchset creates a coccinelle script to do the transformation;
then has individual patches for each sub component.

In one driver dpaaxx, the change suggested a further change
to the compat macros to make them even simpler.

Stephen Hemminger (82):
  devtools/cocci: add script to fix unnecessary null checks
  eal: remove unnecessary NULL checks
  eal/windows: remove unnecessary NULL checks before free
  examples/fips_validation: remove unnecessary NULL checks
  examples/ip_pipeline: remove unnecessary NULL checks
  examples/pipeline/thread: remove unnecessary NULL checks
  examples/l2fwd-cat: remove unnecessary NULL checks
  lib/vhost: remove unnecessary NULL checks
  examples/vhost_blk: remove unnecessary NULL checks
  app/pdump: remove unnecessary NULL checks
  app/test-crypto-perf: remove unnecessary NULL checks
  app/test-pmd: remove unnecessary NULL checks
  app/test-regex: remove unnecessary NULL checks
  app/test: remove unnecessary NULL checks
  baseband/acc100 remove unnecessary NULL checks
  baseband/la12xx remove unnecessary NULL checks
  baseband/null remove unnecessary NULL checks
  baseband/turbo_sw remove unnecessary NULL checks
  bus/fslmc: remove unnecessary NULL checks
  bus/ifpga: remove unnecessary NULL checks
  bus/pci: remove unnecessary NULL checks
  common/cpt: remove unnecessary NULL checks
  common/dpaax: simplify kernel compat macros
  common/mlx5: remove unnecessary NULL checks
  common/qat: remove unnecessary NULL checks
  compress/mlx5: remove unnecessary NULL checks
  compress/octeontx: remove unnecessary NULL checks
  crypto/armv8: remove unnecessary NULL checks
  crypto/ccp: remove unnecessary NULL checks
  crypto/cnxk: remove unnecessary NULL checks
  crypto/ipsec_mb: remove unnecessary NULL checks
  crypto/mvsam: remove unnecessary NULL checks
  crypto/null: remove unnecessary NULL checks
  crypto/octeontx: remove unnecessary NULL checks
  crypto/openssl: remove unnecessary NULL checks
  crypto/scheduler: remove unnecessary NULL checks
  crypto/virtio: remove unnecessary NULL checks
  event/sw: remove unnecessary NULL checks
  net/axgbe: remove unnecessary NULL checks
  net/bnx2x: remove unnecessary NULL checks
  net/bnxt: remove unnecessary NULL checks
  net/bonding: remove unnecessary NULL checks
  net/cnxk: remove unnecessary NULL checks
  net/cxgbe: remove unnecessary NULL checks
  net/dpaa: remove unnecessary NULL checks
  net/dpaa2: remove unnecessary NULL checks
  net/ena: remove unnecessary NULL checks
  net/hinic: remove unnecessary NULL checks
  net/hns3: remove unnecessary NULL checks
  net/i40e: remove unnecessary NULL checks
  net/iavf: remove unnecessary NULL checks
  net/ice: remove unnecessary NULL checks
  net/igc: remove unnecessary NULL checks
  net/ixgbe: remove unnecessary NULL checks
  net/memif: remove unnecessary NULL checks
  net/mlx4: remove unnecessary NULL checks
  net/mlx5: remove unnecessary NULL checks
  net/mvpp2: remove unnecessary NULL checks
  net/netvsc: remove unnecessary NULL checks
  net/null: remove unnecessary NULL checks
  net/octeontx: remove unnecessary NULL checks
  net/qede: remove unnecessary NULL checks
  net/softnic: remove unnecessary NULL checks
  net/tap: remove unnecessary NULL checks
  net/txgbe: remove unnecessary NULL checks
  net/vdev_netvsc: remove unnecessary NULL checks
  net/virtio: remove unnecessary NULL checks
  raw/cnxk_bphy: remove unnecessary NULL checks
  raw/dpaa2_qdma: remove unnecessary NULL checks
  raw/ifpga: remove unnecessary NULL checks
  raw/skeleton: remove unnecessary NULL checks
  regex/cn9k: remove unnecessary NULL checks
  regex/mlx5: remove unnecessary NULL checks
  vdpa/ifc: remove unnecessary NULL checks
  vdpa/mlx5: remove unnecessary NULL checks
  compressdev: remove unnecessary NULL checks
  ethdev: remove unnecessary NULL checks
  graph: remove unnecessary NULL checks
  ipsec: remove unnecessary NULL checks
  port: remove unnecessary NULL checks
  power: remove unnecessary NULL checks
  reorder: remove unnecessary NULL checks

 app/pdump/main.c                              |  9 ++--
 app/test-crypto-perf/cperf_test_latency.c     |  3 +-
 .../cperf_test_pmd_cyclecount.c               |  9 ++--
 app/test-crypto-perf/cperf_test_throughput.c  |  3 +-
 .../cperf_test_vector_parsing.c               |  6 +--
 app/test-crypto-perf/cperf_test_verify.c      |  3 +-
 app/test-pmd/cmd_flex_item.c                  |  3 +-
 app/test-pmd/cmdline.c                        |  3 +-
 app/test-pmd/testpmd.c                        |  3 +-
 app/test-regex/main.c                         | 12 ++---
 app/test/test_cksum.c                         |  3 +-
 app/test/test_compressdev.c                   |  3 +-
 app/test/test_cryptodev.h                     |  3 +-
 app/test/test_cryptodev_asym.c                |  3 +-
 app/test/test_cryptodev_blockcipher.c         | 12 ++---
 app/test/test_func_reentrancy.c               | 15 +++----
 app/test/test_hash.c                          | 15 +++----
 app/test/test_hash_perf.c                     |  7 +--
 app/test/test_link_bonding.c                  |  9 ++--
 app/test/test_link_bonding_mode4.c            |  3 +-
 app/test/test_malloc.c                        |  5 +--
 app/test/test_mbuf.c                          | 45 +++++++------------
 app/test/test_pcapng.c                        |  3 +-
 app/test/test_reorder.c                       | 15 +++----
 app/test/virtual_pmd.c                        |  3 +-
 devtools/cocci/nullfree.cocci                 | 33 ++++++++++++++
 drivers/baseband/acc100/rte_acc100_pmd.c      |  3 +-
 drivers/baseband/la12xx/bbdev_la12xx.c        |  3 +-
 drivers/baseband/null/bbdev_null.c            |  3 +-
 .../baseband/turbo_sw/bbdev_turbo_software.c  |  3 +-
 drivers/bus/fslmc/fslmc_bus.c                 |  6 +--
 drivers/bus/fslmc/portal/dpaa2_hw_dpio.c      |  6 +--
 drivers/bus/ifpga/ifpga_bus.c                 | 12 ++---
 drivers/bus/pci/pci_params.c                  |  3 +-
 drivers/bus/pci/windows/pci.c                 |  3 +-
 drivers/bus/pci/windows/pci_netuio.c          |  3 +-
 drivers/common/cpt/cpt_ucode_asym.h           |  6 +--
 drivers/common/dpaax/compat.h                 | 11 +----
 drivers/common/mlx5/mlx5_common_mr.c          |  3 +-
 drivers/common/mlx5/mlx5_common_pci.c         |  3 +-
 drivers/common/qat/qat_qp.c                   |  9 ++--
 drivers/compress/mlx5/mlx5_compress.c         |  3 +-
 drivers/compress/octeontx/otx_zip_pmd.c       |  9 ++--
 drivers/crypto/armv8/rte_armv8_pmd_ops.c      |  3 +-
 drivers/crypto/ccp/ccp_dev.c                  |  3 +-
 drivers/crypto/ccp/ccp_pmd_ops.c              |  3 +-
 drivers/crypto/cnxk/cnxk_ae.h                 |  6 +--
 drivers/crypto/ipsec_mb/ipsec_mb_ops.c        |  6 +--
 drivers/crypto/mvsam/rte_mrvl_pmd_ops.c       |  6 +--
 drivers/crypto/null/null_crypto_pmd_ops.c     |  6 +--
 drivers/crypto/octeontx/otx_cryptodev_ops.c   |  3 +-
 drivers/crypto/openssl/rte_openssl_pmd_ops.c  |  6 +--
 drivers/crypto/scheduler/scheduler_pmd_ops.c  |  6 +--
 drivers/crypto/virtio/virtqueue.c             |  6 +--
 drivers/event/sw/sw_evdev.c                   |  3 +-
 drivers/net/axgbe/axgbe_rxtx.c                |  6 +--
 drivers/net/bnx2x/bnx2x_rxtx.c                |  6 +--
 drivers/net/bnxt/bnxt_ethdev.c                |  3 +-
 drivers/net/bonding/rte_eth_bond_pmd.c        |  3 +-
 drivers/net/cnxk/cnxk_ethdev.c                |  6 +--
 drivers/net/cxgbe/cxgbe_main.c                |  3 +-
 drivers/net/dpaa/dpaa_ethdev.c                |  3 +-
 drivers/net/dpaa/fmlib/fm_lib.c               |  3 +-
 drivers/net/dpaa2/dpaa2_ethdev.c              |  3 +-
 drivers/net/dpaa2/dpaa2_mux.c                 |  3 +-
 drivers/net/dpaa2/dpaa2_ptp.c                 |  3 +-
 drivers/net/ena/ena_ethdev.c                  | 18 +++-----
 drivers/net/hinic/hinic_pmd_ethdev.c          |  3 +-
 drivers/net/hns3/hns3_rxtx.c                  |  9 ++--
 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                    |  3 +-
 drivers/net/ixgbe/ixgbe_ethdev.c              | 10 ++---
 drivers/net/ixgbe/ixgbe_rxtx.c                |  3 +-
 drivers/net/memif/rte_eth_memif.c             |  6 +--
 drivers/net/mlx4/mlx4_mr.c                    |  3 +-
 drivers/net/mlx5/mlx5_flow.c                  |  3 +-
 drivers/net/mvpp2/mrvl_qos.c                  |  3 +-
 drivers/net/netvsc/hn_rxtx.c                  |  6 +--
 drivers/net/null/rte_eth_null.c               |  3 +-
 drivers/net/octeontx/octeontx_ethdev.c        |  3 +-
 drivers/net/octeontx/octeontx_ethdev_ops.c    |  3 +-
 drivers/net/qede/qede_main.c                  |  3 +-
 drivers/net/qede/qede_rxtx.c                  |  6 +--
 drivers/net/softnic/rte_eth_softnic_cli.c     | 12 ++---
 .../net/softnic/rte_eth_softnic_cryptodev.c   |  6 +--
 drivers/net/softnic/rte_eth_softnic_thread.c  |  6 +--
 drivers/net/tap/tap_flow.c                    |  9 ++--
 drivers/net/txgbe/txgbe_ethdev.c              | 12 ++---
 drivers/net/vdev_netvsc/vdev_netvsc.c         |  3 +-
 drivers/net/virtio/virtio_user_ethdev.c       | 12 ++---
 drivers/raw/cnxk_bphy/cnxk_bphy_cgx.c         |  3 +-
 drivers/raw/dpaa2_qdma/dpaa2_qdma.c           | 15 +++----
 drivers/raw/ifpga/ifpga_rawdev.c              |  9 ++--
 drivers/raw/skeleton/skeleton_rawdev_test.c   |  6 +--
 drivers/regex/cn9k/cn9k_regexdev.c            |  6 +--
 drivers/regex/cn9k/cn9k_regexdev_compiler.c   |  3 +-
 drivers/regex/mlx5/mlx5_regex.c               |  3 +-
 drivers/regex/mlx5/mlx5_rxp.c                 |  3 +-
 drivers/vdpa/ifc/ifcvf_vdpa.c                 |  9 ++--
 drivers/vdpa/mlx5/mlx5_vdpa_mem.c             |  3 +-
 drivers/vdpa/mlx5/mlx5_vdpa_virtq.c           |  3 +-
 examples/fips_validation/fips_dev_self_test.c | 18 +++-----
 examples/fips_validation/fips_validation.c    |  3 +-
 examples/fips_validation/main.c               | 36 +++++----------
 examples/ip_pipeline/cli.c                    | 12 ++---
 examples/ip_pipeline/cryptodev.c              |  6 +--
 examples/ip_pipeline/thread.c                 |  6 +--
 examples/l2fwd-cat/cat.c                      |  3 +-
 examples/pipeline/thread.c                    |  6 +--
 examples/vhost_blk/vhost_blk.c                |  3 +-
 lib/compressdev/rte_compressdev.c             |  3 +-
 lib/eal/common/eal_common_devargs.c           |  6 +--
 lib/eal/common/eal_common_memzone.c           |  3 +-
 lib/eal/common/eal_common_options.c           |  9 ++--
 lib/eal/common/eal_common_trace_ctf.c         |  6 +--
 lib/eal/freebsd/eal.c                         |  4 +-
 lib/eal/linux/eal.c                           | 10 ++---
 lib/eal/windows/eal_alarm.c                   |  3 +-
 lib/eal/windows/eal_memory.c                  |  3 +-
 lib/ethdev/rte_ethdev.c                       |  3 +-
 lib/graph/graph_stats.c                       |  3 +-
 lib/ipsec/ipsec_sad.c                         |  3 +-
 lib/port/rte_port_source_sink.c               | 21 +++------
 lib/power/rte_power_empty_poll.c              |  3 +-
 lib/reorder/rte_reorder.c                     |  6 +--
 lib/vhost/iotlb.c                             |  3 +-
 lib/vhost/vhost_crypto.c                      |  6 +--
 lib/vhost/vhost_user.c                        |  9 ++--
 131 files changed, 306 insertions(+), 557 deletions(-)
 create mode 100644 devtools/cocci/nullfree.cocci

-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 01/82] devtools/cocci: add script to fix unnecessary null checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
@ 2022-01-24  0:03 ` Stephen Hemminger
  2022-01-24  0:03 ` [PATCH 02/82] eal: remove unnecessary NULL checks Stephen Hemminger
                   ` (82 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:03 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

This script is based on the idea of the nullfree script
in the Linux kernel. It finds cases where a check for null
pointer is done, but is unneccessary because the function
already handles NULL pointer.

Basic example:
       if (x->buf)
           rte_free(x->buf);
can be reduced to:
       rte_free(x->buf);

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 devtools/cocci/nullfree.cocci | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
 create mode 100644 devtools/cocci/nullfree.cocci

diff --git a/devtools/cocci/nullfree.cocci b/devtools/cocci/nullfree.cocci
new file mode 100644
index 000000000000..363b6149ac28
--- /dev/null
+++ b/devtools/cocci/nullfree.cocci
@@ -0,0 +1,33 @@
+//
+// Remove unnecessary NULL pointer checks before free functions
+// All these functions work like libc free which allows
+// free(NULL) as a no-op.
+//
+@@
+expression E;
+@@
+(
+- if (E != NULL) free(E);
++ free(E);
+|
+- if (E != NULL) rte_bitmap_free(E);
++ rte_bitmap_free(E);
+|
+- if (E != NULL) rte_free(E);
++ rte_free(E);
+|
+- if (E != NULL) rte_hash_free(E);
++ rte_hash_free(E);
+|
+- if (E != NULL) rte_ring_free(E);
++ rte_ring_free(E);
+|
+- if (E != NULL) rte_pktmbuf_free(E);
++ rte_pktmbuf_free(E);
+|
+- if (E != NULL) rte_mempool_free(E);
++ rte_mempool_free(E);
+|
+- if (E != NULL) rte_kvargs_free(E);
++ rte_kvargs_free(E);
+)
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 02/82] eal: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
  2022-01-24  0:03 ` [PATCH 01/82] devtools/cocci: add script to fix " Stephen Hemminger
@ 2022-01-24  0:03 ` Stephen Hemminger
  2022-01-24  0:03 ` [PATCH 03/82] eal/windows: remove unnecessary NULL checks before free Stephen Hemminger
                   ` (81 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:03 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Anatoly Burakov, Jerin Jacob,
	Sunil Kumar Kori, Bruce Richardson

Functions like free() already handle NULL pointer so
the checks here are not necessary.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_devargs.c   |  6 ++----
 lib/eal/common/eal_common_memzone.c   |  3 +--
 lib/eal/common/eal_common_options.c   |  9 +++------
 lib/eal/common/eal_common_trace_ctf.c |  6 ++----
 lib/eal/freebsd/eal.c                 |  4 +---
 lib/eal/linux/eal.c                   | 10 +++-------
 6 files changed, 12 insertions(+), 26 deletions(-)

diff --git a/lib/eal/common/eal_common_devargs.c b/lib/eal/common/eal_common_devargs.c
index 8c7650cf6c27..69004b0a2d2f 100644
--- a/lib/eal/common/eal_common_devargs.c
+++ b/lib/eal/common/eal_common_devargs.c
@@ -161,8 +161,7 @@ rte_devargs_layers_parse(struct rte_devargs *devargs,
 
 get_out:
 	for (i = 0; i < RTE_DIM(layers); i++) {
-		if (layers[i].kvlist)
-			rte_kvargs_free(layers[i].kvlist);
+		rte_kvargs_free(layers[i].kvlist);
 	}
 	if (ret != 0) {
 		if (allocated_data) {
@@ -285,8 +284,7 @@ rte_devargs_reset(struct rte_devargs *da)
 {
 	if (da == NULL)
 		return;
-	if (da->data)
-		free(da->data);
+	free(da->data);
 	da->data = NULL;
 }
 
diff --git a/lib/eal/common/eal_common_memzone.c b/lib/eal/common/eal_common_memzone.c
index ecde9441ee90..9a0c5309ac7e 100644
--- a/lib/eal/common/eal_common_memzone.c
+++ b/lib/eal/common/eal_common_memzone.c
@@ -300,8 +300,7 @@ rte_memzone_free(const struct rte_memzone *mz)
 
 	rte_rwlock_write_unlock(&mcfg->mlock);
 
-	if (addr != NULL)
-		rte_free(addr);
+	rte_free(addr);
 
 	rte_eal_trace_memzone_free(name, addr, ret);
 	return ret;
diff --git a/lib/eal/common/eal_common_options.c b/lib/eal/common/eal_common_options.c
index 1cfdd75f3b79..09b7b17ffa06 100644
--- a/lib/eal/common/eal_common_options.c
+++ b/lib/eal/common/eal_common_options.c
@@ -1962,12 +1962,9 @@ compute_ctrl_threads_cpuset(struct internal_config *internal_cfg)
 int
 eal_cleanup_config(struct internal_config *internal_cfg)
 {
-	if (internal_cfg->hugefile_prefix != NULL)
-		free(internal_cfg->hugefile_prefix);
-	if (internal_cfg->hugepage_dir != NULL)
-		free(internal_cfg->hugepage_dir);
-	if (internal_cfg->user_mbuf_pool_ops_name != NULL)
-		free(internal_cfg->user_mbuf_pool_ops_name);
+	free(internal_cfg->hugefile_prefix);
+	free(internal_cfg->hugepage_dir);
+	free(internal_cfg->user_mbuf_pool_ops_name);
 
 	return 0;
 }
diff --git a/lib/eal/common/eal_common_trace_ctf.c b/lib/eal/common/eal_common_trace_ctf.c
index 33e419aac7fb..3b83bcdf57fd 100644
--- a/lib/eal/common/eal_common_trace_ctf.c
+++ b/lib/eal/common/eal_common_trace_ctf.c
@@ -52,8 +52,7 @@ meta_copy(char **meta, int *offset, char *str, int rc)
 	return rc;
 
 free_str:
-	if (str)
-		free(str);
+	free(str);
 	return -ENOMEM;
 }
 
@@ -291,8 +290,7 @@ trace_metadata_create(void)
 	return 0;
 
 fail:
-	if (meta)
-		free(meta);
+	free(meta);
 	return -EBADF;
 }
 
diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c
index a1cd2462db1b..00ba32f1d664 100644
--- a/lib/eal/freebsd/eal.c
+++ b/lib/eal/freebsd/eal.c
@@ -544,9 +544,7 @@ eal_parse_args(int argc, char **argv)
 				RTE_LOG(ERR, EAL, "Could not store mbuf pool ops name\n");
 			else {
 				/* free old ops name */
-				if (internal_conf->user_mbuf_pool_ops_name !=
-						NULL)
-					free(internal_conf->user_mbuf_pool_ops_name);
+				free(internal_conf->user_mbuf_pool_ops_name);
 
 				internal_conf->user_mbuf_pool_ops_name =
 						ops_name;
diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c
index 60b49248388e..f8e39b7e4277 100644
--- a/lib/eal/linux/eal.c
+++ b/lib/eal/linux/eal.c
@@ -730,8 +730,7 @@ eal_parse_args(int argc, char **argv)
 				RTE_LOG(ERR, EAL, "Could not store hugepage directory\n");
 			else {
 				/* free old hugepage dir */
-				if (internal_conf->hugepage_dir != NULL)
-					free(internal_conf->hugepage_dir);
+				free(internal_conf->hugepage_dir);
 				internal_conf->hugepage_dir = hdir;
 			}
 			break;
@@ -743,8 +742,7 @@ eal_parse_args(int argc, char **argv)
 				RTE_LOG(ERR, EAL, "Could not store file prefix\n");
 			else {
 				/* free old prefix */
-				if (internal_conf->hugefile_prefix != NULL)
-					free(internal_conf->hugefile_prefix);
+				free(internal_conf->hugefile_prefix);
 				internal_conf->hugefile_prefix = prefix;
 			}
 			break;
@@ -804,9 +802,7 @@ eal_parse_args(int argc, char **argv)
 				RTE_LOG(ERR, EAL, "Could not store mbuf pool ops name\n");
 			else {
 				/* free old ops name */
-				if (internal_conf->user_mbuf_pool_ops_name !=
-						NULL)
-					free(internal_conf->user_mbuf_pool_ops_name);
+				free(internal_conf->user_mbuf_pool_ops_name);
 
 				internal_conf->user_mbuf_pool_ops_name =
 						ops_name;
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 03/82] eal/windows: remove unnecessary NULL checks before free
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
  2022-01-24  0:03 ` [PATCH 01/82] devtools/cocci: add script to fix " Stephen Hemminger
  2022-01-24  0:03 ` [PATCH 02/82] eal: remove unnecessary NULL checks Stephen Hemminger
@ 2022-01-24  0:03 ` Stephen Hemminger
  2022-01-24  0:04 ` [PATCH 04/82] examples/fips_validation: remove unnecessary NULL checks Stephen Hemminger
                   ` (80 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:03 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Dmitry Kozlyuk, Narcisa Ana Maria Vasile,
	Dmitry Malloy, Pallavi Kadam

Calling free/rte_free/rte_mempool_free,... with NULL pointer
is allowed; so remove unnecessary NULL checks.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/windows/eal_alarm.c  | 3 +--
 lib/eal/windows/eal_memory.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/lib/eal/windows/eal_alarm.c b/lib/eal/windows/eal_alarm.c
index 103c1f909da3..51fe752c16d4 100644
--- a/lib/eal/windows/eal_alarm.c
+++ b/lib/eal/windows/eal_alarm.c
@@ -162,8 +162,7 @@ rte_eal_alarm_set(uint64_t us, rte_eal_alarm_callback cb_fn, void *cb_arg)
 fail:
 	if (timer != NULL)
 		CloseHandle(timer);
-	if (ap != NULL)
-		free(ap);
+	free(ap);
 
 exit:
 	rte_eal_trace_alarm_set(us, cb_fn, cb_arg, ret);
diff --git a/lib/eal/windows/eal_memory.c b/lib/eal/windows/eal_memory.c
index 2fd37d97085e..215d768e2c57 100644
--- a/lib/eal/windows/eal_memory.c
+++ b/lib/eal/windows/eal_memory.c
@@ -190,8 +190,7 @@ eal_mem_virt2iova_init(void)
 	ret = 0;
 
 exit:
-	if (detail != NULL)
-		free(detail);
+	free(detail);
 	if (list != INVALID_HANDLE_VALUE)
 		SetupDiDestroyDeviceInfoList(list);
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 04/82] examples/fips_validation: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (2 preceding siblings ...)
  2022-01-24  0:03 ` [PATCH 03/82] eal/windows: remove unnecessary NULL checks before free Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24  0:04 ` [PATCH 05/82] examples/ip_pipeline: " Stephen Hemminger
                   ` (79 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Marko Kovacevic

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 examples/fips_validation/fips_dev_self_test.c | 18 ++++------
 examples/fips_validation/fips_validation.c    |  3 +-
 examples/fips_validation/main.c               | 36 +++++++------------
 3 files changed, 19 insertions(+), 38 deletions(-)

diff --git a/examples/fips_validation/fips_dev_self_test.c b/examples/fips_validation/fips_dev_self_test.c
index b4eab05a9851..076e9de099c0 100644
--- a/examples/fips_validation/fips_dev_self_test.c
+++ b/examples/fips_validation/fips_dev_self_test.c
@@ -1396,8 +1396,7 @@ check_aead_result(struct rte_crypto_op *op,
 	if (!mbuf)
 		return -1;
 
-	if (op->sym->aead.aad.data)
-		rte_free(op->sym->aead.aad.data);
+	rte_free(op->sym->aead.aad.data);
 
 	if (dir == self_test_dir_enc_auth_gen) {
 		src = vec->output.data;
@@ -1523,18 +1522,13 @@ static void
 fips_dev_auto_test_uninit(uint8_t dev_id,
 		struct fips_dev_auto_test_env *env)
 {
-	if (env->mbuf)
-		rte_pktmbuf_free(env->mbuf);
+	rte_pktmbuf_free(env->mbuf);
 	if (env->op)
 		rte_crypto_op_free(env->op);
-	if (env->mpool)
-		rte_mempool_free(env->mpool);
-	if (env->op_pool)
-		rte_mempool_free(env->op_pool);
-	if (env->sess_pool)
-		rte_mempool_free(env->sess_pool);
-	if (env->sess_priv_pool)
-		rte_mempool_free(env->sess_priv_pool);
+	rte_mempool_free(env->mpool);
+	rte_mempool_free(env->op_pool);
+	rte_mempool_free(env->sess_pool);
+	rte_mempool_free(env->sess_priv_pool);
 
 	rte_cryptodev_stop(dev_id);
 }
diff --git a/examples/fips_validation/fips_validation.c b/examples/fips_validation/fips_validation.c
index 52a7bf952d46..94253eaee8bf 100644
--- a/examples/fips_validation/fips_validation.c
+++ b/examples/fips_validation/fips_validation.c
@@ -344,8 +344,7 @@ fips_test_clear(void)
 		fclose(info.fp_rd);
 	if (info.fp_wr)
 		fclose(info.fp_wr);
-	if (info.one_line_text)
-		free(info.one_line_text);
+	free(info.one_line_text);
 	if (info.nb_vec_lines) {
 		uint32_t i;
 
diff --git a/examples/fips_validation/main.c b/examples/fips_validation/main.c
index dc40bffe7d97..e06ae37567fd 100644
--- a/examples/fips_validation/main.c
+++ b/examples/fips_validation/main.c
@@ -143,12 +143,9 @@ cryptodev_fips_validate_app_int(void)
 error_exit:
 
 	rte_mempool_free(env.mpool);
-	if (env.sess_mpool)
-		rte_mempool_free(env.sess_mpool);
-	if (env.sess_priv_mpool)
-		rte_mempool_free(env.sess_priv_mpool);
-	if (env.op_pool)
-		rte_mempool_free(env.op_pool);
+	rte_mempool_free(env.sess_mpool);
+	rte_mempool_free(env.sess_priv_mpool);
+	rte_mempool_free(env.op_pool);
 
 	return ret;
 }
@@ -523,8 +520,7 @@ prepare_data_mbufs(struct fips_val *val)
 	uint16_t nb_seg;
 	int ret = 0;
 
-	if (env.mbuf)
-		rte_pktmbuf_free(env.mbuf);
+	rte_pktmbuf_free(env.mbuf);
 
 	if (total_len > RTE_MBUF_MAX_NB_SEGS) {
 		RTE_LOG(ERR, USER1, "Data len %u too big\n", total_len);
@@ -598,8 +594,7 @@ prepare_data_mbufs(struct fips_val *val)
 	return 0;
 
 error_exit:
-	if (head)
-		rte_pktmbuf_free(head);
+	rte_pktmbuf_free(head);
 	return ret;
 }
 
@@ -656,8 +651,7 @@ prepare_auth_op(void)
 	if (ret < 0)
 		return ret;
 
-	if (env.digest)
-		rte_free(env.digest);
+	rte_free(env.digest);
 
 	env.digest = rte_zmalloc(NULL, vec.cipher_auth.digest.len,
 			RTE_CACHE_LINE_SIZE);
@@ -705,8 +699,7 @@ prepare_aead_op(void)
 		if (ret < 0)
 			return ret;
 
-		if (env.digest)
-			rte_free(env.digest);
+		rte_free(env.digest);
 		env.digest = rte_zmalloc(NULL, vec.aead.digest.len,
 				RTE_CACHE_LINE_SIZE);
 		if (!env.digest) {
@@ -1430,8 +1423,7 @@ fips_mct_tdes_test(void)
 		}
 	}
 
-	if (val.val)
-		free(val.val);
+	free(val.val);
 
 	return 0;
 }
@@ -1510,8 +1502,7 @@ fips_mct_aes_ecb_test(void)
 		}
 	}
 
-	if (val.val)
-		free(val.val);
+	free(val.val);
 
 	return 0;
 }
@@ -1619,8 +1610,7 @@ fips_mct_aes_test(void)
 			memcpy(vec.iv.val, val.val, AES_BLOCK_SIZE);
 	}
 
-	if (val.val)
-		free(val.val);
+	free(val.val);
 
 	return 0;
 }
@@ -1706,8 +1696,7 @@ fips_mct_sha_test(void)
 
 	rte_free(vec.pt.val);
 
-	if (val.val)
-		free(val.val);
+	free(val.val);
 
 	return 0;
 }
@@ -1851,8 +1840,7 @@ fips_test_one_file(void)
 		rte_free(env.digest);
 		env.digest = NULL;
 	}
-	if (env.mbuf)
-		rte_pktmbuf_free(env.mbuf);
+	rte_pktmbuf_free(env.mbuf);
 
 	return ret;
 }
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 05/82] examples/ip_pipeline: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (3 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 04/82] examples/fips_validation: remove unnecessary NULL checks Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24 10:17   ` Dumitrescu, Cristian
  2022-01-24  0:04 ` [PATCH 06/82] examples/pipeline/thread: " Stephen Hemminger
                   ` (78 subsequent siblings)
  83 siblings, 1 reply; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Cristian Dumitrescu

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 examples/ip_pipeline/cli.c       | 12 ++++--------
 examples/ip_pipeline/cryptodev.c |  6 ++----
 examples/ip_pipeline/thread.c    |  6 ++----
 3 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/examples/ip_pipeline/cli.c b/examples/ip_pipeline/cli.c
index 0c372675a919..c918f30e06f3 100644
--- a/examples/ip_pipeline/cli.c
+++ b/examples/ip_pipeline/cli.c
@@ -3773,10 +3773,8 @@ parse_free_sym_crypto_param_data(struct rte_table_action_sym_crypto_params *p)
 
 		switch (xform[i]->type) {
 		case RTE_CRYPTO_SYM_XFORM_CIPHER:
-			if (p->cipher_auth.cipher_iv.val)
-				free(p->cipher_auth.cipher_iv.val);
-			if (p->cipher_auth.cipher_iv_update.val)
-				free(p->cipher_auth.cipher_iv_update.val);
+			free(p->cipher_auth.cipher_iv.val);
+			free(p->cipher_auth.cipher_iv_update.val);
 			break;
 		case RTE_CRYPTO_SYM_XFORM_AUTH:
 			if (p->cipher_auth.auth_iv.val)
@@ -3785,10 +3783,8 @@ parse_free_sym_crypto_param_data(struct rte_table_action_sym_crypto_params *p)
 				free(p->cipher_auth.cipher_iv_update.val);
 			break;
 		case RTE_CRYPTO_SYM_XFORM_AEAD:
-			if (p->aead.iv.val)
-				free(p->aead.iv.val);
-			if (p->aead.aad.val)
-				free(p->aead.aad.val);
+			free(p->aead.iv.val);
+			free(p->aead.aad.val);
 			break;
 		default:
 			continue;
diff --git a/examples/ip_pipeline/cryptodev.c b/examples/ip_pipeline/cryptodev.c
index 9997d974563f..cd0f9c3d4eac 100644
--- a/examples/ip_pipeline/cryptodev.c
+++ b/examples/ip_pipeline/cryptodev.c
@@ -151,10 +151,8 @@ cryptodev_create(const char *name, struct cryptodev_params *params)
 	return cryptodev;
 
 error_exit:
-	if (cryptodev->mp_create)
-		rte_mempool_free(cryptodev->mp_create);
-	if (cryptodev->mp_init)
-		rte_mempool_free(cryptodev->mp_init);
+	rte_mempool_free(cryptodev->mp_create);
+	rte_mempool_free(cryptodev->mp_init);
 
 	free(cryptodev);
 
diff --git a/examples/ip_pipeline/thread.c b/examples/ip_pipeline/thread.c
index b2e97327052f..82d5f87c384c 100644
--- a/examples/ip_pipeline/thread.c
+++ b/examples/ip_pipeline/thread.c
@@ -92,11 +92,9 @@ thread_free(void)
 			continue;
 
 		/* MSGQs */
-		if (t->msgq_req)
-			rte_ring_free(t->msgq_req);
+		rte_ring_free(t->msgq_req);
 
-		if (t->msgq_rsp)
-			rte_ring_free(t->msgq_rsp);
+		rte_ring_free(t->msgq_rsp);
 	}
 }
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 06/82] examples/pipeline/thread: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (4 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 05/82] examples/ip_pipeline: " Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24 10:18   ` Dumitrescu, Cristian
  2022-01-24  0:04 ` [PATCH 07/82] examples/l2fwd-cat: " Stephen Hemminger
                   ` (77 subsequent siblings)
  83 siblings, 1 reply; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Cristian Dumitrescu

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 examples/pipeline/thread.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/examples/pipeline/thread.c b/examples/pipeline/thread.c
index bf11e6144b75..5fe7eae00eb6 100644
--- a/examples/pipeline/thread.c
+++ b/examples/pipeline/thread.c
@@ -89,11 +89,9 @@ thread_free(void)
 			continue;
 
 		/* MSGQs */
-		if (t->msgq_req)
-			rte_ring_free(t->msgq_req);
+		rte_ring_free(t->msgq_req);
 
-		if (t->msgq_rsp)
-			rte_ring_free(t->msgq_rsp);
+		rte_ring_free(t->msgq_rsp);
 	}
 }
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 07/82] examples/l2fwd-cat: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (5 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 06/82] examples/pipeline/thread: " Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24  0:04 ` [PATCH 08/82] lib/vhost: " Stephen Hemminger
                   ` (76 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Tomasz Kantecki

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 examples/l2fwd-cat/cat.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/examples/l2fwd-cat/cat.c b/examples/l2fwd-cat/cat.c
index 502c6b32780e..77154c8b7e61 100644
--- a/examples/l2fwd-cat/cat.c
+++ b/examples/l2fwd-cat/cat.c
@@ -872,8 +872,7 @@ cat_fini(void)
 #if PQOS_VERSION <= 103
 	memset(m_sockets, 0, sizeof(m_sockets));
 #else
-	if (m_sockets != NULL)
-		free(m_sockets);
+	free(m_sockets);
 #endif
 	m_sock_count = 0;
 	memset(m_config, 0, sizeof(m_config));
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 08/82] lib/vhost: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (6 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 07/82] examples/l2fwd-cat: " Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24  0:04 ` [PATCH 09/82] examples/vhost_blk: " Stephen Hemminger
                   ` (75 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Maxime Coquelin, Chenbo Xia

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/vhost/iotlb.c        | 3 +--
 lib/vhost/vhost_crypto.c | 6 ++----
 lib/vhost/vhost_user.c   | 9 +++------
 3 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/lib/vhost/iotlb.c b/lib/vhost/iotlb.c
index 82bdb84526ea..d6b8c0a396b5 100644
--- a/lib/vhost/iotlb.c
+++ b/lib/vhost/iotlb.c
@@ -315,8 +315,7 @@ vhost_user_iotlb_init(struct virtio_net *dev, int vq_index)
 
 	/* If already created, free it and recreate */
 	vq->iotlb_pool = rte_mempool_lookup(pool_name);
-	if (vq->iotlb_pool)
-		rte_mempool_free(vq->iotlb_pool);
+	rte_mempool_free(vq->iotlb_pool);
 
 	vq->iotlb_pool = rte_mempool_create(pool_name,
 			IOTLB_CACHE_SIZE, sizeof(struct vhost_iotlb_entry), 0,
diff --git a/lib/vhost/vhost_crypto.c b/lib/vhost/vhost_crypto.c
index 926b5c0bd94a..012e0cefdeba 100644
--- a/lib/vhost/vhost_crypto.c
+++ b/lib/vhost/vhost_crypto.c
@@ -1498,10 +1498,8 @@ rte_vhost_crypto_create(int vid, uint8_t cryptodev_id,
 	return 0;
 
 error_exit:
-	if (vcrypto->session_map)
-		rte_hash_free(vcrypto->session_map);
-	if (vcrypto->mbuf_pool)
-		rte_mempool_free(vcrypto->mbuf_pool);
+	rte_hash_free(vcrypto->session_map);
+	rte_mempool_free(vcrypto->mbuf_pool);
 
 	rte_free(vcrypto);
 
diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c
index 5eb1dd681231..23a0e3fb3600 100644
--- a/lib/vhost/vhost_user.c
+++ b/lib/vhost/vhost_user.c
@@ -489,8 +489,7 @@ vhost_user_set_vring_num(struct virtio_net **pdev,
 	}
 
 	if (vq_is_packed(dev)) {
-		if (vq->shadow_used_packed)
-			rte_free(vq->shadow_used_packed);
+		rte_free(vq->shadow_used_packed);
 		vq->shadow_used_packed = rte_malloc_socket(NULL,
 				vq->size *
 				sizeof(struct vring_used_elem_packed),
@@ -502,8 +501,7 @@ vhost_user_set_vring_num(struct virtio_net **pdev,
 		}
 
 	} else {
-		if (vq->shadow_used_split)
-			rte_free(vq->shadow_used_split);
+		rte_free(vq->shadow_used_split);
 
 		vq->shadow_used_split = rte_malloc_socket(NULL,
 				vq->size * sizeof(struct vring_used_elem),
@@ -516,8 +514,7 @@ vhost_user_set_vring_num(struct virtio_net **pdev,
 		}
 	}
 
-	if (vq->batch_copy_elems)
-		rte_free(vq->batch_copy_elems);
+	rte_free(vq->batch_copy_elems);
 	vq->batch_copy_elems = rte_malloc_socket(NULL,
 				vq->size * sizeof(struct batch_copy_elem),
 				RTE_CACHE_LINE_SIZE, vq->numa_node);
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 09/82] examples/vhost_blk: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (7 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 08/82] lib/vhost: " Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24  0:04 ` [PATCH 10/82] app/pdump: " Stephen Hemminger
                   ` (74 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Maxime Coquelin, Chenbo Xia

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 examples/vhost_blk/vhost_blk.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/examples/vhost_blk/vhost_blk.c b/examples/vhost_blk/vhost_blk.c
index feadacc62ee5..2cab1e6994fe 100644
--- a/examples/vhost_blk/vhost_blk.c
+++ b/examples/vhost_blk/vhost_blk.c
@@ -849,8 +849,7 @@ static void
 vhost_blk_ctrlr_destroy(struct vhost_blk_ctrlr *ctrlr)
 {
 	if (ctrlr->bdev != NULL) {
-		if (ctrlr->bdev->data != NULL)
-			rte_free(ctrlr->bdev->data);
+		rte_free(ctrlr->bdev->data);
 
 		rte_free(ctrlr->bdev);
 	}
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 10/82] app/pdump: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (8 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 09/82] examples/vhost_blk: " Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24  0:04 ` [PATCH 11/82] app/test-crypto-perf: " Stephen Hemminger
                   ` (73 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Reshma Pattan

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/pdump/main.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/app/pdump/main.c b/app/pdump/main.c
index 46f9d25db004..04a38e891119 100644
--- a/app/pdump/main.c
+++ b/app/pdump/main.c
@@ -502,14 +502,11 @@ cleanup_rings(void)
 	for (i = 0; i < num_tuples; i++) {
 		pt = &pdump_t[i];
 
-		if (pt->device_id)
-			free(pt->device_id);
+		free(pt->device_id);
 
 		/* free the rings */
-		if (pt->rx_ring)
-			rte_ring_free(pt->rx_ring);
-		if (pt->tx_ring)
-			rte_ring_free(pt->tx_ring);
+		rte_ring_free(pt->rx_ring);
+		rte_ring_free(pt->tx_ring);
 	}
 }
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 11/82] app/test-crypto-perf: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (9 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 10/82] app/pdump: " Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24 16:13   ` Power, Ciara
  2022-01-24  0:04 ` [PATCH 12/82] app/test-pmd: " Stephen Hemminger
                   ` (72 subsequent siblings)
  83 siblings, 1 reply; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Declan Doherty, Ciara Power

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/test-crypto-perf/cperf_test_latency.c        | 3 +--
 app/test-crypto-perf/cperf_test_pmd_cyclecount.c | 9 +++------
 app/test-crypto-perf/cperf_test_throughput.c     | 3 +--
 app/test-crypto-perf/cperf_test_vector_parsing.c | 6 ++----
 app/test-crypto-perf/cperf_test_verify.c         | 3 +--
 5 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/app/test-crypto-perf/cperf_test_latency.c b/app/test-crypto-perf/cperf_test_latency.c
index ce49feaba9f3..4c7bc72eb5fd 100644
--- a/app/test-crypto-perf/cperf_test_latency.c
+++ b/app/test-crypto-perf/cperf_test_latency.c
@@ -49,8 +49,7 @@ cperf_latency_test_free(struct cperf_latency_ctx *ctx)
 			rte_cryptodev_sym_session_free(ctx->sess);
 		}
 
-		if (ctx->pool)
-			rte_mempool_free(ctx->pool);
+		rte_mempool_free(ctx->pool);
 
 		rte_free(ctx->res);
 		rte_free(ctx);
diff --git a/app/test-crypto-perf/cperf_test_pmd_cyclecount.c b/app/test-crypto-perf/cperf_test_pmd_cyclecount.c
index 5842f29d43e2..6b4d09e623eb 100644
--- a/app/test-crypto-perf/cperf_test_pmd_cyclecount.c
+++ b/app/test-crypto-perf/cperf_test_pmd_cyclecount.c
@@ -79,14 +79,11 @@ cperf_pmd_cyclecount_test_free(struct cperf_pmd_cyclecount_ctx *ctx)
 		}
 	}
 
-	if (ctx->pool)
-		rte_mempool_free(ctx->pool);
+	rte_mempool_free(ctx->pool);
 
-	if (ctx->ops)
-		rte_free(ctx->ops);
+	rte_free(ctx->ops);
 
-	if (ctx->ops_processed)
-		rte_free(ctx->ops_processed);
+	rte_free(ctx->ops_processed);
 
 	rte_free(ctx);
 }
diff --git a/app/test-crypto-perf/cperf_test_throughput.c b/app/test-crypto-perf/cperf_test_throughput.c
index 51512af2ad81..51fad5a05505 100644
--- a/app/test-crypto-perf/cperf_test_throughput.c
+++ b/app/test-crypto-perf/cperf_test_throughput.c
@@ -57,8 +57,7 @@ cperf_throughput_test_free(struct cperf_throughput_ctx *ctx)
 			rte_cryptodev_sym_session_free(ctx->sess);
 		}
 	}
-	if (ctx->pool)
-		rte_mempool_free(ctx->pool);
+	rte_mempool_free(ctx->pool);
 
 	rte_free(ctx);
 }
diff --git a/app/test-crypto-perf/cperf_test_vector_parsing.c b/app/test-crypto-perf/cperf_test_vector_parsing.c
index 1e9dfcfff087..87f3a90055aa 100644
--- a/app/test-crypto-perf/cperf_test_vector_parsing.c
+++ b/app/test-crypto-perf/cperf_test_vector_parsing.c
@@ -551,10 +551,8 @@ parse_file(struct cperf_test_vector *vector, struct cperf_options *opts)
 err:
 	if (fp)
 		fclose(fp);
-	if (line)
-		free(line);
-	if (entry)
-		rte_free(entry);
+	free(line);
+	rte_free(entry);
 
 	return -1;
 }
diff --git a/app/test-crypto-perf/cperf_test_verify.c b/app/test-crypto-perf/cperf_test_verify.c
index 496eb0de00f0..c031330afcfe 100644
--- a/app/test-crypto-perf/cperf_test_verify.c
+++ b/app/test-crypto-perf/cperf_test_verify.c
@@ -42,8 +42,7 @@ cperf_verify_test_free(struct cperf_verify_ctx *ctx)
 			rte_cryptodev_sym_session_free(ctx->sess);
 		}
 
-		if (ctx->pool)
-			rte_mempool_free(ctx->pool);
+		rte_mempool_free(ctx->pool);
 
 		rte_free(ctx);
 	}
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 12/82] app/test-pmd: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (10 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 11/82] app/test-crypto-perf: " Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24  0:04 ` [PATCH 13/82] app/test-regex: " Stephen Hemminger
                   ` (71 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Xiaoyun Li, Aman Singh, Yuying Zhang

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/test-pmd/cmd_flex_item.c | 3 +--
 app/test-pmd/cmdline.c       | 3 +--
 app/test-pmd/testpmd.c       | 3 +--
 3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/app/test-pmd/cmd_flex_item.c b/app/test-pmd/cmd_flex_item.c
index 908bcb3f47f8..9050825a81d7 100644
--- a/app/test-pmd/cmd_flex_item.c
+++ b/app/test-pmd/cmd_flex_item.c
@@ -364,8 +364,7 @@ flex_item_create(portid_t port_id, uint16_t flex_id, const char *filename)
 		       flow_error.message ? flow_error.message : "");
 	}
 out:
-	if (fp)
-		free(fp);
+	free(fp);
 }
 
 #else /* RTE_HAS_JANSSON */
diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index e626b1c7d9ee..298a594e709b 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -14696,8 +14696,7 @@ cmd_ddp_info_parsed(
 
 	ret = 0;
 no_print_return:
-	if (proto)
-		free(proto);
+	free(proto);
 #endif
 	if (ret == -ENOTSUP)
 		fprintf(stderr, "Function not supported in PMD\n");
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 6c387bde84e5..31efa0fe61e5 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -902,8 +902,7 @@ create_extmem(uint32_t nb_mbufs, uint32_t mbuf_sz, struct extmem_param *param,
 
 	return 0;
 fail:
-	if (iovas)
-		free(iovas);
+	free(iovas);
 	if (addr)
 		munmap(addr, mem_sz);
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 13/82] app/test-regex: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (11 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 12/82] app/test-pmd: " Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24  0:04 ` [PATCH 14/82] app/test: " Stephen Hemminger
                   ` (70 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Ori Kam

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/test-regex/main.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/app/test-regex/main.c b/app/test-regex/main.c
index 8e665df73ce0..ab8a3e56e774 100644
--- a/app/test-regex/main.c
+++ b/app/test-regex/main.c
@@ -210,8 +210,7 @@ read_file(char *file, char **buf)
 	printf("Error, can't open file %s\n, err = %d", file, res);
 	if (fp)
 		fclose(fp);
-	if (*buf)
-		rte_free(*buf);
+	rte_free(*buf);
 	return -res;
 }
 
@@ -299,8 +298,7 @@ init_port(uint16_t *nb_max_payload, char *rules_file, uint8_t *nb_max_matches,
 	rte_free(rules);
 	return 0;
 error:
-	if (rules)
-		rte_free(rules);
+	rte_free(rules);
 	return res;
 }
 
@@ -367,8 +365,7 @@ regex_create_segmented_mbuf(struct rte_mempool *mbuf_pool, int pkt_len,
 	return mbuf;
 
 fail:
-	if (mbuf)
-		rte_pktmbuf_free(mbuf);
+	rte_pktmbuf_free(mbuf);
 	return NULL;
 }
 
@@ -612,8 +609,7 @@ run_regex(void *args)
 		rte_free(qp->buf);
 		qp->buf = NULL;
 	}
-	if (mbuf_mp)
-		rte_mempool_free(mbuf_mp);
+	rte_mempool_free(mbuf_mp);
 	rte_free(qps);
 	return res;
 }
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 14/82] app/test: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (12 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 13/82] app/test-regex: " Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24  0:04 ` [PATCH 15/82] baseband/acc100 " Stephen Hemminger
                   ` (69 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Olivier Matz, Fan Zhang, Ashish Gupta,
	Akhil Goyal, Declan Doherty, Honnappa Nagarahalli,
	Konstantin Ananyev, Anatoly Burakov, Yipeng Wang, Sameh Gobriel,
	Bruce Richardson, Vladimir Medvedkin, Andrew Rybchenko,
	Chas Williams, Min Hu (Connor),
	Reshma Pattan

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/test/test_cksum.c                 |  3 +-
 app/test/test_compressdev.c           |  3 +-
 app/test/test_cryptodev.h             |  3 +-
 app/test/test_cryptodev_asym.c        |  3 +-
 app/test/test_cryptodev_blockcipher.c | 12 +++----
 app/test/test_func_reentrancy.c       | 15 +++------
 app/test/test_hash.c                  | 15 +++------
 app/test/test_hash_perf.c             |  7 +----
 app/test/test_link_bonding.c          |  9 ++----
 app/test/test_link_bonding_mode4.c    |  3 +-
 app/test/test_malloc.c                |  5 ++-
 app/test/test_mbuf.c                  | 45 +++++++++------------------
 app/test/test_pcapng.c                |  3 +-
 app/test/test_reorder.c               | 15 +++------
 app/test/virtual_pmd.c                |  3 +-
 15 files changed, 47 insertions(+), 97 deletions(-)

diff --git a/app/test/test_cksum.c b/app/test/test_cksum.c
index cd983d7c01ce..6c15de9a9312 100644
--- a/app/test/test_cksum.c
+++ b/app/test/test_cksum.c
@@ -218,8 +218,7 @@ test_l4_cksum(struct rte_mempool *pktmbuf_pool, const char *pktdata, size_t len)
 	return 0;
 
 fail:
-	if (m)
-		rte_pktmbuf_free(m);
+	rte_pktmbuf_free(m);
 
 	return -1;
 }
diff --git a/app/test/test_compressdev.c b/app/test/test_compressdev.c
index 57c566aa9229..fbecaf9aaad4 100644
--- a/app/test/test_compressdev.c
+++ b/app/test/test_compressdev.c
@@ -2144,8 +2144,7 @@ test_deflate_comp_decomp(const struct interim_data_params *int_data,
 
 	if (stream != NULL)
 		rte_compressdev_stream_free(0, stream);
-	if (all_decomp_data != NULL)
-		rte_free(all_decomp_data);
+	rte_free(all_decomp_data);
 
 	/* Free compress private xforms */
 	for (i = 0; i < test_priv_data.num_priv_xforms; i++) {
diff --git a/app/test/test_cryptodev.h b/app/test/test_cryptodev.h
index 70f23a3f67d0..29a7d4db2b10 100644
--- a/app/test/test_cryptodev.h
+++ b/app/test/test_cryptodev.h
@@ -230,8 +230,7 @@ create_segmented_mbuf(struct rte_mempool *mbuf_pool, int pkt_len,
 	return mbuf;
 
 fail:
-	if (mbuf)
-		rte_pktmbuf_free(mbuf);
+	rte_pktmbuf_free(mbuf);
 	return NULL;
 }
 
diff --git a/app/test/test_cryptodev_asym.c b/app/test/test_cryptodev_asym.c
index 68f4d8e7a6f9..8c68a12d74b2 100644
--- a/app/test/test_cryptodev_asym.c
+++ b/app/test/test_cryptodev_asym.c
@@ -518,8 +518,7 @@ test_cryptodev_asym_op(struct crypto_testsuite_params_asym *ts_params,
 		if (op != NULL)
 			rte_crypto_op_free(op);
 
-		if (result != NULL)
-			rte_free(result);
+		rte_free(result);
 
 	return status;
 }
diff --git a/app/test/test_cryptodev_blockcipher.c b/app/test/test_cryptodev_blockcipher.c
index 5688a45377b2..127e2a53d379 100644
--- a/app/test/test_cryptodev_blockcipher.c
+++ b/app/test/test_cryptodev_blockcipher.c
@@ -805,20 +805,16 @@ test_blockcipher_one_case(const struct blockcipher_test_case *t,
 			rte_cryptodev_sym_session_clear(dev_id, sess);
 			rte_cryptodev_sym_session_free(sess);
 		}
-		if (cipher_xform)
-			rte_free(cipher_xform);
-		if (auth_xform)
-			rte_free(auth_xform);
+		rte_free(cipher_xform);
+		rte_free(auth_xform);
 	}
 
 	if (op)
 		rte_crypto_op_free(op);
 
-	if (obuf)
-		rte_pktmbuf_free(obuf);
+	rte_pktmbuf_free(obuf);
 
-	if (ibuf)
-		rte_pktmbuf_free(ibuf);
+	rte_pktmbuf_free(ibuf);
 
 	return status;
 }
diff --git a/app/test/test_func_reentrancy.c b/app/test/test_func_reentrancy.c
index ce40c3ce9631..64f27e20370f 100644
--- a/app/test/test_func_reentrancy.c
+++ b/app/test/test_func_reentrancy.c
@@ -89,15 +89,13 @@ ring_clean(unsigned int lcore_id)
 	int i;
 
 	rp = rte_ring_lookup("fr_test_once");
-	if (rp != NULL)
-		rte_ring_free(rp);
+	rte_ring_free(rp);
 
 	for (i = 0; i < MAX_ITER_MULTI; i++) {
 		snprintf(ring_name, sizeof(ring_name),
 				"fr_test_%d_%d", lcore_id, i);
 		rp = rte_ring_lookup(ring_name);
-		if (rp != NULL)
-			rte_ring_free(rp);
+		rte_ring_free(rp);
 	}
 }
 
@@ -152,15 +150,13 @@ mempool_clean(unsigned int lcore_id)
 	int i;
 
 	mp = rte_mempool_lookup("fr_test_once");
-	if (mp != NULL)
-		rte_mempool_free(mp);
+	rte_mempool_free(mp);
 
 	for (i = 0; i < MAX_ITER_MULTI; i++) {
 		snprintf(mempool_name, sizeof(mempool_name), "fr_test_%d_%d",
 			 lcore_id, i);
 		mp = rte_mempool_lookup(mempool_name);
-		if (mp != NULL)
-			rte_mempool_free(mp);
+		rte_mempool_free(mp);
 	}
 }
 
@@ -215,8 +211,7 @@ hash_clean(unsigned lcore_id)
 	int i;
 
 	handle = rte_hash_find_existing("fr_test_once");
-	if (handle != NULL)
-		rte_hash_free(handle);
+	rte_hash_free(handle);
 
 	for (i = 0; i < MAX_ITER_MULTI; i++) {
 		snprintf(hash_name, sizeof(hash_name), "fr_test_%d_%d",  lcore_id, i);
diff --git a/app/test/test_hash.c b/app/test/test_hash.c
index b99e8de1db71..d522cb7f8cbf 100644
--- a/app/test/test_hash.c
+++ b/app/test/test_hash.c
@@ -1654,8 +1654,7 @@ test_hash_add_delete_jhash2(void)
 	ret = 0;
 
 fail_jhash2:
-	if (handle != NULL)
-		rte_hash_free(handle);
+	rte_hash_free(handle);
 
 	return ret;
 }
@@ -1689,8 +1688,7 @@ test_hash_add_delete_2_jhash2(void)
 	ret = 0;
 
 fail_2_jhash2:
-	if (handle != NULL)
-		rte_hash_free(handle);
+	rte_hash_free(handle);
 
 	return ret;
 }
@@ -1754,8 +1752,7 @@ test_hash_add_delete_jhash_1word(void)
 	ret = 0;
 
 fail_jhash_1word:
-	if (handle != NULL)
-		rte_hash_free(handle);
+	rte_hash_free(handle);
 
 	return ret;
 }
@@ -1789,8 +1786,7 @@ test_hash_add_delete_jhash_2word(void)
 	ret = 0;
 
 fail_jhash_2word:
-	if (handle != NULL)
-		rte_hash_free(handle);
+	rte_hash_free(handle);
 
 	return ret;
 }
@@ -1824,8 +1820,7 @@ test_hash_add_delete_jhash_3word(void)
 	ret = 0;
 
 fail_jhash_3word:
-	if (handle != NULL)
-		rte_hash_free(handle);
+	rte_hash_free(handle);
 
 	return ret;
 }
diff --git a/app/test/test_hash_perf.c b/app/test/test_hash_perf.c
index 76cdac5d5320..287f486316f1 100644
--- a/app/test/test_hash_perf.c
+++ b/app/test/test_hash_perf.c
@@ -106,12 +106,7 @@ create_table(unsigned int with_data, unsigned int table_index,
 	ut_params.key_len = hashtest_key_lens[table_index];
 	ut_params.socket_id = rte_socket_id();
 	h[table_index] = rte_hash_find_existing(name);
-	if (h[table_index] != NULL)
-		/*
-		 * If table was already created, free it to create it again,
-		 * so we force it is empty
-		 */
-		rte_hash_free(h[table_index]);
+	rte_hash_free(h[table_index]);
 	h[table_index] = rte_hash_create(&ut_params);
 	if (h[table_index] == NULL) {
 		printf("Error creating table\n");
diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index dc6fc46b9c93..82a9b8e01a82 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -1639,8 +1639,7 @@ test_roundrobin_rx_burst_on_single_slave(void)
 
 	/* free mbufs */
 	for (i = 0; i < MAX_PKT_BURST; i++) {
-		if (rx_pkt_burst[i] != NULL)
-			rte_pktmbuf_free(rx_pkt_burst[i]);
+		rte_pktmbuf_free(rx_pkt_burst[i]);
 	}
 
 
@@ -1722,8 +1721,7 @@ test_roundrobin_rx_burst_on_multiple_slaves(void)
 
 	/* free mbufs */
 	for (i = 0; i < MAX_PKT_BURST; i++) {
-		if (rx_pkt_burst[i] != NULL)
-			rte_pktmbuf_free(rx_pkt_burst[i]);
+		rte_pktmbuf_free(rx_pkt_burst[i]);
 	}
 
 	/* Clean up and remove slaves from bonded device */
@@ -2010,8 +2008,7 @@ test_roundrobin_verify_slave_link_status_change_behaviour(void)
 
 	/* free mbufs */
 	for (i = 0; i < MAX_PKT_BURST; i++) {
-		if (rx_pkt_burst[i] != NULL)
-			rte_pktmbuf_free(rx_pkt_burst[i]);
+		rte_pktmbuf_free(rx_pkt_burst[i]);
 	}
 
 	/* Clean up and remove slaves from bonded device */
diff --git a/app/test/test_link_bonding_mode4.c b/app/test/test_link_bonding_mode4.c
index 351129de2f9b..d9b9c323c7f8 100644
--- a/app/test/test_link_bonding_mode4.c
+++ b/app/test/test_link_bonding_mode4.c
@@ -194,8 +194,7 @@ free_pkts(struct rte_mbuf **pkts, uint16_t count)
 	uint16_t i;
 
 	for (i = 0; i < count; i++) {
-		if (pkts[i] != NULL)
-			rte_pktmbuf_free(pkts[i]);
+		rte_pktmbuf_free(pkts[i]);
 	}
 }
 
diff --git a/app/test/test_malloc.c b/app/test/test_malloc.c
index 6d9249f831be..d424d7808af3 100644
--- a/app/test/test_malloc.c
+++ b/app/test/test_malloc.c
@@ -812,7 +812,7 @@ test_zero_aligned_alloc(void)
 
 err_return:
 	/*clean up */
-	if (p1) rte_free(p1);
+	rte_free(p1);
 	return -1;
 }
 
@@ -865,8 +865,7 @@ test_malloc_bad_params(void)
 
 err_return:
 	/* clean up pointer */
-	if (bad_ptr)
-		rte_free(bad_ptr);
+	rte_free(bad_ptr);
 	return -1;
 }
 
diff --git a/app/test/test_mbuf.c b/app/test/test_mbuf.c
index f54d1d7c006a..daebf09d44b7 100644
--- a/app/test/test_mbuf.c
+++ b/app/test/test_mbuf.c
@@ -304,8 +304,7 @@ test_one_pktmbuf(struct rte_mempool *pktmbuf_pool)
 	return 0;
 
 fail:
-	if (m)
-		rte_pktmbuf_free(m);
+	rte_pktmbuf_free(m);
 	return -1;
 }
 
@@ -416,12 +415,9 @@ testclone_testupdate_testdetach(struct rte_mempool *pktmbuf_pool,
 	return 0;
 
 fail:
-	if (m)
-		rte_pktmbuf_free(m);
-	if (clone)
-		rte_pktmbuf_free(clone);
-	if (clone2)
-		rte_pktmbuf_free(clone2);
+	rte_pktmbuf_free(m);
+	rte_pktmbuf_free(clone);
+	rte_pktmbuf_free(clone2);
 	return -1;
 }
 
@@ -572,12 +568,9 @@ test_pktmbuf_copy(struct rte_mempool *pktmbuf_pool,
 	return 0;
 
 fail:
-	if (m)
-		rte_pktmbuf_free(m);
-	if (copy)
-		rte_pktmbuf_free(copy);
-	if (copy2)
-		rte_pktmbuf_free(copy2);
+	rte_pktmbuf_free(m);
+	rte_pktmbuf_free(copy);
+	rte_pktmbuf_free(copy2);
 	return -1;
 }
 
@@ -679,12 +672,9 @@ test_attach_from_different_pool(struct rte_mempool *pktmbuf_pool,
 	return 0;
 
 fail:
-	if (m)
-		rte_pktmbuf_free(m);
-	if (clone)
-		rte_pktmbuf_free(clone);
-	if (clone2)
-		rte_pktmbuf_free(clone2);
+	rte_pktmbuf_free(m);
+	rte_pktmbuf_free(clone);
+	rte_pktmbuf_free(clone2);
 	return -1;
 }
 
@@ -722,8 +712,7 @@ test_pktmbuf_pool(struct rte_mempool *pktmbuf_pool)
 	}
 	/* free them */
 	for (i=0; i<NB_MBUF; i++) {
-		if (m[i] != NULL)
-			rte_pktmbuf_free(m[i]);
+		rte_pktmbuf_free(m[i]);
 	}
 
 	return ret;
@@ -924,8 +913,7 @@ test_pktmbuf_pool_ptr(struct rte_mempool *pktmbuf_pool)
 
 	/* free them */
 	for (i=0; i<NB_MBUF; i++) {
-		if (m[i] != NULL)
-			rte_pktmbuf_free(m[i]);
+		rte_pktmbuf_free(m[i]);
 	}
 
 	for (i=0; i<NB_MBUF; i++)
@@ -947,8 +935,7 @@ test_pktmbuf_pool_ptr(struct rte_mempool *pktmbuf_pool)
 
 	/* free them */
 	for (i=0; i<NB_MBUF; i++) {
-		if (m[i] != NULL)
-			rte_pktmbuf_free(m[i]);
+		rte_pktmbuf_free(m[i]);
 	}
 
 	return ret;
@@ -1355,8 +1342,7 @@ test_mbuf_linearize(struct rte_mempool *pktmbuf_pool, int pkt_len,
 	return 0;
 
 fail:
-	if (mbuf)
-		rte_pktmbuf_free(mbuf);
+	rte_pktmbuf_free(mbuf);
 	return -1;
 }
 
@@ -2772,8 +2758,7 @@ test_nb_segs_and_next_reset(void)
 	return 0;
 
 fail:
-	if (pool != NULL)
-		rte_mempool_free(pool);
+	rte_mempool_free(pool);
 	return -1;
 }
 
diff --git a/app/test/test_pcapng.c b/app/test/test_pcapng.c
index 34c5e1234695..320dacea3498 100644
--- a/app/test/test_pcapng.c
+++ b/app/test/test_pcapng.c
@@ -240,8 +240,7 @@ test_validate(void)
 static void
 test_cleanup(void)
 {
-	if (mp)
-		rte_mempool_free(mp);
+	rte_mempool_free(mp);
 
 	if (pcapng)
 		rte_pcapng_close(pcapng);
diff --git a/app/test/test_reorder.c b/app/test/test_reorder.c
index 1c4226da6501..962c31953f91 100644
--- a/app/test/test_reorder.c
+++ b/app/test/test_reorder.c
@@ -208,8 +208,7 @@ test_reorder_insert(void)
 exit:
 	rte_reorder_free(b);
 	for (i = 0; i < num_bufs; i++) {
-		if (bufs[i] != NULL)
-			rte_pktmbuf_free(bufs[i]);
+		rte_pktmbuf_free(bufs[i]);
 	}
 	return ret;
 }
@@ -268,8 +267,7 @@ test_reorder_drain(void)
 		ret = -1;
 		goto exit;
 	}
-	if (robufs[0] != NULL)
-		rte_pktmbuf_free(robufs[0]);
+	rte_pktmbuf_free(robufs[0]);
 
 	/* Insert more packets
 	 * RB[] = {NULL, NULL, NULL, NULL}
@@ -303,8 +301,7 @@ test_reorder_drain(void)
 		goto exit;
 	}
 	for (i = 0; i < 3; i++) {
-		if (robufs[i] != NULL)
-			rte_pktmbuf_free(robufs[i]);
+		rte_pktmbuf_free(robufs[i]);
 	}
 
 	/*
@@ -322,10 +319,8 @@ test_reorder_drain(void)
 exit:
 	rte_reorder_free(b);
 	for (i = 0; i < num_bufs; i++) {
-		if (bufs[i] != NULL)
-			rte_pktmbuf_free(bufs[i]);
-		if (robufs[i] != NULL)
-			rte_pktmbuf_free(robufs[i]);
+		rte_pktmbuf_free(bufs[i]);
+		rte_pktmbuf_free(robufs[i]);
 	}
 	return ret;
 }
diff --git a/app/test/virtual_pmd.c b/app/test/virtual_pmd.c
index 3d2793852049..cd4611ab48df 100644
--- a/app/test/virtual_pmd.c
+++ b/app/test/virtual_pmd.c
@@ -397,8 +397,7 @@ virtual_ethdev_tx_burst_fail(void *queue, struct rte_mbuf **bufs,
 		/* free packets in burst */
 		for (i = 0; i < successfully_txd; i++) {
 			/* free packets in burst */
-			if (bufs[i] != NULL)
-				rte_pktmbuf_free(bufs[i]);
+			rte_pktmbuf_free(bufs[i]);
 
 			bufs[i] = NULL;
 		}
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 15/82] baseband/acc100 remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (13 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 14/82] app/test: " Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24  0:04 ` [PATCH 16/82] baseband/la12xx " Stephen Hemminger
                   ` (68 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Nicolas Chautru

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/baseband/acc100/rte_acc100_pmd.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/baseband/acc100/rte_acc100_pmd.c b/drivers/baseband/acc100/rte_acc100_pmd.c
index 1c6080f2f895..f86474f7e099 100644
--- a/drivers/baseband/acc100/rte_acc100_pmd.c
+++ b/drivers/baseband/acc100/rte_acc100_pmd.c
@@ -4402,8 +4402,7 @@ poweron_cleanup(struct rte_bbdev *bbdev, struct acc100_device *d,
 	}
 	printf("Number of 5GUL engines %d\n", numEngines);
 
-	if (d->sw_rings_base != NULL)
-		rte_free(d->sw_rings_base);
+	rte_free(d->sw_rings_base);
 	usleep(ACC100_LONG_WAIT);
 }
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 16/82] baseband/la12xx remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (14 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 15/82] baseband/acc100 " Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24  5:05   ` Hemant Agrawal
  2022-01-24  0:04 ` [PATCH 17/82] baseband/null " Stephen Hemminger
                   ` (67 subsequent siblings)
  83 siblings, 1 reply; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Nipun Gupta, Hemant Agrawal, Nicolas Chautru

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/baseband/la12xx/bbdev_la12xx.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/baseband/la12xx/bbdev_la12xx.c b/drivers/baseband/la12xx/bbdev_la12xx.c
index 4b05b5d3f2a6..4d1bd16751fe 100644
--- a/drivers/baseband/la12xx/bbdev_la12xx.c
+++ b/drivers/baseband/la12xx/bbdev_la12xx.c
@@ -975,8 +975,7 @@ parse_bbdev_la12xx_params(struct bbdev_la12xx_params *params,
 	}
 
 exit:
-	if (kvlist)
-		rte_kvargs_free(kvlist);
+	rte_kvargs_free(kvlist);
 	return ret;
 }
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 17/82] baseband/null remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (15 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 16/82] baseband/la12xx " Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24  0:04 ` [PATCH 18/82] baseband/turbo_sw " Stephen Hemminger
                   ` (66 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Nicolas Chautru

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/baseband/null/bbdev_null.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/baseband/null/bbdev_null.c b/drivers/baseband/null/bbdev_null.c
index 08cff582b99d..248e12987f03 100644
--- a/drivers/baseband/null/bbdev_null.c
+++ b/drivers/baseband/null/bbdev_null.c
@@ -251,8 +251,7 @@ parse_bbdev_null_params(struct bbdev_null_params *params,
 	}
 
 exit:
-	if (kvlist)
-		rte_kvargs_free(kvlist);
+	rte_kvargs_free(kvlist);
 	return ret;
 }
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 18/82] baseband/turbo_sw remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (16 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 17/82] baseband/null " Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24  0:04 ` [PATCH 19/82] bus/fslmc: " Stephen Hemminger
                   ` (65 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Nicolas Chautru

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/baseband/turbo_sw/bbdev_turbo_software.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/baseband/turbo_sw/bbdev_turbo_software.c b/drivers/baseband/turbo_sw/bbdev_turbo_software.c
index c6b1eb8679cb..af7bc416f92e 100644
--- a/drivers/baseband/turbo_sw/bbdev_turbo_software.c
+++ b/drivers/baseband/turbo_sw/bbdev_turbo_software.c
@@ -1918,8 +1918,7 @@ parse_turbo_sw_params(struct turbo_sw_params *params, const char *input_args)
 	}
 
 exit:
-	if (kvlist)
-		rte_kvargs_free(kvlist);
+	rte_kvargs_free(kvlist);
 	return ret;
 }
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 19/82] bus/fslmc: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (17 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 18/82] baseband/turbo_sw " Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24  5:06   ` Hemant Agrawal
  2022-01-24  0:04 ` [PATCH 20/82] bus/ifpga: " Stephen Hemminger
                   ` (64 subsequent siblings)
  83 siblings, 1 reply; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Hemant Agrawal, Sachin Saxena

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/bus/fslmc/fslmc_bus.c            | 6 ++----
 drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 6 ++----
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/bus/fslmc/fslmc_bus.c b/drivers/bus/fslmc/fslmc_bus.c
index 53fd75539e98..30d019516b91 100644
--- a/drivers/bus/fslmc/fslmc_bus.c
+++ b/drivers/bus/fslmc/fslmc_bus.c
@@ -223,13 +223,11 @@ scan_one_fslmc_device(char *dev_name)
 	insert_in_device_list(dev);
 
 	/* Don't need the duplicated device filesystem entry anymore */
-	if (dup_dev_name)
-		free(dup_dev_name);
+	free(dup_dev_name);
 
 	return 0;
 cleanup:
-	if (dup_dev_name)
-		free(dup_dev_name);
+	free(dup_dev_name);
 	if (dev) {
 		rte_intr_instance_free(dev->intr_handle);
 		free(dev);
diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
index 52605ea2c32c..943fadee4816 100644
--- a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
+++ b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
@@ -149,8 +149,7 @@ dpaa2_affine_dpio_intr_to_respective_core(int32_t dpio_id, int cpu_id)
 	if (!token) {
 		DPAA2_BUS_WARN("Failed to get interrupt id for dpio.%d",
 			       dpio_id);
-		if (temp)
-			free(temp);
+		free(temp);
 		fclose(file);
 		return;
 	}
@@ -574,8 +573,7 @@ dpaa2_free_dq_storage(struct queue_storage_info_t *q_storage)
 	int i = 0;
 
 	for (i = 0; i < NUM_DQS_PER_QUEUE; i++) {
-		if (q_storage->dq_storage[i])
-			rte_free(q_storage->dq_storage[i]);
+		rte_free(q_storage->dq_storage[i]);
 	}
 }
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 20/82] bus/ifpga: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (18 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 19/82] bus/fslmc: " Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24  0:04 ` [PATCH 21/82] bus/pci: " Stephen Hemminger
                   ` (63 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Rosen Xu

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/bus/ifpga/ifpga_bus.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/bus/ifpga/ifpga_bus.c b/drivers/bus/ifpga/ifpga_bus.c
index c5c8bbd57219..e005f2cb70b3 100644
--- a/drivers/bus/ifpga/ifpga_bus.c
+++ b/drivers/bus/ifpga/ifpga_bus.c
@@ -191,10 +191,8 @@ ifpga_scan_one(struct rte_rawdev *rawdev,
 	return afu_dev;
 
 end:
-	if (kvlist)
-		rte_kvargs_free(kvlist);
-	if (path)
-		free(path);
+	rte_kvargs_free(kvlist);
+	free(path);
 	if (afu_dev) {
 		rte_intr_instance_free(afu_dev->intr_handle);
 		free(afu_dev);
@@ -254,10 +252,8 @@ ifpga_scan(void)
 	}
 
 end:
-	if (kvlist)
-		rte_kvargs_free(kvlist);
-	if (name)
-		free(name);
+	rte_kvargs_free(kvlist);
+	free(name);
 
 	return 0;
 }
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 21/82] bus/pci: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (19 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 20/82] bus/ifpga: " Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24  0:04 ` [PATCH 22/82] common/cpt: " Stephen Hemminger
                   ` (62 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/bus/pci/pci_params.c         | 3 +--
 drivers/bus/pci/windows/pci.c        | 3 +--
 drivers/bus/pci/windows/pci_netuio.c | 3 +--
 3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/bus/pci/pci_params.c b/drivers/bus/pci/pci_params.c
index 60b424b8297e..61a868707f16 100644
--- a/drivers/bus/pci/pci_params.c
+++ b/drivers/bus/pci/pci_params.c
@@ -117,8 +117,7 @@ rte_pci_devargs_parse(struct rte_devargs *da)
 	rte_pci_device_name(&addr, da->name, sizeof(da->name));
 
 out:
-	if (kvargs != NULL)
-		rte_kvargs_free(kvargs);
+	rte_kvargs_free(kvargs);
 	if (ret != 0)
 		rte_errno = -ret;
 	return ret;
diff --git a/drivers/bus/pci/windows/pci.c b/drivers/bus/pci/windows/pci.c
index 39ba31be7d38..7bf091158ba2 100644
--- a/drivers/bus/pci/windows/pci.c
+++ b/drivers/bus/pci/windows/pci.c
@@ -418,8 +418,7 @@ pci_scan_one(HDEVINFO dev_info, PSP_DEVINFO_DATA device_info_data)
 
 	return 0;
 end:
-	if (dev)
-		free(dev);
+	free(dev);
 	return ret;
 }
 
diff --git a/drivers/bus/pci/windows/pci_netuio.c b/drivers/bus/pci/windows/pci_netuio.c
index a0b175a8fca0..5460399eea5f 100644
--- a/drivers/bus/pci/windows/pci_netuio.c
+++ b/drivers/bus/pci/windows/pci_netuio.c
@@ -180,8 +180,7 @@ get_netuio_device_info(HDEVINFO dev_info, PSP_DEVINFO_DATA dev_info_data,
 			CloseHandle(netuio);
 	}
 
-	if (dev_ifx_detail)
-		free(dev_ifx_detail);
+	free(dev_ifx_detail);
 
 	if (di_set != INVALID_HANDLE_VALUE)
 		SetupDiDestroyDeviceInfoList(di_set);
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 22/82] common/cpt: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (20 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 21/82] bus/pci: " Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24  0:04 ` [PATCH 23/82] common/dpaax: simplify kernel compat macros Stephen Hemminger
                   ` (61 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Anoob Joseph

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/common/cpt/cpt_ucode_asym.h | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/common/cpt/cpt_ucode_asym.h b/drivers/common/cpt/cpt_ucode_asym.h
index f0b5dddd8cdf..f5d91f2583bd 100644
--- a/drivers/common/cpt/cpt_ucode_asym.h
+++ b/drivers/common/cpt/cpt_ucode_asym.h
@@ -192,13 +192,11 @@ cpt_free_asym_session_parameters(struct cpt_asym_sess_misc *sess)
 	switch (sess->xfrm_type) {
 	case RTE_CRYPTO_ASYM_XFORM_RSA:
 		rsa = &sess->rsa_ctx;
-		if (rsa->n.data)
-			rte_free(rsa->n.data);
+		rte_free(rsa->n.data);
 		break;
 	case RTE_CRYPTO_ASYM_XFORM_MODEX:
 		mod = &sess->mod_ctx;
-		if (mod->modulus.data)
-			rte_free(mod->modulus.data);
+		rte_free(mod->modulus.data);
 		break;
 	case RTE_CRYPTO_ASYM_XFORM_ECDSA:
 		/* Fall through */
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 23/82] common/dpaax: simplify kernel compat macros
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (21 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 22/82] common/cpt: " Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24  5:06   ` Hemant Agrawal
  2022-01-24  0:04 ` [PATCH 24/82] common/mlx5: remove unnecessary NULL checks Stephen Hemminger
                   ` (60 subsequent siblings)
  83 siblings, 1 reply; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Hemant Agrawal, Sachin Saxena

The compat wrapper had unnecessary NULL check and also
the emulation of kzalloc() should just use equivalent rte_zmalloc().

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/common/dpaax/compat.h | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/common/dpaax/compat.h b/drivers/common/dpaax/compat.h
index 7166f8cceb41..cbabc1588b21 100644
--- a/drivers/common/dpaax/compat.h
+++ b/drivers/common/dpaax/compat.h
@@ -339,16 +339,9 @@ static inline void copy_bytes(void *dest, const void *src, size_t sz)
 
 /* Allocator stuff */
 #define kmalloc(sz, t)	rte_malloc(NULL, sz, 0)
+#define kzalloc(sz, t)  rte_zmalloc(NULL, sz, 0)
 #define vmalloc(sz)	rte_malloc(NULL, sz, 0)
-#define kfree(p)	{ if (p) rte_free(p); }
-static inline void *kzalloc(size_t sz, gfp_t __foo __rte_unused)
-{
-	void *ptr = rte_malloc(NULL, sz, 0);
-
-	if (ptr)
-		memset(ptr, 0, sz);
-	return ptr;
-}
+#define kfree(p)	rte_free(p)
 
 static inline unsigned long get_zeroed_page(gfp_t __foo __rte_unused)
 {
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 24/82] common/mlx5: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (22 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 23/82] common/dpaax: simplify kernel compat macros Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24  0:04 ` [PATCH 25/82] common/qat: " Stephen Hemminger
                   ` (59 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Matan Azrad, Viacheslav Ovsiienko

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/common/mlx5/mlx5_common_mr.c  | 3 +--
 drivers/common/mlx5/mlx5_common_pci.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/common/mlx5/mlx5_common_mr.c b/drivers/common/mlx5/mlx5_common_mr.c
index 1537b5d42879..07f76a10655f 100644
--- a/drivers/common/mlx5/mlx5_common_mr.c
+++ b/drivers/common/mlx5/mlx5_common_mr.c
@@ -516,8 +516,7 @@ mlx5_mr_free(struct mlx5_mr *mr, mlx5_dereg_mr_t dereg_mr_cb)
 		return;
 	DRV_LOG(DEBUG, "freeing MR(%p):", (void *)mr);
 	dereg_mr_cb(&mr->pmd_mr);
-	if (mr->ms_bmp != NULL)
-		rte_bitmap_free(mr->ms_bmp);
+	rte_bitmap_free(mr->ms_bmp);
 	mlx5_free(mr);
 }
 
diff --git a/drivers/common/mlx5/mlx5_common_pci.c b/drivers/common/mlx5/mlx5_common_pci.c
index 8b38091d8741..458630351cd1 100644
--- a/drivers/common/mlx5/mlx5_common_pci.c
+++ b/drivers/common/mlx5/mlx5_common_pci.c
@@ -97,8 +97,7 @@ pci_ids_table_update(const struct rte_pci_id *driver_id_table)
 	updated_table[i].vendor_id = 0;
 	mlx5_common_pci_driver.id_table = updated_table;
 	mlx5_pci_id_table = updated_table;
-	if (old_table)
-		free(old_table);
+	free(old_table);
 	return 0;
 }
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 25/82] common/qat: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (23 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 24/82] common/mlx5: remove unnecessary NULL checks Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24  0:04 ` [PATCH 26/82] compress/mlx5: " Stephen Hemminger
                   ` (58 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, John Griffin, Fiona Trahe, Deepak Kumar Jain

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/common/qat/qat_qp.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/common/qat/qat_qp.c b/drivers/common/qat/qat_qp.c
index cde421eb7716..57ac8fefca3d 100644
--- a/drivers/common/qat/qat_qp.c
+++ b/drivers/common/qat/qat_qp.c
@@ -175,11 +175,9 @@ qat_qp_setup(struct qat_pci_device *qat_dev,
 
 create_err:
 	if (qp) {
-		if (qp->op_cookie_pool)
-			rte_mempool_free(qp->op_cookie_pool);
+		rte_mempool_free(qp->op_cookie_pool);
 
-		if (qp->op_cookies)
-			rte_free(qp->op_cookies);
+		rte_free(qp->op_cookies);
 
 		rte_free(qp);
 	}
@@ -329,8 +327,7 @@ qat_qp_release(enum qat_device_gen qat_dev_gen, struct qat_qp **qp_addr)
 	for (i = 0; i < qp->nb_descriptors; i++)
 		rte_mempool_put(qp->op_cookie_pool, qp->op_cookies[i]);
 
-	if (qp->op_cookie_pool)
-		rte_mempool_free(qp->op_cookie_pool);
+	rte_mempool_free(qp->op_cookie_pool);
 
 	rte_free(qp->op_cookies);
 	rte_free(qp);
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 26/82] compress/mlx5: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (24 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 25/82] common/qat: " Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24  0:04 ` [PATCH 27/82] compress/octeontx: " Stephen Hemminger
                   ` (57 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Matan Azrad, Fan Zhang, Ashish Gupta

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/compress/mlx5/mlx5_compress.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/compress/mlx5/mlx5_compress.c b/drivers/compress/mlx5/mlx5_compress.c
index 82b871bd860a..b12951da8b51 100644
--- a/drivers/compress/mlx5/mlx5_compress.c
+++ b/drivers/compress/mlx5/mlx5_compress.c
@@ -146,8 +146,7 @@ mlx5_compress_qp_release(struct rte_compressdev *dev, uint16_t qp_id)
 		void *opaq = qp->opaque_mr.addr;
 
 		mlx5_common_verbs_dereg_mr(&qp->opaque_mr);
-		if (opaq != NULL)
-			rte_free(opaq);
+		rte_free(opaq);
 	}
 	mlx5_mr_btree_free(&qp->mr_ctrl.cache_bh);
 	rte_free(qp);
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 27/82] compress/octeontx: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (25 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 26/82] compress/mlx5: " Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24  0:04 ` [PATCH 28/82] crypto/armv8: " Stephen Hemminger
                   ` (56 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Ashish Gupta, Fan Zhang

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/compress/octeontx/otx_zip_pmd.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/compress/octeontx/otx_zip_pmd.c b/drivers/compress/octeontx/otx_zip_pmd.c
index dd62285b863e..26cdce60a859 100644
--- a/drivers/compress/octeontx/otx_zip_pmd.c
+++ b/drivers/compress/octeontx/otx_zip_pmd.c
@@ -337,8 +337,7 @@ zip_pmd_qp_release(struct rte_compressdev *dev, uint16_t qp_id)
 	if (qp != NULL) {
 		zipvf_q_term(qp);
 
-		if (qp->processed_pkts)
-			rte_ring_free(qp->processed_pkts);
+		rte_ring_free(qp->processed_pkts);
 
 		rte_free(qp);
 		dev->data->queue_pairs[qp_id] = NULL;
@@ -423,10 +422,8 @@ zip_pmd_qp_setup(struct rte_compressdev *dev, uint16_t qp_id,
 	return 0;
 
 qp_setup_cleanup:
-	if (qp->processed_pkts)
-		rte_ring_free(qp->processed_pkts);
-	if (qp)
-		rte_free(qp);
+	rte_ring_free(qp->processed_pkts);
+	rte_free(qp);
 	return -1;
 }
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 28/82] crypto/armv8: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (26 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 27/82] compress/octeontx: " Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24  4:15   ` Ruifeng Wang
  2022-01-24  0:04 ` [PATCH 29/82] crypto/ccp: " Stephen Hemminger
                   ` (55 subsequent siblings)
  83 siblings, 1 reply; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Ruifeng Wang

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/crypto/armv8/rte_armv8_pmd_ops.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/crypto/armv8/rte_armv8_pmd_ops.c b/drivers/crypto/armv8/rte_armv8_pmd_ops.c
index 1b2749fe62c6..c07ac0489e57 100644
--- a/drivers/crypto/armv8/rte_armv8_pmd_ops.c
+++ b/drivers/crypto/armv8/rte_armv8_pmd_ops.c
@@ -251,8 +251,7 @@ armv8_crypto_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 	return 0;
 
 qp_setup_cleanup:
-	if (qp)
-		rte_free(qp);
+	rte_free(qp);
 
 	return -1;
 }
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 29/82] crypto/ccp: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (27 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 28/82] crypto/armv8: " Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24  0:04 ` [PATCH 30/82] crypto/cnxk: " Stephen Hemminger
                   ` (54 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Chandubabu Namburu

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/crypto/ccp/ccp_dev.c     | 3 +--
 drivers/crypto/ccp/ccp_pmd_ops.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/crypto/ccp/ccp_dev.c b/drivers/crypto/ccp/ccp_dev.c
index 0eb1b0328ef0..424ead82c3aa 100644
--- a/drivers/crypto/ccp/ccp_dev.c
+++ b/drivers/crypto/ccp/ccp_dev.c
@@ -673,8 +673,7 @@ ccp_probe_device(int ccp_type, struct rte_pci_device *pci_dev)
 	CCP_LOG_ERR("CCP Device probe failed");
 	if (uio_fd >= 0)
 		close(uio_fd);
-	if (ccp_dev)
-		rte_free(ccp_dev);
+	rte_free(ccp_dev);
 	return -1;
 }
 
diff --git a/drivers/crypto/ccp/ccp_pmd_ops.c b/drivers/crypto/ccp/ccp_pmd_ops.c
index 0d615d311c9b..1b600e81ad5c 100644
--- a/drivers/crypto/ccp/ccp_pmd_ops.c
+++ b/drivers/crypto/ccp/ccp_pmd_ops.c
@@ -744,8 +744,7 @@ ccp_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 
 qp_setup_cleanup:
 	dev->data->queue_pairs[qp_id] = NULL;
-	if (qp)
-		rte_free(qp);
+	rte_free(qp);
 	return -1;
 }
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 30/82] crypto/cnxk: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (28 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 29/82] crypto/ccp: " Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24  0:04 ` [PATCH 31/82] crypto/ipsec_mb: " Stephen Hemminger
                   ` (53 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Ankur Dwivedi, Anoob Joseph, Tejasree Kondoj

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/crypto/cnxk/cnxk_ae.h | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/crypto/cnxk/cnxk_ae.h b/drivers/crypto/cnxk/cnxk_ae.h
index 6222171fe603..01ccfcd33432 100644
--- a/drivers/crypto/cnxk/cnxk_ae.h
+++ b/drivers/crypto/cnxk/cnxk_ae.h
@@ -196,13 +196,11 @@ cnxk_ae_free_session_parameters(struct cnxk_ae_sess *sess)
 	switch (sess->xfrm_type) {
 	case RTE_CRYPTO_ASYM_XFORM_RSA:
 		rsa = &sess->rsa_ctx;
-		if (rsa->n.data)
-			rte_free(rsa->n.data);
+		rte_free(rsa->n.data);
 		break;
 	case RTE_CRYPTO_ASYM_XFORM_MODEX:
 		mod = &sess->mod_ctx;
-		if (mod->modulus.data)
-			rte_free(mod->modulus.data);
+		rte_free(mod->modulus.data);
 		break;
 	case RTE_CRYPTO_ASYM_XFORM_ECDSA:
 		/* Fall through */
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 31/82] crypto/ipsec_mb: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (29 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 30/82] crypto/cnxk: " Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24  0:04 ` [PATCH 32/82] crypto/mvsam: " Stephen Hemminger
                   ` (52 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Fan Zhang, Pablo de Lara

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/crypto/ipsec_mb/ipsec_mb_ops.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/crypto/ipsec_mb/ipsec_mb_ops.c b/drivers/crypto/ipsec_mb/ipsec_mb_ops.c
index 189262c4ad52..f808da9edf89 100644
--- a/drivers/crypto/ipsec_mb/ipsec_mb_ops.c
+++ b/drivers/crypto/ipsec_mb/ipsec_mb_ops.c
@@ -102,8 +102,7 @@ ipsec_mb_qp_release(struct rte_cryptodev *dev, uint16_t qp_id)
 
 	if (qp != NULL && rte_eal_process_type() == RTE_PROC_PRIMARY) {
 		r = rte_ring_lookup(qp->name);
-		if (r)
-			rte_ring_free(r);
+		rte_ring_free(r);
 
 #if IMB_VERSION(1, 1, 0) > IMB_VERSION_NUM
 		if (qp->mb_mgr)
@@ -291,8 +290,7 @@ ipsec_mb_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 	if (qp->mb_mgr_mz)
 		rte_memzone_free(qp->mb_mgr_mz);
 #endif
-	if (qp)
-		rte_free(qp);
+	rte_free(qp);
 	return ret;
 }
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 32/82] crypto/mvsam: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (30 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 31/82] crypto/ipsec_mb: " Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24  7:44   ` [EXT] " Liron Himi
  2022-01-24  0:04 ` [PATCH 33/82] crypto/null: " Stephen Hemminger
                   ` (51 subsequent siblings)
  83 siblings, 1 reply; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Michael Shamis, Liron Himi

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/crypto/mvsam/rte_mrvl_pmd_ops.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/crypto/mvsam/rte_mrvl_pmd_ops.c b/drivers/crypto/mvsam/rte_mrvl_pmd_ops.c
index 3064b1f136fe..f828dc9db5f6 100644
--- a/drivers/crypto/mvsam/rte_mrvl_pmd_ops.c
+++ b/drivers/crypto/mvsam/rte_mrvl_pmd_ops.c
@@ -774,10 +774,8 @@ mrvl_crypto_pmd_sym_session_configure(__rte_unused struct rte_cryptodev *dev,
 	}
 
 	/* free the keys memory allocated for session creation */
-	if (mrvl_sess->sam_sess_params.cipher_key != NULL)
-		free(mrvl_sess->sam_sess_params.cipher_key);
-	if (mrvl_sess->sam_sess_params.auth_key != NULL)
-		free(mrvl_sess->sam_sess_params.auth_key);
+	free(mrvl_sess->sam_sess_params.cipher_key);
+	free(mrvl_sess->sam_sess_params.auth_key);
 
 	return 0;
 }
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 33/82] crypto/null: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (31 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 32/82] crypto/mvsam: " Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24  0:04 ` [PATCH 34/82] crypto/octeontx: " Stephen Hemminger
                   ` (50 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Declan Doherty

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/crypto/null/null_crypto_pmd_ops.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/crypto/null/null_crypto_pmd_ops.c b/drivers/crypto/null/null_crypto_pmd_ops.c
index a8b5a06e7f4e..90a675dfffe0 100644
--- a/drivers/crypto/null/null_crypto_pmd_ops.c
+++ b/drivers/crypto/null/null_crypto_pmd_ops.c
@@ -135,8 +135,7 @@ null_crypto_pmd_qp_release(struct rte_cryptodev *dev, uint16_t qp_id)
 	if (dev->data->queue_pairs[qp_id] != NULL) {
 		struct null_crypto_qp *qp = dev->data->queue_pairs[qp_id];
 
-		if (qp->processed_pkts)
-			rte_ring_free(qp->processed_pkts);
+		rte_ring_free(qp->processed_pkts);
 
 		rte_free(dev->data->queue_pairs[qp_id]);
 		dev->data->queue_pairs[qp_id] = NULL;
@@ -241,8 +240,7 @@ null_crypto_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 	return 0;
 
 qp_setup_cleanup:
-	if (qp)
-		rte_free(qp);
+	rte_free(qp);
 
 	return -1;
 }
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 34/82] crypto/octeontx: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (32 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 33/82] crypto/null: " Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24  0:04 ` [PATCH 35/82] crypto/openssl: " Stephen Hemminger
                   ` (49 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Anoob Joseph

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/crypto/octeontx/otx_cryptodev_ops.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/crypto/octeontx/otx_cryptodev_ops.c b/drivers/crypto/octeontx/otx_cryptodev_ops.c
index f7ca8a8a8e90..f1aae481c3c6 100644
--- a/drivers/crypto/octeontx/otx_cryptodev_ops.c
+++ b/drivers/crypto/octeontx/otx_cryptodev_ops.c
@@ -335,8 +335,7 @@ sym_session_clear(int driver_id, struct rte_cryptodev_sym_session *sess)
 	misc = priv;
 	ctx = SESS_PRIV(misc);
 
-	if (ctx->auth_key != NULL)
-		rte_free(ctx->auth_key);
+	rte_free(ctx->auth_key);
 
 	memset(priv, 0, cpt_get_session_size());
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 35/82] crypto/openssl: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (33 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 34/82] crypto/octeontx: " Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24  0:04 ` [PATCH 36/82] crypto/scheduler: " Stephen Hemminger
                   ` (48 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Declan Doherty

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/crypto/openssl/rte_openssl_pmd_ops.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/crypto/openssl/rte_openssl_pmd_ops.c b/drivers/crypto/openssl/rte_openssl_pmd_ops.c
index 52715f86f84a..b1c0b14fefd2 100644
--- a/drivers/crypto/openssl/rte_openssl_pmd_ops.c
+++ b/drivers/crypto/openssl/rte_openssl_pmd_ops.c
@@ -659,8 +659,7 @@ openssl_pmd_qp_release(struct rte_cryptodev *dev, uint16_t qp_id)
 	if (dev->data->queue_pairs[qp_id] != NULL) {
 		struct openssl_qp *qp = dev->data->queue_pairs[qp_id];
 
-		if (qp->processed_ops)
-			rte_ring_free(qp->processed_ops);
+		rte_ring_free(qp->processed_ops);
 
 		rte_free(dev->data->queue_pairs[qp_id]);
 		dev->data->queue_pairs[qp_id] = NULL;
@@ -748,8 +747,7 @@ openssl_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 	return 0;
 
 qp_setup_cleanup:
-	if (qp)
-		rte_free(qp);
+	rte_free(qp);
 
 	return -1;
 }
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 36/82] crypto/scheduler: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (34 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 35/82] crypto/openssl: " Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24  0:04 ` [PATCH 37/82] crypto/virtio: " Stephen Hemminger
                   ` (47 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Fan Zhang

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/crypto/scheduler/scheduler_pmd_ops.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/crypto/scheduler/scheduler_pmd_ops.c b/drivers/crypto/scheduler/scheduler_pmd_ops.c
index f61640c9d646..f3a1bd626c6f 100644
--- a/drivers/crypto/scheduler/scheduler_pmd_ops.c
+++ b/drivers/crypto/scheduler/scheduler_pmd_ops.c
@@ -371,10 +371,8 @@ scheduler_pmd_qp_release(struct rte_cryptodev *dev, uint16_t qp_id)
 	if (!qp_ctx)
 		return 0;
 
-	if (qp_ctx->order_ring)
-		rte_ring_free(qp_ctx->order_ring);
-	if (qp_ctx->private_qp_ctx)
-		rte_free(qp_ctx->private_qp_ctx);
+	rte_ring_free(qp_ctx->order_ring);
+	rte_free(qp_ctx->private_qp_ctx);
 
 	rte_free(qp_ctx);
 	dev->data->queue_pairs[qp_id] = NULL;
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 37/82] crypto/virtio: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (35 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 36/82] crypto/scheduler: " Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24  0:04 ` [PATCH 38/82] event/sw: " Stephen Hemminger
                   ` (46 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Jay Zhou

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/crypto/virtio/virtqueue.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/crypto/virtio/virtqueue.c b/drivers/crypto/virtio/virtqueue.c
index fd8be581c996..3e2db1ebd250 100644
--- a/drivers/crypto/virtio/virtqueue.c
+++ b/drivers/crypto/virtio/virtqueue.c
@@ -32,10 +32,8 @@ virtqueue_detatch_unused(struct virtqueue *vq)
 		for (idx = 0; idx < vq->vq_nentries; idx++) {
 			cop = vq->vq_descx[idx].crypto_op;
 			if (cop) {
-				if (cop->sym->m_src)
-					rte_pktmbuf_free(cop->sym->m_src);
-				if (cop->sym->m_dst)
-					rte_pktmbuf_free(cop->sym->m_dst);
+				rte_pktmbuf_free(cop->sym->m_src);
+				rte_pktmbuf_free(cop->sym->m_dst);
 				rte_crypto_op_free(cop);
 				vq->vq_descx[idx].crypto_op = NULL;
 			}
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 38/82] event/sw: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (36 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 37/82] crypto/virtio: " Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24  0:04 ` [PATCH 39/82] net/axgbe: " Stephen Hemminger
                   ` (45 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Harry van Haaren

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/event/sw/sw_evdev.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/event/sw/sw_evdev.c b/drivers/event/sw/sw_evdev.c
index 6ae613e0f2e7..ba82a80385b6 100644
--- a/drivers/event/sw/sw_evdev.c
+++ b/drivers/event/sw/sw_evdev.c
@@ -526,8 +526,7 @@ sw_dev_configure(const struct rte_eventdev *dev)
 	 * IQ chunk references were cleaned out of the QIDs in sw_stop(), and
 	 * will be reinitialized in sw_start().
 	 */
-	if (sw->chunks)
-		rte_free(sw->chunks);
+	rte_free(sw->chunks);
 
 	sw->chunks = rte_malloc_socket(NULL,
 				       sizeof(struct sw_queue_chunk) *
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 39/82] net/axgbe: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (37 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 38/82] event/sw: " Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24  0:04 ` [PATCH 40/82] net/bnx2x: " Stephen Hemminger
                   ` (44 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Chandubabu Namburu

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/axgbe/axgbe_rxtx.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/axgbe/axgbe_rxtx.c b/drivers/net/axgbe/axgbe_rxtx.c
index 6bd41d3002bf..f38bb64fab6b 100644
--- a/drivers/net/axgbe/axgbe_rxtx.c
+++ b/drivers/net/axgbe/axgbe_rxtx.c
@@ -22,8 +22,7 @@ axgbe_rx_queue_release(struct axgbe_rx_queue *rx_queue)
 		sw_ring = rx_queue->sw_ring;
 		if (sw_ring) {
 			for (i = 0; i < rx_queue->nb_desc; i++) {
-				if (sw_ring[i])
-					rte_pktmbuf_free(sw_ring[i]);
+				rte_pktmbuf_free(sw_ring[i]);
 			}
 			rte_free(sw_ring);
 		}
@@ -507,8 +506,7 @@ static void axgbe_tx_queue_release(struct axgbe_tx_queue *tx_queue)
 		sw_ring = tx_queue->sw_ring;
 		if (sw_ring) {
 			for (i = 0; i < tx_queue->nb_desc; i++) {
-				if (sw_ring[i])
-					rte_pktmbuf_free(sw_ring[i]);
+				rte_pktmbuf_free(sw_ring[i]);
 			}
 			rte_free(sw_ring);
 		}
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 40/82] net/bnx2x: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (38 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 39/82] net/axgbe: " Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24  0:04 ` [PATCH 41/82] net/bnxt: " Stephen Hemminger
                   ` (43 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Rasesh Mody, Shahed Shaikh

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/bnx2x/bnx2x_rxtx.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/bnx2x/bnx2x_rxtx.c b/drivers/net/bnx2x/bnx2x_rxtx.c
index 66b0512c8695..00ddccf151fd 100644
--- a/drivers/net/bnx2x/bnx2x_rxtx.c
+++ b/drivers/net/bnx2x/bnx2x_rxtx.c
@@ -27,8 +27,7 @@ bnx2x_rx_queue_release(struct bnx2x_rx_queue *rx_queue)
 		sw_ring = rx_queue->sw_ring;
 		if (NULL != sw_ring) {
 			for (i = 0; i < rx_queue->nb_rx_desc; i++) {
-				if (NULL != sw_ring[i])
-					rte_pktmbuf_free(sw_ring[i]);
+				rte_pktmbuf_free(sw_ring[i]);
 			}
 			rte_free(sw_ring);
 		}
@@ -172,8 +171,7 @@ bnx2x_tx_queue_release(struct bnx2x_tx_queue *tx_queue)
 		sw_ring = tx_queue->sw_ring;
 		if (NULL != sw_ring) {
 			for (i = 0; i < tx_queue->nb_tx_desc; i++) {
-				if (NULL != sw_ring[i])
-					rte_pktmbuf_free(sw_ring[i]);
+				rte_pktmbuf_free(sw_ring[i]);
 			}
 			rte_free(sw_ring);
 		}
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 41/82] net/bnxt: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (39 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 40/82] net/bnx2x: " Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24  0:04 ` [PATCH 42/82] net/bonding: " Stephen Hemminger
                   ` (42 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Ajit Khaparde, Somnath Kotur

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/bnxt/bnxt_ethdev.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index f79f33ab4e17..78339d43674d 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -5833,8 +5833,7 @@ static void bnxt_free_ctx_mem_buf(struct bnxt_ctx_mem_buf_info *ctx)
 	if (!ctx)
 		return;
 
-	if (ctx->va)
-		rte_free(ctx->va);
+	rte_free(ctx->va);
 
 	ctx->va = NULL;
 	ctx->dma = RTE_BAD_IOVA;
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 42/82] net/bonding: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (40 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 41/82] net/bnxt: " Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24  0:04 ` [PATCH 43/82] net/cnxk: " Stephen Hemminger
                   ` (41 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Chas Williams, Min Hu (Connor)

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/bonding/rte_eth_bond_pmd.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index 84f4900ee52c..963280828a65 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -2148,8 +2148,7 @@ bond_ethdev_close(struct rte_eth_dev *dev)
 	 */
 	rte_mempool_free(internals->mode6.mempool);
 
-	if (internals->kvlist != NULL)
-		rte_kvargs_free(internals->kvlist);
+	rte_kvargs_free(internals->kvlist);
 
 	return 0;
 }
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 43/82] net/cnxk: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (41 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 42/82] net/bonding: " Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24  0:04 ` [PATCH 44/82] net/cxgbe: " Stephen Hemminger
                   ` (40 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Nithin Dabilpuram, Kiran Kumar K,
	Sunil Kumar Kori, Satha Rao

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/cnxk/cnxk_ethdev.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/cnxk/cnxk_ethdev.c b/drivers/net/cnxk/cnxk_ethdev.c
index 74f625553df4..d679a1f78501 100644
--- a/drivers/net/cnxk/cnxk_ethdev.c
+++ b/drivers/net/cnxk/cnxk_ethdev.c
@@ -934,10 +934,8 @@ nix_restore_queue_cfg(struct rte_eth_dev *eth_dev)
 	for (i = 0; i < eth_dev->data->nb_tx_queues; i++)
 		dev_ops->tx_queue_release(eth_dev, i);
 fail:
-	if (tx_qconf)
-		free(tx_qconf);
-	if (rx_qconf)
-		free(rx_qconf);
+	free(tx_qconf);
+	free(rx_qconf);
 
 	return rc;
 }
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 44/82] net/cxgbe: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (42 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 43/82] net/cnxk: " Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24  0:04 ` [PATCH 45/82] net/dpaa: " Stephen Hemminger
                   ` (39 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Rahul Lakkireddy

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/cxgbe/cxgbe_main.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/cxgbe/cxgbe_main.c b/drivers/net/cxgbe/cxgbe_main.c
index f1ac32270961..ab06e30a5e0f 100644
--- a/drivers/net/cxgbe/cxgbe_main.c
+++ b/drivers/net/cxgbe/cxgbe_main.c
@@ -463,8 +463,7 @@ void cxgbe_insert_tid(struct tid_info *t, void *data, unsigned int tid,
 static void tid_free(struct tid_info *t)
 {
 	if (t->tid_tab) {
-		if (t->ftid_bmap)
-			rte_bitmap_free(t->ftid_bmap);
+		rte_bitmap_free(t->ftid_bmap);
 
 		if (t->ftid_bmap_array)
 			t4_os_free(t->ftid_bmap_array);
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 45/82] net/dpaa: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (43 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 44/82] net/cxgbe: " Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24  5:01   ` Hemant Agrawal
  2022-01-24  0:04 ` [PATCH 46/82] net/dpaa2: " Stephen Hemminger
                   ` (38 subsequent siblings)
  83 siblings, 1 reply; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Hemant Agrawal, Sachin Saxena

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/dpaa/dpaa_ethdev.c  | 3 +--
 drivers/net/dpaa/fmlib/fm_lib.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index 2c2c4e4ebb5d..90208a31de26 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -463,8 +463,7 @@ static int dpaa_eth_dev_close(struct rte_eth_dev *dev)
 	}
 
 	/* release configuration memory */
-	if (dpaa_intf->fc_conf)
-		rte_free(dpaa_intf->fc_conf);
+	rte_free(dpaa_intf->fc_conf);
 
 	/* Release RX congestion Groups */
 	if (dpaa_intf->cgr_rx) {
diff --git a/drivers/net/dpaa/fmlib/fm_lib.c b/drivers/net/dpaa/fmlib/fm_lib.c
index 0d1ca12378d8..1d6816050c2f 100644
--- a/drivers/net/dpaa/fmlib/fm_lib.c
+++ b/drivers/net/dpaa/fmlib/fm_lib.c
@@ -408,8 +408,7 @@ fm_port_close(t_handle h_fm_port)
 	_fml_dbg("Calling...\n");
 
 	close(p_dev->fd);
-	if (p_dev->h_user_priv)
-		free(p_dev->h_user_priv);
+	free(p_dev->h_user_priv);
 	free(p_dev);
 
 	_fml_dbg("Finishing.\n");
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 46/82] net/dpaa2: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (44 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 45/82] net/dpaa: " Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24  0:04 ` [PATCH 47/82] net/ena: " Stephen Hemminger
                   ` (37 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Hemant Agrawal, Sachin Saxena

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/dpaa2/dpaa2_ethdev.c | 3 +--
 drivers/net/dpaa2/dpaa2_mux.c    | 3 +--
 drivers/net/dpaa2/dpaa2_ptp.c    | 3 +--
 3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c
index 2b04f1416853..6b85b7740cfa 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.c
+++ b/drivers/net/dpaa2/dpaa2_ethdev.c
@@ -504,8 +504,7 @@ dpaa2_free_rx_tx_queues(struct rte_eth_dev *dev)
 		/* cleaning up queue storage */
 		for (i = 0; i < priv->nb_rx_queues; i++) {
 			dpaa2_q = (struct dpaa2_queue *)priv->rx_vq[i];
-			if (dpaa2_q->q_storage)
-				rte_free(dpaa2_q->q_storage);
+			rte_free(dpaa2_q->q_storage);
 		}
 		/* cleanup tx queue cscn */
 		for (i = 0; i < priv->nb_tx_queues; i++) {
diff --git a/drivers/net/dpaa2/dpaa2_mux.c b/drivers/net/dpaa2/dpaa2_mux.c
index cd2f7b8aa544..bd4596b89149 100644
--- a/drivers/net/dpaa2/dpaa2_mux.c
+++ b/drivers/net/dpaa2/dpaa2_mux.c
@@ -353,8 +353,7 @@ dpaa2_create_dpdmux_device(int vdev_fd __rte_unused,
 	return 0;
 
 init_err:
-	if (dpdmux_dev)
-		rte_free(dpdmux_dev);
+	rte_free(dpdmux_dev);
 
 	return -1;
 }
diff --git a/drivers/net/dpaa2/dpaa2_ptp.c b/drivers/net/dpaa2/dpaa2_ptp.c
index 8d79e392445a..5fcc36abe7b0 100644
--- a/drivers/net/dpaa2/dpaa2_ptp.c
+++ b/drivers/net/dpaa2/dpaa2_ptp.c
@@ -168,8 +168,7 @@ dpaa2_create_dprtc_device(int vdev_fd __rte_unused,
 	return 0;
 
 init_err:
-	if (dprtc_dev)
-		rte_free(dprtc_dev);
+	rte_free(dprtc_dev);
 
 	return -1;
 }
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 47/82] net/ena: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (45 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 46/82] net/dpaa2: " Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24  0:04 ` [PATCH 48/82] net/hinic: " Stephen Hemminger
                   ` (36 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Marcin Wojtas, Michal Krawczyk, Shai Brandes,
	Evgeny Schemeilin, Igor Chauskin

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/ena/ena_ethdev.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c
index dce26cfa48cf..db2b5ec8e77b 100644
--- a/drivers/net/ena/ena_ethdev.c
+++ b/drivers/net/ena/ena_ethdev.c
@@ -567,16 +567,13 @@ static void ena_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
 	struct ena_ring *ring = dev->data->rx_queues[qid];
 
 	/* Free ring resources */
-	if (ring->rx_buffer_info)
-		rte_free(ring->rx_buffer_info);
+	rte_free(ring->rx_buffer_info);
 	ring->rx_buffer_info = NULL;
 
-	if (ring->rx_refill_buffer)
-		rte_free(ring->rx_refill_buffer);
+	rte_free(ring->rx_refill_buffer);
 	ring->rx_refill_buffer = NULL;
 
-	if (ring->empty_rx_reqs)
-		rte_free(ring->empty_rx_reqs);
+	rte_free(ring->empty_rx_reqs);
 	ring->empty_rx_reqs = NULL;
 
 	ring->configured = 0;
@@ -590,14 +587,11 @@ static void ena_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
 	struct ena_ring *ring = dev->data->tx_queues[qid];
 
 	/* Free ring resources */
-	if (ring->push_buf_intermediate_buf)
-		rte_free(ring->push_buf_intermediate_buf);
+	rte_free(ring->push_buf_intermediate_buf);
 
-	if (ring->tx_buffer_info)
-		rte_free(ring->tx_buffer_info);
+	rte_free(ring->tx_buffer_info);
 
-	if (ring->empty_tx_reqs)
-		rte_free(ring->empty_tx_reqs);
+	rte_free(ring->empty_tx_reqs);
 
 	ring->empty_tx_reqs = NULL;
 	ring->tx_buffer_info = NULL;
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 48/82] net/hinic: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (46 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 47/82] net/ena: " Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24  0:04 ` [PATCH 49/82] net/hns3: " Stephen Hemminger
                   ` (35 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Ziyang Xuan, Xiaoyun Wang, Guoyang Zhou

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/hinic/hinic_pmd_ethdev.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/hinic/hinic_pmd_ethdev.c b/drivers/net/hinic/hinic_pmd_ethdev.c
index e8d9aaba84a6..35788f46eb4c 100644
--- a/drivers/net/hinic/hinic_pmd_ethdev.c
+++ b/drivers/net/hinic/hinic_pmd_ethdev.c
@@ -2662,8 +2662,7 @@ static int hinic_copy_mempool_init(struct hinic_nic_dev *nic_dev)
 
 static void hinic_copy_mempool_uninit(struct hinic_nic_dev *nic_dev)
 {
-	if (nic_dev->cpy_mpool != NULL)
-		rte_mempool_free(nic_dev->cpy_mpool);
+	rte_mempool_free(nic_dev->cpy_mpool);
 }
 
 static int hinic_init_sw_rxtxqs(struct hinic_nic_dev *nic_dev)
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 49/82] net/hns3: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (47 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 48/82] net/hinic: " Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24  0:04 ` [PATCH 50/82] net/i40e: " Stephen Hemminger
                   ` (34 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Min Hu (Connor), Yisen Zhuang, Lijun Ou

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/hns3/hns3_rxtx.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
index d240e36e6a86..8a428f88f48e 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -86,8 +86,7 @@ hns3_rx_queue_release(void *queue)
 		hns3_rx_queue_release_mbufs(rxq);
 		if (rxq->mz)
 			rte_memzone_free(rxq->mz);
-		if (rxq->sw_ring)
-			rte_free(rxq->sw_ring);
+		rte_free(rxq->sw_ring);
 		rte_free(rxq);
 	}
 }
@@ -100,10 +99,8 @@ hns3_tx_queue_release(void *queue)
 		hns3_tx_queue_release_mbufs(txq);
 		if (txq->mz)
 			rte_memzone_free(txq->mz);
-		if (txq->sw_ring)
-			rte_free(txq->sw_ring);
-		if (txq->free)
-			rte_free(txq->free);
+		rte_free(txq->sw_ring);
+		rte_free(txq->free);
 		rte_free(txq);
 	}
 }
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 50/82] net/i40e: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (48 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 49/82] net/hns3: " Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24  0:04 ` [PATCH 51/82] net/iavf: " Stephen Hemminger
                   ` (33 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Beilei Xing

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/i40e/i40e_ethdev.c | 27 +++++++++------------------
 drivers/net/i40e/i40e_rxtx.c   |  3 +--
 2 files changed, 10 insertions(+), 20 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(&ethertype_rule->ethertype_list))) {
 		TAILQ_REMOVE(&ethertype_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;
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 51/82] net/iavf: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (49 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 50/82] net/i40e: " Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24  0:04 ` [PATCH 52/82] net/ice: " Stephen Hemminger
                   ` (32 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Jingjing Wu, Beilei Xing

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/iavf/iavf_rxtx.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c
index 59623ac82094..dabe8cba7561 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;
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 52/82] net/ice: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (50 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 51/82] net/iavf: " Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24  0:04 ` [PATCH 53/82] net/igc: " Stephen Hemminger
                   ` (31 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Qiming Yang, Qi Zhang

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/ice/ice_fdir_filter.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ice/ice_fdir_filter.c b/drivers/net/ice/ice_fdir_filter.c
index 13a2ac42df87..3fce8e1e6253 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;
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 53/82] net/igc: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (51 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 52/82] net/ice: " Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24  0:49   ` Wang, Haiyue
  2022-01-24  0:04 ` [PATCH 54/82] net/ixgbe: " Stephen Hemminger
                   ` (30 subsequent siblings)
  83 siblings, 1 reply; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Haiyue Wang

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/igc/igc_flow.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/igc/igc_flow.c b/drivers/net/igc/igc_flow.c
index 66053060af5a..88978ee0e849 100644
--- a/drivers/net/igc/igc_flow.c
+++ b/drivers/net/igc/igc_flow.c
@@ -776,8 +776,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,
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 54/82] net/ixgbe: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (52 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 53/82] net/igc: " Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24  0:48   ` Wang, Haiyue
  2022-01-24  0:04 ` [PATCH 55/82] net/memif: " Stephen Hemminger
                   ` (29 subsequent siblings)
  83 siblings, 1 reply; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Haiyue Wang

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/ixgbe/ixgbe_ethdev.c | 10 +++-------
 drivers/net/ixgbe/ixgbe_rxtx.c   |  3 +--
 2 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index c8f0460440c0..840509ddd460 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_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.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 55/82] net/memif: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (53 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 54/82] net/ixgbe: " Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24  0:04 ` [PATCH 56/82] net/mlx4: " Stephen Hemminger
                   ` (28 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Jakub Grajciar

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/memif/rte_eth_memif.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/memif/rte_eth_memif.c b/drivers/net/memif/rte_eth_memif.c
index 59cb5a82a23f..5c2203f5270b 100644
--- a/drivers/net/memif/rte_eth_memif.c
+++ b/drivers/net/memif/rte_eth_memif.c
@@ -1731,8 +1731,7 @@ memif_check_socket_filename(const char *filename)
 		ret = -EINVAL;
 	}
 
-	if (dir != NULL)
-		rte_free(dir);
+	rte_free(dir);
 
 	return ret;
 }
@@ -1903,8 +1902,7 @@ rte_pmd_memif_probe(struct rte_vdev_device *vdev)
 			   log2_ring_size, pkt_buffer_size, secret, ether_addr);
 
 exit:
-	if (kvlist != NULL)
-		rte_kvargs_free(kvlist);
+	rte_kvargs_free(kvlist);
 	return ret;
 }
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 56/82] net/mlx4: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (54 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 55/82] net/memif: " Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24  0:04 ` [PATCH 57/82] net/mlx5: " Stephen Hemminger
                   ` (27 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Matan Azrad, Viacheslav Ovsiienko

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/mlx4/mlx4_mr.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/mlx4/mlx4_mr.c b/drivers/net/mlx4/mlx4_mr.c
index 2274b5df1950..e95f45aa3e95 100644
--- a/drivers/net/mlx4/mlx4_mr.c
+++ b/drivers/net/mlx4/mlx4_mr.c
@@ -471,8 +471,7 @@ mr_free(struct mlx4_mr *mr)
 	DEBUG("freeing MR(%p):", (void *)mr);
 	if (mr->ibv_mr != NULL)
 		claim_zero(mlx4_glue->dereg_mr(mr->ibv_mr));
-	if (mr->ms_bmp != NULL)
-		rte_bitmap_free(mr->ms_bmp);
+	rte_bitmap_free(mr->ms_bmp);
 	rte_free(mr);
 }
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 57/82] net/mlx5: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (55 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 56/82] net/mlx4: " Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24  0:04 ` [PATCH 58/82] net/mvpp2: " Stephen Hemminger
                   ` (26 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Matan Azrad, Viacheslav Ovsiienko

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/mlx5/mlx5_flow.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index b7cf4143d5a1..c718dbdb3dc7 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -6990,8 +6990,7 @@ flow_alloc_thread_workspace(void)
 	data->rssq_num = MLX5_RSSQ_DEFAULT_NUM;
 	return data;
 err:
-	if (data->rss_desc.queue)
-		free(data->rss_desc.queue);
+	free(data->rss_desc.queue);
 	free(data);
 	return NULL;
 }
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 58/82] net/mvpp2: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (56 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 57/82] net/mlx5: " Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24  7:44   ` [EXT] " Liron Himi
  2022-01-24  0:04 ` [PATCH 59/82] net/netvsc: " Stephen Hemminger
                   ` (25 subsequent siblings)
  83 siblings, 1 reply; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Liron Himi

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/mvpp2/mrvl_qos.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/mvpp2/mrvl_qos.c b/drivers/net/mvpp2/mrvl_qos.c
index 99f0ee56d1a7..f43217bc589c 100644
--- a/drivers/net/mvpp2/mrvl_qos.c
+++ b/drivers/net/mvpp2/mrvl_qos.c
@@ -945,8 +945,7 @@ setup_tc(struct pp2_ppio_tc_params *param, uint8_t inqs,
 	param->num_in_qs = inqs;
 
 	/* Release old config if necessary. */
-	if (param->inqs_params)
-		rte_free(param->inqs_params);
+	rte_free(param->inqs_params);
 
 	param->inqs_params = inq_params;
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 59/82] net/netvsc: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (57 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 58/82] net/mvpp2: " Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24 20:09   ` Long Li
  2022-01-24  0:04 ` [PATCH 60/82] net/null: " Stephen Hemminger
                   ` (24 subsequent siblings)
  83 siblings, 1 reply; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Stephen Hemminger, Long Li

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/netvsc/hn_rxtx.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/netvsc/hn_rxtx.c b/drivers/net/netvsc/hn_rxtx.c
index 50ca1710ef3e..3e3488f1b87a 100644
--- a/drivers/net/netvsc/hn_rxtx.c
+++ b/drivers/net/netvsc/hn_rxtx.c
@@ -315,8 +315,7 @@ hn_dev_tx_queue_setup(struct rte_eth_dev *dev,
 	}
 
 error:
-	if (txq->txdesc_pool)
-		rte_mempool_free(txq->txdesc_pool);
+	rte_mempool_free(txq->txdesc_pool);
 	rte_memzone_free(txq->tx_rndis_mz);
 	rte_free(txq);
 	return err;
@@ -365,8 +364,7 @@ hn_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
 	if (!txq)
 		return;
 
-	if (txq->txdesc_pool)
-		rte_mempool_free(txq->txdesc_pool);
+	rte_mempool_free(txq->txdesc_pool);
 
 	rte_memzone_free(txq->tx_rndis_mz);
 	rte_free(txq);
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 60/82] net/null: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (58 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 59/82] net/netvsc: " Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24  0:04 ` [PATCH 61/82] net/octeontx: " Stephen Hemminger
                   ` (23 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Tetsuya Mukawa

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/null/rte_eth_null.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c
index ca03469d0e6d..bb89c1abc4a2 100644
--- a/drivers/net/null/rte_eth_null.c
+++ b/drivers/net/null/rte_eth_null.c
@@ -717,8 +717,7 @@ rte_pmd_null_probe(struct rte_vdev_device *dev)
 	ret = eth_dev_null_create(dev, &args);
 
 free_kvlist:
-	if (kvlist)
-		rte_kvargs_free(kvlist);
+	rte_kvargs_free(kvlist);
 	return ret;
 }
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 61/82] net/octeontx: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (59 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 60/82] net/null: " Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24  0:04 ` [PATCH 62/82] net/qede: " Stephen Hemminger
                   ` (22 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Harman Kalra

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/octeontx/octeontx_ethdev.c     | 3 +--
 drivers/net/octeontx/octeontx_ethdev_ops.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/octeontx/octeontx_ethdev.c b/drivers/net/octeontx/octeontx_ethdev.c
index b47472ebbd93..f5ea9de8efe5 100644
--- a/drivers/net/octeontx/octeontx_ethdev.c
+++ b/drivers/net/octeontx/octeontx_ethdev.c
@@ -1037,8 +1037,7 @@ octeontx_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t qidx,
 	return res;
 
 err:
-	if (txq)
-		rte_free(txq);
+	rte_free(txq);
 
 	return res;
 }
diff --git a/drivers/net/octeontx/octeontx_ethdev_ops.c b/drivers/net/octeontx/octeontx_ethdev_ops.c
index 6ec2b71b0672..0b22e28a5625 100644
--- a/drivers/net/octeontx/octeontx_ethdev_ops.c
+++ b/drivers/net/octeontx/octeontx_ethdev_ops.c
@@ -108,8 +108,7 @@ octeontx_dev_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
 	if (rc != 0) {
 		octeontx_log_err("Fail to configure vlan filter entry "
 				 "for port %d", nic->port_id);
-		if (entry)
-			rte_free(entry);
+		rte_free(entry);
 
 		goto done;
 	}
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 62/82] net/qede: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (60 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 61/82] net/octeontx: " Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24  0:04 ` [PATCH 63/82] net/softnic: " Stephen Hemminger
                   ` (21 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Rasesh Mody, Devendra Singh Rawat

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/qede/qede_main.c | 3 +--
 drivers/net/qede/qede_rxtx.c | 6 ++----
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/net/qede/qede_main.c b/drivers/net/qede/qede_main.c
index 2d1f70693a3d..ad101194d613 100644
--- a/drivers/net/qede/qede_main.c
+++ b/drivers/net/qede/qede_main.c
@@ -335,8 +335,7 @@ static int qed_slowpath_start(struct ecore_dev *edev,
 err:
 #ifdef CONFIG_ECORE_BINARY_FW
 	if (IS_PF(edev)) {
-		if (edev->firmware)
-			rte_free(edev->firmware);
+		rte_free(edev->firmware);
 		edev->firmware = NULL;
 	}
 #endif
diff --git a/drivers/net/qede/qede_rxtx.c b/drivers/net/qede/qede_rxtx.c
index 7088c57b501d..1c0a6ba5f1bf 100644
--- a/drivers/net/qede/qede_rxtx.c
+++ b/drivers/net/qede/qede_rxtx.c
@@ -706,12 +706,10 @@ void qede_dealloc_fp_resc(struct rte_eth_dev *eth_dev)
 		}
 	}
 
-	if (qdev->fp_array)
-		rte_free(qdev->fp_array);
+	rte_free(qdev->fp_array);
 	qdev->fp_array = NULL;
 
-	if (qdev->fp_array_cmt)
-		rte_free(qdev->fp_array_cmt);
+	rte_free(qdev->fp_array_cmt);
 	qdev->fp_array_cmt = NULL;
 }
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 63/82] net/softnic: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (61 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 62/82] net/qede: " Stephen Hemminger
@ 2022-01-24  0:04 ` Stephen Hemminger
  2022-01-24 10:17   ` Dumitrescu, Cristian
  2022-01-24  0:05 ` [PATCH 64/82] net/tap: " Stephen Hemminger
                   ` (20 subsequent siblings)
  83 siblings, 1 reply; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Jasvinder Singh, Cristian Dumitrescu

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/softnic/rte_eth_softnic_cli.c       | 12 ++++--------
 drivers/net/softnic/rte_eth_softnic_cryptodev.c |  6 ++----
 drivers/net/softnic/rte_eth_softnic_thread.c    |  6 ++----
 3 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/drivers/net/softnic/rte_eth_softnic_cli.c b/drivers/net/softnic/rte_eth_softnic_cli.c
index b04e78c6e0af..7acbeecae7a2 100644
--- a/drivers/net/softnic/rte_eth_softnic_cli.c
+++ b/drivers/net/softnic/rte_eth_softnic_cli.c
@@ -4482,10 +4482,8 @@ parse_free_sym_crypto_param_data(struct rte_table_action_sym_crypto_params *p)
 
 		switch (xform[i]->type) {
 		case RTE_CRYPTO_SYM_XFORM_CIPHER:
-			if (p->cipher_auth.cipher_iv.val)
-				free(p->cipher_auth.cipher_iv.val);
-			if (p->cipher_auth.cipher_iv_update.val)
-				free(p->cipher_auth.cipher_iv_update.val);
+			free(p->cipher_auth.cipher_iv.val);
+			free(p->cipher_auth.cipher_iv_update.val);
 			break;
 		case RTE_CRYPTO_SYM_XFORM_AUTH:
 			if (p->cipher_auth.auth_iv.val)
@@ -4494,10 +4492,8 @@ parse_free_sym_crypto_param_data(struct rte_table_action_sym_crypto_params *p)
 				free(p->cipher_auth.cipher_iv_update.val);
 			break;
 		case RTE_CRYPTO_SYM_XFORM_AEAD:
-			if (p->aead.iv.val)
-				free(p->aead.iv.val);
-			if (p->aead.aad.val)
-				free(p->aead.aad.val);
+			free(p->aead.iv.val);
+			free(p->aead.aad.val);
 			break;
 		default:
 			continue;
diff --git a/drivers/net/softnic/rte_eth_softnic_cryptodev.c b/drivers/net/softnic/rte_eth_softnic_cryptodev.c
index 9a7d006f1a09..e4754055e90b 100644
--- a/drivers/net/softnic/rte_eth_softnic_cryptodev.c
+++ b/drivers/net/softnic/rte_eth_softnic_cryptodev.c
@@ -159,10 +159,8 @@ softnic_cryptodev_create(struct pmd_internals *p,
 	return cryptodev;
 
 error_exit:
-	if (cryptodev->mp_create)
-		rte_mempool_free(cryptodev->mp_create);
-	if (cryptodev->mp_init)
-		rte_mempool_free(cryptodev->mp_init);
+	rte_mempool_free(cryptodev->mp_create);
+	rte_mempool_free(cryptodev->mp_init);
 
 	free(cryptodev);
 
diff --git a/drivers/net/softnic/rte_eth_softnic_thread.c b/drivers/net/softnic/rte_eth_softnic_thread.c
index a8c26a5b2377..1b3b3c33c175 100644
--- a/drivers/net/softnic/rte_eth_softnic_thread.c
+++ b/drivers/net/softnic/rte_eth_softnic_thread.c
@@ -29,11 +29,9 @@ softnic_thread_free(struct pmd_internals *softnic)
 		struct softnic_thread *t = &softnic->thread[i];
 
 		/* MSGQs */
-		if (t->msgq_req)
-			rte_ring_free(t->msgq_req);
+		rte_ring_free(t->msgq_req);
 
-		if (t->msgq_rsp)
-			rte_ring_free(t->msgq_rsp);
+		rte_ring_free(t->msgq_rsp);
 	}
 }
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 64/82] net/tap: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (62 preceding siblings ...)
  2022-01-24  0:04 ` [PATCH 63/82] net/softnic: " Stephen Hemminger
@ 2022-01-24  0:05 ` Stephen Hemminger
  2022-01-24  0:05 ` [PATCH 65/82] net/txgbe: " Stephen Hemminger
                   ` (19 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:05 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Keith Wiles

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/tap/tap_flow.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c
index 76738239458a..a9a55e439efc 100644
--- a/drivers/net/tap/tap_flow.c
+++ b/drivers/net/tap/tap_flow.c
@@ -1465,8 +1465,7 @@ tap_flow_create(struct rte_eth_dev *dev,
 	}
 	return flow;
 fail:
-	if (remote_flow)
-		rte_free(remote_flow);
+	rte_free(remote_flow);
 	if (flow)
 		tap_flow_free(pmd, flow);
 	return NULL;
@@ -1541,8 +1540,7 @@ tap_flow_destroy_pmd(struct pmd_internals *pmd,
 		}
 	}
 end:
-	if (remote_flow)
-		rte_free(remote_flow);
+	rte_free(remote_flow);
 	tap_flow_free(pmd, flow);
 	return ret;
 }
@@ -1764,8 +1762,7 @@ int tap_flow_implicit_create(struct pmd_internals *pmd,
 success:
 	return 0;
 fail:
-	if (remote_flow)
-		rte_free(remote_flow);
+	rte_free(remote_flow);
 	return -1;
 }
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 65/82] net/txgbe: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (63 preceding siblings ...)
  2022-01-24  0:05 ` [PATCH 64/82] net/tap: " Stephen Hemminger
@ 2022-01-24  0:05 ` Stephen Hemminger
  2022-01-24  0:05 ` [PATCH 66/82] net/vdev_netvsc: " Stephen Hemminger
                   ` (18 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:05 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Jiawen Wu, Jian Wang

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/txgbe/txgbe_ethdev.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/net/txgbe/txgbe_ethdev.c b/drivers/net/txgbe/txgbe_ethdev.c
index ac4d4e08f407..6024397072c8 100644
--- a/drivers/net/txgbe/txgbe_ethdev.c
+++ b/drivers/net/txgbe/txgbe_ethdev.c
@@ -821,10 +821,8 @@ static int txgbe_fdir_filter_uninit(struct rte_eth_dev *eth_dev)
 	struct txgbe_hw_fdir_info *fdir_info = TXGBE_DEV_FDIR(eth_dev);
 	struct txgbe_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,
@@ -841,10 +839,8 @@ static int txgbe_l2_tn_filter_uninit(struct rte_eth_dev *eth_dev)
 	struct txgbe_l2_tn_info *l2_tn_info = TXGBE_DEV_L2_TN(eth_dev);
 	struct txgbe_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,
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 66/82] net/vdev_netvsc: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (64 preceding siblings ...)
  2022-01-24  0:05 ` [PATCH 65/82] net/txgbe: " Stephen Hemminger
@ 2022-01-24  0:05 ` Stephen Hemminger
  2022-01-24  0:05 ` [PATCH 67/82] net/virtio: " Stephen Hemminger
                   ` (17 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:05 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Matan Azrad

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/vdev_netvsc/vdev_netvsc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/vdev_netvsc/vdev_netvsc.c b/drivers/net/vdev_netvsc/vdev_netvsc.c
index 55f2a342c5ae..25871951685c 100644
--- a/drivers/net/vdev_netvsc/vdev_netvsc.c
+++ b/drivers/net/vdev_netvsc/vdev_netvsc.c
@@ -717,8 +717,7 @@ vdev_netvsc_vdev_probe(struct rte_vdev_device *dev)
 error:
 	++vdev_netvsc_ctx_inst;
 ignore:
-	if (kvargs)
-		rte_kvargs_free(kvargs);
+	rte_kvargs_free(kvargs);
 	/* Reset alarm if there are device context created */
 	if (vdev_netvsc_ctx_count) {
 		ret = rte_eal_alarm_set(VDEV_NETVSC_PROBE_MS * 1000,
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 67/82] net/virtio: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (65 preceding siblings ...)
  2022-01-24  0:05 ` [PATCH 66/82] net/vdev_netvsc: " Stephen Hemminger
@ 2022-01-24  0:05 ` Stephen Hemminger
  2022-01-24  0:05 ` [PATCH 68/82] raw/cnxk_bphy: " Stephen Hemminger
                   ` (16 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:05 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Maxime Coquelin, Chenbo Xia

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/virtio/virtio_user_ethdev.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c
index 0271098f0da0..f6288fd0c492 100644
--- a/drivers/net/virtio/virtio_user_ethdev.c
+++ b/drivers/net/virtio/virtio_user_ethdev.c
@@ -688,14 +688,10 @@ virtio_user_pmd_probe(struct rte_vdev_device *vdev)
 	ret = 0;
 
 end:
-	if (kvlist)
-		rte_kvargs_free(kvlist);
-	if (path)
-		free(path);
-	if (mac_addr)
-		free(mac_addr);
-	if (ifname)
-		free(ifname);
+	rte_kvargs_free(kvlist);
+	free(path);
+	free(mac_addr);
+	free(ifname);
 	return ret;
 }
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 68/82] raw/cnxk_bphy: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (66 preceding siblings ...)
  2022-01-24  0:05 ` [PATCH 67/82] net/virtio: " Stephen Hemminger
@ 2022-01-24  0:05 ` Stephen Hemminger
  2022-01-24  0:05 ` [PATCH 69/82] raw/dpaa2_qdma: " Stephen Hemminger
                   ` (15 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:05 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Jakub Palider, Tomasz Duszynski

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/raw/cnxk_bphy/cnxk_bphy_cgx.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/raw/cnxk_bphy/cnxk_bphy_cgx.c b/drivers/raw/cnxk_bphy/cnxk_bphy_cgx.c
index 0b694e1c03c3..169cbc785531 100644
--- a/drivers/raw/cnxk_bphy/cnxk_bphy_cgx.c
+++ b/drivers/raw/cnxk_bphy/cnxk_bphy_cgx.c
@@ -233,8 +233,7 @@ cnxk_bphy_cgx_fini_queues(struct cnxk_bphy_cgx *cgx)
 	unsigned int i;
 
 	for (i = 0; i < cgx->num_queues; i++) {
-		if (cgx->queues[i].rsp)
-			rte_free(cgx->queues[i].rsp);
+		rte_free(cgx->queues[i].rsp);
 	}
 
 	cgx->num_queues = 0;
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 69/82] raw/dpaa2_qdma: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (67 preceding siblings ...)
  2022-01-24  0:05 ` [PATCH 68/82] raw/cnxk_bphy: " Stephen Hemminger
@ 2022-01-24  0:05 ` Stephen Hemminger
  2022-01-24  0:05 ` [PATCH 70/82] raw/ifpga: " Stephen Hemminger
                   ` (14 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:05 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Nipun Gupta

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/raw/dpaa2_qdma/dpaa2_qdma.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/raw/dpaa2_qdma/dpaa2_qdma.c b/drivers/raw/dpaa2_qdma/dpaa2_qdma.c
index ebc2cd5d0ddc..b2260439a4ef 100644
--- a/drivers/raw/dpaa2_qdma/dpaa2_qdma.c
+++ b/drivers/raw/dpaa2_qdma/dpaa2_qdma.c
@@ -1115,11 +1115,9 @@ dpaa2_qdma_reset(struct rte_rawdev *rawdev)
 
 	/* Reset and free virtual queues */
 	for (i = 0; i < qdma_dev->max_vqs; i++) {
-		if (qdma_dev->vqs[i].status_ring)
-			rte_ring_free(qdma_dev->vqs[i].status_ring);
+		rte_ring_free(qdma_dev->vqs[i].status_ring);
 	}
-	if (qdma_dev->vqs)
-		rte_free(qdma_dev->vqs);
+	rte_free(qdma_dev->vqs);
 	qdma_dev->vqs = NULL;
 
 	/* Reset per core info */
@@ -1314,8 +1312,7 @@ dpaa2_qdma_queue_setup(struct rte_rawdev *rawdev,
 
 	if (qdma_dev->vqs[i].hw_queue == NULL) {
 		DPAA2_QDMA_ERR("No H/W queue available for VQ");
-		if (qdma_dev->vqs[i].status_ring)
-			rte_ring_free(qdma_dev->vqs[i].status_ring);
+		rte_ring_free(qdma_dev->vqs[i].status_ring);
 		qdma_dev->vqs[i].status_ring = NULL;
 		rte_spinlock_unlock(&qdma_dev->lock);
 		return -ENODEV;
@@ -1516,14 +1513,12 @@ dpaa2_qdma_queue_release(struct rte_rawdev *rawdev,
 	if (qdma_vq->exclusive_hw_queue)
 		free_hw_queue(qdma_vq->hw_queue);
 	else {
-		if (qdma_vq->status_ring)
-			rte_ring_free(qdma_vq->status_ring);
+		rte_ring_free(qdma_vq->status_ring);
 
 		put_hw_queue(qdma_vq->hw_queue);
 	}
 
-	if (qdma_vq->fle_pool)
-		rte_mempool_free(qdma_vq->fle_pool);
+	rte_mempool_free(qdma_vq->fle_pool);
 
 	memset(qdma_vq, 0, sizeof(struct qdma_virt_queue));
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 70/82] raw/ifpga: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (68 preceding siblings ...)
  2022-01-24  0:05 ` [PATCH 69/82] raw/dpaa2_qdma: " Stephen Hemminger
@ 2022-01-24  0:05 ` Stephen Hemminger
  2022-01-24  0:05 ` [PATCH 71/82] raw/skeleton: " Stephen Hemminger
                   ` (13 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:05 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Rosen Xu, Tianfei zhang

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/raw/ifpga/ifpga_rawdev.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/raw/ifpga/ifpga_rawdev.c b/drivers/raw/ifpga/ifpga_rawdev.c
index 0eae0c9477b6..c68e378dc3ce 100644
--- a/drivers/raw/ifpga/ifpga_rawdev.c
+++ b/drivers/raw/ifpga/ifpga_rawdev.c
@@ -836,8 +836,7 @@ rte_fpga_do_pr(struct rte_rawdev *rawdev, int port_id,
 	}
 
 free_buffer:
-	if (buf_to_free)
-		rte_free(buf_to_free);
+	rte_free(buf_to_free);
 close_fd:
 	close(file_fd);
 	file_fd = 0;
@@ -1739,10 +1738,8 @@ ifpga_cfg_probe(struct rte_vdev_device *dev)
 	ret = rte_eal_hotplug_add(RTE_STR(IFPGA_BUS_NAME),
 			dev_name, devargs->args);
 end:
-	if (kvlist)
-		rte_kvargs_free(kvlist);
-	if (name)
-		free(name);
+	rte_kvargs_free(kvlist);
+	free(name);
 
 	return ret;
 }
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 71/82] raw/skeleton: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (69 preceding siblings ...)
  2022-01-24  0:05 ` [PATCH 70/82] raw/ifpga: " Stephen Hemminger
@ 2022-01-24  0:05 ` Stephen Hemminger
  2022-01-24  5:00   ` Hemant Agrawal
  2022-01-24  0:05 ` [PATCH 72/82] regex/cn9k: " Stephen Hemminger
                   ` (12 subsequent siblings)
  83 siblings, 1 reply; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:05 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Nipun Gupta, Hemant Agrawal

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/raw/skeleton/skeleton_rawdev_test.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/raw/skeleton/skeleton_rawdev_test.c b/drivers/raw/skeleton/skeleton_rawdev_test.c
index 484468eeb460..693b24c415de 100644
--- a/drivers/raw/skeleton/skeleton_rawdev_test.c
+++ b/drivers/raw/skeleton/skeleton_rawdev_test.c
@@ -395,13 +395,11 @@ test_rawdev_enqdeq(void)
 	RTE_TEST_ASSERT_EQUAL((unsigned int)ret, count,
 			      "Unable to dequeue buffers");
 
-	if (deq_buffers)
-		free(deq_buffers);
+	free(deq_buffers);
 
 	return TEST_SUCCESS;
 cleanup:
-	if (buffers[0].buf_addr)
-		free(buffers[0].buf_addr);
+	free(buffers[0].buf_addr);
 
 	return TEST_FAILED;
 }
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 72/82] regex/cn9k: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (70 preceding siblings ...)
  2022-01-24  0:05 ` [PATCH 71/82] raw/skeleton: " Stephen Hemminger
@ 2022-01-24  0:05 ` Stephen Hemminger
  2022-01-24  7:44   ` [EXT] " Liron Himi
  2022-01-24  0:05 ` [PATCH 73/82] regex/mlx5: " Stephen Hemminger
                   ` (11 subsequent siblings)
  83 siblings, 1 reply; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:05 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Liron Himi

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/regex/cn9k/cn9k_regexdev.c          | 6 ++----
 drivers/regex/cn9k/cn9k_regexdev_compiler.c | 3 +--
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/regex/cn9k/cn9k_regexdev.c b/drivers/regex/cn9k/cn9k_regexdev.c
index 32d20c1be82b..56c862c5a76c 100644
--- a/drivers/regex/cn9k/cn9k_regexdev.c
+++ b/drivers/regex/cn9k/cn9k_regexdev.c
@@ -256,10 +256,8 @@ ree_dev_fini(struct rte_regexdev *dev)
 		cn9k_err("Could not detach queues");
 
 	/* TEMP : should be in lib */
-	if (data->queue_pairs)
-		rte_free(data->queue_pairs);
-	if (data->rules)
-		rte_free(data->rules);
+	rte_free(data->queue_pairs);
+	rte_free(data->rules);
 
 	roc_ree_dev_fini(vf);
 
diff --git a/drivers/regex/cn9k/cn9k_regexdev_compiler.c b/drivers/regex/cn9k/cn9k_regexdev_compiler.c
index 935b8a53b459..60f1c1b4c4d8 100644
--- a/drivers/regex/cn9k/cn9k_regexdev_compiler.c
+++ b/drivers/regex/cn9k/cn9k_regexdev_compiler.c
@@ -214,8 +214,7 @@ cn9k_ree_rule_db_compile_prog(struct rte_regexdev *dev)
 	rxp_free_structs(NULL, NULL, NULL, NULL, NULL, &rof, NULL, &rofi, NULL,
 			1);
 
-	if (rule_db)
-		rte_free(rule_db);
+	rte_free(rule_db);
 
 	return ret;
 }
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 73/82] regex/mlx5: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (71 preceding siblings ...)
  2022-01-24  0:05 ` [PATCH 72/82] regex/cn9k: " Stephen Hemminger
@ 2022-01-24  0:05 ` Stephen Hemminger
  2022-01-24  0:05 ` [PATCH 74/82] vdpa/ifc: " Stephen Hemminger
                   ` (10 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:05 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Ori Kam

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/regex/mlx5/mlx5_regex.c | 3 +--
 drivers/regex/mlx5/mlx5_rxp.c   | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/regex/mlx5/mlx5_regex.c b/drivers/regex/mlx5/mlx5_regex.c
index e5a12fb3cc4d..48e39f6b8844 100644
--- a/drivers/regex/mlx5/mlx5_regex.c
+++ b/drivers/regex/mlx5/mlx5_regex.c
@@ -127,8 +127,7 @@ mlx5_regex_dev_probe(struct mlx5_common_device *cdev)
 	if (priv->regexdev)
 		rte_regexdev_unregister(priv->regexdev);
 dev_error:
-	if (priv)
-		rte_free(priv);
+	rte_free(priv);
 	return -rte_errno;
 }
 
diff --git a/drivers/regex/mlx5/mlx5_rxp.c b/drivers/regex/mlx5/mlx5_rxp.c
index 5ead3ca341ad..99db1e4a865c 100644
--- a/drivers/regex/mlx5/mlx5_rxp.c
+++ b/drivers/regex/mlx5/mlx5_rxp.c
@@ -166,7 +166,6 @@ mlx5_regex_configure(struct rte_regexdev *dev,
 		DRV_LOG(DEBUG, "Regex config without rules programming!");
 	return 0;
 configure_error:
-	if (priv->qps)
-		rte_free(priv->qps);
+	rte_free(priv->qps);
 	return -rte_errno;
 }
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 74/82] vdpa/ifc: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (72 preceding siblings ...)
  2022-01-24  0:05 ` [PATCH 73/82] regex/mlx5: " Stephen Hemminger
@ 2022-01-24  0:05 ` Stephen Hemminger
  2022-01-24  0:05 ` [PATCH 75/82] vdpa/mlx5: " Stephen Hemminger
                   ` (9 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:05 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Xiao Wang

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/vdpa/ifc/ifcvf_vdpa.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c b/drivers/vdpa/ifc/ifcvf_vdpa.c
index 3853c4cf7e85..9f05595b6b34 100644
--- a/drivers/vdpa/ifc/ifcvf_vdpa.c
+++ b/drivers/vdpa/ifc/ifcvf_vdpa.c
@@ -226,8 +226,7 @@ ifcvf_dma_map(struct ifcvf_internal *internal, bool do_map)
 	}
 
 exit:
-	if (mem)
-		free(mem);
+	free(mem);
 	return ret;
 }
 
@@ -253,8 +252,7 @@ hva_to_gpa(int vid, uint64_t hva)
 	}
 
 exit:
-	if (mem)
-		free(mem);
+	free(mem);
 	return gpa;
 }
 
@@ -661,8 +659,7 @@ m_ifcvf_start(struct ifcvf_internal *internal)
 
 error:
 	for (i = 0; i < nr_vring; i++)
-		if (internal->m_vring[i].desc)
-			rte_free(internal->m_vring[i].desc);
+		rte_free(internal->m_vring[i].desc);
 
 	return -1;
 }
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 75/82] vdpa/mlx5: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (73 preceding siblings ...)
  2022-01-24  0:05 ` [PATCH 74/82] vdpa/ifc: " Stephen Hemminger
@ 2022-01-24  0:05 ` Stephen Hemminger
  2022-01-24  0:05 ` [PATCH 76/82] compressdev: " Stephen Hemminger
                   ` (8 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:05 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Matan Azrad, Viacheslav Ovsiienko

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/vdpa/mlx5/mlx5_vdpa_mem.c   | 3 +--
 drivers/vdpa/mlx5/mlx5_vdpa_virtq.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/vdpa/mlx5/mlx5_vdpa_mem.c b/drivers/vdpa/mlx5/mlx5_vdpa_mem.c
index 130d201a85f5..599079500b03 100644
--- a/drivers/vdpa/mlx5/mlx5_vdpa_mem.c
+++ b/drivers/vdpa/mlx5/mlx5_vdpa_mem.c
@@ -283,8 +283,7 @@ mlx5_vdpa_mem_register(struct mlx5_vdpa_priv *priv)
 	priv->gpa_mkey_index = entry->mkey->id;
 	return 0;
 error:
-	if (entry)
-		rte_free(entry);
+	rte_free(entry);
 	mlx5_vdpa_mem_dereg(priv);
 	rte_errno = -ret;
 	return ret;
diff --git a/drivers/vdpa/mlx5/mlx5_vdpa_virtq.c b/drivers/vdpa/mlx5/mlx5_vdpa_virtq.c
index 2f32aef67fbc..3416797d289c 100644
--- a/drivers/vdpa/mlx5/mlx5_vdpa_virtq.c
+++ b/drivers/vdpa/mlx5/mlx5_vdpa_virtq.c
@@ -91,8 +91,7 @@ mlx5_vdpa_virtq_unset(struct mlx5_vdpa_virtq *virtq)
 		if (virtq->umems[i].obj)
 			claim_zero(mlx5_glue->devx_umem_dereg
 							 (virtq->umems[i].obj));
-		if (virtq->umems[i].buf)
-			rte_free(virtq->umems[i].buf);
+		rte_free(virtq->umems[i].buf);
 	}
 	memset(&virtq->umems, 0, sizeof(virtq->umems));
 	if (virtq->eqp.fw_qp)
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 76/82] compressdev: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (74 preceding siblings ...)
  2022-01-24  0:05 ` [PATCH 75/82] vdpa/mlx5: " Stephen Hemminger
@ 2022-01-24  0:05 ` Stephen Hemminger
  2022-01-24  0:05 ` [PATCH 77/82] ethdev: " Stephen Hemminger
                   ` (7 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:05 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Fan Zhang, Ashish Gupta

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/compressdev/rte_compressdev.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/compressdev/rte_compressdev.c b/lib/compressdev/rte_compressdev.c
index 2e9218af68f6..d4f7d4d3daf2 100644
--- a/lib/compressdev/rte_compressdev.c
+++ b/lib/compressdev/rte_compressdev.c
@@ -405,8 +405,7 @@ rte_compressdev_queue_pairs_release(struct rte_compressdev *dev)
 			return ret;
 	}
 
-	if (dev->data->queue_pairs != NULL)
-		rte_free(dev->data->queue_pairs);
+	rte_free(dev->data->queue_pairs);
 	dev->data->queue_pairs = NULL;
 	dev->data->nb_queue_pairs = 0;
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 77/82] ethdev: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (75 preceding siblings ...)
  2022-01-24  0:05 ` [PATCH 76/82] compressdev: " Stephen Hemminger
@ 2022-01-24  0:05 ` Stephen Hemminger
  2022-01-24  0:05 ` [PATCH 78/82] graph: " Stephen Hemminger
                   ` (6 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:05 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Thomas Monjalon, Ferruh Yigit, Andrew Rybchenko

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/ethdev/rte_ethdev.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index a1d475a29295..98312fa157f6 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -6036,8 +6036,7 @@ rte_eth_devargs_parse(const char *dargs, struct rte_eth_devargs *eth_da)
 	}
 
 parse_cleanup:
-	if (args.str)
-		free(args.str);
+	free(args.str);
 
 	return result;
 }
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 78/82] graph: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (76 preceding siblings ...)
  2022-01-24  0:05 ` [PATCH 77/82] ethdev: " Stephen Hemminger
@ 2022-01-24  0:05 ` Stephen Hemminger
  2022-01-24  0:05 ` [PATCH 79/82] ipsec: " Stephen Hemminger
                   ` (5 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:05 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Jerin Jacob, Kiran Kumar K, Nithin Dabilpuram

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/graph/graph_stats.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/graph/graph_stats.c b/lib/graph/graph_stats.c
index aa70929dc32e..65e12d46a313 100644
--- a/lib/graph/graph_stats.c
+++ b/lib/graph/graph_stats.c
@@ -233,8 +233,7 @@ cluster_add(struct cluster *cluster, struct graph *graph)
 static void
 cluster_fini(struct cluster *cluster)
 {
-	if (cluster->graphs)
-		free(cluster->graphs);
+	free(cluster->graphs);
 }
 
 static int
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 79/82] ipsec: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (77 preceding siblings ...)
  2022-01-24  0:05 ` [PATCH 78/82] graph: " Stephen Hemminger
@ 2022-01-24  0:05 ` Stephen Hemminger
  2022-01-24  0:05 ` [PATCH 80/82] port: " Stephen Hemminger
                   ` (4 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:05 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Konstantin Ananyev, Bernard Iremonger,
	Vladimir Medvedkin

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/ipsec/ipsec_sad.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/ipsec/ipsec_sad.c b/lib/ipsec/ipsec_sad.c
index 531e1e323cdc..af4b1ce757d2 100644
--- a/lib/ipsec/ipsec_sad.c
+++ b/lib/ipsec/ipsec_sad.c
@@ -440,8 +440,7 @@ rte_ipsec_sad_destroy(struct rte_ipsec_sad *sad)
 	rte_hash_free(sad->hash[RTE_IPSEC_SAD_SPI_DIP]);
 	rte_hash_free(sad->hash[RTE_IPSEC_SAD_SPI_DIP_SIP]);
 	rte_free(sad);
-	if (te != NULL)
-		rte_free(te);
+	rte_free(te);
 }
 
 /*
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 80/82] port: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (78 preceding siblings ...)
  2022-01-24  0:05 ` [PATCH 79/82] ipsec: " Stephen Hemminger
@ 2022-01-24  0:05 ` Stephen Hemminger
  2022-01-24  0:05 ` [PATCH 81/82] power: " Stephen Hemminger
                   ` (3 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:05 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Cristian Dumitrescu

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/port/rte_port_source_sink.c | 21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)

diff --git a/lib/port/rte_port_source_sink.c b/lib/port/rte_port_source_sink.c
index 68575c98338d..79042d13ff66 100644
--- a/lib/port/rte_port_source_sink.c
+++ b/lib/port/rte_port_source_sink.c
@@ -163,14 +163,10 @@ pcap_source_load(struct rte_port_source *port,
 	return 0;
 
 error_exit:
-	if (pkt_len_aligns)
-		rte_free(pkt_len_aligns);
-	if (port->pkt_len)
-		rte_free(port->pkt_len);
-	if (port->pkts)
-		rte_free(port->pkts);
-	if (port->pkt_buff)
-		rte_free(port->pkt_buff);
+	rte_free(pkt_len_aligns);
+	rte_free(port->pkt_len);
+	rte_free(port->pkts);
+	rte_free(port->pkt_buff);
 
 	return -1;
 }
@@ -242,12 +238,9 @@ rte_port_source_free(void *port)
 	if (p == NULL)
 		return 0;
 
-	if (p->pkt_len)
-		rte_free(p->pkt_len);
-	if (p->pkts)
-		rte_free(p->pkts);
-	if (p->pkt_buff)
-		rte_free(p->pkt_buff);
+	rte_free(p->pkt_len);
+	rte_free(p->pkts);
+	rte_free(p->pkt_buff);
 
 	rte_free(p);
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 81/82] power: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (79 preceding siblings ...)
  2022-01-24  0:05 ` [PATCH 80/82] port: " Stephen Hemminger
@ 2022-01-24  0:05 ` Stephen Hemminger
  2022-01-24  0:05 ` [PATCH 82/82] reorder: " Stephen Hemminger
                   ` (2 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:05 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, David Hunt

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/power/rte_power_empty_poll.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/power/rte_power_empty_poll.c b/lib/power/rte_power_empty_poll.c
index c4b5de9601cf..2261ce7820f6 100644
--- a/lib/power/rte_power_empty_poll.c
+++ b/lib/power/rte_power_empty_poll.c
@@ -457,8 +457,7 @@ rte_power_empty_poll_stat_free(void)
 
 	RTE_LOG(INFO, POWER, "Close the Empty Poll\n");
 
-	if (ep_params != NULL)
-		rte_free(ep_params);
+	rte_free(ep_params);
 }
 
 int
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH 82/82] reorder: remove unnecessary NULL checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (80 preceding siblings ...)
  2022-01-24  0:05 ` [PATCH 81/82] power: " Stephen Hemminger
@ 2022-01-24  0:05 ` Stephen Hemminger
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
  2022-02-09 19:17 ` [PATCH v3 00/36] " Stephen Hemminger
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24  0:05 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Reshma Pattan

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/reorder/rte_reorder.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/lib/reorder/rte_reorder.c b/lib/reorder/rte_reorder.c
index 9445853b79cc..bc0241bfb3fd 100644
--- a/lib/reorder/rte_reorder.c
+++ b/lib/reorder/rte_reorder.c
@@ -192,10 +192,8 @@ rte_reorder_free_mbufs(struct rte_reorder_buffer *b)
 
 	/* Free up the mbufs of order buffer & ready buffer */
 	for (i = 0; i < b->order_buf.size; i++) {
-		if (b->order_buf.entries[i])
-			rte_pktmbuf_free(b->order_buf.entries[i]);
-		if (b->ready_buf.entries[i])
-			rte_pktmbuf_free(b->ready_buf.entries[i]);
+		rte_pktmbuf_free(b->order_buf.entries[i]);
+		rte_pktmbuf_free(b->ready_buf.entries[i]);
 	}
 }
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* RE: [PATCH 54/82] net/ixgbe: remove unnecessary NULL checks
  2022-01-24  0:04 ` [PATCH 54/82] net/ixgbe: " Stephen Hemminger
@ 2022-01-24  0:48   ` Wang, Haiyue
  0 siblings, 0 replies; 247+ messages in thread
From: Wang, Haiyue @ 2022-01-24  0:48 UTC (permalink / raw)
  To: Stephen Hemminger, dev

> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Monday, January 24, 2022 08:05
> To: dev@dpdk.org
> Cc: Stephen Hemminger <stephen@networkplumber.org>; Wang, Haiyue <haiyue.wang@intel.com>
> Subject: [PATCH 54/82] net/ixgbe: remove unnecessary NULL checks
> 
> Remove redundant NULL pointer checks before free functions
> found by nullfree.cocci
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>  drivers/net/ixgbe/ixgbe_ethdev.c | 10 +++-------
>  drivers/net/ixgbe/ixgbe_rxtx.c   |  3 +--
>  2 files changed, 4 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
> index c8f0460440c0..840509ddd460 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);

This " rte_free(fdir_info->hash_map);" needs to be adjusted by removing one tab. ;-)

> -	if (fdir_info->hash_handle)
> -		rte_hash_free(fdir_info->hash_handle);
> +	rte_hash_free(fdir_info->hash_handle);
> 


> --
> 2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* RE: [PATCH 53/82] net/igc: remove unnecessary NULL checks
  2022-01-24  0:04 ` [PATCH 53/82] net/igc: " Stephen Hemminger
@ 2022-01-24  0:49   ` Wang, Haiyue
  0 siblings, 0 replies; 247+ messages in thread
From: Wang, Haiyue @ 2022-01-24  0:49 UTC (permalink / raw)
  To: Stephen Hemminger, dev

> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Monday, January 24, 2022 08:05
> To: dev@dpdk.org
> Cc: Stephen Hemminger <stephen@networkplumber.org>; Wang, Haiyue <haiyue.wang@intel.com>
> Subject: [PATCH 53/82] net/igc: remove unnecessary NULL checks
> 
> Remove redundant NULL pointer checks before free functions
> found by nullfree.cocci
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>  drivers/net/igc/igc_flow.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/net/igc/igc_flow.c b/drivers/net/igc/igc_flow.c
> index 66053060af5a..88978ee0e849 100644
> --- a/drivers/net/igc/igc_flow.c
> +++ b/drivers/net/igc/igc_flow.c
> @@ -776,8 +776,7 @@ igc_flow_create(struct rte_eth_dev *dev,
> 
>  	if (ret) {
>  		/* check and free the memory */

This comment line can be removed either, since 'check' is done by 'rte_free'
internally.

> -		if (flow)
> -			rte_free(flow);
> +		rte_free(flow);
> 
>  		rte_flow_error_set(error, -ret,
>  				RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
> --
> 2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* RE: [PATCH 28/82] crypto/armv8: remove unnecessary NULL checks
  2022-01-24  0:04 ` [PATCH 28/82] crypto/armv8: " Stephen Hemminger
@ 2022-01-24  4:15   ` Ruifeng Wang
  0 siblings, 0 replies; 247+ messages in thread
From: Ruifeng Wang @ 2022-01-24  4:15 UTC (permalink / raw)
  To: Stephen Hemminger, dev; +Cc: nd

> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Monday, January 24, 2022 8:04 AM
> To: dev@dpdk.org
> Cc: Stephen Hemminger <stephen@networkplumber.org>; Ruifeng Wang
> <Ruifeng.Wang@arm.com>
> Subject: [PATCH 28/82] crypto/armv8: remove unnecessary NULL checks
> 
> Remove redundant NULL pointer checks before free functions found by
> nullfree.cocci
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>  drivers/crypto/armv8/rte_armv8_pmd_ops.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 

Thanks.
Acked-by: Ruifeng Wang <ruifeng.wang@arm.com>

^ permalink raw reply	[flat|nested] 247+ messages in thread

* RE: [PATCH 71/82] raw/skeleton: remove unnecessary NULL checks
  2022-01-24  0:05 ` [PATCH 71/82] raw/skeleton: " Stephen Hemminger
@ 2022-01-24  5:00   ` Hemant Agrawal
  0 siblings, 0 replies; 247+ messages in thread
From: Hemant Agrawal @ 2022-01-24  5:00 UTC (permalink / raw)
  To: Stephen Hemminger, dev; +Cc: Nipun Gupta

Acked-by:  Hemant Agrawal <hemant.agrawal@nxp.com>

^ permalink raw reply	[flat|nested] 247+ messages in thread

* RE: [PATCH 45/82] net/dpaa: remove unnecessary NULL checks
  2022-01-24  0:04 ` [PATCH 45/82] net/dpaa: " Stephen Hemminger
@ 2022-01-24  5:01   ` Hemant Agrawal
  0 siblings, 0 replies; 247+ messages in thread
From: Hemant Agrawal @ 2022-01-24  5:01 UTC (permalink / raw)
  To: Stephen Hemminger, dev; +Cc: Sachin Saxena (OSS)

Acked-by:  Hemant Agrawal <hemant.agrawal@nxp.com>

^ permalink raw reply	[flat|nested] 247+ messages in thread

* RE: [PATCH 16/82] baseband/la12xx remove unnecessary NULL checks
  2022-01-24  0:04 ` [PATCH 16/82] baseband/la12xx " Stephen Hemminger
@ 2022-01-24  5:05   ` Hemant Agrawal
  0 siblings, 0 replies; 247+ messages in thread
From: Hemant Agrawal @ 2022-01-24  5:05 UTC (permalink / raw)
  To: Stephen Hemminger, dev; +Cc: Nipun Gupta, Nicolas Chautru

Acked-by:  Hemant Agrawal <hemant.agrawal@nxp.com>

^ permalink raw reply	[flat|nested] 247+ messages in thread

* RE: [PATCH 23/82] common/dpaax: simplify kernel compat macros
  2022-01-24  0:04 ` [PATCH 23/82] common/dpaax: simplify kernel compat macros Stephen Hemminger
@ 2022-01-24  5:06   ` Hemant Agrawal
  0 siblings, 0 replies; 247+ messages in thread
From: Hemant Agrawal @ 2022-01-24  5:06 UTC (permalink / raw)
  To: Stephen Hemminger, dev; +Cc: Sachin Saxena (OSS)

Acked-by:  Hemant Agrawal <hemant.agrawal@nxp.com>

^ permalink raw reply	[flat|nested] 247+ messages in thread

* RE: [PATCH 19/82] bus/fslmc: remove unnecessary NULL checks
  2022-01-24  0:04 ` [PATCH 19/82] bus/fslmc: " Stephen Hemminger
@ 2022-01-24  5:06   ` Hemant Agrawal
  0 siblings, 0 replies; 247+ messages in thread
From: Hemant Agrawal @ 2022-01-24  5:06 UTC (permalink / raw)
  To: Stephen Hemminger, dev; +Cc: Sachin Saxena (OSS)

Acked-by:  Hemant Agrawal <hemant.agrawal@nxp.com>

^ permalink raw reply	[flat|nested] 247+ messages in thread

* RE: [EXT] [PATCH 72/82] regex/cn9k: remove unnecessary NULL checks
  2022-01-24  0:05 ` [PATCH 72/82] regex/cn9k: " Stephen Hemminger
@ 2022-01-24  7:44   ` Liron Himi
  0 siblings, 0 replies; 247+ messages in thread
From: Liron Himi @ 2022-01-24  7:44 UTC (permalink / raw)
  To: Stephen Hemminger, dev; +Cc: Liron Himi

Reviewed-by: Liron Himi <lironh@marvell.com>


-----Original Message-----
From: Stephen Hemminger <stephen@networkplumber.org> 
Sent: Monday, 24 January 2022 02:05
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>; Liron Himi <lironh@marvell.com>
Subject: [EXT] [PATCH 72/82] regex/cn9k: remove unnecessary NULL checks

External Email

----------------------------------------------------------------------
Remove redundant NULL pointer checks before free functions found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/regex/cn9k/cn9k_regexdev.c          | 6 ++----
 drivers/regex/cn9k/cn9k_regexdev_compiler.c | 3 +--
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/regex/cn9k/cn9k_regexdev.c b/drivers/regex/cn9k/cn9k_regexdev.c
index 32d20c1be82b..56c862c5a76c 100644
--- a/drivers/regex/cn9k/cn9k_regexdev.c
+++ b/drivers/regex/cn9k/cn9k_regexdev.c
@@ -256,10 +256,8 @@ ree_dev_fini(struct rte_regexdev *dev)
 		cn9k_err("Could not detach queues");
 
 	/* TEMP : should be in lib */
-	if (data->queue_pairs)
-		rte_free(data->queue_pairs);
-	if (data->rules)
-		rte_free(data->rules);
+	rte_free(data->queue_pairs);
+	rte_free(data->rules);
 
 	roc_ree_dev_fini(vf);
 
diff --git a/drivers/regex/cn9k/cn9k_regexdev_compiler.c b/drivers/regex/cn9k/cn9k_regexdev_compiler.c
index 935b8a53b459..60f1c1b4c4d8 100644
--- a/drivers/regex/cn9k/cn9k_regexdev_compiler.c
+++ b/drivers/regex/cn9k/cn9k_regexdev_compiler.c
@@ -214,8 +214,7 @@ cn9k_ree_rule_db_compile_prog(struct rte_regexdev *dev)
 	rxp_free_structs(NULL, NULL, NULL, NULL, NULL, &rof, NULL, &rofi, NULL,
 			1);
 
-	if (rule_db)
-		rte_free(rule_db);
+	rte_free(rule_db);
 
 	return ret;
 }
--
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* RE: [EXT] [PATCH 58/82] net/mvpp2: remove unnecessary NULL checks
  2022-01-24  0:04 ` [PATCH 58/82] net/mvpp2: " Stephen Hemminger
@ 2022-01-24  7:44   ` Liron Himi
  0 siblings, 0 replies; 247+ messages in thread
From: Liron Himi @ 2022-01-24  7:44 UTC (permalink / raw)
  To: Stephen Hemminger, dev; +Cc: Liron Himi

Reviewed-by: Liron Himi <lironh@marvell.com>

-----Original Message-----
From: Stephen Hemminger <stephen@networkplumber.org> 
Sent: Monday, 24 January 2022 02:05
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>; Liron Himi <lironh@marvell.com>
Subject: [EXT] [PATCH 58/82] net/mvpp2: remove unnecessary NULL checks

External Email

----------------------------------------------------------------------
Remove redundant NULL pointer checks before free functions found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/mvpp2/mrvl_qos.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/mvpp2/mrvl_qos.c b/drivers/net/mvpp2/mrvl_qos.c index 99f0ee56d1a7..f43217bc589c 100644
--- a/drivers/net/mvpp2/mrvl_qos.c
+++ b/drivers/net/mvpp2/mrvl_qos.c
@@ -945,8 +945,7 @@ setup_tc(struct pp2_ppio_tc_params *param, uint8_t inqs,
 	param->num_in_qs = inqs;
 
 	/* Release old config if necessary. */
-	if (param->inqs_params)
-		rte_free(param->inqs_params);
+	rte_free(param->inqs_params);
 
 	param->inqs_params = inq_params;
 
--
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* RE: [EXT] [PATCH 32/82] crypto/mvsam: remove unnecessary NULL checks
  2022-01-24  0:04 ` [PATCH 32/82] crypto/mvsam: " Stephen Hemminger
@ 2022-01-24  7:44   ` Liron Himi
  0 siblings, 0 replies; 247+ messages in thread
From: Liron Himi @ 2022-01-24  7:44 UTC (permalink / raw)
  To: Stephen Hemminger, dev; +Cc: Michael Shamis, Liron Himi

Reviewed-by: Liron Himi <lironh@marvell.com>

-----Original Message-----
From: Stephen Hemminger <stephen@networkplumber.org> 
Sent: Monday, 24 January 2022 02:04
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>; Michael Shamis <michaelsh@marvell.com>; Liron Himi <lironh@marvell.com>
Subject: [EXT] [PATCH 32/82] crypto/mvsam: remove unnecessary NULL checks

External Email

----------------------------------------------------------------------
Remove redundant NULL pointer checks before free functions found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/crypto/mvsam/rte_mrvl_pmd_ops.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/crypto/mvsam/rte_mrvl_pmd_ops.c b/drivers/crypto/mvsam/rte_mrvl_pmd_ops.c
index 3064b1f136fe..f828dc9db5f6 100644
--- a/drivers/crypto/mvsam/rte_mrvl_pmd_ops.c
+++ b/drivers/crypto/mvsam/rte_mrvl_pmd_ops.c
@@ -774,10 +774,8 @@ mrvl_crypto_pmd_sym_session_configure(__rte_unused struct rte_cryptodev *dev,
 	}
 
 	/* free the keys memory allocated for session creation */
-	if (mrvl_sess->sam_sess_params.cipher_key != NULL)
-		free(mrvl_sess->sam_sess_params.cipher_key);
-	if (mrvl_sess->sam_sess_params.auth_key != NULL)
-		free(mrvl_sess->sam_sess_params.auth_key);
+	free(mrvl_sess->sam_sess_params.cipher_key);
+	free(mrvl_sess->sam_sess_params.auth_key);
 
 	return 0;
 }
--
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* RE: [PATCH 05/82] examples/ip_pipeline: remove unnecessary NULL checks
  2022-01-24  0:04 ` [PATCH 05/82] examples/ip_pipeline: " Stephen Hemminger
@ 2022-01-24 10:17   ` Dumitrescu, Cristian
  2022-01-24 17:23     ` Stephen Hemminger
  0 siblings, 1 reply; 247+ messages in thread
From: Dumitrescu, Cristian @ 2022-01-24 10:17 UTC (permalink / raw)
  To: Stephen Hemminger, dev



> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Monday, January 24, 2022 12:04 AM
> To: dev@dpdk.org
> Cc: Stephen Hemminger <stephen@networkplumber.org>; Dumitrescu,
> Cristian <cristian.dumitrescu@intel.com>
> Subject: [PATCH 05/82] examples/ip_pipeline: remove unnecessary NULL
> checks
> 
> Remove redundant NULL pointer checks before free functions
> found by nullfree.cocci
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>  examples/ip_pipeline/cli.c       | 12 ++++--------
>  examples/ip_pipeline/cryptodev.c |  6 ++----
>  examples/ip_pipeline/thread.c    |  6 ++----
>  3 files changed, 8 insertions(+), 16 deletions(-)
> 

Hi Stephen,

The rte_ring_free() and rte_mempool_free() do not state in their API description that freeing a NULL pointer is harmless. Before pushing these changes, please add the necessary note in the API header files for these functions.

In the absence of the clear note in their API description, the user is forced to check for the NULL pointer. I agree that the implementation of these functions does the right think and exits early when the input pointer is NULL, but there is no guarantee that the implementation is not going to change. Agree?

The stdlib free() and the rte_free() do have the clear API description note that freeing a NULL object is harmless, so removing the NULL check before their call is indeed safe.

This stands for all the patches in this set.

Regards,
Cristian

^ permalink raw reply	[flat|nested] 247+ messages in thread

* RE: [PATCH 63/82] net/softnic: remove unnecessary NULL checks
  2022-01-24  0:04 ` [PATCH 63/82] net/softnic: " Stephen Hemminger
@ 2022-01-24 10:17   ` Dumitrescu, Cristian
  0 siblings, 0 replies; 247+ messages in thread
From: Dumitrescu, Cristian @ 2022-01-24 10:17 UTC (permalink / raw)
  To: Stephen Hemminger, dev; +Cc: Singh, Jasvinder



> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Monday, January 24, 2022 12:05 AM
> To: dev@dpdk.org
> Cc: Stephen Hemminger <stephen@networkplumber.org>; Singh, Jasvinder
> <jasvinder.singh@intel.com>; Dumitrescu, Cristian
> <cristian.dumitrescu@intel.com>
> Subject: [PATCH 63/82] net/softnic: remove unnecessary NULL checks
> 
> Remove redundant NULL pointer checks before free functions
> found by nullfree.cocci
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>  drivers/net/softnic/rte_eth_softnic_cli.c       | 12 ++++--------
>  drivers/net/softnic/rte_eth_softnic_cryptodev.c |  6 ++----
>  drivers/net/softnic/rte_eth_softnic_thread.c    |  6 ++----
>  3 files changed, 8 insertions(+), 16 deletions(-)
> 

Hi Stephen,

The rte_ring_free() and rte_mempool_free() do not state in their API description that freeing a NULL pointer is harmless. Before pushing these changes, please add the necessary note in the API header files for these functions.

In the absence of the clear note in their API description, the user is forced to check for the NULL pointer. I agree that the implementation of these functions does the right think and exits early when the input pointer is NULL, but there is no guarantee that the implementation is not going to change. Agree?

The stdlib free() and the rte_free() do have the clear API description note that freeing a NULL object is harmless, so removing the NULL check before their call is indeed safe.

This stands for all the patches in this set.

Regards,
Cristian

^ permalink raw reply	[flat|nested] 247+ messages in thread

* RE: [PATCH 06/82] examples/pipeline/thread: remove unnecessary NULL checks
  2022-01-24  0:04 ` [PATCH 06/82] examples/pipeline/thread: " Stephen Hemminger
@ 2022-01-24 10:18   ` Dumitrescu, Cristian
  0 siblings, 0 replies; 247+ messages in thread
From: Dumitrescu, Cristian @ 2022-01-24 10:18 UTC (permalink / raw)
  To: Stephen Hemminger, dev



> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Monday, January 24, 2022 12:04 AM
> To: dev@dpdk.org
> Cc: Stephen Hemminger <stephen@networkplumber.org>; Dumitrescu,
> Cristian <cristian.dumitrescu@intel.com>
> Subject: [PATCH 06/82] examples/pipeline/thread: remove unnecessary
> NULL checks
> 
> Remove redundant NULL pointer checks before free functions
> found by nullfree.cocci
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>  examples/pipeline/thread.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/examples/pipeline/thread.c b/examples/pipeline/thread.c
> index bf11e6144b75..5fe7eae00eb6 100644
> --- a/examples/pipeline/thread.c
> +++ b/examples/pipeline/thread.c
> @@ -89,11 +89,9 @@ thread_free(void)
>  			continue;
> 
>  		/* MSGQs */
> -		if (t->msgq_req)
> -			rte_ring_free(t->msgq_req);
> +		rte_ring_free(t->msgq_req);
> 
> -		if (t->msgq_rsp)
> -			rte_ring_free(t->msgq_rsp);
> +		rte_ring_free(t->msgq_rsp);
>  	}
>  }
> 
> --
> 2.30.2

Hi Stephen,

The rte_ring_free() and rte_mempool_free() do not state in their API description that freeing a NULL pointer is harmless. Before pushing these changes, please add the necessary note in the API header files for these functions.

In the absence of the clear note in their API description, the user is forced to check for the NULL pointer. I agree that the implementation of these functions does the right think and exits early when the input pointer is NULL, but there is no guarantee that the implementation is not going to change. Agree?

The stdlib free() and the rte_free() do have the clear API description note that freeing a NULL object is harmless, so removing the NULL check before their call is indeed safe.

This stands for all the patches in this set.

Regards,
Cristian

^ permalink raw reply	[flat|nested] 247+ messages in thread

* RE: [PATCH 11/82] app/test-crypto-perf: remove unnecessary NULL checks
  2022-01-24  0:04 ` [PATCH 11/82] app/test-crypto-perf: " Stephen Hemminger
@ 2022-01-24 16:13   ` Power, Ciara
  0 siblings, 0 replies; 247+ messages in thread
From: Power, Ciara @ 2022-01-24 16:13 UTC (permalink / raw)
  To: Stephen Hemminger, dev; +Cc: Doherty, Declan

Hi Stephen,

Looks good, thanks.

>-----Original Message-----
>From: Stephen Hemminger <stephen@networkplumber.org>
>Sent: Monday 24 January 2022 00:04
>To: dev@dpdk.org
>Cc: Stephen Hemminger <stephen@networkplumber.org>; Doherty, Declan
><declan.doherty@intel.com>; Power, Ciara <ciara.power@intel.com>
>Subject: [PATCH 11/82] app/test-crypto-perf: remove unnecessary NULL
>checks
>
>Remove redundant NULL pointer checks before free functions found by
>nullfree.cocci
>
>Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
>---
> app/test-crypto-perf/cperf_test_latency.c        | 3 +--
> app/test-crypto-perf/cperf_test_pmd_cyclecount.c | 9 +++------
> app/test-crypto-perf/cperf_test_throughput.c     | 3 +--
> app/test-crypto-perf/cperf_test_vector_parsing.c | 6 ++----
> app/test-crypto-perf/cperf_test_verify.c         | 3 +--
> 5 files changed, 8 insertions(+), 16 deletions(-)
>
<snip>

Acked-by: Ciara Power <ciara.power@intel.com>

^ permalink raw reply	[flat|nested] 247+ messages in thread

* Re: [PATCH 05/82] examples/ip_pipeline: remove unnecessary NULL checks
  2022-01-24 10:17   ` Dumitrescu, Cristian
@ 2022-01-24 17:23     ` Stephen Hemminger
  0 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:23 UTC (permalink / raw)
  To: Dumitrescu, Cristian; +Cc: dev

On Mon, 24 Jan 2022 10:17:23 +0000
"Dumitrescu, Cristian" <cristian.dumitrescu@intel.com> wrote:

> > -----Original Message-----
> > From: Stephen Hemminger <stephen@networkplumber.org>
> > Sent: Monday, January 24, 2022 12:04 AM
> > To: dev@dpdk.org
> > Cc: Stephen Hemminger <stephen@networkplumber.org>; Dumitrescu,
> > Cristian <cristian.dumitrescu@intel.com>
> > Subject: [PATCH 05/82] examples/ip_pipeline: remove unnecessary NULL
> > checks
> > 
> > Remove redundant NULL pointer checks before free functions
> > found by nullfree.cocci
> > 
> > Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> > ---
> >  examples/ip_pipeline/cli.c       | 12 ++++--------
> >  examples/ip_pipeline/cryptodev.c |  6 ++----
> >  examples/ip_pipeline/thread.c    |  6 ++----
> >  3 files changed, 8 insertions(+), 16 deletions(-)
> >   
> 
> Hi Stephen,
> 
> The rte_ring_free() and rte_mempool_free() do not state in their API description that freeing a NULL pointer is harmless. Before pushing these changes, please add the necessary note in the API header files for these functions.


Okay, will fix the documentation then.
The implemeentation has always done the right thing.

> In the absence of the clear note in their API description, the user is forced to check for the NULL pointer. I agree that the implementation of these functions does the right think and exits early when the input pointer is NULL, but there is no guarantee that the implementation is not going to change. Agree?


No. I don't agree. All XXX_free() functions should accept NULL and handle it in the same way.
Any inconsistency is an obvious source of bugs.

> 
> The stdlib free() and the rte_free() do have the clear API description note that freeing a NULL object is harmless, so removing the NULL check before their call is indeed safe.

Will add first patch to fix the documentation to match the current implementation.


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 00/83] remove unnecessary null checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (81 preceding siblings ...)
  2022-01-24  0:05 ` [PATCH 82/82] reorder: " Stephen Hemminger
@ 2022-01-24 17:45 ` Stephen Hemminger
  2022-01-24 17:45   ` [PATCH v2 01/83] lib: update documentation of XXX_free() functions Stephen Hemminger
                     ` (83 more replies)
  2022-02-09 19:17 ` [PATCH v3 00/36] " Stephen Hemminger
  83 siblings, 84 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:45 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

While working on a new driver, noticed that some drivers always call
free routines (correct) and others conditionally call free routines
if not null (redundant check).  The extra if(e != NULL) type check
is unneeded and adds extra code.  Better to have all the code
consistent.

The Linux kernel has automated this kind of fixup using coccinelle,
and this patchset creates a coccinelle script to do the transformation;
then has individual patches for each sub component.

In one driver dpaaxx, the change suggested a further change
to the compat macros to make them even simpler.

v2
  - add documentation change patch
  - spelling fix to coccinelle script patch
  - suggested whitespace fix to igc and ixgbe patch

Stephen Hemminger (83):
  lib: update documentation of XXX_free() functions
  devtools/cocci: add script to fix unnecessary null checks
  eal: remove unnecessary NULL checks
  eal/windows: remove unnecessary NULL checks before free
  examples/fips_validation: remove unnecessary NULL checks
  examples/ip_pipeline: remove unnecessary NULL checks
  examples/pipeline/thread: remove unnecessary NULL checks
  examples/l2fwd-cat: remove unnecessary NULL checks
  lib/vhost: remove unnecessary NULL checks
  examples/vhost_blk: remove unnecessary NULL checks
  app/pdump: remove unnecessary NULL checks
  app/test-crypto-perf: remove unnecessary NULL checks
  app/test-pmd: remove unnecessary NULL checks
  app/test-regex: remove unnecessary NULL checks
  app/test: remove unnecessary NULL checks
  baseband/acc100 remove unnecessary NULL checks
  baseband/la12xx remove unnecessary NULL checks
  baseband/null remove unnecessary NULL checks
  baseband/turbo_sw remove unnecessary NULL checks
  bus/fslmc: remove unnecessary NULL checks
  bus/ifpga: remove unnecessary NULL checks
  bus/pci: remove unnecessary NULL checks
  common/cpt: remove unnecessary NULL checks
  common/dpaax: simplify kernel compat macros
  common/mlx5: remove unnecessary NULL checks
  common/qat: remove unnecessary NULL checks
  compress/mlx5: remove unnecessary NULL checks
  compress/octeontx: remove unnecessary NULL checks
  crypto/armv8: remove unnecessary NULL checks
  crypto/ccp: remove unnecessary NULL checks
  crypto/cnxk: remove unnecessary NULL checks
  crypto/ipsec_mb: remove unnecessary NULL checks
  crypto/mvsam: remove unnecessary NULL checks
  crypto/null: remove unnecessary NULL checks
  crypto/octeontx: remove unnecessary NULL checks
  crypto/openssl: remove unnecessary NULL checks
  crypto/scheduler: remove unnecessary NULL checks
  crypto/virtio: remove unnecessary NULL checks
  event/sw: remove unnecessary NULL checks
  net/axgbe: remove unnecessary NULL checks
  net/bnx2x: remove unnecessary NULL checks
  net/bnxt: remove unnecessary NULL checks
  net/bonding: remove unnecessary NULL checks
  net/cnxk: remove unnecessary NULL checks
  net/cxgbe: remove unnecessary NULL checks
  net/dpaa: remove unnecessary NULL checks
  net/dpaa2: remove unnecessary NULL checks
  net/ena: remove unnecessary NULL checks
  net/hinic: remove unnecessary NULL checks
  net/hns3: remove unnecessary NULL checks
  net/i40e: remove unnecessary NULL checks
  net/iavf: remove unnecessary NULL checks
  net/ice: remove unnecessary NULL checks
  net/igc: remove unnecessary NULL checks
  net/ixgbe: remove unnecessary NULL checks
  net/memif: remove unnecessary NULL checks
  net/mlx4: remove unnecessary NULL checks
  net/mlx5: remove unnecessary NULL checks
  net/mvpp2: remove unnecessary NULL checks
  net/netvsc: remove unnecessary NULL checks
  net/null: remove unnecessary NULL checks
  net/octeontx: remove unnecessary NULL checks
  net/qede: remove unnecessary NULL checks
  net/softnic: remove unnecessary NULL checks
  net/tap: remove unnecessary NULL checks
  net/txgbe: remove unnecessary NULL checks
  net/vdev_netvsc: remove unnecessary NULL checks
  net/virtio: remove unnecessary NULL checks
  raw/cnxk_bphy: remove unnecessary NULL checks
  raw/dpaa2_qdma: remove unnecessary NULL checks
  raw/ifpga: remove unnecessary NULL checks
  raw/skeleton: remove unnecessary NULL checks
  regex/cn9k: remove unnecessary NULL checks
  regex/mlx5: remove unnecessary NULL checks
  vdpa/ifc: remove unnecessary NULL checks
  vdpa/mlx5: remove unnecessary NULL checks
  compressdev: remove unnecessary NULL checks
  ethdev: remove unnecessary NULL checks
  graph: remove unnecessary NULL checks
  ipsec: remove unnecessary NULL checks
  port: remove unnecessary NULL checks
  power: remove unnecessary NULL checks
  reorder: remove unnecessary NULL checks

 app/pdump/main.c                              |  9 ++--
 app/test-crypto-perf/cperf_test_latency.c     |  3 +-
 .../cperf_test_pmd_cyclecount.c               |  9 ++--
 app/test-crypto-perf/cperf_test_throughput.c  |  3 +-
 .../cperf_test_vector_parsing.c               |  6 +--
 app/test-crypto-perf/cperf_test_verify.c      |  3 +-
 app/test-pmd/cmd_flex_item.c                  |  3 +-
 app/test-pmd/cmdline.c                        |  3 +-
 app/test-pmd/testpmd.c                        |  3 +-
 app/test-regex/main.c                         | 12 ++---
 app/test/test_cksum.c                         |  3 +-
 app/test/test_compressdev.c                   |  3 +-
 app/test/test_cryptodev.h                     |  3 +-
 app/test/test_cryptodev_asym.c                |  3 +-
 app/test/test_cryptodev_blockcipher.c         | 12 ++---
 app/test/test_func_reentrancy.c               | 15 +++----
 app/test/test_hash.c                          | 15 +++----
 app/test/test_hash_perf.c                     |  7 +--
 app/test/test_link_bonding.c                  |  9 ++--
 app/test/test_link_bonding_mode4.c            |  3 +-
 app/test/test_malloc.c                        |  5 +--
 app/test/test_mbuf.c                          | 45 +++++++------------
 app/test/test_pcapng.c                        |  3 +-
 app/test/test_reorder.c                       | 15 +++----
 app/test/virtual_pmd.c                        |  3 +-
 devtools/cocci/nullfree.cocci                 | 33 ++++++++++++++
 drivers/baseband/acc100/rte_acc100_pmd.c      |  3 +-
 drivers/baseband/la12xx/bbdev_la12xx.c        |  3 +-
 drivers/baseband/null/bbdev_null.c            |  3 +-
 .../baseband/turbo_sw/bbdev_turbo_software.c  |  3 +-
 drivers/bus/fslmc/fslmc_bus.c                 |  6 +--
 drivers/bus/fslmc/portal/dpaa2_hw_dpio.c      |  6 +--
 drivers/bus/ifpga/ifpga_bus.c                 | 12 ++---
 drivers/bus/pci/pci_params.c                  |  3 +-
 drivers/bus/pci/windows/pci.c                 |  3 +-
 drivers/bus/pci/windows/pci_netuio.c          |  3 +-
 drivers/common/cpt/cpt_ucode_asym.h           |  6 +--
 drivers/common/dpaax/compat.h                 | 11 +----
 drivers/common/mlx5/mlx5_common_mr.c          |  3 +-
 drivers/common/mlx5/mlx5_common_pci.c         |  3 +-
 drivers/common/qat/qat_qp.c                   |  9 ++--
 drivers/compress/mlx5/mlx5_compress.c         |  3 +-
 drivers/compress/octeontx/otx_zip_pmd.c       |  9 ++--
 drivers/crypto/armv8/rte_armv8_pmd_ops.c      |  3 +-
 drivers/crypto/ccp/ccp_dev.c                  |  3 +-
 drivers/crypto/ccp/ccp_pmd_ops.c              |  3 +-
 drivers/crypto/cnxk/cnxk_ae.h                 |  6 +--
 drivers/crypto/ipsec_mb/ipsec_mb_ops.c        |  6 +--
 drivers/crypto/mvsam/rte_mrvl_pmd_ops.c       |  6 +--
 drivers/crypto/null/null_crypto_pmd_ops.c     |  6 +--
 drivers/crypto/octeontx/otx_cryptodev_ops.c   |  3 +-
 drivers/crypto/openssl/rte_openssl_pmd_ops.c  |  6 +--
 drivers/crypto/scheduler/scheduler_pmd_ops.c  |  6 +--
 drivers/crypto/virtio/virtqueue.c             |  6 +--
 drivers/event/sw/sw_evdev.c                   |  3 +-
 drivers/net/axgbe/axgbe_rxtx.c                |  6 +--
 drivers/net/bnx2x/bnx2x_rxtx.c                |  6 +--
 drivers/net/bnxt/bnxt_ethdev.c                |  3 +-
 drivers/net/bonding/rte_eth_bond_pmd.c        |  3 +-
 drivers/net/cnxk/cnxk_ethdev.c                |  6 +--
 drivers/net/cxgbe/cxgbe_main.c                |  3 +-
 drivers/net/dpaa/dpaa_ethdev.c                |  3 +-
 drivers/net/dpaa/fmlib/fm_lib.c               |  3 +-
 drivers/net/dpaa2/dpaa2_ethdev.c              |  3 +-
 drivers/net/dpaa2/dpaa2_mux.c                 |  3 +-
 drivers/net/dpaa2/dpaa2_ptp.c                 |  3 +-
 drivers/net/ena/ena_ethdev.c                  | 18 +++-----
 drivers/net/hinic/hinic_pmd_ethdev.c          |  3 +-
 drivers/net/hns3/hns3_rxtx.c                  |  9 ++--
 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 +-
 drivers/net/memif/rte_eth_memif.c             |  6 +--
 drivers/net/mlx4/mlx4_mr.c                    |  3 +-
 drivers/net/mlx5/mlx5_flow.c                  |  3 +-
 drivers/net/mvpp2/mrvl_qos.c                  |  3 +-
 drivers/net/netvsc/hn_rxtx.c                  |  6 +--
 drivers/net/null/rte_eth_null.c               |  3 +-
 drivers/net/octeontx/octeontx_ethdev.c        |  3 +-
 drivers/net/octeontx/octeontx_ethdev_ops.c    |  3 +-
 drivers/net/qede/qede_main.c                  |  3 +-
 drivers/net/qede/qede_rxtx.c                  |  6 +--
 drivers/net/softnic/rte_eth_softnic_cli.c     | 12 ++---
 .../net/softnic/rte_eth_softnic_cryptodev.c   |  6 +--
 drivers/net/softnic/rte_eth_softnic_thread.c  |  6 +--
 drivers/net/tap/tap_flow.c                    |  9 ++--
 drivers/net/txgbe/txgbe_ethdev.c              | 12 ++---
 drivers/net/vdev_netvsc/vdev_netvsc.c         |  3 +-
 drivers/net/virtio/virtio_user_ethdev.c       | 12 ++---
 drivers/raw/cnxk_bphy/cnxk_bphy_cgx.c         |  3 +-
 drivers/raw/dpaa2_qdma/dpaa2_qdma.c           | 15 +++----
 drivers/raw/ifpga/ifpga_rawdev.c              |  9 ++--
 drivers/raw/skeleton/skeleton_rawdev_test.c   |  6 +--
 drivers/regex/cn9k/cn9k_regexdev.c            |  6 +--
 drivers/regex/cn9k/cn9k_regexdev_compiler.c   |  3 +-
 drivers/regex/mlx5/mlx5_regex.c               |  3 +-
 drivers/regex/mlx5/mlx5_rxp.c                 |  3 +-
 drivers/vdpa/ifc/ifcvf_vdpa.c                 |  9 ++--
 drivers/vdpa/mlx5/mlx5_vdpa_mem.c             |  3 +-
 drivers/vdpa/mlx5/mlx5_vdpa_virtq.c           |  3 +-
 examples/fips_validation/fips_dev_self_test.c | 18 +++-----
 examples/fips_validation/fips_validation.c    |  3 +-
 examples/fips_validation/main.c               | 36 +++++----------
 examples/ip_pipeline/cli.c                    | 12 ++---
 examples/ip_pipeline/cryptodev.c              |  6 +--
 examples/ip_pipeline/thread.c                 |  6 +--
 examples/l2fwd-cat/cat.c                      |  3 +-
 examples/pipeline/thread.c                    |  6 +--
 examples/vhost_blk/vhost_blk.c                |  3 +-
 lib/compressdev/rte_compressdev.c             |  3 +-
 lib/eal/common/eal_common_devargs.c           |  6 +--
 lib/eal/common/eal_common_memzone.c           |  3 +-
 lib/eal/common/eal_common_options.c           |  9 ++--
 lib/eal/common/eal_common_trace_ctf.c         |  6 +--
 lib/eal/freebsd/eal.c                         |  4 +-
 lib/eal/linux/eal.c                           | 10 ++---
 lib/eal/windows/eal_alarm.c                   |  3 +-
 lib/eal/windows/eal_memory.c                  |  3 +-
 lib/ethdev/rte_ethdev.c                       |  3 +-
 lib/graph/graph_stats.c                       |  3 +-
 lib/hash/rte_hash.h                           |  3 ++
 lib/ipsec/ipsec_sad.c                         |  3 +-
 lib/kvargs/rte_kvargs.h                       |  2 +
 lib/mbuf/rte_mbuf.h                           |  2 +
 lib/mempool/rte_mempool.h                     |  2 +
 lib/port/rte_port_source_sink.c               | 21 +++------
 lib/power/rte_power_empty_poll.c              |  3 +-
 lib/reorder/rte_reorder.c                     |  6 +--
 lib/ring/rte_ring.h                           |  2 +
 lib/vhost/iotlb.c                             |  3 +-
 lib/vhost/vhost_crypto.c                      |  6 +--
 lib/vhost/vhost_user.c                        |  9 ++--
 136 files changed, 318 insertions(+), 560 deletions(-)
 create mode 100644 devtools/cocci/nullfree.cocci

-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 01/83] lib: update documentation of XXX_free() functions
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
@ 2022-01-24 17:45   ` Stephen Hemminger
  2022-01-28 21:47     ` Thomas Monjalon
  2022-01-24 17:45   ` [PATCH v2 02/83] devtools/cocci: add script to fix unnecessary null checks Stephen Hemminger
                     ` (82 subsequent siblings)
  83 siblings, 1 reply; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:45 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Yipeng Wang, Sameh Gobriel, Bruce Richardson,
	Vladimir Medvedkin, Olivier Matz, Andrew Rybchenko,
	Honnappa Nagarahalli, Konstantin Ananyev

These functions all behave like libc free() and do
nothing if handed a NULL pointer. The code is already doing
this, this patch just documents the behavior.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/hash/rte_hash.h       | 3 +++
 lib/kvargs/rte_kvargs.h   | 2 ++
 lib/mbuf/rte_mbuf.h       | 2 ++
 lib/mempool/rte_mempool.h | 2 ++
 lib/ring/rte_ring.h       | 2 ++
 5 files changed, 11 insertions(+)

diff --git a/lib/hash/rte_hash.h b/lib/hash/rte_hash.h
index 6067aad95431..94223cf81ae0 100644
--- a/lib/hash/rte_hash.h
+++ b/lib/hash/rte_hash.h
@@ -174,6 +174,9 @@ rte_hash_find_existing(const char *name);
 
 /**
  * De-allocate all memory used by hash table.
+ *
+ * If the pointer is NULL, the function does nothing.
+ *
  * @param h
  *   Hash table to free
  */
diff --git a/lib/kvargs/rte_kvargs.h b/lib/kvargs/rte_kvargs.h
index 359a9f5b091c..bf1732ce2b1e 100644
--- a/lib/kvargs/rte_kvargs.h
+++ b/lib/kvargs/rte_kvargs.h
@@ -108,6 +108,8 @@ struct rte_kvargs *rte_kvargs_parse_delim(const char *args,
  * Free a rte_kvargs structure previously allocated with
  * rte_kvargs_parse().
  *
+ * If the pointer is NULL, the function does nothing.
+ *
  * @param kvlist
  *   The rte_kvargs structure. No error if NULL.
  */
diff --git a/lib/mbuf/rte_mbuf.h b/lib/mbuf/rte_mbuf.h
index dedf83c38d1b..cb280108d3f9 100644
--- a/lib/mbuf/rte_mbuf.h
+++ b/lib/mbuf/rte_mbuf.h
@@ -1372,6 +1372,8 @@ rte_pktmbuf_free_seg(struct rte_mbuf *m)
  * Free an mbuf, and all its segments in case of chained buffers. Each
  * segment is added back into its original mempool.
  *
+ * If the pointer is NULL, the function does nothing.
+ *
  * @param m
  *   The packet mbuf to be freed. If NULL, the function does nothing.
  */
diff --git a/lib/mempool/rte_mempool.h b/lib/mempool/rte_mempool.h
index 1e7a3c15273c..c268328b268b 100644
--- a/lib/mempool/rte_mempool.h
+++ b/lib/mempool/rte_mempool.h
@@ -1099,6 +1099,8 @@ rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size,
  * memory referenced by the mempool. The objects must not be used by
  * other cores as they will be freed.
  *
+ * If the pointer is NULL, the function does nothing.
+ *
  * @param mp
  *   A pointer to the mempool structure.
  */
diff --git a/lib/ring/rte_ring.h b/lib/ring/rte_ring.h
index da17ed6d7c04..c2faf7b3e6dc 100644
--- a/lib/ring/rte_ring.h
+++ b/lib/ring/rte_ring.h
@@ -176,6 +176,8 @@ struct rte_ring *rte_ring_create(const char *name, unsigned int count,
 /**
  * De-allocate all memory used by the ring.
  *
+ * If the pointer is NULL, the function does nothing.
+ *
  * @param r
  *   Ring to free
  */
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 02/83] devtools/cocci: add script to fix unnecessary null checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
  2022-01-24 17:45   ` [PATCH v2 01/83] lib: update documentation of XXX_free() functions Stephen Hemminger
@ 2022-01-24 17:45   ` Stephen Hemminger
  2022-01-28 21:48     ` Thomas Monjalon
  2022-01-24 17:45   ` [PATCH v2 03/83] eal: remove unnecessary NULL checks Stephen Hemminger
                     ` (81 subsequent siblings)
  83 siblings, 1 reply; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:45 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

This script is based on the idea of the nullfree script
in the Linux kernel. It finds cases where a check for null
pointer is done, but is unnecessary because the function
already handles NULL pointer.

Basic example:
       if (x->buf)
           rte_free(x->buf);
can be reduced to:
       rte_free(x->buf);

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 devtools/cocci/nullfree.cocci | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
 create mode 100644 devtools/cocci/nullfree.cocci

diff --git a/devtools/cocci/nullfree.cocci b/devtools/cocci/nullfree.cocci
new file mode 100644
index 000000000000..363b6149ac28
--- /dev/null
+++ b/devtools/cocci/nullfree.cocci
@@ -0,0 +1,33 @@
+//
+// Remove unnecessary NULL pointer checks before free functions
+// All these functions work like libc free which allows
+// free(NULL) as a no-op.
+//
+@@
+expression E;
+@@
+(
+- if (E != NULL) free(E);
++ free(E);
+|
+- if (E != NULL) rte_bitmap_free(E);
++ rte_bitmap_free(E);
+|
+- if (E != NULL) rte_free(E);
++ rte_free(E);
+|
+- if (E != NULL) rte_hash_free(E);
++ rte_hash_free(E);
+|
+- if (E != NULL) rte_ring_free(E);
++ rte_ring_free(E);
+|
+- if (E != NULL) rte_pktmbuf_free(E);
++ rte_pktmbuf_free(E);
+|
+- if (E != NULL) rte_mempool_free(E);
++ rte_mempool_free(E);
+|
+- if (E != NULL) rte_kvargs_free(E);
++ rte_kvargs_free(E);
+)
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 03/83] eal: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
  2022-01-24 17:45   ` [PATCH v2 01/83] lib: update documentation of XXX_free() functions Stephen Hemminger
  2022-01-24 17:45   ` [PATCH v2 02/83] devtools/cocci: add script to fix unnecessary null checks Stephen Hemminger
@ 2022-01-24 17:45   ` Stephen Hemminger
  2022-01-24 17:46   ` [PATCH v2 04/83] eal/windows: remove unnecessary NULL checks before free Stephen Hemminger
                     ` (80 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:45 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Anatoly Burakov, Jerin Jacob,
	Sunil Kumar Kori, Bruce Richardson

Functions like free() already handle NULL pointer so
the checks here are not necessary.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_devargs.c   |  6 ++----
 lib/eal/common/eal_common_memzone.c   |  3 +--
 lib/eal/common/eal_common_options.c   |  9 +++------
 lib/eal/common/eal_common_trace_ctf.c |  6 ++----
 lib/eal/freebsd/eal.c                 |  4 +---
 lib/eal/linux/eal.c                   | 10 +++-------
 6 files changed, 12 insertions(+), 26 deletions(-)

diff --git a/lib/eal/common/eal_common_devargs.c b/lib/eal/common/eal_common_devargs.c
index 8c7650cf6c27..69004b0a2d2f 100644
--- a/lib/eal/common/eal_common_devargs.c
+++ b/lib/eal/common/eal_common_devargs.c
@@ -161,8 +161,7 @@ rte_devargs_layers_parse(struct rte_devargs *devargs,
 
 get_out:
 	for (i = 0; i < RTE_DIM(layers); i++) {
-		if (layers[i].kvlist)
-			rte_kvargs_free(layers[i].kvlist);
+		rte_kvargs_free(layers[i].kvlist);
 	}
 	if (ret != 0) {
 		if (allocated_data) {
@@ -285,8 +284,7 @@ rte_devargs_reset(struct rte_devargs *da)
 {
 	if (da == NULL)
 		return;
-	if (da->data)
-		free(da->data);
+	free(da->data);
 	da->data = NULL;
 }
 
diff --git a/lib/eal/common/eal_common_memzone.c b/lib/eal/common/eal_common_memzone.c
index ecde9441ee90..9a0c5309ac7e 100644
--- a/lib/eal/common/eal_common_memzone.c
+++ b/lib/eal/common/eal_common_memzone.c
@@ -300,8 +300,7 @@ rte_memzone_free(const struct rte_memzone *mz)
 
 	rte_rwlock_write_unlock(&mcfg->mlock);
 
-	if (addr != NULL)
-		rte_free(addr);
+	rte_free(addr);
 
 	rte_eal_trace_memzone_free(name, addr, ret);
 	return ret;
diff --git a/lib/eal/common/eal_common_options.c b/lib/eal/common/eal_common_options.c
index 1cfdd75f3b79..09b7b17ffa06 100644
--- a/lib/eal/common/eal_common_options.c
+++ b/lib/eal/common/eal_common_options.c
@@ -1962,12 +1962,9 @@ compute_ctrl_threads_cpuset(struct internal_config *internal_cfg)
 int
 eal_cleanup_config(struct internal_config *internal_cfg)
 {
-	if (internal_cfg->hugefile_prefix != NULL)
-		free(internal_cfg->hugefile_prefix);
-	if (internal_cfg->hugepage_dir != NULL)
-		free(internal_cfg->hugepage_dir);
-	if (internal_cfg->user_mbuf_pool_ops_name != NULL)
-		free(internal_cfg->user_mbuf_pool_ops_name);
+	free(internal_cfg->hugefile_prefix);
+	free(internal_cfg->hugepage_dir);
+	free(internal_cfg->user_mbuf_pool_ops_name);
 
 	return 0;
 }
diff --git a/lib/eal/common/eal_common_trace_ctf.c b/lib/eal/common/eal_common_trace_ctf.c
index 33e419aac7fb..3b83bcdf57fd 100644
--- a/lib/eal/common/eal_common_trace_ctf.c
+++ b/lib/eal/common/eal_common_trace_ctf.c
@@ -52,8 +52,7 @@ meta_copy(char **meta, int *offset, char *str, int rc)
 	return rc;
 
 free_str:
-	if (str)
-		free(str);
+	free(str);
 	return -ENOMEM;
 }
 
@@ -291,8 +290,7 @@ trace_metadata_create(void)
 	return 0;
 
 fail:
-	if (meta)
-		free(meta);
+	free(meta);
 	return -EBADF;
 }
 
diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c
index a1cd2462db1b..00ba32f1d664 100644
--- a/lib/eal/freebsd/eal.c
+++ b/lib/eal/freebsd/eal.c
@@ -544,9 +544,7 @@ eal_parse_args(int argc, char **argv)
 				RTE_LOG(ERR, EAL, "Could not store mbuf pool ops name\n");
 			else {
 				/* free old ops name */
-				if (internal_conf->user_mbuf_pool_ops_name !=
-						NULL)
-					free(internal_conf->user_mbuf_pool_ops_name);
+				free(internal_conf->user_mbuf_pool_ops_name);
 
 				internal_conf->user_mbuf_pool_ops_name =
 						ops_name;
diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c
index 60b49248388e..f8e39b7e4277 100644
--- a/lib/eal/linux/eal.c
+++ b/lib/eal/linux/eal.c
@@ -730,8 +730,7 @@ eal_parse_args(int argc, char **argv)
 				RTE_LOG(ERR, EAL, "Could not store hugepage directory\n");
 			else {
 				/* free old hugepage dir */
-				if (internal_conf->hugepage_dir != NULL)
-					free(internal_conf->hugepage_dir);
+				free(internal_conf->hugepage_dir);
 				internal_conf->hugepage_dir = hdir;
 			}
 			break;
@@ -743,8 +742,7 @@ eal_parse_args(int argc, char **argv)
 				RTE_LOG(ERR, EAL, "Could not store file prefix\n");
 			else {
 				/* free old prefix */
-				if (internal_conf->hugefile_prefix != NULL)
-					free(internal_conf->hugefile_prefix);
+				free(internal_conf->hugefile_prefix);
 				internal_conf->hugefile_prefix = prefix;
 			}
 			break;
@@ -804,9 +802,7 @@ eal_parse_args(int argc, char **argv)
 				RTE_LOG(ERR, EAL, "Could not store mbuf pool ops name\n");
 			else {
 				/* free old ops name */
-				if (internal_conf->user_mbuf_pool_ops_name !=
-						NULL)
-					free(internal_conf->user_mbuf_pool_ops_name);
+				free(internal_conf->user_mbuf_pool_ops_name);
 
 				internal_conf->user_mbuf_pool_ops_name =
 						ops_name;
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 04/83] eal/windows: remove unnecessary NULL checks before free
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (2 preceding siblings ...)
  2022-01-24 17:45   ` [PATCH v2 03/83] eal: remove unnecessary NULL checks Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-24 17:46   ` [PATCH v2 05/83] examples/fips_validation: remove unnecessary NULL checks Stephen Hemminger
                     ` (79 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Dmitry Kozlyuk, Narcisa Ana Maria Vasile,
	Dmitry Malloy, Pallavi Kadam

Calling free/rte_free/rte_mempool_free,... with NULL pointer
is allowed; so remove unnecessary NULL checks.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/windows/eal_alarm.c  | 3 +--
 lib/eal/windows/eal_memory.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/lib/eal/windows/eal_alarm.c b/lib/eal/windows/eal_alarm.c
index 103c1f909da3..51fe752c16d4 100644
--- a/lib/eal/windows/eal_alarm.c
+++ b/lib/eal/windows/eal_alarm.c
@@ -162,8 +162,7 @@ rte_eal_alarm_set(uint64_t us, rte_eal_alarm_callback cb_fn, void *cb_arg)
 fail:
 	if (timer != NULL)
 		CloseHandle(timer);
-	if (ap != NULL)
-		free(ap);
+	free(ap);
 
 exit:
 	rte_eal_trace_alarm_set(us, cb_fn, cb_arg, ret);
diff --git a/lib/eal/windows/eal_memory.c b/lib/eal/windows/eal_memory.c
index 2fd37d97085e..215d768e2c57 100644
--- a/lib/eal/windows/eal_memory.c
+++ b/lib/eal/windows/eal_memory.c
@@ -190,8 +190,7 @@ eal_mem_virt2iova_init(void)
 	ret = 0;
 
 exit:
-	if (detail != NULL)
-		free(detail);
+	free(detail);
 	if (list != INVALID_HANDLE_VALUE)
 		SetupDiDestroyDeviceInfoList(list);
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 05/83] examples/fips_validation: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (3 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 04/83] eal/windows: remove unnecessary NULL checks before free Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-24 17:46   ` [PATCH v2 06/83] examples/ip_pipeline: " Stephen Hemminger
                     ` (78 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Marko Kovacevic

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 examples/fips_validation/fips_dev_self_test.c | 18 ++++------
 examples/fips_validation/fips_validation.c    |  3 +-
 examples/fips_validation/main.c               | 36 +++++++------------
 3 files changed, 19 insertions(+), 38 deletions(-)

diff --git a/examples/fips_validation/fips_dev_self_test.c b/examples/fips_validation/fips_dev_self_test.c
index b4eab05a9851..076e9de099c0 100644
--- a/examples/fips_validation/fips_dev_self_test.c
+++ b/examples/fips_validation/fips_dev_self_test.c
@@ -1396,8 +1396,7 @@ check_aead_result(struct rte_crypto_op *op,
 	if (!mbuf)
 		return -1;
 
-	if (op->sym->aead.aad.data)
-		rte_free(op->sym->aead.aad.data);
+	rte_free(op->sym->aead.aad.data);
 
 	if (dir == self_test_dir_enc_auth_gen) {
 		src = vec->output.data;
@@ -1523,18 +1522,13 @@ static void
 fips_dev_auto_test_uninit(uint8_t dev_id,
 		struct fips_dev_auto_test_env *env)
 {
-	if (env->mbuf)
-		rte_pktmbuf_free(env->mbuf);
+	rte_pktmbuf_free(env->mbuf);
 	if (env->op)
 		rte_crypto_op_free(env->op);
-	if (env->mpool)
-		rte_mempool_free(env->mpool);
-	if (env->op_pool)
-		rte_mempool_free(env->op_pool);
-	if (env->sess_pool)
-		rte_mempool_free(env->sess_pool);
-	if (env->sess_priv_pool)
-		rte_mempool_free(env->sess_priv_pool);
+	rte_mempool_free(env->mpool);
+	rte_mempool_free(env->op_pool);
+	rte_mempool_free(env->sess_pool);
+	rte_mempool_free(env->sess_priv_pool);
 
 	rte_cryptodev_stop(dev_id);
 }
diff --git a/examples/fips_validation/fips_validation.c b/examples/fips_validation/fips_validation.c
index 52a7bf952d46..94253eaee8bf 100644
--- a/examples/fips_validation/fips_validation.c
+++ b/examples/fips_validation/fips_validation.c
@@ -344,8 +344,7 @@ fips_test_clear(void)
 		fclose(info.fp_rd);
 	if (info.fp_wr)
 		fclose(info.fp_wr);
-	if (info.one_line_text)
-		free(info.one_line_text);
+	free(info.one_line_text);
 	if (info.nb_vec_lines) {
 		uint32_t i;
 
diff --git a/examples/fips_validation/main.c b/examples/fips_validation/main.c
index dc40bffe7d97..e06ae37567fd 100644
--- a/examples/fips_validation/main.c
+++ b/examples/fips_validation/main.c
@@ -143,12 +143,9 @@ cryptodev_fips_validate_app_int(void)
 error_exit:
 
 	rte_mempool_free(env.mpool);
-	if (env.sess_mpool)
-		rte_mempool_free(env.sess_mpool);
-	if (env.sess_priv_mpool)
-		rte_mempool_free(env.sess_priv_mpool);
-	if (env.op_pool)
-		rte_mempool_free(env.op_pool);
+	rte_mempool_free(env.sess_mpool);
+	rte_mempool_free(env.sess_priv_mpool);
+	rte_mempool_free(env.op_pool);
 
 	return ret;
 }
@@ -523,8 +520,7 @@ prepare_data_mbufs(struct fips_val *val)
 	uint16_t nb_seg;
 	int ret = 0;
 
-	if (env.mbuf)
-		rte_pktmbuf_free(env.mbuf);
+	rte_pktmbuf_free(env.mbuf);
 
 	if (total_len > RTE_MBUF_MAX_NB_SEGS) {
 		RTE_LOG(ERR, USER1, "Data len %u too big\n", total_len);
@@ -598,8 +594,7 @@ prepare_data_mbufs(struct fips_val *val)
 	return 0;
 
 error_exit:
-	if (head)
-		rte_pktmbuf_free(head);
+	rte_pktmbuf_free(head);
 	return ret;
 }
 
@@ -656,8 +651,7 @@ prepare_auth_op(void)
 	if (ret < 0)
 		return ret;
 
-	if (env.digest)
-		rte_free(env.digest);
+	rte_free(env.digest);
 
 	env.digest = rte_zmalloc(NULL, vec.cipher_auth.digest.len,
 			RTE_CACHE_LINE_SIZE);
@@ -705,8 +699,7 @@ prepare_aead_op(void)
 		if (ret < 0)
 			return ret;
 
-		if (env.digest)
-			rte_free(env.digest);
+		rte_free(env.digest);
 		env.digest = rte_zmalloc(NULL, vec.aead.digest.len,
 				RTE_CACHE_LINE_SIZE);
 		if (!env.digest) {
@@ -1430,8 +1423,7 @@ fips_mct_tdes_test(void)
 		}
 	}
 
-	if (val.val)
-		free(val.val);
+	free(val.val);
 
 	return 0;
 }
@@ -1510,8 +1502,7 @@ fips_mct_aes_ecb_test(void)
 		}
 	}
 
-	if (val.val)
-		free(val.val);
+	free(val.val);
 
 	return 0;
 }
@@ -1619,8 +1610,7 @@ fips_mct_aes_test(void)
 			memcpy(vec.iv.val, val.val, AES_BLOCK_SIZE);
 	}
 
-	if (val.val)
-		free(val.val);
+	free(val.val);
 
 	return 0;
 }
@@ -1706,8 +1696,7 @@ fips_mct_sha_test(void)
 
 	rte_free(vec.pt.val);
 
-	if (val.val)
-		free(val.val);
+	free(val.val);
 
 	return 0;
 }
@@ -1851,8 +1840,7 @@ fips_test_one_file(void)
 		rte_free(env.digest);
 		env.digest = NULL;
 	}
-	if (env.mbuf)
-		rte_pktmbuf_free(env.mbuf);
+	rte_pktmbuf_free(env.mbuf);
 
 	return ret;
 }
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 06/83] examples/ip_pipeline: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (4 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 05/83] examples/fips_validation: remove unnecessary NULL checks Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-24 17:46   ` [PATCH v2 07/83] examples/pipeline/thread: " Stephen Hemminger
                     ` (77 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Cristian Dumitrescu

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 examples/ip_pipeline/cli.c       | 12 ++++--------
 examples/ip_pipeline/cryptodev.c |  6 ++----
 examples/ip_pipeline/thread.c    |  6 ++----
 3 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/examples/ip_pipeline/cli.c b/examples/ip_pipeline/cli.c
index 0c372675a919..c918f30e06f3 100644
--- a/examples/ip_pipeline/cli.c
+++ b/examples/ip_pipeline/cli.c
@@ -3773,10 +3773,8 @@ parse_free_sym_crypto_param_data(struct rte_table_action_sym_crypto_params *p)
 
 		switch (xform[i]->type) {
 		case RTE_CRYPTO_SYM_XFORM_CIPHER:
-			if (p->cipher_auth.cipher_iv.val)
-				free(p->cipher_auth.cipher_iv.val);
-			if (p->cipher_auth.cipher_iv_update.val)
-				free(p->cipher_auth.cipher_iv_update.val);
+			free(p->cipher_auth.cipher_iv.val);
+			free(p->cipher_auth.cipher_iv_update.val);
 			break;
 		case RTE_CRYPTO_SYM_XFORM_AUTH:
 			if (p->cipher_auth.auth_iv.val)
@@ -3785,10 +3783,8 @@ parse_free_sym_crypto_param_data(struct rte_table_action_sym_crypto_params *p)
 				free(p->cipher_auth.cipher_iv_update.val);
 			break;
 		case RTE_CRYPTO_SYM_XFORM_AEAD:
-			if (p->aead.iv.val)
-				free(p->aead.iv.val);
-			if (p->aead.aad.val)
-				free(p->aead.aad.val);
+			free(p->aead.iv.val);
+			free(p->aead.aad.val);
 			break;
 		default:
 			continue;
diff --git a/examples/ip_pipeline/cryptodev.c b/examples/ip_pipeline/cryptodev.c
index 9997d974563f..cd0f9c3d4eac 100644
--- a/examples/ip_pipeline/cryptodev.c
+++ b/examples/ip_pipeline/cryptodev.c
@@ -151,10 +151,8 @@ cryptodev_create(const char *name, struct cryptodev_params *params)
 	return cryptodev;
 
 error_exit:
-	if (cryptodev->mp_create)
-		rte_mempool_free(cryptodev->mp_create);
-	if (cryptodev->mp_init)
-		rte_mempool_free(cryptodev->mp_init);
+	rte_mempool_free(cryptodev->mp_create);
+	rte_mempool_free(cryptodev->mp_init);
 
 	free(cryptodev);
 
diff --git a/examples/ip_pipeline/thread.c b/examples/ip_pipeline/thread.c
index b2e97327052f..82d5f87c384c 100644
--- a/examples/ip_pipeline/thread.c
+++ b/examples/ip_pipeline/thread.c
@@ -92,11 +92,9 @@ thread_free(void)
 			continue;
 
 		/* MSGQs */
-		if (t->msgq_req)
-			rte_ring_free(t->msgq_req);
+		rte_ring_free(t->msgq_req);
 
-		if (t->msgq_rsp)
-			rte_ring_free(t->msgq_rsp);
+		rte_ring_free(t->msgq_rsp);
 	}
 }
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 07/83] examples/pipeline/thread: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (5 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 06/83] examples/ip_pipeline: " Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-24 17:46   ` [PATCH v2 08/83] examples/l2fwd-cat: " Stephen Hemminger
                     ` (76 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Cristian Dumitrescu

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 examples/pipeline/thread.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/examples/pipeline/thread.c b/examples/pipeline/thread.c
index bf11e6144b75..5fe7eae00eb6 100644
--- a/examples/pipeline/thread.c
+++ b/examples/pipeline/thread.c
@@ -89,11 +89,9 @@ thread_free(void)
 			continue;
 
 		/* MSGQs */
-		if (t->msgq_req)
-			rte_ring_free(t->msgq_req);
+		rte_ring_free(t->msgq_req);
 
-		if (t->msgq_rsp)
-			rte_ring_free(t->msgq_rsp);
+		rte_ring_free(t->msgq_rsp);
 	}
 }
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 08/83] examples/l2fwd-cat: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (6 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 07/83] examples/pipeline/thread: " Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-24 17:46   ` [PATCH v2 09/83] lib/vhost: " Stephen Hemminger
                     ` (75 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Tomasz Kantecki

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 examples/l2fwd-cat/cat.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/examples/l2fwd-cat/cat.c b/examples/l2fwd-cat/cat.c
index 502c6b32780e..77154c8b7e61 100644
--- a/examples/l2fwd-cat/cat.c
+++ b/examples/l2fwd-cat/cat.c
@@ -872,8 +872,7 @@ cat_fini(void)
 #if PQOS_VERSION <= 103
 	memset(m_sockets, 0, sizeof(m_sockets));
 #else
-	if (m_sockets != NULL)
-		free(m_sockets);
+	free(m_sockets);
 #endif
 	m_sock_count = 0;
 	memset(m_config, 0, sizeof(m_config));
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 09/83] lib/vhost: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (7 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 08/83] examples/l2fwd-cat: " Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-27  5:52     ` Xia, Chenbo
  2022-01-24 17:46   ` [PATCH v2 10/83] examples/vhost_blk: " Stephen Hemminger
                     ` (74 subsequent siblings)
  83 siblings, 1 reply; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Maxime Coquelin, Chenbo Xia

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/vhost/iotlb.c        | 3 +--
 lib/vhost/vhost_crypto.c | 6 ++----
 lib/vhost/vhost_user.c   | 9 +++------
 3 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/lib/vhost/iotlb.c b/lib/vhost/iotlb.c
index 82bdb84526ea..d6b8c0a396b5 100644
--- a/lib/vhost/iotlb.c
+++ b/lib/vhost/iotlb.c
@@ -315,8 +315,7 @@ vhost_user_iotlb_init(struct virtio_net *dev, int vq_index)
 
 	/* If already created, free it and recreate */
 	vq->iotlb_pool = rte_mempool_lookup(pool_name);
-	if (vq->iotlb_pool)
-		rte_mempool_free(vq->iotlb_pool);
+	rte_mempool_free(vq->iotlb_pool);
 
 	vq->iotlb_pool = rte_mempool_create(pool_name,
 			IOTLB_CACHE_SIZE, sizeof(struct vhost_iotlb_entry), 0,
diff --git a/lib/vhost/vhost_crypto.c b/lib/vhost/vhost_crypto.c
index 926b5c0bd94a..012e0cefdeba 100644
--- a/lib/vhost/vhost_crypto.c
+++ b/lib/vhost/vhost_crypto.c
@@ -1498,10 +1498,8 @@ rte_vhost_crypto_create(int vid, uint8_t cryptodev_id,
 	return 0;
 
 error_exit:
-	if (vcrypto->session_map)
-		rte_hash_free(vcrypto->session_map);
-	if (vcrypto->mbuf_pool)
-		rte_mempool_free(vcrypto->mbuf_pool);
+	rte_hash_free(vcrypto->session_map);
+	rte_mempool_free(vcrypto->mbuf_pool);
 
 	rte_free(vcrypto);
 
diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c
index 5eb1dd681231..23a0e3fb3600 100644
--- a/lib/vhost/vhost_user.c
+++ b/lib/vhost/vhost_user.c
@@ -489,8 +489,7 @@ vhost_user_set_vring_num(struct virtio_net **pdev,
 	}
 
 	if (vq_is_packed(dev)) {
-		if (vq->shadow_used_packed)
-			rte_free(vq->shadow_used_packed);
+		rte_free(vq->shadow_used_packed);
 		vq->shadow_used_packed = rte_malloc_socket(NULL,
 				vq->size *
 				sizeof(struct vring_used_elem_packed),
@@ -502,8 +501,7 @@ vhost_user_set_vring_num(struct virtio_net **pdev,
 		}
 
 	} else {
-		if (vq->shadow_used_split)
-			rte_free(vq->shadow_used_split);
+		rte_free(vq->shadow_used_split);
 
 		vq->shadow_used_split = rte_malloc_socket(NULL,
 				vq->size * sizeof(struct vring_used_elem),
@@ -516,8 +514,7 @@ vhost_user_set_vring_num(struct virtio_net **pdev,
 		}
 	}
 
-	if (vq->batch_copy_elems)
-		rte_free(vq->batch_copy_elems);
+	rte_free(vq->batch_copy_elems);
 	vq->batch_copy_elems = rte_malloc_socket(NULL,
 				vq->size * sizeof(struct batch_copy_elem),
 				RTE_CACHE_LINE_SIZE, vq->numa_node);
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 10/83] examples/vhost_blk: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (8 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 09/83] lib/vhost: " Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-27  5:53     ` Xia, Chenbo
  2022-01-24 17:46   ` [PATCH v2 11/83] app/pdump: " Stephen Hemminger
                     ` (73 subsequent siblings)
  83 siblings, 1 reply; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Maxime Coquelin, Chenbo Xia

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 examples/vhost_blk/vhost_blk.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/examples/vhost_blk/vhost_blk.c b/examples/vhost_blk/vhost_blk.c
index feadacc62ee5..2cab1e6994fe 100644
--- a/examples/vhost_blk/vhost_blk.c
+++ b/examples/vhost_blk/vhost_blk.c
@@ -849,8 +849,7 @@ static void
 vhost_blk_ctrlr_destroy(struct vhost_blk_ctrlr *ctrlr)
 {
 	if (ctrlr->bdev != NULL) {
-		if (ctrlr->bdev->data != NULL)
-			rte_free(ctrlr->bdev->data);
+		rte_free(ctrlr->bdev->data);
 
 		rte_free(ctrlr->bdev);
 	}
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 11/83] app/pdump: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (9 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 10/83] examples/vhost_blk: " Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-24 17:46   ` [PATCH v2 12/83] app/test-crypto-perf: " Stephen Hemminger
                     ` (72 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Reshma Pattan

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/pdump/main.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/app/pdump/main.c b/app/pdump/main.c
index 46f9d25db004..04a38e891119 100644
--- a/app/pdump/main.c
+++ b/app/pdump/main.c
@@ -502,14 +502,11 @@ cleanup_rings(void)
 	for (i = 0; i < num_tuples; i++) {
 		pt = &pdump_t[i];
 
-		if (pt->device_id)
-			free(pt->device_id);
+		free(pt->device_id);
 
 		/* free the rings */
-		if (pt->rx_ring)
-			rte_ring_free(pt->rx_ring);
-		if (pt->tx_ring)
-			rte_ring_free(pt->tx_ring);
+		rte_ring_free(pt->rx_ring);
+		rte_ring_free(pt->tx_ring);
 	}
 }
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 12/83] app/test-crypto-perf: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (10 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 11/83] app/pdump: " Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-24 17:46   ` [PATCH v2 13/83] app/test-pmd: " Stephen Hemminger
                     ` (71 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Ciara Power, Declan Doherty

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Ciara Power <ciara.power@intel.com>
---
 app/test-crypto-perf/cperf_test_latency.c        | 3 +--
 app/test-crypto-perf/cperf_test_pmd_cyclecount.c | 9 +++------
 app/test-crypto-perf/cperf_test_throughput.c     | 3 +--
 app/test-crypto-perf/cperf_test_vector_parsing.c | 6 ++----
 app/test-crypto-perf/cperf_test_verify.c         | 3 +--
 5 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/app/test-crypto-perf/cperf_test_latency.c b/app/test-crypto-perf/cperf_test_latency.c
index ce49feaba9f3..4c7bc72eb5fd 100644
--- a/app/test-crypto-perf/cperf_test_latency.c
+++ b/app/test-crypto-perf/cperf_test_latency.c
@@ -49,8 +49,7 @@ cperf_latency_test_free(struct cperf_latency_ctx *ctx)
 			rte_cryptodev_sym_session_free(ctx->sess);
 		}
 
-		if (ctx->pool)
-			rte_mempool_free(ctx->pool);
+		rte_mempool_free(ctx->pool);
 
 		rte_free(ctx->res);
 		rte_free(ctx);
diff --git a/app/test-crypto-perf/cperf_test_pmd_cyclecount.c b/app/test-crypto-perf/cperf_test_pmd_cyclecount.c
index 5842f29d43e2..6b4d09e623eb 100644
--- a/app/test-crypto-perf/cperf_test_pmd_cyclecount.c
+++ b/app/test-crypto-perf/cperf_test_pmd_cyclecount.c
@@ -79,14 +79,11 @@ cperf_pmd_cyclecount_test_free(struct cperf_pmd_cyclecount_ctx *ctx)
 		}
 	}
 
-	if (ctx->pool)
-		rte_mempool_free(ctx->pool);
+	rte_mempool_free(ctx->pool);
 
-	if (ctx->ops)
-		rte_free(ctx->ops);
+	rte_free(ctx->ops);
 
-	if (ctx->ops_processed)
-		rte_free(ctx->ops_processed);
+	rte_free(ctx->ops_processed);
 
 	rte_free(ctx);
 }
diff --git a/app/test-crypto-perf/cperf_test_throughput.c b/app/test-crypto-perf/cperf_test_throughput.c
index 51512af2ad81..51fad5a05505 100644
--- a/app/test-crypto-perf/cperf_test_throughput.c
+++ b/app/test-crypto-perf/cperf_test_throughput.c
@@ -57,8 +57,7 @@ cperf_throughput_test_free(struct cperf_throughput_ctx *ctx)
 			rte_cryptodev_sym_session_free(ctx->sess);
 		}
 	}
-	if (ctx->pool)
-		rte_mempool_free(ctx->pool);
+	rte_mempool_free(ctx->pool);
 
 	rte_free(ctx);
 }
diff --git a/app/test-crypto-perf/cperf_test_vector_parsing.c b/app/test-crypto-perf/cperf_test_vector_parsing.c
index 1e9dfcfff087..87f3a90055aa 100644
--- a/app/test-crypto-perf/cperf_test_vector_parsing.c
+++ b/app/test-crypto-perf/cperf_test_vector_parsing.c
@@ -551,10 +551,8 @@ parse_file(struct cperf_test_vector *vector, struct cperf_options *opts)
 err:
 	if (fp)
 		fclose(fp);
-	if (line)
-		free(line);
-	if (entry)
-		rte_free(entry);
+	free(line);
+	rte_free(entry);
 
 	return -1;
 }
diff --git a/app/test-crypto-perf/cperf_test_verify.c b/app/test-crypto-perf/cperf_test_verify.c
index 496eb0de00f0..c031330afcfe 100644
--- a/app/test-crypto-perf/cperf_test_verify.c
+++ b/app/test-crypto-perf/cperf_test_verify.c
@@ -42,8 +42,7 @@ cperf_verify_test_free(struct cperf_verify_ctx *ctx)
 			rte_cryptodev_sym_session_free(ctx->sess);
 		}
 
-		if (ctx->pool)
-			rte_mempool_free(ctx->pool);
+		rte_mempool_free(ctx->pool);
 
 		rte_free(ctx);
 	}
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 13/83] app/test-pmd: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (11 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 12/83] app/test-crypto-perf: " Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-24 17:46   ` [PATCH v2 14/83] app/test-regex: " Stephen Hemminger
                     ` (70 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Xiaoyun Li, Aman Singh, Yuying Zhang

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/test-pmd/cmd_flex_item.c | 3 +--
 app/test-pmd/cmdline.c       | 3 +--
 app/test-pmd/testpmd.c       | 3 +--
 3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/app/test-pmd/cmd_flex_item.c b/app/test-pmd/cmd_flex_item.c
index 908bcb3f47f8..9050825a81d7 100644
--- a/app/test-pmd/cmd_flex_item.c
+++ b/app/test-pmd/cmd_flex_item.c
@@ -364,8 +364,7 @@ flex_item_create(portid_t port_id, uint16_t flex_id, const char *filename)
 		       flow_error.message ? flow_error.message : "");
 	}
 out:
-	if (fp)
-		free(fp);
+	free(fp);
 }
 
 #else /* RTE_HAS_JANSSON */
diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index e626b1c7d9ee..298a594e709b 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -14696,8 +14696,7 @@ cmd_ddp_info_parsed(
 
 	ret = 0;
 no_print_return:
-	if (proto)
-		free(proto);
+	free(proto);
 #endif
 	if (ret == -ENOTSUP)
 		fprintf(stderr, "Function not supported in PMD\n");
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 6c387bde84e5..31efa0fe61e5 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -902,8 +902,7 @@ create_extmem(uint32_t nb_mbufs, uint32_t mbuf_sz, struct extmem_param *param,
 
 	return 0;
 fail:
-	if (iovas)
-		free(iovas);
+	free(iovas);
 	if (addr)
 		munmap(addr, mem_sz);
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 14/83] app/test-regex: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (12 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 13/83] app/test-pmd: " Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-24 17:46   ` [PATCH v2 15/83] app/test: " Stephen Hemminger
                     ` (69 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Ori Kam

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/test-regex/main.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/app/test-regex/main.c b/app/test-regex/main.c
index 8e665df73ce0..ab8a3e56e774 100644
--- a/app/test-regex/main.c
+++ b/app/test-regex/main.c
@@ -210,8 +210,7 @@ read_file(char *file, char **buf)
 	printf("Error, can't open file %s\n, err = %d", file, res);
 	if (fp)
 		fclose(fp);
-	if (*buf)
-		rte_free(*buf);
+	rte_free(*buf);
 	return -res;
 }
 
@@ -299,8 +298,7 @@ init_port(uint16_t *nb_max_payload, char *rules_file, uint8_t *nb_max_matches,
 	rte_free(rules);
 	return 0;
 error:
-	if (rules)
-		rte_free(rules);
+	rte_free(rules);
 	return res;
 }
 
@@ -367,8 +365,7 @@ regex_create_segmented_mbuf(struct rte_mempool *mbuf_pool, int pkt_len,
 	return mbuf;
 
 fail:
-	if (mbuf)
-		rte_pktmbuf_free(mbuf);
+	rte_pktmbuf_free(mbuf);
 	return NULL;
 }
 
@@ -612,8 +609,7 @@ run_regex(void *args)
 		rte_free(qp->buf);
 		qp->buf = NULL;
 	}
-	if (mbuf_mp)
-		rte_mempool_free(mbuf_mp);
+	rte_mempool_free(mbuf_mp);
 	rte_free(qps);
 	return res;
 }
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 15/83] app/test: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (13 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 14/83] app/test-regex: " Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-24 17:46   ` [PATCH v2 16/83] baseband/acc100 " Stephen Hemminger
                     ` (68 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Olivier Matz, Fan Zhang, Ashish Gupta,
	Akhil Goyal, Declan Doherty, Bruce Richardson,
	Vladimir Medvedkin, Yipeng Wang, Sameh Gobriel,
	Honnappa Nagarahalli, Konstantin Ananyev, Andrew Rybchenko,
	Anatoly Burakov, Chas Williams, Min Hu (Connor),
	Reshma Pattan

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/test/test_cksum.c                 |  3 +-
 app/test/test_compressdev.c           |  3 +-
 app/test/test_cryptodev.h             |  3 +-
 app/test/test_cryptodev_asym.c        |  3 +-
 app/test/test_cryptodev_blockcipher.c | 12 +++----
 app/test/test_func_reentrancy.c       | 15 +++------
 app/test/test_hash.c                  | 15 +++------
 app/test/test_hash_perf.c             |  7 +----
 app/test/test_link_bonding.c          |  9 ++----
 app/test/test_link_bonding_mode4.c    |  3 +-
 app/test/test_malloc.c                |  5 ++-
 app/test/test_mbuf.c                  | 45 +++++++++------------------
 app/test/test_pcapng.c                |  3 +-
 app/test/test_reorder.c               | 15 +++------
 app/test/virtual_pmd.c                |  3 +-
 15 files changed, 47 insertions(+), 97 deletions(-)

diff --git a/app/test/test_cksum.c b/app/test/test_cksum.c
index cd983d7c01ce..6c15de9a9312 100644
--- a/app/test/test_cksum.c
+++ b/app/test/test_cksum.c
@@ -218,8 +218,7 @@ test_l4_cksum(struct rte_mempool *pktmbuf_pool, const char *pktdata, size_t len)
 	return 0;
 
 fail:
-	if (m)
-		rte_pktmbuf_free(m);
+	rte_pktmbuf_free(m);
 
 	return -1;
 }
diff --git a/app/test/test_compressdev.c b/app/test/test_compressdev.c
index 57c566aa9229..fbecaf9aaad4 100644
--- a/app/test/test_compressdev.c
+++ b/app/test/test_compressdev.c
@@ -2144,8 +2144,7 @@ test_deflate_comp_decomp(const struct interim_data_params *int_data,
 
 	if (stream != NULL)
 		rte_compressdev_stream_free(0, stream);
-	if (all_decomp_data != NULL)
-		rte_free(all_decomp_data);
+	rte_free(all_decomp_data);
 
 	/* Free compress private xforms */
 	for (i = 0; i < test_priv_data.num_priv_xforms; i++) {
diff --git a/app/test/test_cryptodev.h b/app/test/test_cryptodev.h
index 70f23a3f67d0..29a7d4db2b10 100644
--- a/app/test/test_cryptodev.h
+++ b/app/test/test_cryptodev.h
@@ -230,8 +230,7 @@ create_segmented_mbuf(struct rte_mempool *mbuf_pool, int pkt_len,
 	return mbuf;
 
 fail:
-	if (mbuf)
-		rte_pktmbuf_free(mbuf);
+	rte_pktmbuf_free(mbuf);
 	return NULL;
 }
 
diff --git a/app/test/test_cryptodev_asym.c b/app/test/test_cryptodev_asym.c
index 68f4d8e7a6f9..8c68a12d74b2 100644
--- a/app/test/test_cryptodev_asym.c
+++ b/app/test/test_cryptodev_asym.c
@@ -518,8 +518,7 @@ test_cryptodev_asym_op(struct crypto_testsuite_params_asym *ts_params,
 		if (op != NULL)
 			rte_crypto_op_free(op);
 
-		if (result != NULL)
-			rte_free(result);
+		rte_free(result);
 
 	return status;
 }
diff --git a/app/test/test_cryptodev_blockcipher.c b/app/test/test_cryptodev_blockcipher.c
index 5688a45377b2..127e2a53d379 100644
--- a/app/test/test_cryptodev_blockcipher.c
+++ b/app/test/test_cryptodev_blockcipher.c
@@ -805,20 +805,16 @@ test_blockcipher_one_case(const struct blockcipher_test_case *t,
 			rte_cryptodev_sym_session_clear(dev_id, sess);
 			rte_cryptodev_sym_session_free(sess);
 		}
-		if (cipher_xform)
-			rte_free(cipher_xform);
-		if (auth_xform)
-			rte_free(auth_xform);
+		rte_free(cipher_xform);
+		rte_free(auth_xform);
 	}
 
 	if (op)
 		rte_crypto_op_free(op);
 
-	if (obuf)
-		rte_pktmbuf_free(obuf);
+	rte_pktmbuf_free(obuf);
 
-	if (ibuf)
-		rte_pktmbuf_free(ibuf);
+	rte_pktmbuf_free(ibuf);
 
 	return status;
 }
diff --git a/app/test/test_func_reentrancy.c b/app/test/test_func_reentrancy.c
index ce40c3ce9631..64f27e20370f 100644
--- a/app/test/test_func_reentrancy.c
+++ b/app/test/test_func_reentrancy.c
@@ -89,15 +89,13 @@ ring_clean(unsigned int lcore_id)
 	int i;
 
 	rp = rte_ring_lookup("fr_test_once");
-	if (rp != NULL)
-		rte_ring_free(rp);
+	rte_ring_free(rp);
 
 	for (i = 0; i < MAX_ITER_MULTI; i++) {
 		snprintf(ring_name, sizeof(ring_name),
 				"fr_test_%d_%d", lcore_id, i);
 		rp = rte_ring_lookup(ring_name);
-		if (rp != NULL)
-			rte_ring_free(rp);
+		rte_ring_free(rp);
 	}
 }
 
@@ -152,15 +150,13 @@ mempool_clean(unsigned int lcore_id)
 	int i;
 
 	mp = rte_mempool_lookup("fr_test_once");
-	if (mp != NULL)
-		rte_mempool_free(mp);
+	rte_mempool_free(mp);
 
 	for (i = 0; i < MAX_ITER_MULTI; i++) {
 		snprintf(mempool_name, sizeof(mempool_name), "fr_test_%d_%d",
 			 lcore_id, i);
 		mp = rte_mempool_lookup(mempool_name);
-		if (mp != NULL)
-			rte_mempool_free(mp);
+		rte_mempool_free(mp);
 	}
 }
 
@@ -215,8 +211,7 @@ hash_clean(unsigned lcore_id)
 	int i;
 
 	handle = rte_hash_find_existing("fr_test_once");
-	if (handle != NULL)
-		rte_hash_free(handle);
+	rte_hash_free(handle);
 
 	for (i = 0; i < MAX_ITER_MULTI; i++) {
 		snprintf(hash_name, sizeof(hash_name), "fr_test_%d_%d",  lcore_id, i);
diff --git a/app/test/test_hash.c b/app/test/test_hash.c
index b99e8de1db71..d522cb7f8cbf 100644
--- a/app/test/test_hash.c
+++ b/app/test/test_hash.c
@@ -1654,8 +1654,7 @@ test_hash_add_delete_jhash2(void)
 	ret = 0;
 
 fail_jhash2:
-	if (handle != NULL)
-		rte_hash_free(handle);
+	rte_hash_free(handle);
 
 	return ret;
 }
@@ -1689,8 +1688,7 @@ test_hash_add_delete_2_jhash2(void)
 	ret = 0;
 
 fail_2_jhash2:
-	if (handle != NULL)
-		rte_hash_free(handle);
+	rte_hash_free(handle);
 
 	return ret;
 }
@@ -1754,8 +1752,7 @@ test_hash_add_delete_jhash_1word(void)
 	ret = 0;
 
 fail_jhash_1word:
-	if (handle != NULL)
-		rte_hash_free(handle);
+	rte_hash_free(handle);
 
 	return ret;
 }
@@ -1789,8 +1786,7 @@ test_hash_add_delete_jhash_2word(void)
 	ret = 0;
 
 fail_jhash_2word:
-	if (handle != NULL)
-		rte_hash_free(handle);
+	rte_hash_free(handle);
 
 	return ret;
 }
@@ -1824,8 +1820,7 @@ test_hash_add_delete_jhash_3word(void)
 	ret = 0;
 
 fail_jhash_3word:
-	if (handle != NULL)
-		rte_hash_free(handle);
+	rte_hash_free(handle);
 
 	return ret;
 }
diff --git a/app/test/test_hash_perf.c b/app/test/test_hash_perf.c
index 76cdac5d5320..287f486316f1 100644
--- a/app/test/test_hash_perf.c
+++ b/app/test/test_hash_perf.c
@@ -106,12 +106,7 @@ create_table(unsigned int with_data, unsigned int table_index,
 	ut_params.key_len = hashtest_key_lens[table_index];
 	ut_params.socket_id = rte_socket_id();
 	h[table_index] = rte_hash_find_existing(name);
-	if (h[table_index] != NULL)
-		/*
-		 * If table was already created, free it to create it again,
-		 * so we force it is empty
-		 */
-		rte_hash_free(h[table_index]);
+	rte_hash_free(h[table_index]);
 	h[table_index] = rte_hash_create(&ut_params);
 	if (h[table_index] == NULL) {
 		printf("Error creating table\n");
diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index dc6fc46b9c93..82a9b8e01a82 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -1639,8 +1639,7 @@ test_roundrobin_rx_burst_on_single_slave(void)
 
 	/* free mbufs */
 	for (i = 0; i < MAX_PKT_BURST; i++) {
-		if (rx_pkt_burst[i] != NULL)
-			rte_pktmbuf_free(rx_pkt_burst[i]);
+		rte_pktmbuf_free(rx_pkt_burst[i]);
 	}
 
 
@@ -1722,8 +1721,7 @@ test_roundrobin_rx_burst_on_multiple_slaves(void)
 
 	/* free mbufs */
 	for (i = 0; i < MAX_PKT_BURST; i++) {
-		if (rx_pkt_burst[i] != NULL)
-			rte_pktmbuf_free(rx_pkt_burst[i]);
+		rte_pktmbuf_free(rx_pkt_burst[i]);
 	}
 
 	/* Clean up and remove slaves from bonded device */
@@ -2010,8 +2008,7 @@ test_roundrobin_verify_slave_link_status_change_behaviour(void)
 
 	/* free mbufs */
 	for (i = 0; i < MAX_PKT_BURST; i++) {
-		if (rx_pkt_burst[i] != NULL)
-			rte_pktmbuf_free(rx_pkt_burst[i]);
+		rte_pktmbuf_free(rx_pkt_burst[i]);
 	}
 
 	/* Clean up and remove slaves from bonded device */
diff --git a/app/test/test_link_bonding_mode4.c b/app/test/test_link_bonding_mode4.c
index 351129de2f9b..d9b9c323c7f8 100644
--- a/app/test/test_link_bonding_mode4.c
+++ b/app/test/test_link_bonding_mode4.c
@@ -194,8 +194,7 @@ free_pkts(struct rte_mbuf **pkts, uint16_t count)
 	uint16_t i;
 
 	for (i = 0; i < count; i++) {
-		if (pkts[i] != NULL)
-			rte_pktmbuf_free(pkts[i]);
+		rte_pktmbuf_free(pkts[i]);
 	}
 }
 
diff --git a/app/test/test_malloc.c b/app/test/test_malloc.c
index 6d9249f831be..d424d7808af3 100644
--- a/app/test/test_malloc.c
+++ b/app/test/test_malloc.c
@@ -812,7 +812,7 @@ test_zero_aligned_alloc(void)
 
 err_return:
 	/*clean up */
-	if (p1) rte_free(p1);
+	rte_free(p1);
 	return -1;
 }
 
@@ -865,8 +865,7 @@ test_malloc_bad_params(void)
 
 err_return:
 	/* clean up pointer */
-	if (bad_ptr)
-		rte_free(bad_ptr);
+	rte_free(bad_ptr);
 	return -1;
 }
 
diff --git a/app/test/test_mbuf.c b/app/test/test_mbuf.c
index f54d1d7c006a..daebf09d44b7 100644
--- a/app/test/test_mbuf.c
+++ b/app/test/test_mbuf.c
@@ -304,8 +304,7 @@ test_one_pktmbuf(struct rte_mempool *pktmbuf_pool)
 	return 0;
 
 fail:
-	if (m)
-		rte_pktmbuf_free(m);
+	rte_pktmbuf_free(m);
 	return -1;
 }
 
@@ -416,12 +415,9 @@ testclone_testupdate_testdetach(struct rte_mempool *pktmbuf_pool,
 	return 0;
 
 fail:
-	if (m)
-		rte_pktmbuf_free(m);
-	if (clone)
-		rte_pktmbuf_free(clone);
-	if (clone2)
-		rte_pktmbuf_free(clone2);
+	rte_pktmbuf_free(m);
+	rte_pktmbuf_free(clone);
+	rte_pktmbuf_free(clone2);
 	return -1;
 }
 
@@ -572,12 +568,9 @@ test_pktmbuf_copy(struct rte_mempool *pktmbuf_pool,
 	return 0;
 
 fail:
-	if (m)
-		rte_pktmbuf_free(m);
-	if (copy)
-		rte_pktmbuf_free(copy);
-	if (copy2)
-		rte_pktmbuf_free(copy2);
+	rte_pktmbuf_free(m);
+	rte_pktmbuf_free(copy);
+	rte_pktmbuf_free(copy2);
 	return -1;
 }
 
@@ -679,12 +672,9 @@ test_attach_from_different_pool(struct rte_mempool *pktmbuf_pool,
 	return 0;
 
 fail:
-	if (m)
-		rte_pktmbuf_free(m);
-	if (clone)
-		rte_pktmbuf_free(clone);
-	if (clone2)
-		rte_pktmbuf_free(clone2);
+	rte_pktmbuf_free(m);
+	rte_pktmbuf_free(clone);
+	rte_pktmbuf_free(clone2);
 	return -1;
 }
 
@@ -722,8 +712,7 @@ test_pktmbuf_pool(struct rte_mempool *pktmbuf_pool)
 	}
 	/* free them */
 	for (i=0; i<NB_MBUF; i++) {
-		if (m[i] != NULL)
-			rte_pktmbuf_free(m[i]);
+		rte_pktmbuf_free(m[i]);
 	}
 
 	return ret;
@@ -924,8 +913,7 @@ test_pktmbuf_pool_ptr(struct rte_mempool *pktmbuf_pool)
 
 	/* free them */
 	for (i=0; i<NB_MBUF; i++) {
-		if (m[i] != NULL)
-			rte_pktmbuf_free(m[i]);
+		rte_pktmbuf_free(m[i]);
 	}
 
 	for (i=0; i<NB_MBUF; i++)
@@ -947,8 +935,7 @@ test_pktmbuf_pool_ptr(struct rte_mempool *pktmbuf_pool)
 
 	/* free them */
 	for (i=0; i<NB_MBUF; i++) {
-		if (m[i] != NULL)
-			rte_pktmbuf_free(m[i]);
+		rte_pktmbuf_free(m[i]);
 	}
 
 	return ret;
@@ -1355,8 +1342,7 @@ test_mbuf_linearize(struct rte_mempool *pktmbuf_pool, int pkt_len,
 	return 0;
 
 fail:
-	if (mbuf)
-		rte_pktmbuf_free(mbuf);
+	rte_pktmbuf_free(mbuf);
 	return -1;
 }
 
@@ -2772,8 +2758,7 @@ test_nb_segs_and_next_reset(void)
 	return 0;
 
 fail:
-	if (pool != NULL)
-		rte_mempool_free(pool);
+	rte_mempool_free(pool);
 	return -1;
 }
 
diff --git a/app/test/test_pcapng.c b/app/test/test_pcapng.c
index 34c5e1234695..320dacea3498 100644
--- a/app/test/test_pcapng.c
+++ b/app/test/test_pcapng.c
@@ -240,8 +240,7 @@ test_validate(void)
 static void
 test_cleanup(void)
 {
-	if (mp)
-		rte_mempool_free(mp);
+	rte_mempool_free(mp);
 
 	if (pcapng)
 		rte_pcapng_close(pcapng);
diff --git a/app/test/test_reorder.c b/app/test/test_reorder.c
index 1c4226da6501..962c31953f91 100644
--- a/app/test/test_reorder.c
+++ b/app/test/test_reorder.c
@@ -208,8 +208,7 @@ test_reorder_insert(void)
 exit:
 	rte_reorder_free(b);
 	for (i = 0; i < num_bufs; i++) {
-		if (bufs[i] != NULL)
-			rte_pktmbuf_free(bufs[i]);
+		rte_pktmbuf_free(bufs[i]);
 	}
 	return ret;
 }
@@ -268,8 +267,7 @@ test_reorder_drain(void)
 		ret = -1;
 		goto exit;
 	}
-	if (robufs[0] != NULL)
-		rte_pktmbuf_free(robufs[0]);
+	rte_pktmbuf_free(robufs[0]);
 
 	/* Insert more packets
 	 * RB[] = {NULL, NULL, NULL, NULL}
@@ -303,8 +301,7 @@ test_reorder_drain(void)
 		goto exit;
 	}
 	for (i = 0; i < 3; i++) {
-		if (robufs[i] != NULL)
-			rte_pktmbuf_free(robufs[i]);
+		rte_pktmbuf_free(robufs[i]);
 	}
 
 	/*
@@ -322,10 +319,8 @@ test_reorder_drain(void)
 exit:
 	rte_reorder_free(b);
 	for (i = 0; i < num_bufs; i++) {
-		if (bufs[i] != NULL)
-			rte_pktmbuf_free(bufs[i]);
-		if (robufs[i] != NULL)
-			rte_pktmbuf_free(robufs[i]);
+		rte_pktmbuf_free(bufs[i]);
+		rte_pktmbuf_free(robufs[i]);
 	}
 	return ret;
 }
diff --git a/app/test/virtual_pmd.c b/app/test/virtual_pmd.c
index 3d2793852049..cd4611ab48df 100644
--- a/app/test/virtual_pmd.c
+++ b/app/test/virtual_pmd.c
@@ -397,8 +397,7 @@ virtual_ethdev_tx_burst_fail(void *queue, struct rte_mbuf **bufs,
 		/* free packets in burst */
 		for (i = 0; i < successfully_txd; i++) {
 			/* free packets in burst */
-			if (bufs[i] != NULL)
-				rte_pktmbuf_free(bufs[i]);
+			rte_pktmbuf_free(bufs[i]);
 
 			bufs[i] = NULL;
 		}
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 16/83] baseband/acc100 remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (14 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 15/83] app/test: " Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-24 17:46   ` [PATCH v2 17/83] baseband/la12xx " Stephen Hemminger
                     ` (67 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Nicolas Chautru

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/baseband/acc100/rte_acc100_pmd.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/baseband/acc100/rte_acc100_pmd.c b/drivers/baseband/acc100/rte_acc100_pmd.c
index 1c6080f2f895..f86474f7e099 100644
--- a/drivers/baseband/acc100/rte_acc100_pmd.c
+++ b/drivers/baseband/acc100/rte_acc100_pmd.c
@@ -4402,8 +4402,7 @@ poweron_cleanup(struct rte_bbdev *bbdev, struct acc100_device *d,
 	}
 	printf("Number of 5GUL engines %d\n", numEngines);
 
-	if (d->sw_rings_base != NULL)
-		rte_free(d->sw_rings_base);
+	rte_free(d->sw_rings_base);
 	usleep(ACC100_LONG_WAIT);
 }
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 17/83] baseband/la12xx remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (15 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 16/83] baseband/acc100 " Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-24 17:46   ` [PATCH v2 18/83] baseband/null " Stephen Hemminger
                     ` (66 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Hemant Agrawal, Nipun Gupta, Nicolas Chautru

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by:  Hemant Agrawal <hemant.agrawal@nxp.com>
---
 drivers/baseband/la12xx/bbdev_la12xx.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/baseband/la12xx/bbdev_la12xx.c b/drivers/baseband/la12xx/bbdev_la12xx.c
index 4b05b5d3f2a6..4d1bd16751fe 100644
--- a/drivers/baseband/la12xx/bbdev_la12xx.c
+++ b/drivers/baseband/la12xx/bbdev_la12xx.c
@@ -975,8 +975,7 @@ parse_bbdev_la12xx_params(struct bbdev_la12xx_params *params,
 	}
 
 exit:
-	if (kvlist)
-		rte_kvargs_free(kvlist);
+	rte_kvargs_free(kvlist);
 	return ret;
 }
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 18/83] baseband/null remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (16 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 17/83] baseband/la12xx " Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-24 17:46   ` [PATCH v2 19/83] baseband/turbo_sw " Stephen Hemminger
                     ` (65 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Nicolas Chautru

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/baseband/null/bbdev_null.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/baseband/null/bbdev_null.c b/drivers/baseband/null/bbdev_null.c
index 08cff582b99d..248e12987f03 100644
--- a/drivers/baseband/null/bbdev_null.c
+++ b/drivers/baseband/null/bbdev_null.c
@@ -251,8 +251,7 @@ parse_bbdev_null_params(struct bbdev_null_params *params,
 	}
 
 exit:
-	if (kvlist)
-		rte_kvargs_free(kvlist);
+	rte_kvargs_free(kvlist);
 	return ret;
 }
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 19/83] baseband/turbo_sw remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (17 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 18/83] baseband/null " Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-24 17:46   ` [PATCH v2 20/83] bus/fslmc: " Stephen Hemminger
                     ` (64 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Nicolas Chautru

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/baseband/turbo_sw/bbdev_turbo_software.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/baseband/turbo_sw/bbdev_turbo_software.c b/drivers/baseband/turbo_sw/bbdev_turbo_software.c
index c6b1eb8679cb..af7bc416f92e 100644
--- a/drivers/baseband/turbo_sw/bbdev_turbo_software.c
+++ b/drivers/baseband/turbo_sw/bbdev_turbo_software.c
@@ -1918,8 +1918,7 @@ parse_turbo_sw_params(struct turbo_sw_params *params, const char *input_args)
 	}
 
 exit:
-	if (kvlist)
-		rte_kvargs_free(kvlist);
+	rte_kvargs_free(kvlist);
 	return ret;
 }
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 20/83] bus/fslmc: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (18 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 19/83] baseband/turbo_sw " Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-24 17:46   ` [PATCH v2 21/83] bus/ifpga: " Stephen Hemminger
                     ` (63 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Hemant Agrawal, Sachin Saxena

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by:  Hemant Agrawal <hemant.agrawal@nxp.com>
---
 drivers/bus/fslmc/fslmc_bus.c            | 6 ++----
 drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 6 ++----
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/bus/fslmc/fslmc_bus.c b/drivers/bus/fslmc/fslmc_bus.c
index 53fd75539e98..30d019516b91 100644
--- a/drivers/bus/fslmc/fslmc_bus.c
+++ b/drivers/bus/fslmc/fslmc_bus.c
@@ -223,13 +223,11 @@ scan_one_fslmc_device(char *dev_name)
 	insert_in_device_list(dev);
 
 	/* Don't need the duplicated device filesystem entry anymore */
-	if (dup_dev_name)
-		free(dup_dev_name);
+	free(dup_dev_name);
 
 	return 0;
 cleanup:
-	if (dup_dev_name)
-		free(dup_dev_name);
+	free(dup_dev_name);
 	if (dev) {
 		rte_intr_instance_free(dev->intr_handle);
 		free(dev);
diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
index 52605ea2c32c..943fadee4816 100644
--- a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
+++ b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
@@ -149,8 +149,7 @@ dpaa2_affine_dpio_intr_to_respective_core(int32_t dpio_id, int cpu_id)
 	if (!token) {
 		DPAA2_BUS_WARN("Failed to get interrupt id for dpio.%d",
 			       dpio_id);
-		if (temp)
-			free(temp);
+		free(temp);
 		fclose(file);
 		return;
 	}
@@ -574,8 +573,7 @@ dpaa2_free_dq_storage(struct queue_storage_info_t *q_storage)
 	int i = 0;
 
 	for (i = 0; i < NUM_DQS_PER_QUEUE; i++) {
-		if (q_storage->dq_storage[i])
-			rte_free(q_storage->dq_storage[i]);
+		rte_free(q_storage->dq_storage[i]);
 	}
 }
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 21/83] bus/ifpga: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (19 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 20/83] bus/fslmc: " Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-24 17:46   ` [PATCH v2 22/83] bus/pci: " Stephen Hemminger
                     ` (62 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Rosen Xu

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/bus/ifpga/ifpga_bus.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/bus/ifpga/ifpga_bus.c b/drivers/bus/ifpga/ifpga_bus.c
index c5c8bbd57219..e005f2cb70b3 100644
--- a/drivers/bus/ifpga/ifpga_bus.c
+++ b/drivers/bus/ifpga/ifpga_bus.c
@@ -191,10 +191,8 @@ ifpga_scan_one(struct rte_rawdev *rawdev,
 	return afu_dev;
 
 end:
-	if (kvlist)
-		rte_kvargs_free(kvlist);
-	if (path)
-		free(path);
+	rte_kvargs_free(kvlist);
+	free(path);
 	if (afu_dev) {
 		rte_intr_instance_free(afu_dev->intr_handle);
 		free(afu_dev);
@@ -254,10 +252,8 @@ ifpga_scan(void)
 	}
 
 end:
-	if (kvlist)
-		rte_kvargs_free(kvlist);
-	if (name)
-		free(name);
+	rte_kvargs_free(kvlist);
+	free(name);
 
 	return 0;
 }
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 22/83] bus/pci: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (20 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 21/83] bus/ifpga: " Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-24 17:46   ` [PATCH v2 23/83] common/cpt: " Stephen Hemminger
                     ` (61 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/bus/pci/pci_params.c         | 3 +--
 drivers/bus/pci/windows/pci.c        | 3 +--
 drivers/bus/pci/windows/pci_netuio.c | 3 +--
 3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/bus/pci/pci_params.c b/drivers/bus/pci/pci_params.c
index 60b424b8297e..61a868707f16 100644
--- a/drivers/bus/pci/pci_params.c
+++ b/drivers/bus/pci/pci_params.c
@@ -117,8 +117,7 @@ rte_pci_devargs_parse(struct rte_devargs *da)
 	rte_pci_device_name(&addr, da->name, sizeof(da->name));
 
 out:
-	if (kvargs != NULL)
-		rte_kvargs_free(kvargs);
+	rte_kvargs_free(kvargs);
 	if (ret != 0)
 		rte_errno = -ret;
 	return ret;
diff --git a/drivers/bus/pci/windows/pci.c b/drivers/bus/pci/windows/pci.c
index 39ba31be7d38..7bf091158ba2 100644
--- a/drivers/bus/pci/windows/pci.c
+++ b/drivers/bus/pci/windows/pci.c
@@ -418,8 +418,7 @@ pci_scan_one(HDEVINFO dev_info, PSP_DEVINFO_DATA device_info_data)
 
 	return 0;
 end:
-	if (dev)
-		free(dev);
+	free(dev);
 	return ret;
 }
 
diff --git a/drivers/bus/pci/windows/pci_netuio.c b/drivers/bus/pci/windows/pci_netuio.c
index a0b175a8fca0..5460399eea5f 100644
--- a/drivers/bus/pci/windows/pci_netuio.c
+++ b/drivers/bus/pci/windows/pci_netuio.c
@@ -180,8 +180,7 @@ get_netuio_device_info(HDEVINFO dev_info, PSP_DEVINFO_DATA dev_info_data,
 			CloseHandle(netuio);
 	}
 
-	if (dev_ifx_detail)
-		free(dev_ifx_detail);
+	free(dev_ifx_detail);
 
 	if (di_set != INVALID_HANDLE_VALUE)
 		SetupDiDestroyDeviceInfoList(di_set);
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 23/83] common/cpt: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (21 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 22/83] bus/pci: " Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-24 17:46   ` [PATCH v2 24/83] common/dpaax: simplify kernel compat macros Stephen Hemminger
                     ` (60 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Anoob Joseph

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/common/cpt/cpt_ucode_asym.h | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/common/cpt/cpt_ucode_asym.h b/drivers/common/cpt/cpt_ucode_asym.h
index f0b5dddd8cdf..f5d91f2583bd 100644
--- a/drivers/common/cpt/cpt_ucode_asym.h
+++ b/drivers/common/cpt/cpt_ucode_asym.h
@@ -192,13 +192,11 @@ cpt_free_asym_session_parameters(struct cpt_asym_sess_misc *sess)
 	switch (sess->xfrm_type) {
 	case RTE_CRYPTO_ASYM_XFORM_RSA:
 		rsa = &sess->rsa_ctx;
-		if (rsa->n.data)
-			rte_free(rsa->n.data);
+		rte_free(rsa->n.data);
 		break;
 	case RTE_CRYPTO_ASYM_XFORM_MODEX:
 		mod = &sess->mod_ctx;
-		if (mod->modulus.data)
-			rte_free(mod->modulus.data);
+		rte_free(mod->modulus.data);
 		break;
 	case RTE_CRYPTO_ASYM_XFORM_ECDSA:
 		/* Fall through */
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 24/83] common/dpaax: simplify kernel compat macros
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (22 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 23/83] common/cpt: " Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-24 17:46   ` [PATCH v2 25/83] common/mlx5: remove unnecessary NULL checks Stephen Hemminger
                     ` (59 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Hemant Agrawal, Sachin Saxena

The compat wrapper had unnecessary NULL check and also
the emulation of kzalloc() should just use equivalent rte_zmalloc().

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/common/dpaax/compat.h | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/common/dpaax/compat.h b/drivers/common/dpaax/compat.h
index 7166f8cceb41..cbabc1588b21 100644
--- a/drivers/common/dpaax/compat.h
+++ b/drivers/common/dpaax/compat.h
@@ -339,16 +339,9 @@ static inline void copy_bytes(void *dest, const void *src, size_t sz)
 
 /* Allocator stuff */
 #define kmalloc(sz, t)	rte_malloc(NULL, sz, 0)
+#define kzalloc(sz, t)  rte_zmalloc(NULL, sz, 0)
 #define vmalloc(sz)	rte_malloc(NULL, sz, 0)
-#define kfree(p)	{ if (p) rte_free(p); }
-static inline void *kzalloc(size_t sz, gfp_t __foo __rte_unused)
-{
-	void *ptr = rte_malloc(NULL, sz, 0);
-
-	if (ptr)
-		memset(ptr, 0, sz);
-	return ptr;
-}
+#define kfree(p)	rte_free(p)
 
 static inline unsigned long get_zeroed_page(gfp_t __foo __rte_unused)
 {
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 25/83] common/mlx5: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (23 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 24/83] common/dpaax: simplify kernel compat macros Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-24 17:46   ` [PATCH v2 26/83] common/qat: " Stephen Hemminger
                     ` (58 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Matan Azrad, Viacheslav Ovsiienko

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/common/mlx5/mlx5_common_mr.c  | 3 +--
 drivers/common/mlx5/mlx5_common_pci.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/common/mlx5/mlx5_common_mr.c b/drivers/common/mlx5/mlx5_common_mr.c
index 1537b5d42879..07f76a10655f 100644
--- a/drivers/common/mlx5/mlx5_common_mr.c
+++ b/drivers/common/mlx5/mlx5_common_mr.c
@@ -516,8 +516,7 @@ mlx5_mr_free(struct mlx5_mr *mr, mlx5_dereg_mr_t dereg_mr_cb)
 		return;
 	DRV_LOG(DEBUG, "freeing MR(%p):", (void *)mr);
 	dereg_mr_cb(&mr->pmd_mr);
-	if (mr->ms_bmp != NULL)
-		rte_bitmap_free(mr->ms_bmp);
+	rte_bitmap_free(mr->ms_bmp);
 	mlx5_free(mr);
 }
 
diff --git a/drivers/common/mlx5/mlx5_common_pci.c b/drivers/common/mlx5/mlx5_common_pci.c
index 8b38091d8741..458630351cd1 100644
--- a/drivers/common/mlx5/mlx5_common_pci.c
+++ b/drivers/common/mlx5/mlx5_common_pci.c
@@ -97,8 +97,7 @@ pci_ids_table_update(const struct rte_pci_id *driver_id_table)
 	updated_table[i].vendor_id = 0;
 	mlx5_common_pci_driver.id_table = updated_table;
 	mlx5_pci_id_table = updated_table;
-	if (old_table)
-		free(old_table);
+	free(old_table);
 	return 0;
 }
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 26/83] common/qat: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (24 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 25/83] common/mlx5: remove unnecessary NULL checks Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-24 17:46   ` [PATCH v2 27/83] compress/mlx5: " Stephen Hemminger
                     ` (57 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Fiona Trahe, John Griffin, Deepak Kumar Jain

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/common/qat/qat_qp.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/common/qat/qat_qp.c b/drivers/common/qat/qat_qp.c
index cde421eb7716..57ac8fefca3d 100644
--- a/drivers/common/qat/qat_qp.c
+++ b/drivers/common/qat/qat_qp.c
@@ -175,11 +175,9 @@ qat_qp_setup(struct qat_pci_device *qat_dev,
 
 create_err:
 	if (qp) {
-		if (qp->op_cookie_pool)
-			rte_mempool_free(qp->op_cookie_pool);
+		rte_mempool_free(qp->op_cookie_pool);
 
-		if (qp->op_cookies)
-			rte_free(qp->op_cookies);
+		rte_free(qp->op_cookies);
 
 		rte_free(qp);
 	}
@@ -329,8 +327,7 @@ qat_qp_release(enum qat_device_gen qat_dev_gen, struct qat_qp **qp_addr)
 	for (i = 0; i < qp->nb_descriptors; i++)
 		rte_mempool_put(qp->op_cookie_pool, qp->op_cookies[i]);
 
-	if (qp->op_cookie_pool)
-		rte_mempool_free(qp->op_cookie_pool);
+	rte_mempool_free(qp->op_cookie_pool);
 
 	rte_free(qp->op_cookies);
 	rte_free(qp);
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 27/83] compress/mlx5: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (25 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 26/83] common/qat: " Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-24 17:46   ` [PATCH v2 28/83] compress/octeontx: " Stephen Hemminger
                     ` (56 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Matan Azrad, Fan Zhang, Ashish Gupta

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/compress/mlx5/mlx5_compress.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/compress/mlx5/mlx5_compress.c b/drivers/compress/mlx5/mlx5_compress.c
index 82b871bd860a..b12951da8b51 100644
--- a/drivers/compress/mlx5/mlx5_compress.c
+++ b/drivers/compress/mlx5/mlx5_compress.c
@@ -146,8 +146,7 @@ mlx5_compress_qp_release(struct rte_compressdev *dev, uint16_t qp_id)
 		void *opaq = qp->opaque_mr.addr;
 
 		mlx5_common_verbs_dereg_mr(&qp->opaque_mr);
-		if (opaq != NULL)
-			rte_free(opaq);
+		rte_free(opaq);
 	}
 	mlx5_mr_btree_free(&qp->mr_ctrl.cache_bh);
 	rte_free(qp);
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 28/83] compress/octeontx: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (26 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 27/83] compress/mlx5: " Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-24 17:46   ` [PATCH v2 29/83] crypto/armv8: " Stephen Hemminger
                     ` (55 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Ashish Gupta, Fan Zhang

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/compress/octeontx/otx_zip_pmd.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/compress/octeontx/otx_zip_pmd.c b/drivers/compress/octeontx/otx_zip_pmd.c
index dd62285b863e..26cdce60a859 100644
--- a/drivers/compress/octeontx/otx_zip_pmd.c
+++ b/drivers/compress/octeontx/otx_zip_pmd.c
@@ -337,8 +337,7 @@ zip_pmd_qp_release(struct rte_compressdev *dev, uint16_t qp_id)
 	if (qp != NULL) {
 		zipvf_q_term(qp);
 
-		if (qp->processed_pkts)
-			rte_ring_free(qp->processed_pkts);
+		rte_ring_free(qp->processed_pkts);
 
 		rte_free(qp);
 		dev->data->queue_pairs[qp_id] = NULL;
@@ -423,10 +422,8 @@ zip_pmd_qp_setup(struct rte_compressdev *dev, uint16_t qp_id,
 	return 0;
 
 qp_setup_cleanup:
-	if (qp->processed_pkts)
-		rte_ring_free(qp->processed_pkts);
-	if (qp)
-		rte_free(qp);
+	rte_ring_free(qp->processed_pkts);
+	rte_free(qp);
 	return -1;
 }
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 29/83] crypto/armv8: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (27 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 28/83] compress/octeontx: " Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-24 17:46   ` [PATCH v2 30/83] crypto/ccp: " Stephen Hemminger
                     ` (54 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Ruifeng Wang

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Ruifeng Wang <ruifeng.wang@arm.com>
---
 drivers/crypto/armv8/rte_armv8_pmd_ops.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/crypto/armv8/rte_armv8_pmd_ops.c b/drivers/crypto/armv8/rte_armv8_pmd_ops.c
index 1b2749fe62c6..c07ac0489e57 100644
--- a/drivers/crypto/armv8/rte_armv8_pmd_ops.c
+++ b/drivers/crypto/armv8/rte_armv8_pmd_ops.c
@@ -251,8 +251,7 @@ armv8_crypto_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 	return 0;
 
 qp_setup_cleanup:
-	if (qp)
-		rte_free(qp);
+	rte_free(qp);
 
 	return -1;
 }
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 30/83] crypto/ccp: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (28 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 29/83] crypto/armv8: " Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-24 17:46   ` [PATCH v2 31/83] crypto/cnxk: " Stephen Hemminger
                     ` (53 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Chandubabu Namburu

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/crypto/ccp/ccp_dev.c     | 3 +--
 drivers/crypto/ccp/ccp_pmd_ops.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/crypto/ccp/ccp_dev.c b/drivers/crypto/ccp/ccp_dev.c
index 0eb1b0328ef0..424ead82c3aa 100644
--- a/drivers/crypto/ccp/ccp_dev.c
+++ b/drivers/crypto/ccp/ccp_dev.c
@@ -673,8 +673,7 @@ ccp_probe_device(int ccp_type, struct rte_pci_device *pci_dev)
 	CCP_LOG_ERR("CCP Device probe failed");
 	if (uio_fd >= 0)
 		close(uio_fd);
-	if (ccp_dev)
-		rte_free(ccp_dev);
+	rte_free(ccp_dev);
 	return -1;
 }
 
diff --git a/drivers/crypto/ccp/ccp_pmd_ops.c b/drivers/crypto/ccp/ccp_pmd_ops.c
index 0d615d311c9b..1b600e81ad5c 100644
--- a/drivers/crypto/ccp/ccp_pmd_ops.c
+++ b/drivers/crypto/ccp/ccp_pmd_ops.c
@@ -744,8 +744,7 @@ ccp_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 
 qp_setup_cleanup:
 	dev->data->queue_pairs[qp_id] = NULL;
-	if (qp)
-		rte_free(qp);
+	rte_free(qp);
 	return -1;
 }
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 31/83] crypto/cnxk: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (29 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 30/83] crypto/ccp: " Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-24 17:46   ` [PATCH v2 32/83] crypto/ipsec_mb: " Stephen Hemminger
                     ` (52 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Ankur Dwivedi, Anoob Joseph, Tejasree Kondoj

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/crypto/cnxk/cnxk_ae.h | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/crypto/cnxk/cnxk_ae.h b/drivers/crypto/cnxk/cnxk_ae.h
index 6222171fe603..01ccfcd33432 100644
--- a/drivers/crypto/cnxk/cnxk_ae.h
+++ b/drivers/crypto/cnxk/cnxk_ae.h
@@ -196,13 +196,11 @@ cnxk_ae_free_session_parameters(struct cnxk_ae_sess *sess)
 	switch (sess->xfrm_type) {
 	case RTE_CRYPTO_ASYM_XFORM_RSA:
 		rsa = &sess->rsa_ctx;
-		if (rsa->n.data)
-			rte_free(rsa->n.data);
+		rte_free(rsa->n.data);
 		break;
 	case RTE_CRYPTO_ASYM_XFORM_MODEX:
 		mod = &sess->mod_ctx;
-		if (mod->modulus.data)
-			rte_free(mod->modulus.data);
+		rte_free(mod->modulus.data);
 		break;
 	case RTE_CRYPTO_ASYM_XFORM_ECDSA:
 		/* Fall through */
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 32/83] crypto/ipsec_mb: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (30 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 31/83] crypto/cnxk: " Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-27 11:08     ` Zhang, Roy Fan
  2022-01-24 17:46   ` [PATCH v2 33/83] crypto/mvsam: " Stephen Hemminger
                     ` (51 subsequent siblings)
  83 siblings, 1 reply; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Fan Zhang, Pablo de Lara

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/crypto/ipsec_mb/ipsec_mb_ops.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/crypto/ipsec_mb/ipsec_mb_ops.c b/drivers/crypto/ipsec_mb/ipsec_mb_ops.c
index 189262c4ad52..f808da9edf89 100644
--- a/drivers/crypto/ipsec_mb/ipsec_mb_ops.c
+++ b/drivers/crypto/ipsec_mb/ipsec_mb_ops.c
@@ -102,8 +102,7 @@ ipsec_mb_qp_release(struct rte_cryptodev *dev, uint16_t qp_id)
 
 	if (qp != NULL && rte_eal_process_type() == RTE_PROC_PRIMARY) {
 		r = rte_ring_lookup(qp->name);
-		if (r)
-			rte_ring_free(r);
+		rte_ring_free(r);
 
 #if IMB_VERSION(1, 1, 0) > IMB_VERSION_NUM
 		if (qp->mb_mgr)
@@ -291,8 +290,7 @@ ipsec_mb_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 	if (qp->mb_mgr_mz)
 		rte_memzone_free(qp->mb_mgr_mz);
 #endif
-	if (qp)
-		rte_free(qp);
+	rte_free(qp);
 	return ret;
 }
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 33/83] crypto/mvsam: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (31 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 32/83] crypto/ipsec_mb: " Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-24 17:46   ` [PATCH v2 34/83] crypto/null: " Stephen Hemminger
                     ` (50 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Liron Himi, Michael Shamis

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Reviewed-by: Liron Himi <lironh@marvell.com>
---
 drivers/crypto/mvsam/rte_mrvl_pmd_ops.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/crypto/mvsam/rte_mrvl_pmd_ops.c b/drivers/crypto/mvsam/rte_mrvl_pmd_ops.c
index 3064b1f136fe..f828dc9db5f6 100644
--- a/drivers/crypto/mvsam/rte_mrvl_pmd_ops.c
+++ b/drivers/crypto/mvsam/rte_mrvl_pmd_ops.c
@@ -774,10 +774,8 @@ mrvl_crypto_pmd_sym_session_configure(__rte_unused struct rte_cryptodev *dev,
 	}
 
 	/* free the keys memory allocated for session creation */
-	if (mrvl_sess->sam_sess_params.cipher_key != NULL)
-		free(mrvl_sess->sam_sess_params.cipher_key);
-	if (mrvl_sess->sam_sess_params.auth_key != NULL)
-		free(mrvl_sess->sam_sess_params.auth_key);
+	free(mrvl_sess->sam_sess_params.cipher_key);
+	free(mrvl_sess->sam_sess_params.auth_key);
 
 	return 0;
 }
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 34/83] crypto/null: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (32 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 33/83] crypto/mvsam: " Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-24 17:46   ` [PATCH v2 35/83] crypto/octeontx: " Stephen Hemminger
                     ` (49 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Declan Doherty

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/crypto/null/null_crypto_pmd_ops.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/crypto/null/null_crypto_pmd_ops.c b/drivers/crypto/null/null_crypto_pmd_ops.c
index a8b5a06e7f4e..90a675dfffe0 100644
--- a/drivers/crypto/null/null_crypto_pmd_ops.c
+++ b/drivers/crypto/null/null_crypto_pmd_ops.c
@@ -135,8 +135,7 @@ null_crypto_pmd_qp_release(struct rte_cryptodev *dev, uint16_t qp_id)
 	if (dev->data->queue_pairs[qp_id] != NULL) {
 		struct null_crypto_qp *qp = dev->data->queue_pairs[qp_id];
 
-		if (qp->processed_pkts)
-			rte_ring_free(qp->processed_pkts);
+		rte_ring_free(qp->processed_pkts);
 
 		rte_free(dev->data->queue_pairs[qp_id]);
 		dev->data->queue_pairs[qp_id] = NULL;
@@ -241,8 +240,7 @@ null_crypto_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 	return 0;
 
 qp_setup_cleanup:
-	if (qp)
-		rte_free(qp);
+	rte_free(qp);
 
 	return -1;
 }
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 35/83] crypto/octeontx: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (33 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 34/83] crypto/null: " Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-24 17:46   ` [PATCH v2 36/83] crypto/openssl: " Stephen Hemminger
                     ` (48 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Anoob Joseph

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/crypto/octeontx/otx_cryptodev_ops.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/crypto/octeontx/otx_cryptodev_ops.c b/drivers/crypto/octeontx/otx_cryptodev_ops.c
index f7ca8a8a8e90..f1aae481c3c6 100644
--- a/drivers/crypto/octeontx/otx_cryptodev_ops.c
+++ b/drivers/crypto/octeontx/otx_cryptodev_ops.c
@@ -335,8 +335,7 @@ sym_session_clear(int driver_id, struct rte_cryptodev_sym_session *sess)
 	misc = priv;
 	ctx = SESS_PRIV(misc);
 
-	if (ctx->auth_key != NULL)
-		rte_free(ctx->auth_key);
+	rte_free(ctx->auth_key);
 
 	memset(priv, 0, cpt_get_session_size());
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 36/83] crypto/openssl: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (34 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 35/83] crypto/octeontx: " Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-24 17:46   ` [PATCH v2 37/83] crypto/scheduler: " Stephen Hemminger
                     ` (47 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Declan Doherty

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/crypto/openssl/rte_openssl_pmd_ops.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/crypto/openssl/rte_openssl_pmd_ops.c b/drivers/crypto/openssl/rte_openssl_pmd_ops.c
index 52715f86f84a..b1c0b14fefd2 100644
--- a/drivers/crypto/openssl/rte_openssl_pmd_ops.c
+++ b/drivers/crypto/openssl/rte_openssl_pmd_ops.c
@@ -659,8 +659,7 @@ openssl_pmd_qp_release(struct rte_cryptodev *dev, uint16_t qp_id)
 	if (dev->data->queue_pairs[qp_id] != NULL) {
 		struct openssl_qp *qp = dev->data->queue_pairs[qp_id];
 
-		if (qp->processed_ops)
-			rte_ring_free(qp->processed_ops);
+		rte_ring_free(qp->processed_ops);
 
 		rte_free(dev->data->queue_pairs[qp_id]);
 		dev->data->queue_pairs[qp_id] = NULL;
@@ -748,8 +747,7 @@ openssl_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 	return 0;
 
 qp_setup_cleanup:
-	if (qp)
-		rte_free(qp);
+	rte_free(qp);
 
 	return -1;
 }
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 37/83] crypto/scheduler: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (35 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 36/83] crypto/openssl: " Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-25 10:07     ` Zhang, Roy Fan
  2022-01-24 17:46   ` [PATCH v2 38/83] crypto/virtio: " Stephen Hemminger
                     ` (46 subsequent siblings)
  83 siblings, 1 reply; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Fan Zhang

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/crypto/scheduler/scheduler_pmd_ops.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/crypto/scheduler/scheduler_pmd_ops.c b/drivers/crypto/scheduler/scheduler_pmd_ops.c
index f61640c9d646..f3a1bd626c6f 100644
--- a/drivers/crypto/scheduler/scheduler_pmd_ops.c
+++ b/drivers/crypto/scheduler/scheduler_pmd_ops.c
@@ -371,10 +371,8 @@ scheduler_pmd_qp_release(struct rte_cryptodev *dev, uint16_t qp_id)
 	if (!qp_ctx)
 		return 0;
 
-	if (qp_ctx->order_ring)
-		rte_ring_free(qp_ctx->order_ring);
-	if (qp_ctx->private_qp_ctx)
-		rte_free(qp_ctx->private_qp_ctx);
+	rte_ring_free(qp_ctx->order_ring);
+	rte_free(qp_ctx->private_qp_ctx);
 
 	rte_free(qp_ctx);
 	dev->data->queue_pairs[qp_id] = NULL;
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 38/83] crypto/virtio: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (36 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 37/83] crypto/scheduler: " Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-24 17:46   ` [PATCH v2 39/83] event/sw: " Stephen Hemminger
                     ` (45 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Jay Zhou

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/crypto/virtio/virtqueue.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/crypto/virtio/virtqueue.c b/drivers/crypto/virtio/virtqueue.c
index fd8be581c996..3e2db1ebd250 100644
--- a/drivers/crypto/virtio/virtqueue.c
+++ b/drivers/crypto/virtio/virtqueue.c
@@ -32,10 +32,8 @@ virtqueue_detatch_unused(struct virtqueue *vq)
 		for (idx = 0; idx < vq->vq_nentries; idx++) {
 			cop = vq->vq_descx[idx].crypto_op;
 			if (cop) {
-				if (cop->sym->m_src)
-					rte_pktmbuf_free(cop->sym->m_src);
-				if (cop->sym->m_dst)
-					rte_pktmbuf_free(cop->sym->m_dst);
+				rte_pktmbuf_free(cop->sym->m_src);
+				rte_pktmbuf_free(cop->sym->m_dst);
 				rte_crypto_op_free(cop);
 				vq->vq_descx[idx].crypto_op = NULL;
 			}
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 39/83] event/sw: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (37 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 38/83] crypto/virtio: " Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-24 17:46   ` [PATCH v2 40/83] net/axgbe: " Stephen Hemminger
                     ` (44 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Harry van Haaren

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/event/sw/sw_evdev.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/event/sw/sw_evdev.c b/drivers/event/sw/sw_evdev.c
index 6ae613e0f2e7..ba82a80385b6 100644
--- a/drivers/event/sw/sw_evdev.c
+++ b/drivers/event/sw/sw_evdev.c
@@ -526,8 +526,7 @@ sw_dev_configure(const struct rte_eventdev *dev)
 	 * IQ chunk references were cleaned out of the QIDs in sw_stop(), and
 	 * will be reinitialized in sw_start().
 	 */
-	if (sw->chunks)
-		rte_free(sw->chunks);
+	rte_free(sw->chunks);
 
 	sw->chunks = rte_malloc_socket(NULL,
 				       sizeof(struct sw_queue_chunk) *
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 40/83] net/axgbe: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (38 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 39/83] event/sw: " Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-24 17:46   ` [PATCH v2 41/83] net/bnx2x: " Stephen Hemminger
                     ` (43 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Chandubabu Namburu

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/axgbe/axgbe_rxtx.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/axgbe/axgbe_rxtx.c b/drivers/net/axgbe/axgbe_rxtx.c
index 6bd41d3002bf..f38bb64fab6b 100644
--- a/drivers/net/axgbe/axgbe_rxtx.c
+++ b/drivers/net/axgbe/axgbe_rxtx.c
@@ -22,8 +22,7 @@ axgbe_rx_queue_release(struct axgbe_rx_queue *rx_queue)
 		sw_ring = rx_queue->sw_ring;
 		if (sw_ring) {
 			for (i = 0; i < rx_queue->nb_desc; i++) {
-				if (sw_ring[i])
-					rte_pktmbuf_free(sw_ring[i]);
+				rte_pktmbuf_free(sw_ring[i]);
 			}
 			rte_free(sw_ring);
 		}
@@ -507,8 +506,7 @@ static void axgbe_tx_queue_release(struct axgbe_tx_queue *tx_queue)
 		sw_ring = tx_queue->sw_ring;
 		if (sw_ring) {
 			for (i = 0; i < tx_queue->nb_desc; i++) {
-				if (sw_ring[i])
-					rte_pktmbuf_free(sw_ring[i]);
+				rte_pktmbuf_free(sw_ring[i]);
 			}
 			rte_free(sw_ring);
 		}
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 41/83] net/bnx2x: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (39 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 40/83] net/axgbe: " Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-24 17:46   ` [PATCH v2 42/83] net/bnxt: " Stephen Hemminger
                     ` (42 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Rasesh Mody, Shahed Shaikh

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/bnx2x/bnx2x_rxtx.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/bnx2x/bnx2x_rxtx.c b/drivers/net/bnx2x/bnx2x_rxtx.c
index 66b0512c8695..00ddccf151fd 100644
--- a/drivers/net/bnx2x/bnx2x_rxtx.c
+++ b/drivers/net/bnx2x/bnx2x_rxtx.c
@@ -27,8 +27,7 @@ bnx2x_rx_queue_release(struct bnx2x_rx_queue *rx_queue)
 		sw_ring = rx_queue->sw_ring;
 		if (NULL != sw_ring) {
 			for (i = 0; i < rx_queue->nb_rx_desc; i++) {
-				if (NULL != sw_ring[i])
-					rte_pktmbuf_free(sw_ring[i]);
+				rte_pktmbuf_free(sw_ring[i]);
 			}
 			rte_free(sw_ring);
 		}
@@ -172,8 +171,7 @@ bnx2x_tx_queue_release(struct bnx2x_tx_queue *tx_queue)
 		sw_ring = tx_queue->sw_ring;
 		if (NULL != sw_ring) {
 			for (i = 0; i < tx_queue->nb_tx_desc; i++) {
-				if (NULL != sw_ring[i])
-					rte_pktmbuf_free(sw_ring[i]);
+				rte_pktmbuf_free(sw_ring[i]);
 			}
 			rte_free(sw_ring);
 		}
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 42/83] net/bnxt: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (40 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 41/83] net/bnx2x: " Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-24 17:46   ` [PATCH v2 43/83] net/bonding: " Stephen Hemminger
                     ` (41 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Ajit Khaparde, Somnath Kotur

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/bnxt/bnxt_ethdev.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index f79f33ab4e17..78339d43674d 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -5833,8 +5833,7 @@ static void bnxt_free_ctx_mem_buf(struct bnxt_ctx_mem_buf_info *ctx)
 	if (!ctx)
 		return;
 
-	if (ctx->va)
-		rte_free(ctx->va);
+	rte_free(ctx->va);
 
 	ctx->va = NULL;
 	ctx->dma = RTE_BAD_IOVA;
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 43/83] net/bonding: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (41 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 42/83] net/bnxt: " Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-25  0:49     ` Min Hu (Connor)
  2022-01-24 17:46   ` [PATCH v2 44/83] net/cnxk: " Stephen Hemminger
                     ` (40 subsequent siblings)
  83 siblings, 1 reply; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Chas Williams, Min Hu (Connor)

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/bonding/rte_eth_bond_pmd.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index 84f4900ee52c..963280828a65 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -2148,8 +2148,7 @@ bond_ethdev_close(struct rte_eth_dev *dev)
 	 */
 	rte_mempool_free(internals->mode6.mempool);
 
-	if (internals->kvlist != NULL)
-		rte_kvargs_free(internals->kvlist);
+	rte_kvargs_free(internals->kvlist);
 
 	return 0;
 }
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 44/83] net/cnxk: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (42 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 43/83] net/bonding: " Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-24 17:46   ` [PATCH v2 45/83] net/cxgbe: " Stephen Hemminger
                     ` (39 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Nithin Dabilpuram, Kiran Kumar K,
	Sunil Kumar Kori, Satha Rao

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/cnxk/cnxk_ethdev.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/cnxk/cnxk_ethdev.c b/drivers/net/cnxk/cnxk_ethdev.c
index 74f625553df4..d679a1f78501 100644
--- a/drivers/net/cnxk/cnxk_ethdev.c
+++ b/drivers/net/cnxk/cnxk_ethdev.c
@@ -934,10 +934,8 @@ nix_restore_queue_cfg(struct rte_eth_dev *eth_dev)
 	for (i = 0; i < eth_dev->data->nb_tx_queues; i++)
 		dev_ops->tx_queue_release(eth_dev, i);
 fail:
-	if (tx_qconf)
-		free(tx_qconf);
-	if (rx_qconf)
-		free(rx_qconf);
+	free(tx_qconf);
+	free(rx_qconf);
 
 	return rc;
 }
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 45/83] net/cxgbe: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (43 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 44/83] net/cnxk: " Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-24 17:46   ` [PATCH v2 46/83] net/dpaa: " Stephen Hemminger
                     ` (38 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Rahul Lakkireddy

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/cxgbe/cxgbe_main.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/cxgbe/cxgbe_main.c b/drivers/net/cxgbe/cxgbe_main.c
index f1ac32270961..ab06e30a5e0f 100644
--- a/drivers/net/cxgbe/cxgbe_main.c
+++ b/drivers/net/cxgbe/cxgbe_main.c
@@ -463,8 +463,7 @@ void cxgbe_insert_tid(struct tid_info *t, void *data, unsigned int tid,
 static void tid_free(struct tid_info *t)
 {
 	if (t->tid_tab) {
-		if (t->ftid_bmap)
-			rte_bitmap_free(t->ftid_bmap);
+		rte_bitmap_free(t->ftid_bmap);
 
 		if (t->ftid_bmap_array)
 			t4_os_free(t->ftid_bmap_array);
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 46/83] net/dpaa: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (44 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 45/83] net/cxgbe: " Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-24 17:46   ` [PATCH v2 47/83] net/dpaa2: " Stephen Hemminger
                     ` (37 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Hemant Agrawal, Sachin Saxena

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/dpaa/dpaa_ethdev.c  | 3 +--
 drivers/net/dpaa/fmlib/fm_lib.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index 2c2c4e4ebb5d..90208a31de26 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -463,8 +463,7 @@ static int dpaa_eth_dev_close(struct rte_eth_dev *dev)
 	}
 
 	/* release configuration memory */
-	if (dpaa_intf->fc_conf)
-		rte_free(dpaa_intf->fc_conf);
+	rte_free(dpaa_intf->fc_conf);
 
 	/* Release RX congestion Groups */
 	if (dpaa_intf->cgr_rx) {
diff --git a/drivers/net/dpaa/fmlib/fm_lib.c b/drivers/net/dpaa/fmlib/fm_lib.c
index 0d1ca12378d8..1d6816050c2f 100644
--- a/drivers/net/dpaa/fmlib/fm_lib.c
+++ b/drivers/net/dpaa/fmlib/fm_lib.c
@@ -408,8 +408,7 @@ fm_port_close(t_handle h_fm_port)
 	_fml_dbg("Calling...\n");
 
 	close(p_dev->fd);
-	if (p_dev->h_user_priv)
-		free(p_dev->h_user_priv);
+	free(p_dev->h_user_priv);
 	free(p_dev);
 
 	_fml_dbg("Finishing.\n");
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 47/83] net/dpaa2: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (45 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 46/83] net/dpaa: " Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-24 17:46   ` [PATCH v2 48/83] net/ena: " Stephen Hemminger
                     ` (36 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Hemant Agrawal, Sachin Saxena

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by:  Hemant Agrawal <hemant.agrawal@nxp.com>
---
 drivers/net/dpaa2/dpaa2_ethdev.c | 3 +--
 drivers/net/dpaa2/dpaa2_mux.c    | 3 +--
 drivers/net/dpaa2/dpaa2_ptp.c    | 3 +--
 3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c
index 2b04f1416853..6b85b7740cfa 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.c
+++ b/drivers/net/dpaa2/dpaa2_ethdev.c
@@ -504,8 +504,7 @@ dpaa2_free_rx_tx_queues(struct rte_eth_dev *dev)
 		/* cleaning up queue storage */
 		for (i = 0; i < priv->nb_rx_queues; i++) {
 			dpaa2_q = (struct dpaa2_queue *)priv->rx_vq[i];
-			if (dpaa2_q->q_storage)
-				rte_free(dpaa2_q->q_storage);
+			rte_free(dpaa2_q->q_storage);
 		}
 		/* cleanup tx queue cscn */
 		for (i = 0; i < priv->nb_tx_queues; i++) {
diff --git a/drivers/net/dpaa2/dpaa2_mux.c b/drivers/net/dpaa2/dpaa2_mux.c
index cd2f7b8aa544..bd4596b89149 100644
--- a/drivers/net/dpaa2/dpaa2_mux.c
+++ b/drivers/net/dpaa2/dpaa2_mux.c
@@ -353,8 +353,7 @@ dpaa2_create_dpdmux_device(int vdev_fd __rte_unused,
 	return 0;
 
 init_err:
-	if (dpdmux_dev)
-		rte_free(dpdmux_dev);
+	rte_free(dpdmux_dev);
 
 	return -1;
 }
diff --git a/drivers/net/dpaa2/dpaa2_ptp.c b/drivers/net/dpaa2/dpaa2_ptp.c
index 8d79e392445a..5fcc36abe7b0 100644
--- a/drivers/net/dpaa2/dpaa2_ptp.c
+++ b/drivers/net/dpaa2/dpaa2_ptp.c
@@ -168,8 +168,7 @@ dpaa2_create_dprtc_device(int vdev_fd __rte_unused,
 	return 0;
 
 init_err:
-	if (dprtc_dev)
-		rte_free(dprtc_dev);
+	rte_free(dprtc_dev);
 
 	return -1;
 }
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 48/83] net/ena: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (46 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 47/83] net/dpaa2: " Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-24 17:46   ` [PATCH v2 49/83] net/hinic: " Stephen Hemminger
                     ` (35 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Marcin Wojtas, Michal Krawczyk, Shai Brandes,
	Evgeny Schemeilin, Igor Chauskin

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/ena/ena_ethdev.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c
index dce26cfa48cf..db2b5ec8e77b 100644
--- a/drivers/net/ena/ena_ethdev.c
+++ b/drivers/net/ena/ena_ethdev.c
@@ -567,16 +567,13 @@ static void ena_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
 	struct ena_ring *ring = dev->data->rx_queues[qid];
 
 	/* Free ring resources */
-	if (ring->rx_buffer_info)
-		rte_free(ring->rx_buffer_info);
+	rte_free(ring->rx_buffer_info);
 	ring->rx_buffer_info = NULL;
 
-	if (ring->rx_refill_buffer)
-		rte_free(ring->rx_refill_buffer);
+	rte_free(ring->rx_refill_buffer);
 	ring->rx_refill_buffer = NULL;
 
-	if (ring->empty_rx_reqs)
-		rte_free(ring->empty_rx_reqs);
+	rte_free(ring->empty_rx_reqs);
 	ring->empty_rx_reqs = NULL;
 
 	ring->configured = 0;
@@ -590,14 +587,11 @@ static void ena_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
 	struct ena_ring *ring = dev->data->tx_queues[qid];
 
 	/* Free ring resources */
-	if (ring->push_buf_intermediate_buf)
-		rte_free(ring->push_buf_intermediate_buf);
+	rte_free(ring->push_buf_intermediate_buf);
 
-	if (ring->tx_buffer_info)
-		rte_free(ring->tx_buffer_info);
+	rte_free(ring->tx_buffer_info);
 
-	if (ring->empty_tx_reqs)
-		rte_free(ring->empty_tx_reqs);
+	rte_free(ring->empty_tx_reqs);
 
 	ring->empty_tx_reqs = NULL;
 	ring->tx_buffer_info = NULL;
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 49/83] net/hinic: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (47 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 48/83] net/ena: " Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-24 17:46   ` [PATCH v2 50/83] net/hns3: " Stephen Hemminger
                     ` (34 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Ziyang Xuan, Xiaoyun Wang, Guoyang Zhou

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/hinic/hinic_pmd_ethdev.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/hinic/hinic_pmd_ethdev.c b/drivers/net/hinic/hinic_pmd_ethdev.c
index e8d9aaba84a6..35788f46eb4c 100644
--- a/drivers/net/hinic/hinic_pmd_ethdev.c
+++ b/drivers/net/hinic/hinic_pmd_ethdev.c
@@ -2662,8 +2662,7 @@ static int hinic_copy_mempool_init(struct hinic_nic_dev *nic_dev)
 
 static void hinic_copy_mempool_uninit(struct hinic_nic_dev *nic_dev)
 {
-	if (nic_dev->cpy_mpool != NULL)
-		rte_mempool_free(nic_dev->cpy_mpool);
+	rte_mempool_free(nic_dev->cpy_mpool);
 }
 
 static int hinic_init_sw_rxtxqs(struct hinic_nic_dev *nic_dev)
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 50/83] net/hns3: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (48 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 49/83] net/hinic: " Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-25  0:49     ` Min Hu (Connor)
  2022-01-24 17:46   ` [PATCH v2 51/83] net/i40e: " Stephen Hemminger
                     ` (33 subsequent siblings)
  83 siblings, 1 reply; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Min Hu (Connor), Yisen Zhuang, Lijun Ou

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/hns3/hns3_rxtx.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
index d240e36e6a86..8a428f88f48e 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -86,8 +86,7 @@ hns3_rx_queue_release(void *queue)
 		hns3_rx_queue_release_mbufs(rxq);
 		if (rxq->mz)
 			rte_memzone_free(rxq->mz);
-		if (rxq->sw_ring)
-			rte_free(rxq->sw_ring);
+		rte_free(rxq->sw_ring);
 		rte_free(rxq);
 	}
 }
@@ -100,10 +99,8 @@ hns3_tx_queue_release(void *queue)
 		hns3_tx_queue_release_mbufs(txq);
 		if (txq->mz)
 			rte_memzone_free(txq->mz);
-		if (txq->sw_ring)
-			rte_free(txq->sw_ring);
-		if (txq->free)
-			rte_free(txq->free);
+		rte_free(txq->sw_ring);
+		rte_free(txq->free);
 		rte_free(txq);
 	}
 }
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 51/83] net/i40e: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (49 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 50/83] net/hns3: " Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-24 17:46   ` [PATCH v2 52/83] net/iavf: " Stephen Hemminger
                     ` (32 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Beilei Xing

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/i40e/i40e_ethdev.c | 27 +++++++++------------------
 drivers/net/i40e/i40e_rxtx.c   |  3 +--
 2 files changed, 10 insertions(+), 20 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(&ethertype_rule->ethertype_list))) {
 		TAILQ_REMOVE(&ethertype_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;
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 52/83] net/iavf: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (50 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 51/83] net/i40e: " Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-24 17:46   ` [PATCH v2 53/83] net/ice: " Stephen Hemminger
                     ` (31 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Jingjing Wu, Beilei Xing

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/iavf/iavf_rxtx.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c
index 59623ac82094..dabe8cba7561 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;
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 53/83] net/ice: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (51 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 52/83] net/iavf: " Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-24 17:46   ` [PATCH v2 54/83] net/igc: " Stephen Hemminger
                     ` (30 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Qiming Yang, Qi Zhang

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/ice/ice_fdir_filter.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ice/ice_fdir_filter.c b/drivers/net/ice/ice_fdir_filter.c
index 13a2ac42df87..3fce8e1e6253 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;
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 54/83] net/igc: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (52 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 53/83] net/ice: " Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-25  0:44     ` Wang, Haiyue
  2022-01-24 17:46   ` [PATCH v2 55/83] net/ixgbe: " Stephen Hemminger
                     ` (29 subsequent siblings)
  83 siblings, 1 reply; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Haiyue Wang

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/igc/igc_flow.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

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.");
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 55/83] net/ixgbe: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (53 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 54/83] net/igc: " Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-25  0:43     ` Wang, Haiyue
  2022-01-24 17:46   ` [PATCH v2 56/83] net/memif: " Stephen Hemminger
                     ` (28 subsequent siblings)
  83 siblings, 1 reply; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Haiyue Wang

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/ixgbe/ixgbe_ethdev.c | 12 ++++--------
 drivers/net/ixgbe/ixgbe_rxtx.c   |  3 +--
 2 files changed, 5 insertions(+), 10 deletions(-)

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.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 56/83] net/memif: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (54 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 55/83] net/ixgbe: " Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-24 17:46   ` [PATCH v2 57/83] net/mlx4: " Stephen Hemminger
                     ` (27 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Jakub Grajciar

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/memif/rte_eth_memif.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/memif/rte_eth_memif.c b/drivers/net/memif/rte_eth_memif.c
index 59cb5a82a23f..5c2203f5270b 100644
--- a/drivers/net/memif/rte_eth_memif.c
+++ b/drivers/net/memif/rte_eth_memif.c
@@ -1731,8 +1731,7 @@ memif_check_socket_filename(const char *filename)
 		ret = -EINVAL;
 	}
 
-	if (dir != NULL)
-		rte_free(dir);
+	rte_free(dir);
 
 	return ret;
 }
@@ -1903,8 +1902,7 @@ rte_pmd_memif_probe(struct rte_vdev_device *vdev)
 			   log2_ring_size, pkt_buffer_size, secret, ether_addr);
 
 exit:
-	if (kvlist != NULL)
-		rte_kvargs_free(kvlist);
+	rte_kvargs_free(kvlist);
 	return ret;
 }
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 57/83] net/mlx4: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (55 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 56/83] net/memif: " Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-26  7:00     ` Slava Ovsiienko
  2022-01-24 17:46   ` [PATCH v2 58/83] net/mlx5: " Stephen Hemminger
                     ` (26 subsequent siblings)
  83 siblings, 1 reply; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Matan Azrad, Viacheslav Ovsiienko

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/mlx4/mlx4_mr.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/mlx4/mlx4_mr.c b/drivers/net/mlx4/mlx4_mr.c
index 2274b5df1950..e95f45aa3e95 100644
--- a/drivers/net/mlx4/mlx4_mr.c
+++ b/drivers/net/mlx4/mlx4_mr.c
@@ -471,8 +471,7 @@ mr_free(struct mlx4_mr *mr)
 	DEBUG("freeing MR(%p):", (void *)mr);
 	if (mr->ibv_mr != NULL)
 		claim_zero(mlx4_glue->dereg_mr(mr->ibv_mr));
-	if (mr->ms_bmp != NULL)
-		rte_bitmap_free(mr->ms_bmp);
+	rte_bitmap_free(mr->ms_bmp);
 	rte_free(mr);
 }
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 58/83] net/mlx5: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (56 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 57/83] net/mlx4: " Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-26  7:00     ` Slava Ovsiienko
  2022-01-24 17:46   ` [PATCH v2 59/83] net/mvpp2: " Stephen Hemminger
                     ` (25 subsequent siblings)
  83 siblings, 1 reply; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Matan Azrad, Viacheslav Ovsiienko

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/mlx5/mlx5_flow.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index b7cf4143d5a1..c718dbdb3dc7 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -6990,8 +6990,7 @@ flow_alloc_thread_workspace(void)
 	data->rssq_num = MLX5_RSSQ_DEFAULT_NUM;
 	return data;
 err:
-	if (data->rss_desc.queue)
-		free(data->rss_desc.queue);
+	free(data->rss_desc.queue);
 	free(data);
 	return NULL;
 }
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 59/83] net/mvpp2: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (57 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 58/83] net/mlx5: " Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-24 17:46   ` [PATCH v2 60/83] net/netvsc: " Stephen Hemminger
                     ` (24 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Liron Himi

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Reviewed-by: Liron Himi <lironh@marvell.com>
---
 drivers/net/mvpp2/mrvl_qos.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/mvpp2/mrvl_qos.c b/drivers/net/mvpp2/mrvl_qos.c
index 99f0ee56d1a7..f43217bc589c 100644
--- a/drivers/net/mvpp2/mrvl_qos.c
+++ b/drivers/net/mvpp2/mrvl_qos.c
@@ -945,8 +945,7 @@ setup_tc(struct pp2_ppio_tc_params *param, uint8_t inqs,
 	param->num_in_qs = inqs;
 
 	/* Release old config if necessary. */
-	if (param->inqs_params)
-		rte_free(param->inqs_params);
+	rte_free(param->inqs_params);
 
 	param->inqs_params = inq_params;
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 60/83] net/netvsc: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (58 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 59/83] net/mvpp2: " Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-24 20:11     ` Long Li
  2022-01-24 17:46   ` [PATCH v2 61/83] net/null: " Stephen Hemminger
                     ` (23 subsequent siblings)
  83 siblings, 1 reply; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Stephen Hemminger, Long Li

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/netvsc/hn_rxtx.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/netvsc/hn_rxtx.c b/drivers/net/netvsc/hn_rxtx.c
index 50ca1710ef3e..3e3488f1b87a 100644
--- a/drivers/net/netvsc/hn_rxtx.c
+++ b/drivers/net/netvsc/hn_rxtx.c
@@ -315,8 +315,7 @@ hn_dev_tx_queue_setup(struct rte_eth_dev *dev,
 	}
 
 error:
-	if (txq->txdesc_pool)
-		rte_mempool_free(txq->txdesc_pool);
+	rte_mempool_free(txq->txdesc_pool);
 	rte_memzone_free(txq->tx_rndis_mz);
 	rte_free(txq);
 	return err;
@@ -365,8 +364,7 @@ hn_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
 	if (!txq)
 		return;
 
-	if (txq->txdesc_pool)
-		rte_mempool_free(txq->txdesc_pool);
+	rte_mempool_free(txq->txdesc_pool);
 
 	rte_memzone_free(txq->tx_rndis_mz);
 	rte_free(txq);
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 61/83] net/null: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (59 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 60/83] net/netvsc: " Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-24 17:46   ` [PATCH v2 62/83] net/octeontx: " Stephen Hemminger
                     ` (22 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Tetsuya Mukawa

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/null/rte_eth_null.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c
index ca03469d0e6d..bb89c1abc4a2 100644
--- a/drivers/net/null/rte_eth_null.c
+++ b/drivers/net/null/rte_eth_null.c
@@ -717,8 +717,7 @@ rte_pmd_null_probe(struct rte_vdev_device *dev)
 	ret = eth_dev_null_create(dev, &args);
 
 free_kvlist:
-	if (kvlist)
-		rte_kvargs_free(kvlist);
+	rte_kvargs_free(kvlist);
 	return ret;
 }
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 62/83] net/octeontx: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (60 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 61/83] net/null: " Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-24 17:46   ` [PATCH v2 63/83] net/qede: " Stephen Hemminger
                     ` (21 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Harman Kalra

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/octeontx/octeontx_ethdev.c     | 3 +--
 drivers/net/octeontx/octeontx_ethdev_ops.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/octeontx/octeontx_ethdev.c b/drivers/net/octeontx/octeontx_ethdev.c
index b47472ebbd93..f5ea9de8efe5 100644
--- a/drivers/net/octeontx/octeontx_ethdev.c
+++ b/drivers/net/octeontx/octeontx_ethdev.c
@@ -1037,8 +1037,7 @@ octeontx_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t qidx,
 	return res;
 
 err:
-	if (txq)
-		rte_free(txq);
+	rte_free(txq);
 
 	return res;
 }
diff --git a/drivers/net/octeontx/octeontx_ethdev_ops.c b/drivers/net/octeontx/octeontx_ethdev_ops.c
index 6ec2b71b0672..0b22e28a5625 100644
--- a/drivers/net/octeontx/octeontx_ethdev_ops.c
+++ b/drivers/net/octeontx/octeontx_ethdev_ops.c
@@ -108,8 +108,7 @@ octeontx_dev_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
 	if (rc != 0) {
 		octeontx_log_err("Fail to configure vlan filter entry "
 				 "for port %d", nic->port_id);
-		if (entry)
-			rte_free(entry);
+		rte_free(entry);
 
 		goto done;
 	}
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 63/83] net/qede: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (61 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 62/83] net/octeontx: " Stephen Hemminger
@ 2022-01-24 17:46   ` Stephen Hemminger
  2022-01-25  3:53     ` [EXT] " Devendra Singh Rawat
  2022-01-24 17:47   ` [PATCH v2 64/83] net/softnic: " Stephen Hemminger
                     ` (20 subsequent siblings)
  83 siblings, 1 reply; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Rasesh Mody, Devendra Singh Rawat

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/qede/qede_main.c | 3 +--
 drivers/net/qede/qede_rxtx.c | 6 ++----
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/net/qede/qede_main.c b/drivers/net/qede/qede_main.c
index 2d1f70693a3d..ad101194d613 100644
--- a/drivers/net/qede/qede_main.c
+++ b/drivers/net/qede/qede_main.c
@@ -335,8 +335,7 @@ static int qed_slowpath_start(struct ecore_dev *edev,
 err:
 #ifdef CONFIG_ECORE_BINARY_FW
 	if (IS_PF(edev)) {
-		if (edev->firmware)
-			rte_free(edev->firmware);
+		rte_free(edev->firmware);
 		edev->firmware = NULL;
 	}
 #endif
diff --git a/drivers/net/qede/qede_rxtx.c b/drivers/net/qede/qede_rxtx.c
index 7088c57b501d..1c0a6ba5f1bf 100644
--- a/drivers/net/qede/qede_rxtx.c
+++ b/drivers/net/qede/qede_rxtx.c
@@ -706,12 +706,10 @@ void qede_dealloc_fp_resc(struct rte_eth_dev *eth_dev)
 		}
 	}
 
-	if (qdev->fp_array)
-		rte_free(qdev->fp_array);
+	rte_free(qdev->fp_array);
 	qdev->fp_array = NULL;
 
-	if (qdev->fp_array_cmt)
-		rte_free(qdev->fp_array_cmt);
+	rte_free(qdev->fp_array_cmt);
 	qdev->fp_array_cmt = NULL;
 }
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 64/83] net/softnic: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (62 preceding siblings ...)
  2022-01-24 17:46   ` [PATCH v2 63/83] net/qede: " Stephen Hemminger
@ 2022-01-24 17:47   ` Stephen Hemminger
  2022-01-24 17:47   ` [PATCH v2 65/83] net/tap: " Stephen Hemminger
                     ` (19 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:47 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Jasvinder Singh, Cristian Dumitrescu

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/softnic/rte_eth_softnic_cli.c       | 12 ++++--------
 drivers/net/softnic/rte_eth_softnic_cryptodev.c |  6 ++----
 drivers/net/softnic/rte_eth_softnic_thread.c    |  6 ++----
 3 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/drivers/net/softnic/rte_eth_softnic_cli.c b/drivers/net/softnic/rte_eth_softnic_cli.c
index b04e78c6e0af..7acbeecae7a2 100644
--- a/drivers/net/softnic/rte_eth_softnic_cli.c
+++ b/drivers/net/softnic/rte_eth_softnic_cli.c
@@ -4482,10 +4482,8 @@ parse_free_sym_crypto_param_data(struct rte_table_action_sym_crypto_params *p)
 
 		switch (xform[i]->type) {
 		case RTE_CRYPTO_SYM_XFORM_CIPHER:
-			if (p->cipher_auth.cipher_iv.val)
-				free(p->cipher_auth.cipher_iv.val);
-			if (p->cipher_auth.cipher_iv_update.val)
-				free(p->cipher_auth.cipher_iv_update.val);
+			free(p->cipher_auth.cipher_iv.val);
+			free(p->cipher_auth.cipher_iv_update.val);
 			break;
 		case RTE_CRYPTO_SYM_XFORM_AUTH:
 			if (p->cipher_auth.auth_iv.val)
@@ -4494,10 +4492,8 @@ parse_free_sym_crypto_param_data(struct rte_table_action_sym_crypto_params *p)
 				free(p->cipher_auth.cipher_iv_update.val);
 			break;
 		case RTE_CRYPTO_SYM_XFORM_AEAD:
-			if (p->aead.iv.val)
-				free(p->aead.iv.val);
-			if (p->aead.aad.val)
-				free(p->aead.aad.val);
+			free(p->aead.iv.val);
+			free(p->aead.aad.val);
 			break;
 		default:
 			continue;
diff --git a/drivers/net/softnic/rte_eth_softnic_cryptodev.c b/drivers/net/softnic/rte_eth_softnic_cryptodev.c
index 9a7d006f1a09..e4754055e90b 100644
--- a/drivers/net/softnic/rte_eth_softnic_cryptodev.c
+++ b/drivers/net/softnic/rte_eth_softnic_cryptodev.c
@@ -159,10 +159,8 @@ softnic_cryptodev_create(struct pmd_internals *p,
 	return cryptodev;
 
 error_exit:
-	if (cryptodev->mp_create)
-		rte_mempool_free(cryptodev->mp_create);
-	if (cryptodev->mp_init)
-		rte_mempool_free(cryptodev->mp_init);
+	rte_mempool_free(cryptodev->mp_create);
+	rte_mempool_free(cryptodev->mp_init);
 
 	free(cryptodev);
 
diff --git a/drivers/net/softnic/rte_eth_softnic_thread.c b/drivers/net/softnic/rte_eth_softnic_thread.c
index a8c26a5b2377..1b3b3c33c175 100644
--- a/drivers/net/softnic/rte_eth_softnic_thread.c
+++ b/drivers/net/softnic/rte_eth_softnic_thread.c
@@ -29,11 +29,9 @@ softnic_thread_free(struct pmd_internals *softnic)
 		struct softnic_thread *t = &softnic->thread[i];
 
 		/* MSGQs */
-		if (t->msgq_req)
-			rte_ring_free(t->msgq_req);
+		rte_ring_free(t->msgq_req);
 
-		if (t->msgq_rsp)
-			rte_ring_free(t->msgq_rsp);
+		rte_ring_free(t->msgq_rsp);
 	}
 }
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 65/83] net/tap: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (63 preceding siblings ...)
  2022-01-24 17:47   ` [PATCH v2 64/83] net/softnic: " Stephen Hemminger
@ 2022-01-24 17:47   ` Stephen Hemminger
  2022-01-24 17:47   ` [PATCH v2 66/83] net/txgbe: " Stephen Hemminger
                     ` (18 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:47 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Keith Wiles

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/tap/tap_flow.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c
index 76738239458a..a9a55e439efc 100644
--- a/drivers/net/tap/tap_flow.c
+++ b/drivers/net/tap/tap_flow.c
@@ -1465,8 +1465,7 @@ tap_flow_create(struct rte_eth_dev *dev,
 	}
 	return flow;
 fail:
-	if (remote_flow)
-		rte_free(remote_flow);
+	rte_free(remote_flow);
 	if (flow)
 		tap_flow_free(pmd, flow);
 	return NULL;
@@ -1541,8 +1540,7 @@ tap_flow_destroy_pmd(struct pmd_internals *pmd,
 		}
 	}
 end:
-	if (remote_flow)
-		rte_free(remote_flow);
+	rte_free(remote_flow);
 	tap_flow_free(pmd, flow);
 	return ret;
 }
@@ -1764,8 +1762,7 @@ int tap_flow_implicit_create(struct pmd_internals *pmd,
 success:
 	return 0;
 fail:
-	if (remote_flow)
-		rte_free(remote_flow);
+	rte_free(remote_flow);
 	return -1;
 }
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 66/83] net/txgbe: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (64 preceding siblings ...)
  2022-01-24 17:47   ` [PATCH v2 65/83] net/tap: " Stephen Hemminger
@ 2022-01-24 17:47   ` Stephen Hemminger
  2022-01-24 17:47   ` [PATCH v2 67/83] net/vdev_netvsc: " Stephen Hemminger
                     ` (17 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:47 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Jiawen Wu, Jian Wang

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/txgbe/txgbe_ethdev.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/net/txgbe/txgbe_ethdev.c b/drivers/net/txgbe/txgbe_ethdev.c
index ac4d4e08f407..6024397072c8 100644
--- a/drivers/net/txgbe/txgbe_ethdev.c
+++ b/drivers/net/txgbe/txgbe_ethdev.c
@@ -821,10 +821,8 @@ static int txgbe_fdir_filter_uninit(struct rte_eth_dev *eth_dev)
 	struct txgbe_hw_fdir_info *fdir_info = TXGBE_DEV_FDIR(eth_dev);
 	struct txgbe_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,
@@ -841,10 +839,8 @@ static int txgbe_l2_tn_filter_uninit(struct rte_eth_dev *eth_dev)
 	struct txgbe_l2_tn_info *l2_tn_info = TXGBE_DEV_L2_TN(eth_dev);
 	struct txgbe_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,
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 67/83] net/vdev_netvsc: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (65 preceding siblings ...)
  2022-01-24 17:47   ` [PATCH v2 66/83] net/txgbe: " Stephen Hemminger
@ 2022-01-24 17:47   ` Stephen Hemminger
  2022-01-24 17:47   ` [PATCH v2 68/83] net/virtio: " Stephen Hemminger
                     ` (16 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:47 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Matan Azrad

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/vdev_netvsc/vdev_netvsc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/vdev_netvsc/vdev_netvsc.c b/drivers/net/vdev_netvsc/vdev_netvsc.c
index 55f2a342c5ae..25871951685c 100644
--- a/drivers/net/vdev_netvsc/vdev_netvsc.c
+++ b/drivers/net/vdev_netvsc/vdev_netvsc.c
@@ -717,8 +717,7 @@ vdev_netvsc_vdev_probe(struct rte_vdev_device *dev)
 error:
 	++vdev_netvsc_ctx_inst;
 ignore:
-	if (kvargs)
-		rte_kvargs_free(kvargs);
+	rte_kvargs_free(kvargs);
 	/* Reset alarm if there are device context created */
 	if (vdev_netvsc_ctx_count) {
 		ret = rte_eal_alarm_set(VDEV_NETVSC_PROBE_MS * 1000,
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 68/83] net/virtio: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (66 preceding siblings ...)
  2022-01-24 17:47   ` [PATCH v2 67/83] net/vdev_netvsc: " Stephen Hemminger
@ 2022-01-24 17:47   ` Stephen Hemminger
  2022-01-24 17:47   ` [PATCH v2 69/83] raw/cnxk_bphy: " Stephen Hemminger
                     ` (15 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:47 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Maxime Coquelin, Chenbo Xia

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/virtio/virtio_user_ethdev.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c
index 0271098f0da0..f6288fd0c492 100644
--- a/drivers/net/virtio/virtio_user_ethdev.c
+++ b/drivers/net/virtio/virtio_user_ethdev.c
@@ -688,14 +688,10 @@ virtio_user_pmd_probe(struct rte_vdev_device *vdev)
 	ret = 0;
 
 end:
-	if (kvlist)
-		rte_kvargs_free(kvlist);
-	if (path)
-		free(path);
-	if (mac_addr)
-		free(mac_addr);
-	if (ifname)
-		free(ifname);
+	rte_kvargs_free(kvlist);
+	free(path);
+	free(mac_addr);
+	free(ifname);
 	return ret;
 }
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 69/83] raw/cnxk_bphy: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (67 preceding siblings ...)
  2022-01-24 17:47   ` [PATCH v2 68/83] net/virtio: " Stephen Hemminger
@ 2022-01-24 17:47   ` Stephen Hemminger
  2022-01-24 17:47   ` [PATCH v2 70/83] raw/dpaa2_qdma: " Stephen Hemminger
                     ` (14 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:47 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Jakub Palider, Tomasz Duszynski

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/raw/cnxk_bphy/cnxk_bphy_cgx.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/raw/cnxk_bphy/cnxk_bphy_cgx.c b/drivers/raw/cnxk_bphy/cnxk_bphy_cgx.c
index 0b694e1c03c3..169cbc785531 100644
--- a/drivers/raw/cnxk_bphy/cnxk_bphy_cgx.c
+++ b/drivers/raw/cnxk_bphy/cnxk_bphy_cgx.c
@@ -233,8 +233,7 @@ cnxk_bphy_cgx_fini_queues(struct cnxk_bphy_cgx *cgx)
 	unsigned int i;
 
 	for (i = 0; i < cgx->num_queues; i++) {
-		if (cgx->queues[i].rsp)
-			rte_free(cgx->queues[i].rsp);
+		rte_free(cgx->queues[i].rsp);
 	}
 
 	cgx->num_queues = 0;
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 70/83] raw/dpaa2_qdma: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (68 preceding siblings ...)
  2022-01-24 17:47   ` [PATCH v2 69/83] raw/cnxk_bphy: " Stephen Hemminger
@ 2022-01-24 17:47   ` Stephen Hemminger
  2022-01-24 18:09     ` Nipun Gupta
  2022-01-24 17:47   ` [PATCH v2 71/83] raw/ifpga: " Stephen Hemminger
                     ` (13 subsequent siblings)
  83 siblings, 1 reply; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:47 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Nipun Gupta

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/raw/dpaa2_qdma/dpaa2_qdma.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/raw/dpaa2_qdma/dpaa2_qdma.c b/drivers/raw/dpaa2_qdma/dpaa2_qdma.c
index ebc2cd5d0ddc..b2260439a4ef 100644
--- a/drivers/raw/dpaa2_qdma/dpaa2_qdma.c
+++ b/drivers/raw/dpaa2_qdma/dpaa2_qdma.c
@@ -1115,11 +1115,9 @@ dpaa2_qdma_reset(struct rte_rawdev *rawdev)
 
 	/* Reset and free virtual queues */
 	for (i = 0; i < qdma_dev->max_vqs; i++) {
-		if (qdma_dev->vqs[i].status_ring)
-			rte_ring_free(qdma_dev->vqs[i].status_ring);
+		rte_ring_free(qdma_dev->vqs[i].status_ring);
 	}
-	if (qdma_dev->vqs)
-		rte_free(qdma_dev->vqs);
+	rte_free(qdma_dev->vqs);
 	qdma_dev->vqs = NULL;
 
 	/* Reset per core info */
@@ -1314,8 +1312,7 @@ dpaa2_qdma_queue_setup(struct rte_rawdev *rawdev,
 
 	if (qdma_dev->vqs[i].hw_queue == NULL) {
 		DPAA2_QDMA_ERR("No H/W queue available for VQ");
-		if (qdma_dev->vqs[i].status_ring)
-			rte_ring_free(qdma_dev->vqs[i].status_ring);
+		rte_ring_free(qdma_dev->vqs[i].status_ring);
 		qdma_dev->vqs[i].status_ring = NULL;
 		rte_spinlock_unlock(&qdma_dev->lock);
 		return -ENODEV;
@@ -1516,14 +1513,12 @@ dpaa2_qdma_queue_release(struct rte_rawdev *rawdev,
 	if (qdma_vq->exclusive_hw_queue)
 		free_hw_queue(qdma_vq->hw_queue);
 	else {
-		if (qdma_vq->status_ring)
-			rte_ring_free(qdma_vq->status_ring);
+		rte_ring_free(qdma_vq->status_ring);
 
 		put_hw_queue(qdma_vq->hw_queue);
 	}
 
-	if (qdma_vq->fle_pool)
-		rte_mempool_free(qdma_vq->fle_pool);
+	rte_mempool_free(qdma_vq->fle_pool);
 
 	memset(qdma_vq, 0, sizeof(struct qdma_virt_queue));
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 71/83] raw/ifpga: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (69 preceding siblings ...)
  2022-01-24 17:47   ` [PATCH v2 70/83] raw/dpaa2_qdma: " Stephen Hemminger
@ 2022-01-24 17:47   ` Stephen Hemminger
  2022-01-24 17:47   ` [PATCH v2 72/83] raw/skeleton: " Stephen Hemminger
                     ` (12 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:47 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Rosen Xu, Tianfei zhang

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/raw/ifpga/ifpga_rawdev.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/raw/ifpga/ifpga_rawdev.c b/drivers/raw/ifpga/ifpga_rawdev.c
index 0eae0c9477b6..c68e378dc3ce 100644
--- a/drivers/raw/ifpga/ifpga_rawdev.c
+++ b/drivers/raw/ifpga/ifpga_rawdev.c
@@ -836,8 +836,7 @@ rte_fpga_do_pr(struct rte_rawdev *rawdev, int port_id,
 	}
 
 free_buffer:
-	if (buf_to_free)
-		rte_free(buf_to_free);
+	rte_free(buf_to_free);
 close_fd:
 	close(file_fd);
 	file_fd = 0;
@@ -1739,10 +1738,8 @@ ifpga_cfg_probe(struct rte_vdev_device *dev)
 	ret = rte_eal_hotplug_add(RTE_STR(IFPGA_BUS_NAME),
 			dev_name, devargs->args);
 end:
-	if (kvlist)
-		rte_kvargs_free(kvlist);
-	if (name)
-		free(name);
+	rte_kvargs_free(kvlist);
+	free(name);
 
 	return ret;
 }
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 72/83] raw/skeleton: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (70 preceding siblings ...)
  2022-01-24 17:47   ` [PATCH v2 71/83] raw/ifpga: " Stephen Hemminger
@ 2022-01-24 17:47   ` Stephen Hemminger
  2022-01-24 17:47   ` [PATCH v2 73/83] regex/cn9k: " Stephen Hemminger
                     ` (11 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:47 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Hemant Agrawal, Nipun Gupta

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by:  Hemant Agrawal <hemant.agrawal@nxp.com>
---
 drivers/raw/skeleton/skeleton_rawdev_test.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/raw/skeleton/skeleton_rawdev_test.c b/drivers/raw/skeleton/skeleton_rawdev_test.c
index 484468eeb460..693b24c415de 100644
--- a/drivers/raw/skeleton/skeleton_rawdev_test.c
+++ b/drivers/raw/skeleton/skeleton_rawdev_test.c
@@ -395,13 +395,11 @@ test_rawdev_enqdeq(void)
 	RTE_TEST_ASSERT_EQUAL((unsigned int)ret, count,
 			      "Unable to dequeue buffers");
 
-	if (deq_buffers)
-		free(deq_buffers);
+	free(deq_buffers);
 
 	return TEST_SUCCESS;
 cleanup:
-	if (buffers[0].buf_addr)
-		free(buffers[0].buf_addr);
+	free(buffers[0].buf_addr);
 
 	return TEST_FAILED;
 }
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 73/83] regex/cn9k: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (71 preceding siblings ...)
  2022-01-24 17:47   ` [PATCH v2 72/83] raw/skeleton: " Stephen Hemminger
@ 2022-01-24 17:47   ` Stephen Hemminger
  2022-01-24 17:47   ` [PATCH v2 74/83] regex/mlx5: " Stephen Hemminger
                     ` (10 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:47 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Liron Himi

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Reviewed-by: Liron Himi <lironh@marvell.com>
---
 drivers/regex/cn9k/cn9k_regexdev.c          | 6 ++----
 drivers/regex/cn9k/cn9k_regexdev_compiler.c | 3 +--
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/regex/cn9k/cn9k_regexdev.c b/drivers/regex/cn9k/cn9k_regexdev.c
index 32d20c1be82b..56c862c5a76c 100644
--- a/drivers/regex/cn9k/cn9k_regexdev.c
+++ b/drivers/regex/cn9k/cn9k_regexdev.c
@@ -256,10 +256,8 @@ ree_dev_fini(struct rte_regexdev *dev)
 		cn9k_err("Could not detach queues");
 
 	/* TEMP : should be in lib */
-	if (data->queue_pairs)
-		rte_free(data->queue_pairs);
-	if (data->rules)
-		rte_free(data->rules);
+	rte_free(data->queue_pairs);
+	rte_free(data->rules);
 
 	roc_ree_dev_fini(vf);
 
diff --git a/drivers/regex/cn9k/cn9k_regexdev_compiler.c b/drivers/regex/cn9k/cn9k_regexdev_compiler.c
index 935b8a53b459..60f1c1b4c4d8 100644
--- a/drivers/regex/cn9k/cn9k_regexdev_compiler.c
+++ b/drivers/regex/cn9k/cn9k_regexdev_compiler.c
@@ -214,8 +214,7 @@ cn9k_ree_rule_db_compile_prog(struct rte_regexdev *dev)
 	rxp_free_structs(NULL, NULL, NULL, NULL, NULL, &rof, NULL, &rofi, NULL,
 			1);
 
-	if (rule_db)
-		rte_free(rule_db);
+	rte_free(rule_db);
 
 	return ret;
 }
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 74/83] regex/mlx5: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (72 preceding siblings ...)
  2022-01-24 17:47   ` [PATCH v2 73/83] regex/cn9k: " Stephen Hemminger
@ 2022-01-24 17:47   ` Stephen Hemminger
  2022-01-24 17:47   ` [PATCH v2 75/83] vdpa/ifc: " Stephen Hemminger
                     ` (9 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:47 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Ori Kam

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/regex/mlx5/mlx5_regex.c | 3 +--
 drivers/regex/mlx5/mlx5_rxp.c   | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/regex/mlx5/mlx5_regex.c b/drivers/regex/mlx5/mlx5_regex.c
index e5a12fb3cc4d..48e39f6b8844 100644
--- a/drivers/regex/mlx5/mlx5_regex.c
+++ b/drivers/regex/mlx5/mlx5_regex.c
@@ -127,8 +127,7 @@ mlx5_regex_dev_probe(struct mlx5_common_device *cdev)
 	if (priv->regexdev)
 		rte_regexdev_unregister(priv->regexdev);
 dev_error:
-	if (priv)
-		rte_free(priv);
+	rte_free(priv);
 	return -rte_errno;
 }
 
diff --git a/drivers/regex/mlx5/mlx5_rxp.c b/drivers/regex/mlx5/mlx5_rxp.c
index 5ead3ca341ad..99db1e4a865c 100644
--- a/drivers/regex/mlx5/mlx5_rxp.c
+++ b/drivers/regex/mlx5/mlx5_rxp.c
@@ -166,7 +166,6 @@ mlx5_regex_configure(struct rte_regexdev *dev,
 		DRV_LOG(DEBUG, "Regex config without rules programming!");
 	return 0;
 configure_error:
-	if (priv->qps)
-		rte_free(priv->qps);
+	rte_free(priv->qps);
 	return -rte_errno;
 }
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 75/83] vdpa/ifc: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (73 preceding siblings ...)
  2022-01-24 17:47   ` [PATCH v2 74/83] regex/mlx5: " Stephen Hemminger
@ 2022-01-24 17:47   ` Stephen Hemminger
  2022-01-27  5:54     ` Xia, Chenbo
  2022-01-24 17:47   ` [PATCH v2 76/83] vdpa/mlx5: " Stephen Hemminger
                     ` (8 subsequent siblings)
  83 siblings, 1 reply; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:47 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Xiao Wang

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/vdpa/ifc/ifcvf_vdpa.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c b/drivers/vdpa/ifc/ifcvf_vdpa.c
index 3853c4cf7e85..9f05595b6b34 100644
--- a/drivers/vdpa/ifc/ifcvf_vdpa.c
+++ b/drivers/vdpa/ifc/ifcvf_vdpa.c
@@ -226,8 +226,7 @@ ifcvf_dma_map(struct ifcvf_internal *internal, bool do_map)
 	}
 
 exit:
-	if (mem)
-		free(mem);
+	free(mem);
 	return ret;
 }
 
@@ -253,8 +252,7 @@ hva_to_gpa(int vid, uint64_t hva)
 	}
 
 exit:
-	if (mem)
-		free(mem);
+	free(mem);
 	return gpa;
 }
 
@@ -661,8 +659,7 @@ m_ifcvf_start(struct ifcvf_internal *internal)
 
 error:
 	for (i = 0; i < nr_vring; i++)
-		if (internal->m_vring[i].desc)
-			rte_free(internal->m_vring[i].desc);
+		rte_free(internal->m_vring[i].desc);
 
 	return -1;
 }
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 76/83] vdpa/mlx5: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (74 preceding siblings ...)
  2022-01-24 17:47   ` [PATCH v2 75/83] vdpa/ifc: " Stephen Hemminger
@ 2022-01-24 17:47   ` Stephen Hemminger
  2022-01-24 17:47   ` [PATCH v2 77/83] compressdev: " Stephen Hemminger
                     ` (7 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:47 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Matan Azrad, Viacheslav Ovsiienko

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/vdpa/mlx5/mlx5_vdpa_mem.c   | 3 +--
 drivers/vdpa/mlx5/mlx5_vdpa_virtq.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/vdpa/mlx5/mlx5_vdpa_mem.c b/drivers/vdpa/mlx5/mlx5_vdpa_mem.c
index 130d201a85f5..599079500b03 100644
--- a/drivers/vdpa/mlx5/mlx5_vdpa_mem.c
+++ b/drivers/vdpa/mlx5/mlx5_vdpa_mem.c
@@ -283,8 +283,7 @@ mlx5_vdpa_mem_register(struct mlx5_vdpa_priv *priv)
 	priv->gpa_mkey_index = entry->mkey->id;
 	return 0;
 error:
-	if (entry)
-		rte_free(entry);
+	rte_free(entry);
 	mlx5_vdpa_mem_dereg(priv);
 	rte_errno = -ret;
 	return ret;
diff --git a/drivers/vdpa/mlx5/mlx5_vdpa_virtq.c b/drivers/vdpa/mlx5/mlx5_vdpa_virtq.c
index 2f32aef67fbc..3416797d289c 100644
--- a/drivers/vdpa/mlx5/mlx5_vdpa_virtq.c
+++ b/drivers/vdpa/mlx5/mlx5_vdpa_virtq.c
@@ -91,8 +91,7 @@ mlx5_vdpa_virtq_unset(struct mlx5_vdpa_virtq *virtq)
 		if (virtq->umems[i].obj)
 			claim_zero(mlx5_glue->devx_umem_dereg
 							 (virtq->umems[i].obj));
-		if (virtq->umems[i].buf)
-			rte_free(virtq->umems[i].buf);
+		rte_free(virtq->umems[i].buf);
 	}
 	memset(&virtq->umems, 0, sizeof(virtq->umems));
 	if (virtq->eqp.fw_qp)
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 77/83] compressdev: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (75 preceding siblings ...)
  2022-01-24 17:47   ` [PATCH v2 76/83] vdpa/mlx5: " Stephen Hemminger
@ 2022-01-24 17:47   ` Stephen Hemminger
  2022-01-27 11:07     ` Zhang, Roy Fan
  2022-01-24 17:47   ` [PATCH v2 78/83] ethdev: " Stephen Hemminger
                     ` (6 subsequent siblings)
  83 siblings, 1 reply; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:47 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Fan Zhang, Ashish Gupta

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/compressdev/rte_compressdev.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/compressdev/rte_compressdev.c b/lib/compressdev/rte_compressdev.c
index 2e9218af68f6..d4f7d4d3daf2 100644
--- a/lib/compressdev/rte_compressdev.c
+++ b/lib/compressdev/rte_compressdev.c
@@ -405,8 +405,7 @@ rte_compressdev_queue_pairs_release(struct rte_compressdev *dev)
 			return ret;
 	}
 
-	if (dev->data->queue_pairs != NULL)
-		rte_free(dev->data->queue_pairs);
+	rte_free(dev->data->queue_pairs);
 	dev->data->queue_pairs = NULL;
 	dev->data->nb_queue_pairs = 0;
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 78/83] ethdev: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (76 preceding siblings ...)
  2022-01-24 17:47   ` [PATCH v2 77/83] compressdev: " Stephen Hemminger
@ 2022-01-24 17:47   ` Stephen Hemminger
  2022-01-24 17:47   ` [PATCH v2 79/83] graph: " Stephen Hemminger
                     ` (5 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:47 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Thomas Monjalon, Ferruh Yigit, Andrew Rybchenko

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/ethdev/rte_ethdev.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index a1d475a29295..98312fa157f6 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -6036,8 +6036,7 @@ rte_eth_devargs_parse(const char *dargs, struct rte_eth_devargs *eth_da)
 	}
 
 parse_cleanup:
-	if (args.str)
-		free(args.str);
+	free(args.str);
 
 	return result;
 }
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 79/83] graph: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (77 preceding siblings ...)
  2022-01-24 17:47   ` [PATCH v2 78/83] ethdev: " Stephen Hemminger
@ 2022-01-24 17:47   ` Stephen Hemminger
  2022-01-24 17:47   ` [PATCH v2 80/83] ipsec: " Stephen Hemminger
                     ` (4 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:47 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Jerin Jacob, Kiran Kumar K, Nithin Dabilpuram

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/graph/graph_stats.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/graph/graph_stats.c b/lib/graph/graph_stats.c
index aa70929dc32e..65e12d46a313 100644
--- a/lib/graph/graph_stats.c
+++ b/lib/graph/graph_stats.c
@@ -233,8 +233,7 @@ cluster_add(struct cluster *cluster, struct graph *graph)
 static void
 cluster_fini(struct cluster *cluster)
 {
-	if (cluster->graphs)
-		free(cluster->graphs);
+	free(cluster->graphs);
 }
 
 static int
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 80/83] ipsec: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (78 preceding siblings ...)
  2022-01-24 17:47   ` [PATCH v2 79/83] graph: " Stephen Hemminger
@ 2022-01-24 17:47   ` Stephen Hemminger
  2022-01-24 17:47   ` [PATCH v2 81/83] port: " Stephen Hemminger
                     ` (3 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:47 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Konstantin Ananyev, Bernard Iremonger,
	Vladimir Medvedkin

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/ipsec/ipsec_sad.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/ipsec/ipsec_sad.c b/lib/ipsec/ipsec_sad.c
index 531e1e323cdc..af4b1ce757d2 100644
--- a/lib/ipsec/ipsec_sad.c
+++ b/lib/ipsec/ipsec_sad.c
@@ -440,8 +440,7 @@ rte_ipsec_sad_destroy(struct rte_ipsec_sad *sad)
 	rte_hash_free(sad->hash[RTE_IPSEC_SAD_SPI_DIP]);
 	rte_hash_free(sad->hash[RTE_IPSEC_SAD_SPI_DIP_SIP]);
 	rte_free(sad);
-	if (te != NULL)
-		rte_free(te);
+	rte_free(te);
 }
 
 /*
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 81/83] port: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (79 preceding siblings ...)
  2022-01-24 17:47   ` [PATCH v2 80/83] ipsec: " Stephen Hemminger
@ 2022-01-24 17:47   ` Stephen Hemminger
  2022-01-24 17:47   ` [PATCH v2 82/83] power: " Stephen Hemminger
                     ` (2 subsequent siblings)
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:47 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Cristian Dumitrescu

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/port/rte_port_source_sink.c | 21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)

diff --git a/lib/port/rte_port_source_sink.c b/lib/port/rte_port_source_sink.c
index 68575c98338d..79042d13ff66 100644
--- a/lib/port/rte_port_source_sink.c
+++ b/lib/port/rte_port_source_sink.c
@@ -163,14 +163,10 @@ pcap_source_load(struct rte_port_source *port,
 	return 0;
 
 error_exit:
-	if (pkt_len_aligns)
-		rte_free(pkt_len_aligns);
-	if (port->pkt_len)
-		rte_free(port->pkt_len);
-	if (port->pkts)
-		rte_free(port->pkts);
-	if (port->pkt_buff)
-		rte_free(port->pkt_buff);
+	rte_free(pkt_len_aligns);
+	rte_free(port->pkt_len);
+	rte_free(port->pkts);
+	rte_free(port->pkt_buff);
 
 	return -1;
 }
@@ -242,12 +238,9 @@ rte_port_source_free(void *port)
 	if (p == NULL)
 		return 0;
 
-	if (p->pkt_len)
-		rte_free(p->pkt_len);
-	if (p->pkts)
-		rte_free(p->pkts);
-	if (p->pkt_buff)
-		rte_free(p->pkt_buff);
+	rte_free(p->pkt_len);
+	rte_free(p->pkts);
+	rte_free(p->pkt_buff);
 
 	rte_free(p);
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 82/83] power: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (80 preceding siblings ...)
  2022-01-24 17:47   ` [PATCH v2 81/83] port: " Stephen Hemminger
@ 2022-01-24 17:47   ` Stephen Hemminger
  2022-01-25  8:50     ` David Hunt
  2022-01-24 17:47   ` [PATCH v2 83/83] reorder: " Stephen Hemminger
  2022-01-28 21:49   ` [PATCH v2 00/83] remove unnecessary null checks Thomas Monjalon
  83 siblings, 1 reply; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:47 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, David Hunt

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/power/rte_power_empty_poll.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/power/rte_power_empty_poll.c b/lib/power/rte_power_empty_poll.c
index c4b5de9601cf..2261ce7820f6 100644
--- a/lib/power/rte_power_empty_poll.c
+++ b/lib/power/rte_power_empty_poll.c
@@ -457,8 +457,7 @@ rte_power_empty_poll_stat_free(void)
 
 	RTE_LOG(INFO, POWER, "Close the Empty Poll\n");
 
-	if (ep_params != NULL)
-		rte_free(ep_params);
+	rte_free(ep_params);
 }
 
 int
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v2 83/83] reorder: remove unnecessary NULL checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (81 preceding siblings ...)
  2022-01-24 17:47   ` [PATCH v2 82/83] power: " Stephen Hemminger
@ 2022-01-24 17:47   ` Stephen Hemminger
  2022-01-28 21:49   ` [PATCH v2 00/83] remove unnecessary null checks Thomas Monjalon
  83 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-24 17:47 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Reshma Pattan

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/reorder/rte_reorder.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/lib/reorder/rte_reorder.c b/lib/reorder/rte_reorder.c
index 9445853b79cc..bc0241bfb3fd 100644
--- a/lib/reorder/rte_reorder.c
+++ b/lib/reorder/rte_reorder.c
@@ -192,10 +192,8 @@ rte_reorder_free_mbufs(struct rte_reorder_buffer *b)
 
 	/* Free up the mbufs of order buffer & ready buffer */
 	for (i = 0; i < b->order_buf.size; i++) {
-		if (b->order_buf.entries[i])
-			rte_pktmbuf_free(b->order_buf.entries[i]);
-		if (b->ready_buf.entries[i])
-			rte_pktmbuf_free(b->ready_buf.entries[i]);
+		rte_pktmbuf_free(b->order_buf.entries[i]);
+		rte_pktmbuf_free(b->ready_buf.entries[i]);
 	}
 }
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* RE: [PATCH v2 70/83] raw/dpaa2_qdma: remove unnecessary NULL checks
  2022-01-24 17:47   ` [PATCH v2 70/83] raw/dpaa2_qdma: " Stephen Hemminger
@ 2022-01-24 18:09     ` Nipun Gupta
  0 siblings, 0 replies; 247+ messages in thread
From: Nipun Gupta @ 2022-01-24 18:09 UTC (permalink / raw)
  To: Stephen Hemminger, dev

Acked-by: Nipun Gupta <nipun.gupta@nxp.com>

> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: 24 January 2022 23:17
> To: dev@dpdk.org
> Cc: Stephen Hemminger <stephen@networkplumber.org>; Nipun Gupta
> <nipun.gupta@nxp.com>
> Subject: [PATCH v2 70/83] raw/dpaa2_qdma: remove unnecessary NULL checks
> 
> Remove redundant NULL pointer checks before free functions
> found by nullfree.cocci
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>  drivers/raw/dpaa2_qdma/dpaa2_qdma.c | 15 +++++----------
>  1 file changed, 5 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/raw/dpaa2_qdma/dpaa2_qdma.c
> b/drivers/raw/dpaa2_qdma/dpaa2_qdma.c
> index ebc2cd5d0ddc..b2260439a4ef 100644
> --- a/drivers/raw/dpaa2_qdma/dpaa2_qdma.c
> +++ b/drivers/raw/dpaa2_qdma/dpaa2_qdma.c
> @@ -1115,11 +1115,9 @@ dpaa2_qdma_reset(struct rte_rawdev *rawdev)
> 
>  	/* Reset and free virtual queues */
>  	for (i = 0; i < qdma_dev->max_vqs; i++) {
> -		if (qdma_dev->vqs[i].status_ring)
> -			rte_ring_free(qdma_dev->vqs[i].status_ring);
> +		rte_ring_free(qdma_dev->vqs[i].status_ring);
>  	}
> -	if (qdma_dev->vqs)
> -		rte_free(qdma_dev->vqs);
> +	rte_free(qdma_dev->vqs);
>  	qdma_dev->vqs = NULL;
> 
>  	/* Reset per core info */
> @@ -1314,8 +1312,7 @@ dpaa2_qdma_queue_setup(struct rte_rawdev
> *rawdev,
> 
>  	if (qdma_dev->vqs[i].hw_queue == NULL) {
>  		DPAA2_QDMA_ERR("No H/W queue available for VQ");
> -		if (qdma_dev->vqs[i].status_ring)
> -			rte_ring_free(qdma_dev->vqs[i].status_ring);
> +		rte_ring_free(qdma_dev->vqs[i].status_ring);
>  		qdma_dev->vqs[i].status_ring = NULL;
>  		rte_spinlock_unlock(&qdma_dev->lock);
>  		return -ENODEV;
> @@ -1516,14 +1513,12 @@ dpaa2_qdma_queue_release(struct rte_rawdev
> *rawdev,
>  	if (qdma_vq->exclusive_hw_queue)
>  		free_hw_queue(qdma_vq->hw_queue);
>  	else {
> -		if (qdma_vq->status_ring)
> -			rte_ring_free(qdma_vq->status_ring);
> +		rte_ring_free(qdma_vq->status_ring);
> 
>  		put_hw_queue(qdma_vq->hw_queue);
>  	}
> 
> -	if (qdma_vq->fle_pool)
> -		rte_mempool_free(qdma_vq->fle_pool);
> +	rte_mempool_free(qdma_vq->fle_pool);
> 
>  	memset(qdma_vq, 0, sizeof(struct qdma_virt_queue));
> 
> --
> 2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* RE: [PATCH 59/82] net/netvsc: remove unnecessary NULL checks
  2022-01-24  0:04 ` [PATCH 59/82] net/netvsc: " Stephen Hemminger
@ 2022-01-24 20:09   ` Long Li
  0 siblings, 0 replies; 247+ messages in thread
From: Long Li @ 2022-01-24 20:09 UTC (permalink / raw)
  To: Stephen Hemminger, dev; +Cc: Stephen Hemminger

> Subject: [PATCH 59/82] net/netvsc: remove unnecessary NULL checks
> 
> Remove redundant NULL pointer checks before free functions found by
> nullfree.cocci
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>

Acked-by: Long Li <longli@microsoft.com>

> ---
>  drivers/net/netvsc/hn_rxtx.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/netvsc/hn_rxtx.c b/drivers/net/netvsc/hn_rxtx.c index
> 50ca1710ef3e..3e3488f1b87a 100644
> --- a/drivers/net/netvsc/hn_rxtx.c
> +++ b/drivers/net/netvsc/hn_rxtx.c
> @@ -315,8 +315,7 @@ hn_dev_tx_queue_setup(struct rte_eth_dev *dev,
>  	}
> 
>  error:
> -	if (txq->txdesc_pool)
> -		rte_mempool_free(txq->txdesc_pool);
> +	rte_mempool_free(txq->txdesc_pool);
>  	rte_memzone_free(txq->tx_rndis_mz);
>  	rte_free(txq);
>  	return err;
> @@ -365,8 +364,7 @@ hn_dev_tx_queue_release(struct rte_eth_dev *dev,
> uint16_t qid)
>  	if (!txq)
>  		return;
> 
> -	if (txq->txdesc_pool)
> -		rte_mempool_free(txq->txdesc_pool);
> +	rte_mempool_free(txq->txdesc_pool);
> 
>  	rte_memzone_free(txq->tx_rndis_mz);
>  	rte_free(txq);
> --
> 2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* RE: [PATCH v2 60/83] net/netvsc: remove unnecessary NULL checks
  2022-01-24 17:46   ` [PATCH v2 60/83] net/netvsc: " Stephen Hemminger
@ 2022-01-24 20:11     ` Long Li
  0 siblings, 0 replies; 247+ messages in thread
From: Long Li @ 2022-01-24 20:11 UTC (permalink / raw)
  To: Stephen Hemminger, dev; +Cc: Stephen Hemminger

> Subject: [PATCH v2 60/83] net/netvsc: remove unnecessary NULL checks
> 
> Remove redundant NULL pointer checks before free functions found by
> nullfree.cocci
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Long Li <longli@microsoft.com>
> ---
>  drivers/net/netvsc/hn_rxtx.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/netvsc/hn_rxtx.c b/drivers/net/netvsc/hn_rxtx.c index
> 50ca1710ef3e..3e3488f1b87a 100644
> --- a/drivers/net/netvsc/hn_rxtx.c
> +++ b/drivers/net/netvsc/hn_rxtx.c
> @@ -315,8 +315,7 @@ hn_dev_tx_queue_setup(struct rte_eth_dev *dev,
>  	}
> 
>  error:
> -	if (txq->txdesc_pool)
> -		rte_mempool_free(txq->txdesc_pool);
> +	rte_mempool_free(txq->txdesc_pool);
>  	rte_memzone_free(txq->tx_rndis_mz);
>  	rte_free(txq);
>  	return err;
> @@ -365,8 +364,7 @@ hn_dev_tx_queue_release(struct rte_eth_dev *dev,
> uint16_t qid)
>  	if (!txq)
>  		return;
> 
> -	if (txq->txdesc_pool)
> -		rte_mempool_free(txq->txdesc_pool);
> +	rte_mempool_free(txq->txdesc_pool);
> 
>  	rte_memzone_free(txq->tx_rndis_mz);
>  	rte_free(txq);
> --
> 2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* RE: [PATCH v2 55/83] net/ixgbe: remove unnecessary NULL checks
  2022-01-24 17:46   ` [PATCH v2 55/83] net/ixgbe: " Stephen Hemminger
@ 2022-01-25  0:43     ` Wang, Haiyue
  0 siblings, 0 replies; 247+ messages in thread
From: Wang, Haiyue @ 2022-01-25  0:43 UTC (permalink / raw)
  To: Stephen Hemminger, dev

> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Tuesday, January 25, 2022 01:47
> To: dev@dpdk.org
> Cc: Stephen Hemminger <stephen@networkplumber.org>; Wang, Haiyue <haiyue.wang@intel.com>
> Subject: [PATCH v2 55/83] net/ixgbe: remove unnecessary NULL checks
> 
> Remove redundant NULL pointer checks before free functions
> found by nullfree.cocci
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>  drivers/net/ixgbe/ixgbe_ethdev.c | 12 ++++--------
>  drivers/net/ixgbe/ixgbe_rxtx.c   |  3 +--
>  2 files changed, 5 insertions(+), 10 deletions(-)
> 

Acked-by: Haiyue Wang <haiyue.wang@intel.com>

> --
> 2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* RE: [PATCH v2 54/83] net/igc: remove unnecessary NULL checks
  2022-01-24 17:46   ` [PATCH v2 54/83] net/igc: " Stephen Hemminger
@ 2022-01-25  0:44     ` Wang, Haiyue
  0 siblings, 0 replies; 247+ messages in thread
From: Wang, Haiyue @ 2022-01-25  0:44 UTC (permalink / raw)
  To: Stephen Hemminger, dev

> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Tuesday, January 25, 2022 01:47
> To: dev@dpdk.org
> Cc: Stephen Hemminger <stephen@networkplumber.org>; Wang, Haiyue <haiyue.wang@intel.com>
> Subject: [PATCH v2 54/83] net/igc: remove unnecessary NULL checks
> 
> Remove redundant NULL pointer checks before free functions
> found by nullfree.cocci
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>  drivers/net/igc/igc_flow.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 

Acked-by: Haiyue Wang <haiyue.wang@intel.com>

> 2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* Re: [PATCH v2 50/83] net/hns3: remove unnecessary NULL checks
  2022-01-24 17:46   ` [PATCH v2 50/83] net/hns3: " Stephen Hemminger
@ 2022-01-25  0:49     ` Min Hu (Connor)
  0 siblings, 0 replies; 247+ messages in thread
From: Min Hu (Connor) @ 2022-01-25  0:49 UTC (permalink / raw)
  To: Stephen Hemminger, dev; +Cc: Yisen Zhuang, Lijun Ou

Acked-by: Min Hu (Connor) <humin29@huawei.com>

在 2022/1/25 1:46, Stephen Hemminger 写道:
> Remove redundant NULL pointer checks before free functions
> found by nullfree.cocci
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>   drivers/net/hns3/hns3_rxtx.c | 9 +++------
>   1 file changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
> index d240e36e6a86..8a428f88f48e 100644
> --- a/drivers/net/hns3/hns3_rxtx.c
> +++ b/drivers/net/hns3/hns3_rxtx.c
> @@ -86,8 +86,7 @@ hns3_rx_queue_release(void *queue)
>   		hns3_rx_queue_release_mbufs(rxq);
>   		if (rxq->mz)
>   			rte_memzone_free(rxq->mz);
> -		if (rxq->sw_ring)
> -			rte_free(rxq->sw_ring);
> +		rte_free(rxq->sw_ring);
>   		rte_free(rxq);
>   	}
>   }
> @@ -100,10 +99,8 @@ hns3_tx_queue_release(void *queue)
>   		hns3_tx_queue_release_mbufs(txq);
>   		if (txq->mz)
>   			rte_memzone_free(txq->mz);
> -		if (txq->sw_ring)
> -			rte_free(txq->sw_ring);
> -		if (txq->free)
> -			rte_free(txq->free);
> +		rte_free(txq->sw_ring);
> +		rte_free(txq->free);
>   		rte_free(txq);
>   	}
>   }
> 

^ permalink raw reply	[flat|nested] 247+ messages in thread

* Re: [PATCH v2 43/83] net/bonding: remove unnecessary NULL checks
  2022-01-24 17:46   ` [PATCH v2 43/83] net/bonding: " Stephen Hemminger
@ 2022-01-25  0:49     ` Min Hu (Connor)
  0 siblings, 0 replies; 247+ messages in thread
From: Min Hu (Connor) @ 2022-01-25  0:49 UTC (permalink / raw)
  To: Stephen Hemminger, dev; +Cc: Chas Williams

Acked-by: Min Hu (Connor) <humin29@huawei.com>

在 2022/1/25 1:46, Stephen Hemminger 写道:
> Remove redundant NULL pointer checks before free functions
> found by nullfree.cocci
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>   drivers/net/bonding/rte_eth_bond_pmd.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
> index 84f4900ee52c..963280828a65 100644
> --- a/drivers/net/bonding/rte_eth_bond_pmd.c
> +++ b/drivers/net/bonding/rte_eth_bond_pmd.c
> @@ -2148,8 +2148,7 @@ bond_ethdev_close(struct rte_eth_dev *dev)
>   	 */
>   	rte_mempool_free(internals->mode6.mempool);
>   
> -	if (internals->kvlist != NULL)
> -		rte_kvargs_free(internals->kvlist);
> +	rte_kvargs_free(internals->kvlist);
>   
>   	return 0;
>   }
> 

^ permalink raw reply	[flat|nested] 247+ messages in thread

* RE: [EXT] [PATCH v2 63/83] net/qede: remove unnecessary NULL checks
  2022-01-24 17:46   ` [PATCH v2 63/83] net/qede: " Stephen Hemminger
@ 2022-01-25  3:53     ` Devendra Singh Rawat
  0 siblings, 0 replies; 247+ messages in thread
From: Devendra Singh Rawat @ 2022-01-25  3:53 UTC (permalink / raw)
  To: Stephen Hemminger, dev; +Cc: Rasesh Mody



> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Monday, January 24, 2022 11:17 PM
> To: dev@dpdk.org
> Cc: Stephen Hemminger <stephen@networkplumber.org>; Rasesh Mody
> <rmody@marvell.com>; Devendra Singh Rawat <dsinghrawat@marvell.com>
> Subject: [EXT] [PATCH v2 63/83] net/qede: remove unnecessary NULL checks
> 
> External Email
> 
> ----------------------------------------------------------------------
> Remove redundant NULL pointer checks before free functions found by
> nullfree.cocci
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>  drivers/net/qede/qede_main.c | 3 +--
>  drivers/net/qede/qede_rxtx.c | 6 ++----
>  2 files changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/qede/qede_main.c b/drivers/net/qede/qede_main.c
> index 2d1f70693a3d..ad101194d613 100644
> --- a/drivers/net/qede/qede_main.c
> +++ b/drivers/net/qede/qede_main.c
> @@ -335,8 +335,7 @@ static int qed_slowpath_start(struct ecore_dev *edev,
>  err:
>  #ifdef CONFIG_ECORE_BINARY_FW
>  	if (IS_PF(edev)) {
> -		if (edev->firmware)
> -			rte_free(edev->firmware);
> +		rte_free(edev->firmware);
>  		edev->firmware = NULL;
>  	}
>  #endif
> diff --git a/drivers/net/qede/qede_rxtx.c b/drivers/net/qede/qede_rxtx.c index
> 7088c57b501d..1c0a6ba5f1bf 100644
> --- a/drivers/net/qede/qede_rxtx.c
> +++ b/drivers/net/qede/qede_rxtx.c
> @@ -706,12 +706,10 @@ void qede_dealloc_fp_resc(struct rte_eth_dev
> *eth_dev)
>  		}
>  	}
> 
> -	if (qdev->fp_array)
> -		rte_free(qdev->fp_array);
> +	rte_free(qdev->fp_array);
>  	qdev->fp_array = NULL;
> 
> -	if (qdev->fp_array_cmt)
> -		rte_free(qdev->fp_array_cmt);
> +	rte_free(qdev->fp_array_cmt);
>  	qdev->fp_array_cmt = NULL;
>  }
> 
> --
> 2.30.2


Acked-by: Devendra Singh Rawat <dsinghrawat@marvell.com>

Thanks,
Devendra


^ permalink raw reply	[flat|nested] 247+ messages in thread

* Re: [PATCH v2 82/83] power: remove unnecessary NULL checks
  2022-01-24 17:47   ` [PATCH v2 82/83] power: " Stephen Hemminger
@ 2022-01-25  8:50     ` David Hunt
  0 siblings, 0 replies; 247+ messages in thread
From: David Hunt @ 2022-01-25  8:50 UTC (permalink / raw)
  To: Stephen Hemminger, dev


On 24/1/2022 5:47 PM, Stephen Hemminger wrote:
> Remove redundant NULL pointer checks before free functions
> found by nullfree.cocci
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>   lib/power/rte_power_empty_poll.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/lib/power/rte_power_empty_poll.c b/lib/power/rte_power_empty_poll.c
> index c4b5de9601cf..2261ce7820f6 100644
> --- a/lib/power/rte_power_empty_poll.c
> +++ b/lib/power/rte_power_empty_poll.c
> @@ -457,8 +457,7 @@ rte_power_empty_poll_stat_free(void)
>   
>   	RTE_LOG(INFO, POWER, "Close the Empty Poll\n");
>   
> -	if (ep_params != NULL)
> -		rte_free(ep_params);
> +	rte_free(ep_params);
>   }
>   
>   int


Acked-by: David Hunt <david.hunt@intel.com>



^ permalink raw reply	[flat|nested] 247+ messages in thread

* RE: [PATCH v2 37/83] crypto/scheduler: remove unnecessary NULL checks
  2022-01-24 17:46   ` [PATCH v2 37/83] crypto/scheduler: " Stephen Hemminger
@ 2022-01-25 10:07     ` Zhang, Roy Fan
  0 siblings, 0 replies; 247+ messages in thread
From: Zhang, Roy Fan @ 2022-01-25 10:07 UTC (permalink / raw)
  To: Stephen Hemminger, dev

> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Monday, January 24, 2022 5:47 PM
> To: dev@dpdk.org
> Cc: Stephen Hemminger <stephen@networkplumber.org>; Zhang, Roy Fan
> <roy.fan.zhang@intel.com>
> Subject: [PATCH v2 37/83] crypto/scheduler: remove unnecessary NULL
> checks
> 
> Remove redundant NULL pointer checks before free functions
> found by nullfree.cocci
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
Acked-by: Fan Zhang <roy.fan.zhang@intel.com>

^ permalink raw reply	[flat|nested] 247+ messages in thread

* RE: [PATCH v2 57/83] net/mlx4: remove unnecessary NULL checks
  2022-01-24 17:46   ` [PATCH v2 57/83] net/mlx4: " Stephen Hemminger
@ 2022-01-26  7:00     ` Slava Ovsiienko
  0 siblings, 0 replies; 247+ messages in thread
From: Slava Ovsiienko @ 2022-01-26  7:00 UTC (permalink / raw)
  To: Stephen Hemminger, dev; +Cc: Matan Azrad

> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Monday, January 24, 2022 19:47
> To: dev@dpdk.org
> Cc: Stephen Hemminger <stephen@networkplumber.org>; Matan Azrad
> <matan@nvidia.com>; Slava Ovsiienko <viacheslavo@nvidia.com>
> Subject: [PATCH v2 57/83] net/mlx4: remove unnecessary NULL checks
> 
> Remove redundant NULL pointer checks before free functions found by
> nullfree.cocci
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>


^ permalink raw reply	[flat|nested] 247+ messages in thread

* RE: [PATCH v2 58/83] net/mlx5: remove unnecessary NULL checks
  2022-01-24 17:46   ` [PATCH v2 58/83] net/mlx5: " Stephen Hemminger
@ 2022-01-26  7:00     ` Slava Ovsiienko
  0 siblings, 0 replies; 247+ messages in thread
From: Slava Ovsiienko @ 2022-01-26  7:00 UTC (permalink / raw)
  To: Stephen Hemminger, dev; +Cc: Matan Azrad

> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Monday, January 24, 2022 19:47
> To: dev@dpdk.org
> Cc: Stephen Hemminger <stephen@networkplumber.org>; Matan Azrad
> <matan@nvidia.com>; Slava Ovsiienko <viacheslavo@nvidia.com>
> Subject: [PATCH v2 58/83] net/mlx5: remove unnecessary NULL checks
> 
> Remove redundant NULL pointer checks before free functions found by
> nullfree.cocci
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>


^ permalink raw reply	[flat|nested] 247+ messages in thread

* RE: [PATCH v2 09/83] lib/vhost: remove unnecessary NULL checks
  2022-01-24 17:46   ` [PATCH v2 09/83] lib/vhost: " Stephen Hemminger
@ 2022-01-27  5:52     ` Xia, Chenbo
  0 siblings, 0 replies; 247+ messages in thread
From: Xia, Chenbo @ 2022-01-27  5:52 UTC (permalink / raw)
  To: Stephen Hemminger, dev; +Cc: Maxime Coquelin

Hi Stephen,

> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Tuesday, January 25, 2022 1:46 AM
> To: dev@dpdk.org
> Cc: Stephen Hemminger <stephen@networkplumber.org>; Maxime Coquelin
> <maxime.coquelin@redhat.com>; Xia, Chenbo <chenbo.xia@intel.com>
> Subject: [PATCH v2 09/83] lib/vhost: remove unnecessary NULL checks

Title should be: vhost: remove unnecessary NULL checks

With this fixed:

Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>

> 
> Remove redundant NULL pointer checks before free functions
> found by nullfree.cocci
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>  lib/vhost/iotlb.c        | 3 +--
>  lib/vhost/vhost_crypto.c | 6 ++----
>  lib/vhost/vhost_user.c   | 9 +++------
>  3 files changed, 6 insertions(+), 12 deletions(-)
> 
> diff --git a/lib/vhost/iotlb.c b/lib/vhost/iotlb.c
> index 82bdb84526ea..d6b8c0a396b5 100644
> --- a/lib/vhost/iotlb.c
> +++ b/lib/vhost/iotlb.c
> @@ -315,8 +315,7 @@ vhost_user_iotlb_init(struct virtio_net *dev, int vq_index)
> 
>  	/* If already created, free it and recreate */
>  	vq->iotlb_pool = rte_mempool_lookup(pool_name);
> -	if (vq->iotlb_pool)
> -		rte_mempool_free(vq->iotlb_pool);
> +	rte_mempool_free(vq->iotlb_pool);
> 
>  	vq->iotlb_pool = rte_mempool_create(pool_name,
>  			IOTLB_CACHE_SIZE, sizeof(struct vhost_iotlb_entry), 0,
> diff --git a/lib/vhost/vhost_crypto.c b/lib/vhost/vhost_crypto.c
> index 926b5c0bd94a..012e0cefdeba 100644
> --- a/lib/vhost/vhost_crypto.c
> +++ b/lib/vhost/vhost_crypto.c
> @@ -1498,10 +1498,8 @@ rte_vhost_crypto_create(int vid, uint8_t cryptodev_id,
>  	return 0;
> 
>  error_exit:
> -	if (vcrypto->session_map)
> -		rte_hash_free(vcrypto->session_map);
> -	if (vcrypto->mbuf_pool)
> -		rte_mempool_free(vcrypto->mbuf_pool);
> +	rte_hash_free(vcrypto->session_map);
> +	rte_mempool_free(vcrypto->mbuf_pool);
> 
>  	rte_free(vcrypto);
> 
> diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c
> index 5eb1dd681231..23a0e3fb3600 100644
> --- a/lib/vhost/vhost_user.c
> +++ b/lib/vhost/vhost_user.c
> @@ -489,8 +489,7 @@ vhost_user_set_vring_num(struct virtio_net **pdev,
>  	}
> 
>  	if (vq_is_packed(dev)) {
> -		if (vq->shadow_used_packed)
> -			rte_free(vq->shadow_used_packed);
> +		rte_free(vq->shadow_used_packed);
>  		vq->shadow_used_packed = rte_malloc_socket(NULL,
>  				vq->size *
>  				sizeof(struct vring_used_elem_packed),
> @@ -502,8 +501,7 @@ vhost_user_set_vring_num(struct virtio_net **pdev,
>  		}
> 
>  	} else {
> -		if (vq->shadow_used_split)
> -			rte_free(vq->shadow_used_split);
> +		rte_free(vq->shadow_used_split);
> 
>  		vq->shadow_used_split = rte_malloc_socket(NULL,
>  				vq->size * sizeof(struct vring_used_elem),
> @@ -516,8 +514,7 @@ vhost_user_set_vring_num(struct virtio_net **pdev,
>  		}
>  	}
> 
> -	if (vq->batch_copy_elems)
> -		rte_free(vq->batch_copy_elems);
> +	rte_free(vq->batch_copy_elems);
>  	vq->batch_copy_elems = rte_malloc_socket(NULL,
>  				vq->size * sizeof(struct batch_copy_elem),
>  				RTE_CACHE_LINE_SIZE, vq->numa_node);
> --
> 2.30.2


^ permalink raw reply	[flat|nested] 247+ messages in thread

* RE: [PATCH v2 10/83] examples/vhost_blk: remove unnecessary NULL checks
  2022-01-24 17:46   ` [PATCH v2 10/83] examples/vhost_blk: " Stephen Hemminger
@ 2022-01-27  5:53     ` Xia, Chenbo
  0 siblings, 0 replies; 247+ messages in thread
From: Xia, Chenbo @ 2022-01-27  5:53 UTC (permalink / raw)
  To: Stephen Hemminger, dev; +Cc: Maxime Coquelin

> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Tuesday, January 25, 2022 1:46 AM
> To: dev@dpdk.org
> Cc: Stephen Hemminger <stephen@networkplumber.org>; Maxime Coquelin
> <maxime.coquelin@redhat.com>; Xia, Chenbo <chenbo.xia@intel.com>
> Subject: [PATCH v2 10/83] examples/vhost_blk: remove unnecessary NULL checks
> 
> Remove redundant NULL pointer checks before free functions
> found by nullfree.cocci
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>  examples/vhost_blk/vhost_blk.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/examples/vhost_blk/vhost_blk.c b/examples/vhost_blk/vhost_blk.c
> index feadacc62ee5..2cab1e6994fe 100644
> --- a/examples/vhost_blk/vhost_blk.c
> +++ b/examples/vhost_blk/vhost_blk.c
> @@ -849,8 +849,7 @@ static void
>  vhost_blk_ctrlr_destroy(struct vhost_blk_ctrlr *ctrlr)
>  {
>  	if (ctrlr->bdev != NULL) {
> -		if (ctrlr->bdev->data != NULL)
> -			rte_free(ctrlr->bdev->data);
> +		rte_free(ctrlr->bdev->data);
> 
>  		rte_free(ctrlr->bdev);
>  	}
> --
> 2.30.2

Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>

^ permalink raw reply	[flat|nested] 247+ messages in thread

* RE: [PATCH v2 75/83] vdpa/ifc: remove unnecessary NULL checks
  2022-01-24 17:47   ` [PATCH v2 75/83] vdpa/ifc: " Stephen Hemminger
@ 2022-01-27  5:54     ` Xia, Chenbo
  0 siblings, 0 replies; 247+ messages in thread
From: Xia, Chenbo @ 2022-01-27  5:54 UTC (permalink / raw)
  To: Stephen Hemminger, dev; +Cc: Wang, Xiao W

> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Tuesday, January 25, 2022 1:47 AM
> To: dev@dpdk.org
> Cc: Stephen Hemminger <stephen@networkplumber.org>; Wang, Xiao W
> <xiao.w.wang@intel.com>
> Subject: [PATCH v2 75/83] vdpa/ifc: remove unnecessary NULL checks
> 
> Remove redundant NULL pointer checks before free functions
> found by nullfree.cocci
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>  drivers/vdpa/ifc/ifcvf_vdpa.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c b/drivers/vdpa/ifc/ifcvf_vdpa.c
> index 3853c4cf7e85..9f05595b6b34 100644
> --- a/drivers/vdpa/ifc/ifcvf_vdpa.c
> +++ b/drivers/vdpa/ifc/ifcvf_vdpa.c
> @@ -226,8 +226,7 @@ ifcvf_dma_map(struct ifcvf_internal *internal, bool do_map)
>  	}
> 
>  exit:
> -	if (mem)
> -		free(mem);
> +	free(mem);
>  	return ret;
>  }
> 
> @@ -253,8 +252,7 @@ hva_to_gpa(int vid, uint64_t hva)
>  	}
> 
>  exit:
> -	if (mem)
> -		free(mem);
> +	free(mem);
>  	return gpa;
>  }
> 
> @@ -661,8 +659,7 @@ m_ifcvf_start(struct ifcvf_internal *internal)
> 
>  error:
>  	for (i = 0; i < nr_vring; i++)
> -		if (internal->m_vring[i].desc)
> -			rte_free(internal->m_vring[i].desc);
> +		rte_free(internal->m_vring[i].desc);
> 
>  	return -1;
>  }
> --
> 2.30.2

Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>

^ permalink raw reply	[flat|nested] 247+ messages in thread

* RE: [PATCH v2 77/83] compressdev: remove unnecessary NULL checks
  2022-01-24 17:47   ` [PATCH v2 77/83] compressdev: " Stephen Hemminger
@ 2022-01-27 11:07     ` Zhang, Roy Fan
  0 siblings, 0 replies; 247+ messages in thread
From: Zhang, Roy Fan @ 2022-01-27 11:07 UTC (permalink / raw)
  To: Stephen Hemminger, dev; +Cc: Ashish Gupta

> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Monday, January 24, 2022 5:47 PM
> To: dev@dpdk.org
> Cc: Stephen Hemminger <stephen@networkplumber.org>; Zhang, Roy Fan
> <roy.fan.zhang@intel.com>; Ashish Gupta <ashish.gupta@marvell.com>
> Subject: [PATCH v2 77/83] compressdev: remove unnecessary NULL checks
> 
> Remove redundant NULL pointer checks before free functions
> found by nullfree.cocci
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>  lib/compressdev/rte_compressdev.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/lib/compressdev/rte_compressdev.c
> b/lib/compressdev/rte_compressdev.c
> index 2e9218af68f6..d4f7d4d3daf2 100644
> --- a/lib/compressdev/rte_compressdev.c
> +++ b/lib/compressdev/rte_compressdev.c
> @@ -405,8 +405,7 @@ rte_compressdev_queue_pairs_release(struct
> rte_compressdev *dev)
>  			return ret;
>  	}
> 
> -	if (dev->data->queue_pairs != NULL)
> -		rte_free(dev->data->queue_pairs);
> +	rte_free(dev->data->queue_pairs);
>  	dev->data->queue_pairs = NULL;
>  	dev->data->nb_queue_pairs = 0;
> 
> --
> 2.30.2
Acked-by: Fan Zhang <roy.fan.zhang@intel.com>

^ permalink raw reply	[flat|nested] 247+ messages in thread

* RE: [PATCH v2 32/83] crypto/ipsec_mb: remove unnecessary NULL checks
  2022-01-24 17:46   ` [PATCH v2 32/83] crypto/ipsec_mb: " Stephen Hemminger
@ 2022-01-27 11:08     ` Zhang, Roy Fan
  0 siblings, 0 replies; 247+ messages in thread
From: Zhang, Roy Fan @ 2022-01-27 11:08 UTC (permalink / raw)
  To: Stephen Hemminger, dev; +Cc: De Lara Guarch, Pablo

> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Monday, January 24, 2022 5:46 PM
> To: dev@dpdk.org
> Cc: Stephen Hemminger <stephen@networkplumber.org>; Zhang, Roy Fan
> <roy.fan.zhang@intel.com>; De Lara Guarch, Pablo
> <pablo.de.lara.guarch@intel.com>
> Subject: [PATCH v2 32/83] crypto/ipsec_mb: remove unnecessary NULL
> checks
> 
> Remove redundant NULL pointer checks before free functions
> found by nullfree.cocci
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>  drivers/crypto/ipsec_mb/ipsec_mb_ops.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/crypto/ipsec_mb/ipsec_mb_ops.c
> b/drivers/crypto/ipsec_mb/ipsec_mb_ops.c
> index 189262c4ad52..f808da9edf89 100644
> --- a/drivers/crypto/ipsec_mb/ipsec_mb_ops.c
> +++ b/drivers/crypto/ipsec_mb/ipsec_mb_ops.c
> @@ -102,8 +102,7 @@ ipsec_mb_qp_release(struct rte_cryptodev *dev,
> uint16_t qp_id)
> 
>  	if (qp != NULL && rte_eal_process_type() == RTE_PROC_PRIMARY) {
>  		r = rte_ring_lookup(qp->name);
> -		if (r)
> -			rte_ring_free(r);
> +		rte_ring_free(r);
> 
>  #if IMB_VERSION(1, 1, 0) > IMB_VERSION_NUM
>  		if (qp->mb_mgr)
> @@ -291,8 +290,7 @@ ipsec_mb_qp_setup(struct rte_cryptodev *dev,
> uint16_t qp_id,
>  	if (qp->mb_mgr_mz)
>  		rte_memzone_free(qp->mb_mgr_mz);
>  #endif
> -	if (qp)
> -		rte_free(qp);
> +	rte_free(qp);
>  	return ret;
>  }
> 
> --
> 2.30.2
Acked-by: Fan Zhang <roy.fan.zhang@intel.com>

^ permalink raw reply	[flat|nested] 247+ messages in thread

* Re: [PATCH v2 01/83] lib: update documentation of XXX_free() functions
  2022-01-24 17:45   ` [PATCH v2 01/83] lib: update documentation of XXX_free() functions Stephen Hemminger
@ 2022-01-28 21:47     ` Thomas Monjalon
  2022-01-28 22:51       ` Stephen Hemminger
  0 siblings, 1 reply; 247+ messages in thread
From: Thomas Monjalon @ 2022-01-28 21:47 UTC (permalink / raw)
  To: Stephen Hemminger
  Cc: dev, Yipeng Wang, Sameh Gobriel, Bruce Richardson,
	Vladimir Medvedkin, Olivier Matz, Andrew Rybchenko,
	Honnappa Nagarahalli, Konstantin Ananyev

24/01/2022 18:45, Stephen Hemminger:
> These functions all behave like libc free() and do
> nothing if handed a NULL pointer. The code is already doing
> this, this patch just documents the behavior.
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>  /**
>   * De-allocate all memory used by hash table.
> + *
> + * If the pointer is NULL, the function does nothing.

Would be better to move in the context of the parameter.

> + *
>   * @param h
>   *   Hash table to free

Here:
	If NULL, the function does nothing.

Same for comment for all files of this patch.

> @@ -108,6 +108,8 @@ struct rte_kvargs *rte_kvargs_parse_delim(const char *args,
>   * Free a rte_kvargs structure previously allocated with
>   * rte_kvargs_parse().
>   *
> + * If the pointer is NULL, the function does nothing.
> + *
>   * @param kvlist
>   *   The rte_kvargs structure. No error if NULL.

Would need to reword "No error" to "Does nothing".

> @@ -1372,6 +1372,8 @@ rte_pktmbuf_free_seg(struct rte_mbuf *m)
>   * Free an mbuf, and all its segments in case of chained buffers. Each
>   * segment is added back into its original mempool.
>   *
> + * If the pointer is NULL, the function does nothing.
> + *
>   * @param m
>   *   The packet mbuf to be freed. If NULL, the function does nothing.

Here the comment exists already in the right place.




^ permalink raw reply	[flat|nested] 247+ messages in thread

* Re: [PATCH v2 02/83] devtools/cocci: add script to fix unnecessary null checks
  2022-01-24 17:45   ` [PATCH v2 02/83] devtools/cocci: add script to fix unnecessary null checks Stephen Hemminger
@ 2022-01-28 21:48     ` Thomas Monjalon
  0 siblings, 0 replies; 247+ messages in thread
From: Thomas Monjalon @ 2022-01-28 21:48 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev

24/01/2022 18:45, Stephen Hemminger:
> This script is based on the idea of the nullfree script
> in the Linux kernel. It finds cases where a check for null
> pointer is done, but is unnecessary because the function
> already handles NULL pointer.
> 
> Basic example:
>        if (x->buf)
>            rte_free(x->buf);
> can be reduced to:
>        rte_free(x->buf);
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>

Good to have, thank you.



^ permalink raw reply	[flat|nested] 247+ messages in thread

* Re: [PATCH v2 00/83] remove unnecessary null checks
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
                     ` (82 preceding siblings ...)
  2022-01-24 17:47   ` [PATCH v2 83/83] reorder: " Stephen Hemminger
@ 2022-01-28 21:49   ` Thomas Monjalon
  2022-01-28 22:14     ` Stephen Hemminger
  83 siblings, 1 reply; 247+ messages in thread
From: Thomas Monjalon @ 2022-01-28 21:49 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev

24/01/2022 18:45, Stephen Hemminger:
> Stephen Hemminger (83):
>   lib: update documentation of XXX_free() functions
>   devtools/cocci: add script to fix unnecessary null checks

I think it is good to have the first 2 patches separate,
but the rest could go in a single third patch.



^ permalink raw reply	[flat|nested] 247+ messages in thread

* Re: [PATCH v2 00/83] remove unnecessary null checks
  2022-01-28 21:49   ` [PATCH v2 00/83] remove unnecessary null checks Thomas Monjalon
@ 2022-01-28 22:14     ` Stephen Hemminger
  0 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-28 22:14 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev

On Fri, 28 Jan 2022 22:49:31 +0100
Thomas Monjalon <thomas@monjalon.net> wrote:

> 24/01/2022 18:45, Stephen Hemminger:
> > Stephen Hemminger (83):
> >   lib: update documentation of XXX_free() functions
> >   devtools/cocci: add script to fix unnecessary null checks  
> 
> I think it is good to have the first 2 patches separate,
> but the rest could go in a single third patch.
> 
> 

Split up to get subsystem reviewers attention, if you want
can merge in next version

^ permalink raw reply	[flat|nested] 247+ messages in thread

* Re: [PATCH v2 01/83] lib: update documentation of XXX_free() functions
  2022-01-28 21:47     ` Thomas Monjalon
@ 2022-01-28 22:51       ` Stephen Hemminger
  2022-01-29 18:51         ` Thomas Monjalon
  0 siblings, 1 reply; 247+ messages in thread
From: Stephen Hemminger @ 2022-01-28 22:51 UTC (permalink / raw)
  To: Thomas Monjalon
  Cc: dev, Yipeng Wang, Sameh Gobriel, Bruce Richardson,
	Vladimir Medvedkin, Olivier Matz, Andrew Rybchenko,
	Honnappa Nagarahalli, Konstantin Ananyev

On Fri, 28 Jan 2022 22:47:15 +0100
Thomas Monjalon <thomas@monjalon.net> wrote:

> 24/01/2022 18:45, Stephen Hemminger:
> > These functions all behave like libc free() and do
> > nothing if handed a NULL pointer. The code is already doing
> > this, this patch just documents the behavior.
> > 
> > Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> > ---
> >  /**
> >   * De-allocate all memory used by hash table.
> > + *
> > + * If the pointer is NULL, the function does nothing.  
> 
> Would be better to move in the context of the parameter

I copied text from rte_free to other functions...
For consistency, lets document it one way in all cases.
Don't care which one...

^ permalink raw reply	[flat|nested] 247+ messages in thread

* Re: [PATCH v2 01/83] lib: update documentation of XXX_free() functions
  2022-01-28 22:51       ` Stephen Hemminger
@ 2022-01-29 18:51         ` Thomas Monjalon
  2022-02-08 17:03           ` Thomas Monjalon
  0 siblings, 1 reply; 247+ messages in thread
From: Thomas Monjalon @ 2022-01-29 18:51 UTC (permalink / raw)
  To: Stephen Hemminger
  Cc: dev, Yipeng Wang, Sameh Gobriel, Bruce Richardson,
	Vladimir Medvedkin, Olivier Matz, Andrew Rybchenko,
	Honnappa Nagarahalli, Konstantin Ananyev

28/01/2022 23:51, Stephen Hemminger:
> On Fri, 28 Jan 2022 22:47:15 +0100
> Thomas Monjalon <thomas@monjalon.net> wrote:
> 
> > 24/01/2022 18:45, Stephen Hemminger:
> > > These functions all behave like libc free() and do
> > > nothing if handed a NULL pointer. The code is already doing
> > > this, this patch just documents the behavior.
> > > 
> > > Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> > > ---
> > >  /**
> > >   * De-allocate all memory used by hash table.
> > > + *
> > > + * If the pointer is NULL, the function does nothing.  
> > 
> > Would be better to move in the context of the parameter
> 
> I copied text from rte_free to other functions...
> For consistency, lets document it one way in all cases.
> Don't care which one...

I prefer to have comments about a parameter inside the @param please.



^ permalink raw reply	[flat|nested] 247+ messages in thread

* Re: [PATCH v2 01/83] lib: update documentation of XXX_free() functions
  2022-01-29 18:51         ` Thomas Monjalon
@ 2022-02-08 17:03           ` Thomas Monjalon
  0 siblings, 0 replies; 247+ messages in thread
From: Thomas Monjalon @ 2022-02-08 17:03 UTC (permalink / raw)
  To: Stephen Hemminger
  Cc: dev, Yipeng Wang, Sameh Gobriel, Bruce Richardson,
	Vladimir Medvedkin, Olivier Matz, Andrew Rybchenko,
	Honnappa Nagarahalli, Konstantin Ananyev

29/01/2022 19:51, Thomas Monjalon:
> 28/01/2022 23:51, Stephen Hemminger:
> > On Fri, 28 Jan 2022 22:47:15 +0100
> > Thomas Monjalon <thomas@monjalon.net> wrote:
> > 
> > > 24/01/2022 18:45, Stephen Hemminger:
> > > > These functions all behave like libc free() and do
> > > > nothing if handed a NULL pointer. The code is already doing
> > > > this, this patch just documents the behavior.
> > > > 
> > > > Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> > > > ---
> > > >  /**
> > > >   * De-allocate all memory used by hash table.
> > > > + *
> > > > + * If the pointer is NULL, the function does nothing.  
> > > 
> > > Would be better to move in the context of the parameter
> > 
> > I copied text from rte_free to other functions...
> > For consistency, lets document it one way in all cases.
> > Don't care which one...
> 
> I prefer to have comments about a parameter inside the @param please.

Please would you provide a v3 before -rc1?



^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v3 00/36] remove unnecessary null checks
  2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
                   ` (82 preceding siblings ...)
  2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
@ 2022-02-09 19:17 ` Stephen Hemminger
  2022-02-09 19:17   ` [PATCH v3 01/36] lib: update documentation of XXX_free() functions Stephen Hemminger
                     ` (36 more replies)
  83 siblings, 37 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-02-09 19:17 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

While working on a new driver, noticed that some drivers always call
free routines (correct) and others conditionally call free routines
if not null (redundant check).  The extra if(e != NULL) type check
is unneeded and adds extra code.  Better to have all the code
consistent.

The Linux kernel has automated this kind of fixup using coccinelle,
and this patchset creates a coccinelle script to do the transformation;
then has individual patches for each sub component.

In one driver dpaaxx, the change suggested a further change
to the compat macros to make them even simpler.

v3
  - consolidate patches into logical groups

v2
  - add documentation change patch
  - spelling fix to coccinelle script patch
  - suggested whitespace fix to igc and ixgbe patch


Stephen Hemminger (36):
  lib: update documentation of XXX_free() functions
  devtools/cocci: add script to fix unnecessary null checks
  eal: remove unnecessary NULL checks
  ethdev: remove unnecessary NULL checks
  examples: remove unnecessary NULL checks
  vhost: remove unnecessary NULL checks
  app: remove unnecessary NULL checks
  baseband/*: remove unnecessary NULL checks
  bus/*: remove unnecessary NULL checks
  common/*: remove unnecessary NULL checks
  compress/*: remove unnecessary NULL checks
  crypto: remove unnecessary NULL checks
  event/sw: remove unnecessary NULL checks
  net/axgbe: remove unnecessary NULL checks
  net/bnx*: remove unnecessary NULL checks
  net/cnxk: remove unnecessary NULL checks
  net/cxgbe: remove unnecessary NULL checks
  net/dpaa*: remove unnecessary NULL checks
  net/ena: remove unnecessary NULL checks
  net/hinic: remove unnecessary NULL checks
  net/hns3: remove unnecessary NULL checks
  net/i*: remove unnecessary NULL checks
  net/mlx*: remove unnecessary NULL checks
  net/mvpp2: remove unnecessary NULL checks
  net/netvsc: remove unnecessary NULL checks
  net/octeontx: remove unnecessary NULL checks
  net/qede: remove unnecessary NULL checks
  net/txgbe: remove unnecessary NULL checks
  net/vdev_netvsc: remove unnecessary NULL checks
  net/virtio: remove unnecessary NULL checks
  net/other: remove unnecessary NULL checks
  raw/*: remove unnecessary NULL checks
  regex/*: remove unnecessary NULL checks
  vdpa/*: remove unnecessary NULL checks
  compressdev: remove unnecessary NULL checks
  other: remove unnecessary NULL checks

 app/pdump/main.c                              |  9 ++--
 app/test-crypto-perf/cperf_test_latency.c     |  3 +-
 .../cperf_test_pmd_cyclecount.c               |  9 ++--
 app/test-crypto-perf/cperf_test_throughput.c  |  3 +-
 .../cperf_test_vector_parsing.c               |  6 +--
 app/test-crypto-perf/cperf_test_verify.c      |  3 +-
 app/test-pmd/cmd_flex_item.c                  |  3 +-
 app/test-pmd/cmdline.c                        |  3 +-
 app/test-pmd/testpmd.c                        |  3 +-
 app/test-regex/main.c                         | 12 ++---
 app/test/test_cksum.c                         |  3 +-
 app/test/test_compressdev.c                   |  3 +-
 app/test/test_cryptodev.h                     |  3 +-
 app/test/test_cryptodev_asym.c                |  3 +-
 app/test/test_cryptodev_blockcipher.c         | 12 ++---
 app/test/test_func_reentrancy.c               | 15 +++----
 app/test/test_hash.c                          | 15 +++----
 app/test/test_hash_perf.c                     |  7 +--
 app/test/test_link_bonding.c                  |  9 ++--
 app/test/test_link_bonding_mode4.c            |  3 +-
 app/test/test_malloc.c                        |  5 +--
 app/test/test_mbuf.c                          | 45 +++++++------------
 app/test/test_pcapng.c                        |  3 +-
 app/test/test_reorder.c                       | 15 +++----
 app/test/virtual_pmd.c                        |  3 +-
 devtools/cocci/nullfree.cocci                 | 33 ++++++++++++++
 drivers/baseband/acc100/rte_acc100_pmd.c      |  3 +-
 drivers/baseband/la12xx/bbdev_la12xx.c        |  3 +-
 drivers/baseband/null/bbdev_null.c            |  3 +-
 .../baseband/turbo_sw/bbdev_turbo_software.c  |  3 +-
 drivers/bus/fslmc/fslmc_bus.c                 |  6 +--
 drivers/bus/fslmc/portal/dpaa2_hw_dpio.c      |  6 +--
 drivers/bus/ifpga/ifpga_bus.c                 | 12 ++---
 drivers/bus/pci/pci_params.c                  |  3 +-
 drivers/bus/pci/windows/pci.c                 |  3 +-
 drivers/bus/pci/windows/pci_netuio.c          |  3 +-
 drivers/common/cpt/cpt_ucode_asym.h           |  6 +--
 drivers/common/dpaax/compat.h                 | 11 +----
 drivers/common/mlx5/mlx5_common_mr.c          |  3 +-
 drivers/common/mlx5/mlx5_common_pci.c         |  3 +-
 drivers/common/qat/qat_qp.c                   |  9 ++--
 drivers/compress/mlx5/mlx5_compress.c         |  3 +-
 drivers/compress/octeontx/otx_zip_pmd.c       |  9 ++--
 drivers/crypto/armv8/rte_armv8_pmd_ops.c      |  3 +-
 drivers/crypto/ccp/ccp_dev.c                  |  3 +-
 drivers/crypto/ccp/ccp_pmd_ops.c              |  3 +-
 drivers/crypto/cnxk/cnxk_ae.h                 |  6 +--
 drivers/crypto/ipsec_mb/ipsec_mb_ops.c        |  3 +-
 drivers/crypto/mvsam/rte_mrvl_pmd_ops.c       |  6 +--
 drivers/crypto/null/null_crypto_pmd_ops.c     |  6 +--
 drivers/crypto/octeontx/otx_cryptodev_ops.c   |  3 +-
 drivers/crypto/openssl/rte_openssl_pmd_ops.c  |  6 +--
 drivers/crypto/scheduler/scheduler_pmd_ops.c  |  6 +--
 drivers/crypto/virtio/virtqueue.c             |  6 +--
 drivers/event/sw/sw_evdev.c                   |  3 +-
 drivers/net/axgbe/axgbe_rxtx.c                |  6 +--
 drivers/net/bnx2x/bnx2x_rxtx.c                |  6 +--
 drivers/net/bnxt/bnxt_ethdev.c                |  3 +-
 drivers/net/bonding/rte_eth_bond_pmd.c        |  3 +-
 drivers/net/cnxk/cnxk_ethdev.c                |  6 +--
 drivers/net/cxgbe/cxgbe_main.c                |  3 +-
 drivers/net/dpaa/dpaa_ethdev.c                |  3 +-
 drivers/net/dpaa/fmlib/fm_lib.c               |  3 +-
 drivers/net/dpaa2/dpaa2_ethdev.c              |  3 +-
 drivers/net/dpaa2/dpaa2_mux.c                 |  3 +-
 drivers/net/dpaa2/dpaa2_ptp.c                 |  3 +-
 drivers/net/ena/ena_ethdev.c                  | 18 +++-----
 drivers/net/hinic/hinic_pmd_ethdev.c          |  3 +-
 drivers/net/hns3/hns3_rxtx.c                  |  9 ++--
 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 +-
 drivers/net/memif/rte_eth_memif.c             |  6 +--
 drivers/net/mlx4/mlx4_mr.c                    |  3 +-
 drivers/net/mlx5/mlx5_flow.c                  |  3 +-
 drivers/net/mvpp2/mrvl_qos.c                  |  3 +-
 drivers/net/netvsc/hn_rxtx.c                  |  6 +--
 drivers/net/null/rte_eth_null.c               |  3 +-
 drivers/net/octeontx/octeontx_ethdev.c        |  3 +-
 drivers/net/octeontx/octeontx_ethdev_ops.c    |  3 +-
 drivers/net/qede/qede_main.c                  |  3 +-
 drivers/net/qede/qede_rxtx.c                  |  6 +--
 drivers/net/softnic/rte_eth_softnic_cli.c     | 12 ++---
 .../net/softnic/rte_eth_softnic_cryptodev.c   |  6 +--
 drivers/net/softnic/rte_eth_softnic_thread.c  |  6 +--
 drivers/net/tap/tap_flow.c                    |  9 ++--
 drivers/net/txgbe/txgbe_ethdev.c              | 12 ++---
 drivers/net/vdev_netvsc/vdev_netvsc.c         |  3 +-
 drivers/net/virtio/virtio_user_ethdev.c       | 12 ++---
 drivers/raw/cnxk_bphy/cnxk_bphy_cgx.c         |  3 +-
 drivers/raw/dpaa2_qdma/dpaa2_qdma.c           | 15 +++----
 drivers/raw/ifpga/ifpga_rawdev.c              |  9 ++--
 drivers/raw/skeleton/skeleton_rawdev_test.c   |  6 +--
 drivers/regex/cn9k/cn9k_regexdev.c            |  6 +--
 drivers/regex/cn9k/cn9k_regexdev_compiler.c   |  3 +-
 drivers/regex/mlx5/mlx5_regex.c               |  3 +-
 drivers/regex/mlx5/mlx5_rxp.c                 |  3 +-
 drivers/vdpa/ifc/ifcvf_vdpa.c                 |  9 ++--
 drivers/vdpa/mlx5/mlx5_vdpa_mem.c             |  3 +-
 drivers/vdpa/mlx5/mlx5_vdpa_virtq.c           |  3 +-
 examples/fips_validation/fips_dev_self_test.c | 18 +++-----
 examples/fips_validation/fips_validation.c    |  3 +-
 examples/fips_validation/main.c               | 36 +++++----------
 examples/ip_pipeline/cli.c                    | 12 ++---
 examples/ip_pipeline/cryptodev.c              |  6 +--
 examples/ip_pipeline/thread.c                 |  6 +--
 examples/l2fwd-cat/cat.c                      |  3 +-
 examples/pipeline/thread.c                    |  6 +--
 examples/vhost_blk/vhost_blk.c                |  3 +-
 lib/compressdev/rte_compressdev.c             |  3 +-
 lib/eal/common/eal_common_devargs.c           |  6 +--
 lib/eal/common/eal_common_memzone.c           |  3 +-
 lib/eal/common/eal_common_options.c           |  9 ++--
 lib/eal/common/eal_common_trace_ctf.c         |  6 +--
 lib/eal/freebsd/eal.c                         |  4 +-
 lib/eal/linux/eal.c                           | 10 ++---
 lib/eal/windows/eal_alarm.c                   |  3 +-
 lib/eal/windows/eal_memory.c                  |  3 +-
 lib/ethdev/rte_ethdev.c                       |  3 +-
 lib/graph/graph_stats.c                       |  3 +-
 lib/hash/rte_hash.h                           |  4 +-
 lib/ipsec/ipsec_sad.c                         |  3 +-
 lib/mempool/rte_mempool.h                     |  1 +
 lib/port/rte_port_source_sink.c               | 21 +++------
 lib/power/rte_power_empty_poll.c              |  3 +-
 lib/reorder/rte_reorder.c                     |  6 +--
 lib/ring/rte_ring.h                           |  3 +-
 lib/vhost/iotlb.c                             |  3 +-
 lib/vhost/vhost_crypto.c                      |  6 +--
 lib/vhost/vhost_user.c                        |  9 ++--
 134 files changed, 312 insertions(+), 560 deletions(-)
 create mode 100644 devtools/cocci/nullfree.cocci

-- 
2.34.1


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v3 01/36] lib: update documentation of XXX_free() functions
  2022-02-09 19:17 ` [PATCH v3 00/36] " Stephen Hemminger
@ 2022-02-09 19:17   ` Stephen Hemminger
  2022-02-09 19:17   ` [PATCH v3 02/36] devtools/cocci: add script to fix unnecessary null checks Stephen Hemminger
                     ` (35 subsequent siblings)
  36 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-02-09 19:17 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Yipeng Wang, Sameh Gobriel, Bruce Richardson,
	Vladimir Medvedkin, Olivier Matz, Andrew Rybchenko,
	Honnappa Nagarahalli, Konstantin Ananyev

These functions all behave like libc free() and do
nothing if handed a NULL pointer. The code is already doing
this, this patch just documents the behavior.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/hash/rte_hash.h       | 4 +++-
 lib/mempool/rte_mempool.h | 1 +
 lib/ring/rte_ring.h       | 3 ++-
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/lib/hash/rte_hash.h b/lib/hash/rte_hash.h
index 6067aad95431..7fa9702742a9 100644
--- a/lib/hash/rte_hash.h
+++ b/lib/hash/rte_hash.h
@@ -174,8 +174,10 @@ rte_hash_find_existing(const char *name);
 
 /**
  * De-allocate all memory used by hash table.
+ *
  * @param h
- *   Hash table to free
+ *   Hash table to free, if NULL, the function does nothing.
+ *
  */
 void
 rte_hash_free(struct rte_hash *h);
diff --git a/lib/mempool/rte_mempool.h b/lib/mempool/rte_mempool.h
index 1e7a3c15273c..1d3cdf7f2209 100644
--- a/lib/mempool/rte_mempool.h
+++ b/lib/mempool/rte_mempool.h
@@ -1101,6 +1101,7 @@ rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size,
  *
  * @param mp
  *   A pointer to the mempool structure.
+ *   If NULL then, the function does nothing.
  */
 void
 rte_mempool_free(struct rte_mempool *mp);
diff --git a/lib/ring/rte_ring.h b/lib/ring/rte_ring.h
index ab6b4244c89e..980e92e59493 100644
--- a/lib/ring/rte_ring.h
+++ b/lib/ring/rte_ring.h
@@ -193,7 +193,8 @@ struct rte_ring *rte_ring_create(const char *name, unsigned int count,
  * De-allocate all memory used by the ring.
  *
  * @param r
- *   Ring to free
+ *   Ring to free.
+ *   If NULL then, the function does nothing.
  */
 void rte_ring_free(struct rte_ring *r);
 
-- 
2.34.1


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v3 02/36] devtools/cocci: add script to fix unnecessary null checks
  2022-02-09 19:17 ` [PATCH v3 00/36] " Stephen Hemminger
  2022-02-09 19:17   ` [PATCH v3 01/36] lib: update documentation of XXX_free() functions Stephen Hemminger
@ 2022-02-09 19:17   ` Stephen Hemminger
  2022-02-09 19:17   ` [PATCH v3 03/36] eal: remove unnecessary NULL checks Stephen Hemminger
                     ` (34 subsequent siblings)
  36 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-02-09 19:17 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

This script is based on the idea of the nullfree script
in the Linux kernel. It finds cases where a check for null
pointer is done, but is unnecessary because the function
already handles NULL pointer.

Basic example:
       if (x->buf)
           rte_free(x->buf);
can be reduced to:
       rte_free(x->buf);

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 devtools/cocci/nullfree.cocci | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
 create mode 100644 devtools/cocci/nullfree.cocci

diff --git a/devtools/cocci/nullfree.cocci b/devtools/cocci/nullfree.cocci
new file mode 100644
index 000000000000..363b6149ac28
--- /dev/null
+++ b/devtools/cocci/nullfree.cocci
@@ -0,0 +1,33 @@
+//
+// Remove unnecessary NULL pointer checks before free functions
+// All these functions work like libc free which allows
+// free(NULL) as a no-op.
+//
+@@
+expression E;
+@@
+(
+- if (E != NULL) free(E);
++ free(E);
+|
+- if (E != NULL) rte_bitmap_free(E);
++ rte_bitmap_free(E);
+|
+- if (E != NULL) rte_free(E);
++ rte_free(E);
+|
+- if (E != NULL) rte_hash_free(E);
++ rte_hash_free(E);
+|
+- if (E != NULL) rte_ring_free(E);
++ rte_ring_free(E);
+|
+- if (E != NULL) rte_pktmbuf_free(E);
++ rte_pktmbuf_free(E);
+|
+- if (E != NULL) rte_mempool_free(E);
++ rte_mempool_free(E);
+|
+- if (E != NULL) rte_kvargs_free(E);
++ rte_kvargs_free(E);
+)
-- 
2.34.1


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v3 03/36] eal: remove unnecessary NULL checks
  2022-02-09 19:17 ` [PATCH v3 00/36] " Stephen Hemminger
  2022-02-09 19:17   ` [PATCH v3 01/36] lib: update documentation of XXX_free() functions Stephen Hemminger
  2022-02-09 19:17   ` [PATCH v3 02/36] devtools/cocci: add script to fix unnecessary null checks Stephen Hemminger
@ 2022-02-09 19:17   ` Stephen Hemminger
  2022-02-09 19:17   ` [PATCH v3 04/36] ethdev: " Stephen Hemminger
                     ` (33 subsequent siblings)
  36 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-02-09 19:17 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Anatoly Burakov, Jerin Jacob,
	Sunil Kumar Kori, Bruce Richardson, Dmitry Kozlyuk,
	Narcisa Ana Maria Vasile, Dmitry Malloy, Pallavi Kadam

Functions like free, rte_free, and rte_mempool_free
already handle NULL pointer so the checks here are not necessary.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_devargs.c   |  6 ++----
 lib/eal/common/eal_common_memzone.c   |  3 +--
 lib/eal/common/eal_common_options.c   |  9 +++------
 lib/eal/common/eal_common_trace_ctf.c |  6 ++----
 lib/eal/freebsd/eal.c                 |  4 +---
 lib/eal/linux/eal.c                   | 10 +++-------
 lib/eal/windows/eal_alarm.c           |  3 +--
 lib/eal/windows/eal_memory.c          |  3 +--
 8 files changed, 14 insertions(+), 30 deletions(-)

diff --git a/lib/eal/common/eal_common_devargs.c b/lib/eal/common/eal_common_devargs.c
index 8c7650cf6c27..69004b0a2d2f 100644
--- a/lib/eal/common/eal_common_devargs.c
+++ b/lib/eal/common/eal_common_devargs.c
@@ -161,8 +161,7 @@ rte_devargs_layers_parse(struct rte_devargs *devargs,
 
 get_out:
 	for (i = 0; i < RTE_DIM(layers); i++) {
-		if (layers[i].kvlist)
-			rte_kvargs_free(layers[i].kvlist);
+		rte_kvargs_free(layers[i].kvlist);
 	}
 	if (ret != 0) {
 		if (allocated_data) {
@@ -285,8 +284,7 @@ rte_devargs_reset(struct rte_devargs *da)
 {
 	if (da == NULL)
 		return;
-	if (da->data)
-		free(da->data);
+	free(da->data);
 	da->data = NULL;
 }
 
diff --git a/lib/eal/common/eal_common_memzone.c b/lib/eal/common/eal_common_memzone.c
index ecde9441ee90..9a0c5309ac7e 100644
--- a/lib/eal/common/eal_common_memzone.c
+++ b/lib/eal/common/eal_common_memzone.c
@@ -300,8 +300,7 @@ rte_memzone_free(const struct rte_memzone *mz)
 
 	rte_rwlock_write_unlock(&mcfg->mlock);
 
-	if (addr != NULL)
-		rte_free(addr);
+	rte_free(addr);
 
 	rte_eal_trace_memzone_free(name, addr, ret);
 	return ret;
diff --git a/lib/eal/common/eal_common_options.c b/lib/eal/common/eal_common_options.c
index 45d393b3937e..ff44d2124bab 100644
--- a/lib/eal/common/eal_common_options.c
+++ b/lib/eal/common/eal_common_options.c
@@ -1989,12 +1989,9 @@ compute_ctrl_threads_cpuset(struct internal_config *internal_cfg)
 int
 eal_cleanup_config(struct internal_config *internal_cfg)
 {
-	if (internal_cfg->hugefile_prefix != NULL)
-		free(internal_cfg->hugefile_prefix);
-	if (internal_cfg->hugepage_dir != NULL)
-		free(internal_cfg->hugepage_dir);
-	if (internal_cfg->user_mbuf_pool_ops_name != NULL)
-		free(internal_cfg->user_mbuf_pool_ops_name);
+	free(internal_cfg->hugefile_prefix);
+	free(internal_cfg->hugepage_dir);
+	free(internal_cfg->user_mbuf_pool_ops_name);
 
 	return 0;
 }
diff --git a/lib/eal/common/eal_common_trace_ctf.c b/lib/eal/common/eal_common_trace_ctf.c
index 33e419aac7fb..3b83bcdf57fd 100644
--- a/lib/eal/common/eal_common_trace_ctf.c
+++ b/lib/eal/common/eal_common_trace_ctf.c
@@ -52,8 +52,7 @@ meta_copy(char **meta, int *offset, char *str, int rc)
 	return rc;
 
 free_str:
-	if (str)
-		free(str);
+	free(str);
 	return -ENOMEM;
 }
 
@@ -291,8 +290,7 @@ trace_metadata_create(void)
 	return 0;
 
 fail:
-	if (meta)
-		free(meta);
+	free(meta);
 	return -EBADF;
 }
 
diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c
index a1cd2462db1b..00ba32f1d664 100644
--- a/lib/eal/freebsd/eal.c
+++ b/lib/eal/freebsd/eal.c
@@ -544,9 +544,7 @@ eal_parse_args(int argc, char **argv)
 				RTE_LOG(ERR, EAL, "Could not store mbuf pool ops name\n");
 			else {
 				/* free old ops name */
-				if (internal_conf->user_mbuf_pool_ops_name !=
-						NULL)
-					free(internal_conf->user_mbuf_pool_ops_name);
+				free(internal_conf->user_mbuf_pool_ops_name);
 
 				internal_conf->user_mbuf_pool_ops_name =
 						ops_name;
diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c
index 9c8395ab14d0..68fcf86a2e4c 100644
--- a/lib/eal/linux/eal.c
+++ b/lib/eal/linux/eal.c
@@ -730,8 +730,7 @@ eal_parse_args(int argc, char **argv)
 				RTE_LOG(ERR, EAL, "Could not store hugepage directory\n");
 			else {
 				/* free old hugepage dir */
-				if (internal_conf->hugepage_dir != NULL)
-					free(internal_conf->hugepage_dir);
+				free(internal_conf->hugepage_dir);
 				internal_conf->hugepage_dir = hdir;
 			}
 			break;
@@ -743,8 +742,7 @@ eal_parse_args(int argc, char **argv)
 				RTE_LOG(ERR, EAL, "Could not store file prefix\n");
 			else {
 				/* free old prefix */
-				if (internal_conf->hugefile_prefix != NULL)
-					free(internal_conf->hugefile_prefix);
+				free(internal_conf->hugefile_prefix);
 				internal_conf->hugefile_prefix = prefix;
 			}
 			break;
@@ -804,9 +802,7 @@ eal_parse_args(int argc, char **argv)
 				RTE_LOG(ERR, EAL, "Could not store mbuf pool ops name\n");
 			else {
 				/* free old ops name */
-				if (internal_conf->user_mbuf_pool_ops_name !=
-						NULL)
-					free(internal_conf->user_mbuf_pool_ops_name);
+				free(internal_conf->user_mbuf_pool_ops_name);
 
 				internal_conf->user_mbuf_pool_ops_name =
 						ops_name;
diff --git a/lib/eal/windows/eal_alarm.c b/lib/eal/windows/eal_alarm.c
index 103c1f909da3..51fe752c16d4 100644
--- a/lib/eal/windows/eal_alarm.c
+++ b/lib/eal/windows/eal_alarm.c
@@ -162,8 +162,7 @@ rte_eal_alarm_set(uint64_t us, rte_eal_alarm_callback cb_fn, void *cb_arg)
 fail:
 	if (timer != NULL)
 		CloseHandle(timer);
-	if (ap != NULL)
-		free(ap);
+	free(ap);
 
 exit:
 	rte_eal_trace_alarm_set(us, cb_fn, cb_arg, ret);
diff --git a/lib/eal/windows/eal_memory.c b/lib/eal/windows/eal_memory.c
index 2fd37d97085e..215d768e2c57 100644
--- a/lib/eal/windows/eal_memory.c
+++ b/lib/eal/windows/eal_memory.c
@@ -190,8 +190,7 @@ eal_mem_virt2iova_init(void)
 	ret = 0;
 
 exit:
-	if (detail != NULL)
-		free(detail);
+	free(detail);
 	if (list != INVALID_HANDLE_VALUE)
 		SetupDiDestroyDeviceInfoList(list);
 
-- 
2.34.1


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v3 04/36] ethdev: remove unnecessary NULL checks
  2022-02-09 19:17 ` [PATCH v3 00/36] " Stephen Hemminger
                     ` (2 preceding siblings ...)
  2022-02-09 19:17   ` [PATCH v3 03/36] eal: remove unnecessary NULL checks Stephen Hemminger
@ 2022-02-09 19:17   ` Stephen Hemminger
  2022-02-09 19:17   ` [PATCH v3 05/36] examples: " Stephen Hemminger
                     ` (32 subsequent siblings)
  36 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-02-09 19:17 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Thomas Monjalon, Ferruh Yigit, Andrew Rybchenko

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/ethdev/rte_ethdev.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index 29e21ad58003..cab7b7947eb7 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -6036,8 +6036,7 @@ rte_eth_devargs_parse(const char *dargs, struct rte_eth_devargs *eth_da)
 	}
 
 parse_cleanup:
-	if (args.str)
-		free(args.str);
+	free(args.str);
 
 	return result;
 }
-- 
2.34.1


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v3 05/36] examples: remove unnecessary NULL checks
  2022-02-09 19:17 ` [PATCH v3 00/36] " Stephen Hemminger
                     ` (3 preceding siblings ...)
  2022-02-09 19:17   ` [PATCH v3 04/36] ethdev: " Stephen Hemminger
@ 2022-02-09 19:17   ` Stephen Hemminger
  2022-02-09 19:17   ` [PATCH v3 06/36] vhost: " Stephen Hemminger
                     ` (31 subsequent siblings)
  36 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-02-09 19:17 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Marko Kovacevic, Cristian Dumitrescu,
	Tomasz Kantecki, Maxime Coquelin, Chenbo Xia

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 examples/fips_validation/fips_dev_self_test.c | 18 ++++------
 examples/fips_validation/fips_validation.c    |  3 +-
 examples/fips_validation/main.c               | 36 +++++++------------
 examples/ip_pipeline/cli.c                    | 12 +++----
 examples/ip_pipeline/cryptodev.c              |  6 ++--
 examples/ip_pipeline/thread.c                 |  6 ++--
 examples/l2fwd-cat/cat.c                      |  3 +-
 examples/pipeline/thread.c                    |  6 ++--
 examples/vhost_blk/vhost_blk.c                |  3 +-
 9 files changed, 31 insertions(+), 62 deletions(-)

diff --git a/examples/fips_validation/fips_dev_self_test.c b/examples/fips_validation/fips_dev_self_test.c
index b4eab05a9851..076e9de099c0 100644
--- a/examples/fips_validation/fips_dev_self_test.c
+++ b/examples/fips_validation/fips_dev_self_test.c
@@ -1396,8 +1396,7 @@ check_aead_result(struct rte_crypto_op *op,
 	if (!mbuf)
 		return -1;
 
-	if (op->sym->aead.aad.data)
-		rte_free(op->sym->aead.aad.data);
+	rte_free(op->sym->aead.aad.data);
 
 	if (dir == self_test_dir_enc_auth_gen) {
 		src = vec->output.data;
@@ -1523,18 +1522,13 @@ static void
 fips_dev_auto_test_uninit(uint8_t dev_id,
 		struct fips_dev_auto_test_env *env)
 {
-	if (env->mbuf)
-		rte_pktmbuf_free(env->mbuf);
+	rte_pktmbuf_free(env->mbuf);
 	if (env->op)
 		rte_crypto_op_free(env->op);
-	if (env->mpool)
-		rte_mempool_free(env->mpool);
-	if (env->op_pool)
-		rte_mempool_free(env->op_pool);
-	if (env->sess_pool)
-		rte_mempool_free(env->sess_pool);
-	if (env->sess_priv_pool)
-		rte_mempool_free(env->sess_priv_pool);
+	rte_mempool_free(env->mpool);
+	rte_mempool_free(env->op_pool);
+	rte_mempool_free(env->sess_pool);
+	rte_mempool_free(env->sess_priv_pool);
 
 	rte_cryptodev_stop(dev_id);
 }
diff --git a/examples/fips_validation/fips_validation.c b/examples/fips_validation/fips_validation.c
index 52a7bf952d46..94253eaee8bf 100644
--- a/examples/fips_validation/fips_validation.c
+++ b/examples/fips_validation/fips_validation.c
@@ -344,8 +344,7 @@ fips_test_clear(void)
 		fclose(info.fp_rd);
 	if (info.fp_wr)
 		fclose(info.fp_wr);
-	if (info.one_line_text)
-		free(info.one_line_text);
+	free(info.one_line_text);
 	if (info.nb_vec_lines) {
 		uint32_t i;
 
diff --git a/examples/fips_validation/main.c b/examples/fips_validation/main.c
index dc40bffe7d97..e06ae37567fd 100644
--- a/examples/fips_validation/main.c
+++ b/examples/fips_validation/main.c
@@ -143,12 +143,9 @@ cryptodev_fips_validate_app_int(void)
 error_exit:
 
 	rte_mempool_free(env.mpool);
-	if (env.sess_mpool)
-		rte_mempool_free(env.sess_mpool);
-	if (env.sess_priv_mpool)
-		rte_mempool_free(env.sess_priv_mpool);
-	if (env.op_pool)
-		rte_mempool_free(env.op_pool);
+	rte_mempool_free(env.sess_mpool);
+	rte_mempool_free(env.sess_priv_mpool);
+	rte_mempool_free(env.op_pool);
 
 	return ret;
 }
@@ -523,8 +520,7 @@ prepare_data_mbufs(struct fips_val *val)
 	uint16_t nb_seg;
 	int ret = 0;
 
-	if (env.mbuf)
-		rte_pktmbuf_free(env.mbuf);
+	rte_pktmbuf_free(env.mbuf);
 
 	if (total_len > RTE_MBUF_MAX_NB_SEGS) {
 		RTE_LOG(ERR, USER1, "Data len %u too big\n", total_len);
@@ -598,8 +594,7 @@ prepare_data_mbufs(struct fips_val *val)
 	return 0;
 
 error_exit:
-	if (head)
-		rte_pktmbuf_free(head);
+	rte_pktmbuf_free(head);
 	return ret;
 }
 
@@ -656,8 +651,7 @@ prepare_auth_op(void)
 	if (ret < 0)
 		return ret;
 
-	if (env.digest)
-		rte_free(env.digest);
+	rte_free(env.digest);
 
 	env.digest = rte_zmalloc(NULL, vec.cipher_auth.digest.len,
 			RTE_CACHE_LINE_SIZE);
@@ -705,8 +699,7 @@ prepare_aead_op(void)
 		if (ret < 0)
 			return ret;
 
-		if (env.digest)
-			rte_free(env.digest);
+		rte_free(env.digest);
 		env.digest = rte_zmalloc(NULL, vec.aead.digest.len,
 				RTE_CACHE_LINE_SIZE);
 		if (!env.digest) {
@@ -1430,8 +1423,7 @@ fips_mct_tdes_test(void)
 		}
 	}
 
-	if (val.val)
-		free(val.val);
+	free(val.val);
 
 	return 0;
 }
@@ -1510,8 +1502,7 @@ fips_mct_aes_ecb_test(void)
 		}
 	}
 
-	if (val.val)
-		free(val.val);
+	free(val.val);
 
 	return 0;
 }
@@ -1619,8 +1610,7 @@ fips_mct_aes_test(void)
 			memcpy(vec.iv.val, val.val, AES_BLOCK_SIZE);
 	}
 
-	if (val.val)
-		free(val.val);
+	free(val.val);
 
 	return 0;
 }
@@ -1706,8 +1696,7 @@ fips_mct_sha_test(void)
 
 	rte_free(vec.pt.val);
 
-	if (val.val)
-		free(val.val);
+	free(val.val);
 
 	return 0;
 }
@@ -1851,8 +1840,7 @@ fips_test_one_file(void)
 		rte_free(env.digest);
 		env.digest = NULL;
 	}
-	if (env.mbuf)
-		rte_pktmbuf_free(env.mbuf);
+	rte_pktmbuf_free(env.mbuf);
 
 	return ret;
 }
diff --git a/examples/ip_pipeline/cli.c b/examples/ip_pipeline/cli.c
index 0c372675a919..c918f30e06f3 100644
--- a/examples/ip_pipeline/cli.c
+++ b/examples/ip_pipeline/cli.c
@@ -3773,10 +3773,8 @@ parse_free_sym_crypto_param_data(struct rte_table_action_sym_crypto_params *p)
 
 		switch (xform[i]->type) {
 		case RTE_CRYPTO_SYM_XFORM_CIPHER:
-			if (p->cipher_auth.cipher_iv.val)
-				free(p->cipher_auth.cipher_iv.val);
-			if (p->cipher_auth.cipher_iv_update.val)
-				free(p->cipher_auth.cipher_iv_update.val);
+			free(p->cipher_auth.cipher_iv.val);
+			free(p->cipher_auth.cipher_iv_update.val);
 			break;
 		case RTE_CRYPTO_SYM_XFORM_AUTH:
 			if (p->cipher_auth.auth_iv.val)
@@ -3785,10 +3783,8 @@ parse_free_sym_crypto_param_data(struct rte_table_action_sym_crypto_params *p)
 				free(p->cipher_auth.cipher_iv_update.val);
 			break;
 		case RTE_CRYPTO_SYM_XFORM_AEAD:
-			if (p->aead.iv.val)
-				free(p->aead.iv.val);
-			if (p->aead.aad.val)
-				free(p->aead.aad.val);
+			free(p->aead.iv.val);
+			free(p->aead.aad.val);
 			break;
 		default:
 			continue;
diff --git a/examples/ip_pipeline/cryptodev.c b/examples/ip_pipeline/cryptodev.c
index 9997d974563f..cd0f9c3d4eac 100644
--- a/examples/ip_pipeline/cryptodev.c
+++ b/examples/ip_pipeline/cryptodev.c
@@ -151,10 +151,8 @@ cryptodev_create(const char *name, struct cryptodev_params *params)
 	return cryptodev;
 
 error_exit:
-	if (cryptodev->mp_create)
-		rte_mempool_free(cryptodev->mp_create);
-	if (cryptodev->mp_init)
-		rte_mempool_free(cryptodev->mp_init);
+	rte_mempool_free(cryptodev->mp_create);
+	rte_mempool_free(cryptodev->mp_init);
 
 	free(cryptodev);
 
diff --git a/examples/ip_pipeline/thread.c b/examples/ip_pipeline/thread.c
index b2e97327052f..82d5f87c384c 100644
--- a/examples/ip_pipeline/thread.c
+++ b/examples/ip_pipeline/thread.c
@@ -92,11 +92,9 @@ thread_free(void)
 			continue;
 
 		/* MSGQs */
-		if (t->msgq_req)
-			rte_ring_free(t->msgq_req);
+		rte_ring_free(t->msgq_req);
 
-		if (t->msgq_rsp)
-			rte_ring_free(t->msgq_rsp);
+		rte_ring_free(t->msgq_rsp);
 	}
 }
 
diff --git a/examples/l2fwd-cat/cat.c b/examples/l2fwd-cat/cat.c
index 502c6b32780e..77154c8b7e61 100644
--- a/examples/l2fwd-cat/cat.c
+++ b/examples/l2fwd-cat/cat.c
@@ -872,8 +872,7 @@ cat_fini(void)
 #if PQOS_VERSION <= 103
 	memset(m_sockets, 0, sizeof(m_sockets));
 #else
-	if (m_sockets != NULL)
-		free(m_sockets);
+	free(m_sockets);
 #endif
 	m_sock_count = 0;
 	memset(m_config, 0, sizeof(m_config));
diff --git a/examples/pipeline/thread.c b/examples/pipeline/thread.c
index bf11e6144b75..5fe7eae00eb6 100644
--- a/examples/pipeline/thread.c
+++ b/examples/pipeline/thread.c
@@ -89,11 +89,9 @@ thread_free(void)
 			continue;
 
 		/* MSGQs */
-		if (t->msgq_req)
-			rte_ring_free(t->msgq_req);
+		rte_ring_free(t->msgq_req);
 
-		if (t->msgq_rsp)
-			rte_ring_free(t->msgq_rsp);
+		rte_ring_free(t->msgq_rsp);
 	}
 }
 
diff --git a/examples/vhost_blk/vhost_blk.c b/examples/vhost_blk/vhost_blk.c
index feadacc62ee5..2cab1e6994fe 100644
--- a/examples/vhost_blk/vhost_blk.c
+++ b/examples/vhost_blk/vhost_blk.c
@@ -849,8 +849,7 @@ static void
 vhost_blk_ctrlr_destroy(struct vhost_blk_ctrlr *ctrlr)
 {
 	if (ctrlr->bdev != NULL) {
-		if (ctrlr->bdev->data != NULL)
-			rte_free(ctrlr->bdev->data);
+		rte_free(ctrlr->bdev->data);
 
 		rte_free(ctrlr->bdev);
 	}
-- 
2.34.1


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v3 06/36] vhost: remove unnecessary NULL checks
  2022-02-09 19:17 ` [PATCH v3 00/36] " Stephen Hemminger
                     ` (4 preceding siblings ...)
  2022-02-09 19:17   ` [PATCH v3 05/36] examples: " Stephen Hemminger
@ 2022-02-09 19:17   ` Stephen Hemminger
  2022-02-09 19:17   ` [PATCH v3 07/36] app: " Stephen Hemminger
                     ` (30 subsequent siblings)
  36 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-02-09 19:17 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Chenbo Xia, Maxime Coquelin

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
---
 lib/vhost/iotlb.c        | 3 +--
 lib/vhost/vhost_crypto.c | 6 ++----
 lib/vhost/vhost_user.c   | 9 +++------
 3 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/lib/vhost/iotlb.c b/lib/vhost/iotlb.c
index b24202a7eba3..5a5ba8b82a61 100644
--- a/lib/vhost/iotlb.c
+++ b/lib/vhost/iotlb.c
@@ -324,8 +324,7 @@ vhost_user_iotlb_init(struct virtio_net *dev, int vq_index)
 
 	/* If already created, free it and recreate */
 	vq->iotlb_pool = rte_mempool_lookup(pool_name);
-	if (vq->iotlb_pool)
-		rte_mempool_free(vq->iotlb_pool);
+	rte_mempool_free(vq->iotlb_pool);
 
 	vq->iotlb_pool = rte_mempool_create(pool_name,
 			IOTLB_CACHE_SIZE, sizeof(struct vhost_iotlb_entry), 0,
diff --git a/lib/vhost/vhost_crypto.c b/lib/vhost/vhost_crypto.c
index 926b5c0bd94a..012e0cefdeba 100644
--- a/lib/vhost/vhost_crypto.c
+++ b/lib/vhost/vhost_crypto.c
@@ -1498,10 +1498,8 @@ rte_vhost_crypto_create(int vid, uint8_t cryptodev_id,
 	return 0;
 
 error_exit:
-	if (vcrypto->session_map)
-		rte_hash_free(vcrypto->session_map);
-	if (vcrypto->mbuf_pool)
-		rte_mempool_free(vcrypto->mbuf_pool);
+	rte_hash_free(vcrypto->session_map);
+	rte_mempool_free(vcrypto->mbuf_pool);
 
 	rte_free(vcrypto);
 
diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c
index e8297a09eb73..b50e5ab5a9c4 100644
--- a/lib/vhost/vhost_user.c
+++ b/lib/vhost/vhost_user.c
@@ -488,8 +488,7 @@ vhost_user_set_vring_num(struct virtio_net **pdev,
 	}
 
 	if (vq_is_packed(dev)) {
-		if (vq->shadow_used_packed)
-			rte_free(vq->shadow_used_packed);
+		rte_free(vq->shadow_used_packed);
 		vq->shadow_used_packed = rte_malloc_socket(NULL,
 				vq->size *
 				sizeof(struct vring_used_elem_packed),
@@ -502,8 +501,7 @@ vhost_user_set_vring_num(struct virtio_net **pdev,
 		}
 
 	} else {
-		if (vq->shadow_used_split)
-			rte_free(vq->shadow_used_split);
+		rte_free(vq->shadow_used_split);
 
 		vq->shadow_used_split = rte_malloc_socket(NULL,
 				vq->size * sizeof(struct vring_used_elem),
@@ -517,8 +515,7 @@ vhost_user_set_vring_num(struct virtio_net **pdev,
 		}
 	}
 
-	if (vq->batch_copy_elems)
-		rte_free(vq->batch_copy_elems);
+	rte_free(vq->batch_copy_elems);
 	vq->batch_copy_elems = rte_malloc_socket(NULL,
 				vq->size * sizeof(struct batch_copy_elem),
 				RTE_CACHE_LINE_SIZE, vq->numa_node);
-- 
2.34.1


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v3 07/36] app: remove unnecessary NULL checks
  2022-02-09 19:17 ` [PATCH v3 00/36] " Stephen Hemminger
                     ` (5 preceding siblings ...)
  2022-02-09 19:17   ` [PATCH v3 06/36] vhost: " Stephen Hemminger
@ 2022-02-09 19:17   ` Stephen Hemminger
  2022-02-09 19:17   ` [PATCH v3 08/36] baseband/*: " Stephen Hemminger
                     ` (29 subsequent siblings)
  36 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-02-09 19:17 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Reshma Pattan, Declan Doherty, Ciara Power,
	Xiaoyun Li, Aman Singh, Yuying Zhang, Ori Kam, Olivier Matz,
	Fan Zhang, Ashish Gupta, Akhil Goyal, Bruce Richardson,
	Vladimir Medvedkin, Andrew Rybchenko, Honnappa Nagarahalli,
	Konstantin Ananyev, Anatoly Burakov, Yipeng Wang, Sameh Gobriel,
	Chas Williams, Min Hu (Connor)

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/pdump/main.c                              |  9 ++--
 app/test-crypto-perf/cperf_test_latency.c     |  3 +-
 .../cperf_test_pmd_cyclecount.c               |  9 ++--
 app/test-crypto-perf/cperf_test_throughput.c  |  3 +-
 .../cperf_test_vector_parsing.c               |  6 +--
 app/test-crypto-perf/cperf_test_verify.c      |  3 +-
 app/test-pmd/cmd_flex_item.c                  |  3 +-
 app/test-pmd/cmdline.c                        |  3 +-
 app/test-pmd/testpmd.c                        |  3 +-
 app/test-regex/main.c                         | 12 ++---
 app/test/test_cksum.c                         |  3 +-
 app/test/test_compressdev.c                   |  3 +-
 app/test/test_cryptodev.h                     |  3 +-
 app/test/test_cryptodev_asym.c                |  3 +-
 app/test/test_cryptodev_blockcipher.c         | 12 ++---
 app/test/test_func_reentrancy.c               | 15 +++----
 app/test/test_hash.c                          | 15 +++----
 app/test/test_hash_perf.c                     |  7 +--
 app/test/test_link_bonding.c                  |  9 ++--
 app/test/test_link_bonding_mode4.c            |  3 +-
 app/test/test_malloc.c                        |  5 +--
 app/test/test_mbuf.c                          | 45 +++++++------------
 app/test/test_pcapng.c                        |  3 +-
 app/test/test_reorder.c                       | 15 +++----
 app/test/virtual_pmd.c                        |  3 +-
 25 files changed, 65 insertions(+), 133 deletions(-)

diff --git a/app/pdump/main.c b/app/pdump/main.c
index 46f9d25db004..04a38e891119 100644
--- a/app/pdump/main.c
+++ b/app/pdump/main.c
@@ -502,14 +502,11 @@ cleanup_rings(void)
 	for (i = 0; i < num_tuples; i++) {
 		pt = &pdump_t[i];
 
-		if (pt->device_id)
-			free(pt->device_id);
+		free(pt->device_id);
 
 		/* free the rings */
-		if (pt->rx_ring)
-			rte_ring_free(pt->rx_ring);
-		if (pt->tx_ring)
-			rte_ring_free(pt->tx_ring);
+		rte_ring_free(pt->rx_ring);
+		rte_ring_free(pt->tx_ring);
 	}
 }
 
diff --git a/app/test-crypto-perf/cperf_test_latency.c b/app/test-crypto-perf/cperf_test_latency.c
index ce49feaba9f3..4c7bc72eb5fd 100644
--- a/app/test-crypto-perf/cperf_test_latency.c
+++ b/app/test-crypto-perf/cperf_test_latency.c
@@ -49,8 +49,7 @@ cperf_latency_test_free(struct cperf_latency_ctx *ctx)
 			rte_cryptodev_sym_session_free(ctx->sess);
 		}
 
-		if (ctx->pool)
-			rte_mempool_free(ctx->pool);
+		rte_mempool_free(ctx->pool);
 
 		rte_free(ctx->res);
 		rte_free(ctx);
diff --git a/app/test-crypto-perf/cperf_test_pmd_cyclecount.c b/app/test-crypto-perf/cperf_test_pmd_cyclecount.c
index 5842f29d43e2..6b4d09e623eb 100644
--- a/app/test-crypto-perf/cperf_test_pmd_cyclecount.c
+++ b/app/test-crypto-perf/cperf_test_pmd_cyclecount.c
@@ -79,14 +79,11 @@ cperf_pmd_cyclecount_test_free(struct cperf_pmd_cyclecount_ctx *ctx)
 		}
 	}
 
-	if (ctx->pool)
-		rte_mempool_free(ctx->pool);
+	rte_mempool_free(ctx->pool);
 
-	if (ctx->ops)
-		rte_free(ctx->ops);
+	rte_free(ctx->ops);
 
-	if (ctx->ops_processed)
-		rte_free(ctx->ops_processed);
+	rte_free(ctx->ops_processed);
 
 	rte_free(ctx);
 }
diff --git a/app/test-crypto-perf/cperf_test_throughput.c b/app/test-crypto-perf/cperf_test_throughput.c
index 51512af2ad81..51fad5a05505 100644
--- a/app/test-crypto-perf/cperf_test_throughput.c
+++ b/app/test-crypto-perf/cperf_test_throughput.c
@@ -57,8 +57,7 @@ cperf_throughput_test_free(struct cperf_throughput_ctx *ctx)
 			rte_cryptodev_sym_session_free(ctx->sess);
 		}
 	}
-	if (ctx->pool)
-		rte_mempool_free(ctx->pool);
+	rte_mempool_free(ctx->pool);
 
 	rte_free(ctx);
 }
diff --git a/app/test-crypto-perf/cperf_test_vector_parsing.c b/app/test-crypto-perf/cperf_test_vector_parsing.c
index 1e9dfcfff087..87f3a90055aa 100644
--- a/app/test-crypto-perf/cperf_test_vector_parsing.c
+++ b/app/test-crypto-perf/cperf_test_vector_parsing.c
@@ -551,10 +551,8 @@ parse_file(struct cperf_test_vector *vector, struct cperf_options *opts)
 err:
 	if (fp)
 		fclose(fp);
-	if (line)
-		free(line);
-	if (entry)
-		rte_free(entry);
+	free(line);
+	rte_free(entry);
 
 	return -1;
 }
diff --git a/app/test-crypto-perf/cperf_test_verify.c b/app/test-crypto-perf/cperf_test_verify.c
index 496eb0de00f0..c031330afcfe 100644
--- a/app/test-crypto-perf/cperf_test_verify.c
+++ b/app/test-crypto-perf/cperf_test_verify.c
@@ -42,8 +42,7 @@ cperf_verify_test_free(struct cperf_verify_ctx *ctx)
 			rte_cryptodev_sym_session_free(ctx->sess);
 		}
 
-		if (ctx->pool)
-			rte_mempool_free(ctx->pool);
+		rte_mempool_free(ctx->pool);
 
 		rte_free(ctx);
 	}
diff --git a/app/test-pmd/cmd_flex_item.c b/app/test-pmd/cmd_flex_item.c
index 908bcb3f47f8..9050825a81d7 100644
--- a/app/test-pmd/cmd_flex_item.c
+++ b/app/test-pmd/cmd_flex_item.c
@@ -364,8 +364,7 @@ flex_item_create(portid_t port_id, uint16_t flex_id, const char *filename)
 		       flow_error.message ? flow_error.message : "");
 	}
 out:
-	if (fp)
-		free(fp);
+	free(fp);
 }
 
 #else /* RTE_HAS_JANSSON */
diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index e626b1c7d9ee..298a594e709b 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -14696,8 +14696,7 @@ cmd_ddp_info_parsed(
 
 	ret = 0;
 no_print_return:
-	if (proto)
-		free(proto);
+	free(proto);
 #endif
 	if (ret == -ENOTSUP)
 		fprintf(stderr, "Function not supported in PMD\n");
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index e1da961311f8..6d2e52c7905f 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -908,8 +908,7 @@ create_extmem(uint32_t nb_mbufs, uint32_t mbuf_sz, struct extmem_param *param,
 
 	return 0;
 fail:
-	if (iovas)
-		free(iovas);
+	free(iovas);
 	if (addr)
 		munmap(addr, mem_sz);
 
diff --git a/app/test-regex/main.c b/app/test-regex/main.c
index 8e665df73ce0..ab8a3e56e774 100644
--- a/app/test-regex/main.c
+++ b/app/test-regex/main.c
@@ -210,8 +210,7 @@ read_file(char *file, char **buf)
 	printf("Error, can't open file %s\n, err = %d", file, res);
 	if (fp)
 		fclose(fp);
-	if (*buf)
-		rte_free(*buf);
+	rte_free(*buf);
 	return -res;
 }
 
@@ -299,8 +298,7 @@ init_port(uint16_t *nb_max_payload, char *rules_file, uint8_t *nb_max_matches,
 	rte_free(rules);
 	return 0;
 error:
-	if (rules)
-		rte_free(rules);
+	rte_free(rules);
 	return res;
 }
 
@@ -367,8 +365,7 @@ regex_create_segmented_mbuf(struct rte_mempool *mbuf_pool, int pkt_len,
 	return mbuf;
 
 fail:
-	if (mbuf)
-		rte_pktmbuf_free(mbuf);
+	rte_pktmbuf_free(mbuf);
 	return NULL;
 }
 
@@ -612,8 +609,7 @@ run_regex(void *args)
 		rte_free(qp->buf);
 		qp->buf = NULL;
 	}
-	if (mbuf_mp)
-		rte_mempool_free(mbuf_mp);
+	rte_mempool_free(mbuf_mp);
 	rte_free(qps);
 	return res;
 }
diff --git a/app/test/test_cksum.c b/app/test/test_cksum.c
index cd983d7c01ce..6c15de9a9312 100644
--- a/app/test/test_cksum.c
+++ b/app/test/test_cksum.c
@@ -218,8 +218,7 @@ test_l4_cksum(struct rte_mempool *pktmbuf_pool, const char *pktdata, size_t len)
 	return 0;
 
 fail:
-	if (m)
-		rte_pktmbuf_free(m);
+	rte_pktmbuf_free(m);
 
 	return -1;
 }
diff --git a/app/test/test_compressdev.c b/app/test/test_compressdev.c
index 57c566aa9229..fbecaf9aaad4 100644
--- a/app/test/test_compressdev.c
+++ b/app/test/test_compressdev.c
@@ -2144,8 +2144,7 @@ test_deflate_comp_decomp(const struct interim_data_params *int_data,
 
 	if (stream != NULL)
 		rte_compressdev_stream_free(0, stream);
-	if (all_decomp_data != NULL)
-		rte_free(all_decomp_data);
+	rte_free(all_decomp_data);
 
 	/* Free compress private xforms */
 	for (i = 0; i < test_priv_data.num_priv_xforms; i++) {
diff --git a/app/test/test_cryptodev.h b/app/test/test_cryptodev.h
index 70f23a3f67d0..29a7d4db2b10 100644
--- a/app/test/test_cryptodev.h
+++ b/app/test/test_cryptodev.h
@@ -230,8 +230,7 @@ create_segmented_mbuf(struct rte_mempool *mbuf_pool, int pkt_len,
 	return mbuf;
 
 fail:
-	if (mbuf)
-		rte_pktmbuf_free(mbuf);
+	rte_pktmbuf_free(mbuf);
 	return NULL;
 }
 
diff --git a/app/test/test_cryptodev_asym.c b/app/test/test_cryptodev_asym.c
index 9d3a5589bb9c..3dadedf733e9 100644
--- a/app/test/test_cryptodev_asym.c
+++ b/app/test/test_cryptodev_asym.c
@@ -520,8 +520,7 @@ test_cryptodev_asym_op(struct crypto_testsuite_params_asym *ts_params,
 		if (op != NULL)
 			rte_crypto_op_free(op);
 
-		if (result != NULL)
-			rte_free(result);
+		rte_free(result);
 
 	return status;
 }
diff --git a/app/test/test_cryptodev_blockcipher.c b/app/test/test_cryptodev_blockcipher.c
index 0c6f3ff42d4b..494459195c49 100644
--- a/app/test/test_cryptodev_blockcipher.c
+++ b/app/test/test_cryptodev_blockcipher.c
@@ -807,20 +807,16 @@ test_blockcipher_one_case(const struct blockcipher_test_case *t,
 			rte_cryptodev_sym_session_clear(dev_id, sess);
 			rte_cryptodev_sym_session_free(sess);
 		}
-		if (cipher_xform)
-			rte_free(cipher_xform);
-		if (auth_xform)
-			rte_free(auth_xform);
+		rte_free(cipher_xform);
+		rte_free(auth_xform);
 	}
 
 	if (op)
 		rte_crypto_op_free(op);
 
-	if (obuf)
-		rte_pktmbuf_free(obuf);
+	rte_pktmbuf_free(obuf);
 
-	if (ibuf)
-		rte_pktmbuf_free(ibuf);
+	rte_pktmbuf_free(ibuf);
 
 	return status;
 }
diff --git a/app/test/test_func_reentrancy.c b/app/test/test_func_reentrancy.c
index 4ab4167eb031..da00694daafd 100644
--- a/app/test/test_func_reentrancy.c
+++ b/app/test/test_func_reentrancy.c
@@ -89,15 +89,13 @@ ring_clean(unsigned int lcore_id)
 	int i;
 
 	rp = rte_ring_lookup("fr_test_once");
-	if (rp != NULL)
-		rte_ring_free(rp);
+	rte_ring_free(rp);
 
 	for (i = 0; i < MAX_ITER_MULTI; i++) {
 		snprintf(ring_name, sizeof(ring_name),
 				"fr_test_%d_%d", lcore_id, i);
 		rp = rte_ring_lookup(ring_name);
-		if (rp != NULL)
-			rte_ring_free(rp);
+		rte_ring_free(rp);
 	}
 }
 
@@ -152,15 +150,13 @@ mempool_clean(unsigned int lcore_id)
 	int i;
 
 	mp = rte_mempool_lookup("fr_test_once");
-	if (mp != NULL)
-		rte_mempool_free(mp);
+	rte_mempool_free(mp);
 
 	for (i = 0; i < MAX_ITER_MULTI; i++) {
 		snprintf(mempool_name, sizeof(mempool_name), "fr_test_%d_%d",
 			 lcore_id, i);
 		mp = rte_mempool_lookup(mempool_name);
-		if (mp != NULL)
-			rte_mempool_free(mp);
+		rte_mempool_free(mp);
 	}
 }
 
@@ -215,8 +211,7 @@ hash_clean(unsigned lcore_id)
 	int i;
 
 	handle = rte_hash_find_existing("fr_test_once");
-	if (handle != NULL)
-		rte_hash_free(handle);
+	rte_hash_free(handle);
 
 	for (i = 0; i < MAX_ITER_MULTI; i++) {
 		snprintf(hash_name, sizeof(hash_name), "fr_test_%d_%d",  lcore_id, i);
diff --git a/app/test/test_hash.c b/app/test/test_hash.c
index b99e8de1db71..d522cb7f8cbf 100644
--- a/app/test/test_hash.c
+++ b/app/test/test_hash.c
@@ -1654,8 +1654,7 @@ test_hash_add_delete_jhash2(void)
 	ret = 0;
 
 fail_jhash2:
-	if (handle != NULL)
-		rte_hash_free(handle);
+	rte_hash_free(handle);
 
 	return ret;
 }
@@ -1689,8 +1688,7 @@ test_hash_add_delete_2_jhash2(void)
 	ret = 0;
 
 fail_2_jhash2:
-	if (handle != NULL)
-		rte_hash_free(handle);
+	rte_hash_free(handle);
 
 	return ret;
 }
@@ -1754,8 +1752,7 @@ test_hash_add_delete_jhash_1word(void)
 	ret = 0;
 
 fail_jhash_1word:
-	if (handle != NULL)
-		rte_hash_free(handle);
+	rte_hash_free(handle);
 
 	return ret;
 }
@@ -1789,8 +1786,7 @@ test_hash_add_delete_jhash_2word(void)
 	ret = 0;
 
 fail_jhash_2word:
-	if (handle != NULL)
-		rte_hash_free(handle);
+	rte_hash_free(handle);
 
 	return ret;
 }
@@ -1824,8 +1820,7 @@ test_hash_add_delete_jhash_3word(void)
 	ret = 0;
 
 fail_jhash_3word:
-	if (handle != NULL)
-		rte_hash_free(handle);
+	rte_hash_free(handle);
 
 	return ret;
 }
diff --git a/app/test/test_hash_perf.c b/app/test/test_hash_perf.c
index 104a70b3974e..5d36c0f4543d 100644
--- a/app/test/test_hash_perf.c
+++ b/app/test/test_hash_perf.c
@@ -106,12 +106,7 @@ create_table(unsigned int with_data, unsigned int table_index,
 	ut_params.key_len = hashtest_key_lens[table_index];
 	ut_params.socket_id = rte_socket_id();
 	h[table_index] = rte_hash_find_existing(name);
-	if (h[table_index] != NULL)
-		/*
-		 * If table was already created, free it to create it again,
-		 * so we force it is empty
-		 */
-		rte_hash_free(h[table_index]);
+	rte_hash_free(h[table_index]);
 	h[table_index] = rte_hash_create(&ut_params);
 	if (h[table_index] == NULL) {
 		printf("Error creating table\n");
diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index dc6fc46b9c93..82a9b8e01a82 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -1639,8 +1639,7 @@ test_roundrobin_rx_burst_on_single_slave(void)
 
 	/* free mbufs */
 	for (i = 0; i < MAX_PKT_BURST; i++) {
-		if (rx_pkt_burst[i] != NULL)
-			rte_pktmbuf_free(rx_pkt_burst[i]);
+		rte_pktmbuf_free(rx_pkt_burst[i]);
 	}
 
 
@@ -1722,8 +1721,7 @@ test_roundrobin_rx_burst_on_multiple_slaves(void)
 
 	/* free mbufs */
 	for (i = 0; i < MAX_PKT_BURST; i++) {
-		if (rx_pkt_burst[i] != NULL)
-			rte_pktmbuf_free(rx_pkt_burst[i]);
+		rte_pktmbuf_free(rx_pkt_burst[i]);
 	}
 
 	/* Clean up and remove slaves from bonded device */
@@ -2010,8 +2008,7 @@ test_roundrobin_verify_slave_link_status_change_behaviour(void)
 
 	/* free mbufs */
 	for (i = 0; i < MAX_PKT_BURST; i++) {
-		if (rx_pkt_burst[i] != NULL)
-			rte_pktmbuf_free(rx_pkt_burst[i]);
+		rte_pktmbuf_free(rx_pkt_burst[i]);
 	}
 
 	/* Clean up and remove slaves from bonded device */
diff --git a/app/test/test_link_bonding_mode4.c b/app/test/test_link_bonding_mode4.c
index 351129de2f9b..d9b9c323c7f8 100644
--- a/app/test/test_link_bonding_mode4.c
+++ b/app/test/test_link_bonding_mode4.c
@@ -194,8 +194,7 @@ free_pkts(struct rte_mbuf **pkts, uint16_t count)
 	uint16_t i;
 
 	for (i = 0; i < count; i++) {
-		if (pkts[i] != NULL)
-			rte_pktmbuf_free(pkts[i]);
+		rte_pktmbuf_free(pkts[i]);
 	}
 }
 
diff --git a/app/test/test_malloc.c b/app/test/test_malloc.c
index 8db500c514e7..de40e506113a 100644
--- a/app/test/test_malloc.c
+++ b/app/test/test_malloc.c
@@ -823,7 +823,7 @@ test_zero_aligned_alloc(void)
 
 err_return:
 	/*clean up */
-	if (p1) rte_free(p1);
+	rte_free(p1);
 	return -1;
 }
 
@@ -876,8 +876,7 @@ test_malloc_bad_params(void)
 
 err_return:
 	/* clean up pointer */
-	if (bad_ptr)
-		rte_free(bad_ptr);
+	rte_free(bad_ptr);
 	return -1;
 }
 
diff --git a/app/test/test_mbuf.c b/app/test/test_mbuf.c
index f762befb6954..cf0577308f4d 100644
--- a/app/test/test_mbuf.c
+++ b/app/test/test_mbuf.c
@@ -304,8 +304,7 @@ test_one_pktmbuf(struct rte_mempool *pktmbuf_pool)
 	return 0;
 
 fail:
-	if (m)
-		rte_pktmbuf_free(m);
+	rte_pktmbuf_free(m);
 	return -1;
 }
 
@@ -416,12 +415,9 @@ testclone_testupdate_testdetach(struct rte_mempool *pktmbuf_pool,
 	return 0;
 
 fail:
-	if (m)
-		rte_pktmbuf_free(m);
-	if (clone)
-		rte_pktmbuf_free(clone);
-	if (clone2)
-		rte_pktmbuf_free(clone2);
+	rte_pktmbuf_free(m);
+	rte_pktmbuf_free(clone);
+	rte_pktmbuf_free(clone2);
 	return -1;
 }
 
@@ -572,12 +568,9 @@ test_pktmbuf_copy(struct rte_mempool *pktmbuf_pool,
 	return 0;
 
 fail:
-	if (m)
-		rte_pktmbuf_free(m);
-	if (copy)
-		rte_pktmbuf_free(copy);
-	if (copy2)
-		rte_pktmbuf_free(copy2);
+	rte_pktmbuf_free(m);
+	rte_pktmbuf_free(copy);
+	rte_pktmbuf_free(copy2);
 	return -1;
 }
 
@@ -679,12 +672,9 @@ test_attach_from_different_pool(struct rte_mempool *pktmbuf_pool,
 	return 0;
 
 fail:
-	if (m)
-		rte_pktmbuf_free(m);
-	if (clone)
-		rte_pktmbuf_free(clone);
-	if (clone2)
-		rte_pktmbuf_free(clone2);
+	rte_pktmbuf_free(m);
+	rte_pktmbuf_free(clone);
+	rte_pktmbuf_free(clone2);
 	return -1;
 }
 
@@ -722,8 +712,7 @@ test_pktmbuf_pool(struct rte_mempool *pktmbuf_pool)
 	}
 	/* free them */
 	for (i=0; i<NB_MBUF; i++) {
-		if (m[i] != NULL)
-			rte_pktmbuf_free(m[i]);
+		rte_pktmbuf_free(m[i]);
 	}
 
 	return ret;
@@ -924,8 +913,7 @@ test_pktmbuf_pool_ptr(struct rte_mempool *pktmbuf_pool)
 
 	/* free them */
 	for (i=0; i<NB_MBUF; i++) {
-		if (m[i] != NULL)
-			rte_pktmbuf_free(m[i]);
+		rte_pktmbuf_free(m[i]);
 	}
 
 	for (i=0; i<NB_MBUF; i++)
@@ -947,8 +935,7 @@ test_pktmbuf_pool_ptr(struct rte_mempool *pktmbuf_pool)
 
 	/* free them */
 	for (i=0; i<NB_MBUF; i++) {
-		if (m[i] != NULL)
-			rte_pktmbuf_free(m[i]);
+		rte_pktmbuf_free(m[i]);
 	}
 
 	return ret;
@@ -1366,8 +1353,7 @@ test_mbuf_linearize(struct rte_mempool *pktmbuf_pool, int pkt_len,
 	return 0;
 
 fail:
-	if (mbuf)
-		rte_pktmbuf_free(mbuf);
+	rte_pktmbuf_free(mbuf);
 	return -1;
 }
 
@@ -2783,8 +2769,7 @@ test_nb_segs_and_next_reset(void)
 	return 0;
 
 fail:
-	if (pool != NULL)
-		rte_mempool_free(pool);
+	rte_mempool_free(pool);
 	return -1;
 }
 
diff --git a/app/test/test_pcapng.c b/app/test/test_pcapng.c
index 34c5e1234695..320dacea3498 100644
--- a/app/test/test_pcapng.c
+++ b/app/test/test_pcapng.c
@@ -240,8 +240,7 @@ test_validate(void)
 static void
 test_cleanup(void)
 {
-	if (mp)
-		rte_mempool_free(mp);
+	rte_mempool_free(mp);
 
 	if (pcapng)
 		rte_pcapng_close(pcapng);
diff --git a/app/test/test_reorder.c b/app/test/test_reorder.c
index 07dcce06d293..f0714a5c18a3 100644
--- a/app/test/test_reorder.c
+++ b/app/test/test_reorder.c
@@ -218,8 +218,7 @@ test_reorder_insert(void)
 exit:
 	rte_reorder_free(b);
 	for (i = 0; i < num_bufs; i++) {
-		if (bufs[i] != NULL)
-			rte_pktmbuf_free(bufs[i]);
+		rte_pktmbuf_free(bufs[i]);
 	}
 	return ret;
 }
@@ -278,8 +277,7 @@ test_reorder_drain(void)
 		ret = -1;
 		goto exit;
 	}
-	if (robufs[0] != NULL)
-		rte_pktmbuf_free(robufs[0]);
+	rte_pktmbuf_free(robufs[0]);
 
 	/* Insert more packets
 	 * RB[] = {NULL, NULL, NULL, NULL}
@@ -313,8 +311,7 @@ test_reorder_drain(void)
 		goto exit;
 	}
 	for (i = 0; i < 3; i++) {
-		if (robufs[i] != NULL)
-			rte_pktmbuf_free(robufs[i]);
+		rte_pktmbuf_free(robufs[i]);
 	}
 
 	/*
@@ -332,10 +329,8 @@ test_reorder_drain(void)
 exit:
 	rte_reorder_free(b);
 	for (i = 0; i < num_bufs; i++) {
-		if (bufs[i] != NULL)
-			rte_pktmbuf_free(bufs[i]);
-		if (robufs[i] != NULL)
-			rte_pktmbuf_free(robufs[i]);
+		rte_pktmbuf_free(bufs[i]);
+		rte_pktmbuf_free(robufs[i]);
 	}
 	return ret;
 }
diff --git a/app/test/virtual_pmd.c b/app/test/virtual_pmd.c
index 3d2793852049..cd4611ab48df 100644
--- a/app/test/virtual_pmd.c
+++ b/app/test/virtual_pmd.c
@@ -397,8 +397,7 @@ virtual_ethdev_tx_burst_fail(void *queue, struct rte_mbuf **bufs,
 		/* free packets in burst */
 		for (i = 0; i < successfully_txd; i++) {
 			/* free packets in burst */
-			if (bufs[i] != NULL)
-				rte_pktmbuf_free(bufs[i]);
+			rte_pktmbuf_free(bufs[i]);
 
 			bufs[i] = NULL;
 		}
-- 
2.34.1


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v3 08/36] baseband/*: remove unnecessary NULL checks
  2022-02-09 19:17 ` [PATCH v3 00/36] " Stephen Hemminger
                     ` (6 preceding siblings ...)
  2022-02-09 19:17   ` [PATCH v3 07/36] app: " Stephen Hemminger
@ 2022-02-09 19:17   ` Stephen Hemminger
  2022-02-09 19:17   ` [PATCH v3 09/36] bus/*: " Stephen Hemminger
                     ` (28 subsequent siblings)
  36 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-02-09 19:17 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Hemant Agrawal, Nicolas Chautru, Nipun Gupta

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>
---
 drivers/baseband/acc100/rte_acc100_pmd.c         | 3 +--
 drivers/baseband/la12xx/bbdev_la12xx.c           | 3 +--
 drivers/baseband/null/bbdev_null.c               | 3 +--
 drivers/baseband/turbo_sw/bbdev_turbo_software.c | 3 +--
 4 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/baseband/acc100/rte_acc100_pmd.c b/drivers/baseband/acc100/rte_acc100_pmd.c
index 1c6080f2f895..f86474f7e099 100644
--- a/drivers/baseband/acc100/rte_acc100_pmd.c
+++ b/drivers/baseband/acc100/rte_acc100_pmd.c
@@ -4402,8 +4402,7 @@ poweron_cleanup(struct rte_bbdev *bbdev, struct acc100_device *d,
 	}
 	printf("Number of 5GUL engines %d\n", numEngines);
 
-	if (d->sw_rings_base != NULL)
-		rte_free(d->sw_rings_base);
+	rte_free(d->sw_rings_base);
 	usleep(ACC100_LONG_WAIT);
 }
 
diff --git a/drivers/baseband/la12xx/bbdev_la12xx.c b/drivers/baseband/la12xx/bbdev_la12xx.c
index 4b05b5d3f2a6..4d1bd16751fe 100644
--- a/drivers/baseband/la12xx/bbdev_la12xx.c
+++ b/drivers/baseband/la12xx/bbdev_la12xx.c
@@ -975,8 +975,7 @@ parse_bbdev_la12xx_params(struct bbdev_la12xx_params *params,
 	}
 
 exit:
-	if (kvlist)
-		rte_kvargs_free(kvlist);
+	rte_kvargs_free(kvlist);
 	return ret;
 }
 
diff --git a/drivers/baseband/null/bbdev_null.c b/drivers/baseband/null/bbdev_null.c
index 08cff582b99d..248e12987f03 100644
--- a/drivers/baseband/null/bbdev_null.c
+++ b/drivers/baseband/null/bbdev_null.c
@@ -251,8 +251,7 @@ parse_bbdev_null_params(struct bbdev_null_params *params,
 	}
 
 exit:
-	if (kvlist)
-		rte_kvargs_free(kvlist);
+	rte_kvargs_free(kvlist);
 	return ret;
 }
 
diff --git a/drivers/baseband/turbo_sw/bbdev_turbo_software.c b/drivers/baseband/turbo_sw/bbdev_turbo_software.c
index c6b1eb8679cb..af7bc416f92e 100644
--- a/drivers/baseband/turbo_sw/bbdev_turbo_software.c
+++ b/drivers/baseband/turbo_sw/bbdev_turbo_software.c
@@ -1918,8 +1918,7 @@ parse_turbo_sw_params(struct turbo_sw_params *params, const char *input_args)
 	}
 
 exit:
-	if (kvlist)
-		rte_kvargs_free(kvlist);
+	rte_kvargs_free(kvlist);
 	return ret;
 }
 
-- 
2.34.1


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v3 09/36] bus/*: remove unnecessary NULL checks
  2022-02-09 19:17 ` [PATCH v3 00/36] " Stephen Hemminger
                     ` (7 preceding siblings ...)
  2022-02-09 19:17   ` [PATCH v3 08/36] baseband/*: " Stephen Hemminger
@ 2022-02-09 19:17   ` Stephen Hemminger
  2022-02-10  3:02     ` Xu, Rosen
  2022-02-09 19:17   ` [PATCH v3 10/36] common/*: " Stephen Hemminger
                     ` (27 subsequent siblings)
  36 siblings, 1 reply; 247+ messages in thread
From: Stephen Hemminger @ 2022-02-09 19:17 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Hemant Agrawal, Sachin Saxena, Rosen Xu

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>
---
 drivers/bus/fslmc/fslmc_bus.c            |  6 ++----
 drivers/bus/fslmc/portal/dpaa2_hw_dpio.c |  6 ++----
 drivers/bus/ifpga/ifpga_bus.c            | 12 ++++--------
 drivers/bus/pci/pci_params.c             |  3 +--
 drivers/bus/pci/windows/pci.c            |  3 +--
 drivers/bus/pci/windows/pci_netuio.c     |  3 +--
 6 files changed, 11 insertions(+), 22 deletions(-)

diff --git a/drivers/bus/fslmc/fslmc_bus.c b/drivers/bus/fslmc/fslmc_bus.c
index 356253f6b412..e9edc27e0ab0 100644
--- a/drivers/bus/fslmc/fslmc_bus.c
+++ b/drivers/bus/fslmc/fslmc_bus.c
@@ -221,13 +221,11 @@ scan_one_fslmc_device(char *dev_name)
 	insert_in_device_list(dev);
 
 	/* Don't need the duplicated device filesystem entry anymore */
-	if (dup_dev_name)
-		free(dup_dev_name);
+	free(dup_dev_name);
 
 	return 0;
 cleanup:
-	if (dup_dev_name)
-		free(dup_dev_name);
+	free(dup_dev_name);
 	if (dev) {
 		rte_intr_instance_free(dev->intr_handle);
 		free(dev);
diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
index 52605ea2c32c..943fadee4816 100644
--- a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
+++ b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
@@ -149,8 +149,7 @@ dpaa2_affine_dpio_intr_to_respective_core(int32_t dpio_id, int cpu_id)
 	if (!token) {
 		DPAA2_BUS_WARN("Failed to get interrupt id for dpio.%d",
 			       dpio_id);
-		if (temp)
-			free(temp);
+		free(temp);
 		fclose(file);
 		return;
 	}
@@ -574,8 +573,7 @@ dpaa2_free_dq_storage(struct queue_storage_info_t *q_storage)
 	int i = 0;
 
 	for (i = 0; i < NUM_DQS_PER_QUEUE; i++) {
-		if (q_storage->dq_storage[i])
-			rte_free(q_storage->dq_storage[i]);
+		rte_free(q_storage->dq_storage[i]);
 	}
 }
 
diff --git a/drivers/bus/ifpga/ifpga_bus.c b/drivers/bus/ifpga/ifpga_bus.c
index c5c8bbd57219..e005f2cb70b3 100644
--- a/drivers/bus/ifpga/ifpga_bus.c
+++ b/drivers/bus/ifpga/ifpga_bus.c
@@ -191,10 +191,8 @@ ifpga_scan_one(struct rte_rawdev *rawdev,
 	return afu_dev;
 
 end:
-	if (kvlist)
-		rte_kvargs_free(kvlist);
-	if (path)
-		free(path);
+	rte_kvargs_free(kvlist);
+	free(path);
 	if (afu_dev) {
 		rte_intr_instance_free(afu_dev->intr_handle);
 		free(afu_dev);
@@ -254,10 +252,8 @@ ifpga_scan(void)
 	}
 
 end:
-	if (kvlist)
-		rte_kvargs_free(kvlist);
-	if (name)
-		free(name);
+	rte_kvargs_free(kvlist);
+	free(name);
 
 	return 0;
 }
diff --git a/drivers/bus/pci/pci_params.c b/drivers/bus/pci/pci_params.c
index 60b424b8297e..61a868707f16 100644
--- a/drivers/bus/pci/pci_params.c
+++ b/drivers/bus/pci/pci_params.c
@@ -117,8 +117,7 @@ rte_pci_devargs_parse(struct rte_devargs *da)
 	rte_pci_device_name(&addr, da->name, sizeof(da->name));
 
 out:
-	if (kvargs != NULL)
-		rte_kvargs_free(kvargs);
+	rte_kvargs_free(kvargs);
 	if (ret != 0)
 		rte_errno = -ret;
 	return ret;
diff --git a/drivers/bus/pci/windows/pci.c b/drivers/bus/pci/windows/pci.c
index 39ba31be7d38..7bf091158ba2 100644
--- a/drivers/bus/pci/windows/pci.c
+++ b/drivers/bus/pci/windows/pci.c
@@ -418,8 +418,7 @@ pci_scan_one(HDEVINFO dev_info, PSP_DEVINFO_DATA device_info_data)
 
 	return 0;
 end:
-	if (dev)
-		free(dev);
+	free(dev);
 	return ret;
 }
 
diff --git a/drivers/bus/pci/windows/pci_netuio.c b/drivers/bus/pci/windows/pci_netuio.c
index a0b175a8fca0..5460399eea5f 100644
--- a/drivers/bus/pci/windows/pci_netuio.c
+++ b/drivers/bus/pci/windows/pci_netuio.c
@@ -180,8 +180,7 @@ get_netuio_device_info(HDEVINFO dev_info, PSP_DEVINFO_DATA dev_info_data,
 			CloseHandle(netuio);
 	}
 
-	if (dev_ifx_detail)
-		free(dev_ifx_detail);
+	free(dev_ifx_detail);
 
 	if (di_set != INVALID_HANDLE_VALUE)
 		SetupDiDestroyDeviceInfoList(di_set);
-- 
2.34.1


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v3 10/36] common/*: remove unnecessary NULL checks
  2022-02-09 19:17 ` [PATCH v3 00/36] " Stephen Hemminger
                     ` (8 preceding siblings ...)
  2022-02-09 19:17   ` [PATCH v3 09/36] bus/*: " Stephen Hemminger
@ 2022-02-09 19:17   ` Stephen Hemminger
  2022-02-09 19:17   ` [PATCH v3 11/36] compress/*: " Stephen Hemminger
                     ` (26 subsequent siblings)
  36 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-02-09 19:17 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Anoob Joseph, Hemant Agrawal, Sachin Saxena,
	Matan Azrad, Viacheslav Ovsiienko, John Griffin, Fiona Trahe,
	Deepak Kumar Jain

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/common/cpt/cpt_ucode_asym.h   |  6 ++----
 drivers/common/dpaax/compat.h         | 11 ++---------
 drivers/common/mlx5/mlx5_common_mr.c  |  3 +--
 drivers/common/mlx5/mlx5_common_pci.c |  3 +--
 drivers/common/qat/qat_qp.c           |  9 +++------
 5 files changed, 9 insertions(+), 23 deletions(-)

diff --git a/drivers/common/cpt/cpt_ucode_asym.h b/drivers/common/cpt/cpt_ucode_asym.h
index f0b5dddd8cdf..f5d91f2583bd 100644
--- a/drivers/common/cpt/cpt_ucode_asym.h
+++ b/drivers/common/cpt/cpt_ucode_asym.h
@@ -192,13 +192,11 @@ cpt_free_asym_session_parameters(struct cpt_asym_sess_misc *sess)
 	switch (sess->xfrm_type) {
 	case RTE_CRYPTO_ASYM_XFORM_RSA:
 		rsa = &sess->rsa_ctx;
-		if (rsa->n.data)
-			rte_free(rsa->n.data);
+		rte_free(rsa->n.data);
 		break;
 	case RTE_CRYPTO_ASYM_XFORM_MODEX:
 		mod = &sess->mod_ctx;
-		if (mod->modulus.data)
-			rte_free(mod->modulus.data);
+		rte_free(mod->modulus.data);
 		break;
 	case RTE_CRYPTO_ASYM_XFORM_ECDSA:
 		/* Fall through */
diff --git a/drivers/common/dpaax/compat.h b/drivers/common/dpaax/compat.h
index 7166f8cceb41..cbabc1588b21 100644
--- a/drivers/common/dpaax/compat.h
+++ b/drivers/common/dpaax/compat.h
@@ -339,16 +339,9 @@ static inline void copy_bytes(void *dest, const void *src, size_t sz)
 
 /* Allocator stuff */
 #define kmalloc(sz, t)	rte_malloc(NULL, sz, 0)
+#define kzalloc(sz, t)  rte_zmalloc(NULL, sz, 0)
 #define vmalloc(sz)	rte_malloc(NULL, sz, 0)
-#define kfree(p)	{ if (p) rte_free(p); }
-static inline void *kzalloc(size_t sz, gfp_t __foo __rte_unused)
-{
-	void *ptr = rte_malloc(NULL, sz, 0);
-
-	if (ptr)
-		memset(ptr, 0, sz);
-	return ptr;
-}
+#define kfree(p)	rte_free(p)
 
 static inline unsigned long get_zeroed_page(gfp_t __foo __rte_unused)
 {
diff --git a/drivers/common/mlx5/mlx5_common_mr.c b/drivers/common/mlx5/mlx5_common_mr.c
index 5f7e4f6734aa..fa27bd98de04 100644
--- a/drivers/common/mlx5/mlx5_common_mr.c
+++ b/drivers/common/mlx5/mlx5_common_mr.c
@@ -516,8 +516,7 @@ mlx5_mr_free(struct mlx5_mr *mr, mlx5_dereg_mr_t dereg_mr_cb)
 		return;
 	DRV_LOG(DEBUG, "freeing MR(%p):", (void *)mr);
 	dereg_mr_cb(&mr->pmd_mr);
-	if (mr->ms_bmp != NULL)
-		rte_bitmap_free(mr->ms_bmp);
+	rte_bitmap_free(mr->ms_bmp);
 	mlx5_free(mr);
 }
 
diff --git a/drivers/common/mlx5/mlx5_common_pci.c b/drivers/common/mlx5/mlx5_common_pci.c
index 8b38091d8741..458630351cd1 100644
--- a/drivers/common/mlx5/mlx5_common_pci.c
+++ b/drivers/common/mlx5/mlx5_common_pci.c
@@ -97,8 +97,7 @@ pci_ids_table_update(const struct rte_pci_id *driver_id_table)
 	updated_table[i].vendor_id = 0;
 	mlx5_common_pci_driver.id_table = updated_table;
 	mlx5_pci_id_table = updated_table;
-	if (old_table)
-		free(old_table);
+	free(old_table);
 	return 0;
 }
 
diff --git a/drivers/common/qat/qat_qp.c b/drivers/common/qat/qat_qp.c
index cde421eb7716..57ac8fefca3d 100644
--- a/drivers/common/qat/qat_qp.c
+++ b/drivers/common/qat/qat_qp.c
@@ -175,11 +175,9 @@ qat_qp_setup(struct qat_pci_device *qat_dev,
 
 create_err:
 	if (qp) {
-		if (qp->op_cookie_pool)
-			rte_mempool_free(qp->op_cookie_pool);
+		rte_mempool_free(qp->op_cookie_pool);
 
-		if (qp->op_cookies)
-			rte_free(qp->op_cookies);
+		rte_free(qp->op_cookies);
 
 		rte_free(qp);
 	}
@@ -329,8 +327,7 @@ qat_qp_release(enum qat_device_gen qat_dev_gen, struct qat_qp **qp_addr)
 	for (i = 0; i < qp->nb_descriptors; i++)
 		rte_mempool_put(qp->op_cookie_pool, qp->op_cookies[i]);
 
-	if (qp->op_cookie_pool)
-		rte_mempool_free(qp->op_cookie_pool);
+	rte_mempool_free(qp->op_cookie_pool);
 
 	rte_free(qp->op_cookies);
 	rte_free(qp);
-- 
2.34.1


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v3 11/36] compress/*: remove unnecessary NULL checks
  2022-02-09 19:17 ` [PATCH v3 00/36] " Stephen Hemminger
                     ` (9 preceding siblings ...)
  2022-02-09 19:17   ` [PATCH v3 10/36] common/*: " Stephen Hemminger
@ 2022-02-09 19:17   ` Stephen Hemminger
  2022-02-09 19:17   ` [PATCH v3 12/36] crypto: " Stephen Hemminger
                     ` (25 subsequent siblings)
  36 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-02-09 19:17 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Matan Azrad, Fan Zhang, Ashish Gupta

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/compress/mlx5/mlx5_compress.c   | 3 +--
 drivers/compress/octeontx/otx_zip_pmd.c | 9 +++------
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/compress/mlx5/mlx5_compress.c b/drivers/compress/mlx5/mlx5_compress.c
index 82b871bd860a..b12951da8b51 100644
--- a/drivers/compress/mlx5/mlx5_compress.c
+++ b/drivers/compress/mlx5/mlx5_compress.c
@@ -146,8 +146,7 @@ mlx5_compress_qp_release(struct rte_compressdev *dev, uint16_t qp_id)
 		void *opaq = qp->opaque_mr.addr;
 
 		mlx5_common_verbs_dereg_mr(&qp->opaque_mr);
-		if (opaq != NULL)
-			rte_free(opaq);
+		rte_free(opaq);
 	}
 	mlx5_mr_btree_free(&qp->mr_ctrl.cache_bh);
 	rte_free(qp);
diff --git a/drivers/compress/octeontx/otx_zip_pmd.c b/drivers/compress/octeontx/otx_zip_pmd.c
index dd62285b863e..26cdce60a859 100644
--- a/drivers/compress/octeontx/otx_zip_pmd.c
+++ b/drivers/compress/octeontx/otx_zip_pmd.c
@@ -337,8 +337,7 @@ zip_pmd_qp_release(struct rte_compressdev *dev, uint16_t qp_id)
 	if (qp != NULL) {
 		zipvf_q_term(qp);
 
-		if (qp->processed_pkts)
-			rte_ring_free(qp->processed_pkts);
+		rte_ring_free(qp->processed_pkts);
 
 		rte_free(qp);
 		dev->data->queue_pairs[qp_id] = NULL;
@@ -423,10 +422,8 @@ zip_pmd_qp_setup(struct rte_compressdev *dev, uint16_t qp_id,
 	return 0;
 
 qp_setup_cleanup:
-	if (qp->processed_pkts)
-		rte_ring_free(qp->processed_pkts);
-	if (qp)
-		rte_free(qp);
+	rte_ring_free(qp->processed_pkts);
+	rte_free(qp);
 	return -1;
 }
 
-- 
2.34.1


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v3 12/36] crypto: remove unnecessary NULL checks
  2022-02-09 19:17 ` [PATCH v3 00/36] " Stephen Hemminger
                     ` (10 preceding siblings ...)
  2022-02-09 19:17   ` [PATCH v3 11/36] compress/*: " Stephen Hemminger
@ 2022-02-09 19:17   ` Stephen Hemminger
  2022-02-09 19:17   ` [PATCH v3 13/36] event/sw: " Stephen Hemminger
                     ` (24 subsequent siblings)
  36 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-02-09 19:17 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Ruifeng Wang, Fan Zhang, Chandubabu Namburu,
	Ankur Dwivedi, Anoob Joseph, Tejasree Kondoj, Pablo de Lara,
	Michael Shamis, Liron Himi, Declan Doherty, Jay Zhou

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Ruifeng Wang <ruifeng.wang@arm.com>
Acked-by: Fan Zhang <roy.fan.zhang@intel.com>
---
 drivers/crypto/armv8/rte_armv8_pmd_ops.c     | 3 +--
 drivers/crypto/ccp/ccp_dev.c                 | 3 +--
 drivers/crypto/ccp/ccp_pmd_ops.c             | 3 +--
 drivers/crypto/cnxk/cnxk_ae.h                | 6 ++----
 drivers/crypto/ipsec_mb/ipsec_mb_ops.c       | 3 +--
 drivers/crypto/mvsam/rte_mrvl_pmd_ops.c      | 6 ++----
 drivers/crypto/null/null_crypto_pmd_ops.c    | 6 ++----
 drivers/crypto/octeontx/otx_cryptodev_ops.c  | 3 +--
 drivers/crypto/openssl/rte_openssl_pmd_ops.c | 6 ++----
 drivers/crypto/scheduler/scheduler_pmd_ops.c | 6 ++----
 drivers/crypto/virtio/virtqueue.c            | 6 ++----
 11 files changed, 17 insertions(+), 34 deletions(-)

diff --git a/drivers/crypto/armv8/rte_armv8_pmd_ops.c b/drivers/crypto/armv8/rte_armv8_pmd_ops.c
index 1b2749fe62c6..c07ac0489e57 100644
--- a/drivers/crypto/armv8/rte_armv8_pmd_ops.c
+++ b/drivers/crypto/armv8/rte_armv8_pmd_ops.c
@@ -251,8 +251,7 @@ armv8_crypto_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 	return 0;
 
 qp_setup_cleanup:
-	if (qp)
-		rte_free(qp);
+	rte_free(qp);
 
 	return -1;
 }
diff --git a/drivers/crypto/ccp/ccp_dev.c b/drivers/crypto/ccp/ccp_dev.c
index 0eb1b0328ef0..424ead82c3aa 100644
--- a/drivers/crypto/ccp/ccp_dev.c
+++ b/drivers/crypto/ccp/ccp_dev.c
@@ -673,8 +673,7 @@ ccp_probe_device(int ccp_type, struct rte_pci_device *pci_dev)
 	CCP_LOG_ERR("CCP Device probe failed");
 	if (uio_fd >= 0)
 		close(uio_fd);
-	if (ccp_dev)
-		rte_free(ccp_dev);
+	rte_free(ccp_dev);
 	return -1;
 }
 
diff --git a/drivers/crypto/ccp/ccp_pmd_ops.c b/drivers/crypto/ccp/ccp_pmd_ops.c
index 0d615d311c9b..1b600e81ad5c 100644
--- a/drivers/crypto/ccp/ccp_pmd_ops.c
+++ b/drivers/crypto/ccp/ccp_pmd_ops.c
@@ -744,8 +744,7 @@ ccp_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 
 qp_setup_cleanup:
 	dev->data->queue_pairs[qp_id] = NULL;
-	if (qp)
-		rte_free(qp);
+	rte_free(qp);
 	return -1;
 }
 
diff --git a/drivers/crypto/cnxk/cnxk_ae.h b/drivers/crypto/cnxk/cnxk_ae.h
index 6222171fe603..01ccfcd33432 100644
--- a/drivers/crypto/cnxk/cnxk_ae.h
+++ b/drivers/crypto/cnxk/cnxk_ae.h
@@ -196,13 +196,11 @@ cnxk_ae_free_session_parameters(struct cnxk_ae_sess *sess)
 	switch (sess->xfrm_type) {
 	case RTE_CRYPTO_ASYM_XFORM_RSA:
 		rsa = &sess->rsa_ctx;
-		if (rsa->n.data)
-			rte_free(rsa->n.data);
+		rte_free(rsa->n.data);
 		break;
 	case RTE_CRYPTO_ASYM_XFORM_MODEX:
 		mod = &sess->mod_ctx;
-		if (mod->modulus.data)
-			rte_free(mod->modulus.data);
+		rte_free(mod->modulus.data);
 		break;
 	case RTE_CRYPTO_ASYM_XFORM_ECDSA:
 		/* Fall through */
diff --git a/drivers/crypto/ipsec_mb/ipsec_mb_ops.c b/drivers/crypto/ipsec_mb/ipsec_mb_ops.c
index 1ebd23e8f073..1cf37e983617 100644
--- a/drivers/crypto/ipsec_mb/ipsec_mb_ops.c
+++ b/drivers/crypto/ipsec_mb/ipsec_mb_ops.c
@@ -102,8 +102,7 @@ ipsec_mb_qp_release(struct rte_cryptodev *dev, uint16_t qp_id)
 
 	if (qp != NULL && rte_eal_process_type() == RTE_PROC_PRIMARY) {
 		r = rte_ring_lookup(qp->name);
-		if (r)
-			rte_ring_free(r);
+		rte_ring_free(r);
 
 #if IMB_VERSION(1, 1, 0) > IMB_VERSION_NUM
 		if (qp->mb_mgr)
diff --git a/drivers/crypto/mvsam/rte_mrvl_pmd_ops.c b/drivers/crypto/mvsam/rte_mrvl_pmd_ops.c
index 3064b1f136fe..f828dc9db5f6 100644
--- a/drivers/crypto/mvsam/rte_mrvl_pmd_ops.c
+++ b/drivers/crypto/mvsam/rte_mrvl_pmd_ops.c
@@ -774,10 +774,8 @@ mrvl_crypto_pmd_sym_session_configure(__rte_unused struct rte_cryptodev *dev,
 	}
 
 	/* free the keys memory allocated for session creation */
-	if (mrvl_sess->sam_sess_params.cipher_key != NULL)
-		free(mrvl_sess->sam_sess_params.cipher_key);
-	if (mrvl_sess->sam_sess_params.auth_key != NULL)
-		free(mrvl_sess->sam_sess_params.auth_key);
+	free(mrvl_sess->sam_sess_params.cipher_key);
+	free(mrvl_sess->sam_sess_params.auth_key);
 
 	return 0;
 }
diff --git a/drivers/crypto/null/null_crypto_pmd_ops.c b/drivers/crypto/null/null_crypto_pmd_ops.c
index a8b5a06e7f4e..90a675dfffe0 100644
--- a/drivers/crypto/null/null_crypto_pmd_ops.c
+++ b/drivers/crypto/null/null_crypto_pmd_ops.c
@@ -135,8 +135,7 @@ null_crypto_pmd_qp_release(struct rte_cryptodev *dev, uint16_t qp_id)
 	if (dev->data->queue_pairs[qp_id] != NULL) {
 		struct null_crypto_qp *qp = dev->data->queue_pairs[qp_id];
 
-		if (qp->processed_pkts)
-			rte_ring_free(qp->processed_pkts);
+		rte_ring_free(qp->processed_pkts);
 
 		rte_free(dev->data->queue_pairs[qp_id]);
 		dev->data->queue_pairs[qp_id] = NULL;
@@ -241,8 +240,7 @@ null_crypto_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 	return 0;
 
 qp_setup_cleanup:
-	if (qp)
-		rte_free(qp);
+	rte_free(qp);
 
 	return -1;
 }
diff --git a/drivers/crypto/octeontx/otx_cryptodev_ops.c b/drivers/crypto/octeontx/otx_cryptodev_ops.c
index f7ca8a8a8e90..f1aae481c3c6 100644
--- a/drivers/crypto/octeontx/otx_cryptodev_ops.c
+++ b/drivers/crypto/octeontx/otx_cryptodev_ops.c
@@ -335,8 +335,7 @@ sym_session_clear(int driver_id, struct rte_cryptodev_sym_session *sess)
 	misc = priv;
 	ctx = SESS_PRIV(misc);
 
-	if (ctx->auth_key != NULL)
-		rte_free(ctx->auth_key);
+	rte_free(ctx->auth_key);
 
 	memset(priv, 0, cpt_get_session_size());
 
diff --git a/drivers/crypto/openssl/rte_openssl_pmd_ops.c b/drivers/crypto/openssl/rte_openssl_pmd_ops.c
index 52715f86f84a..b1c0b14fefd2 100644
--- a/drivers/crypto/openssl/rte_openssl_pmd_ops.c
+++ b/drivers/crypto/openssl/rte_openssl_pmd_ops.c
@@ -659,8 +659,7 @@ openssl_pmd_qp_release(struct rte_cryptodev *dev, uint16_t qp_id)
 	if (dev->data->queue_pairs[qp_id] != NULL) {
 		struct openssl_qp *qp = dev->data->queue_pairs[qp_id];
 
-		if (qp->processed_ops)
-			rte_ring_free(qp->processed_ops);
+		rte_ring_free(qp->processed_ops);
 
 		rte_free(dev->data->queue_pairs[qp_id]);
 		dev->data->queue_pairs[qp_id] = NULL;
@@ -748,8 +747,7 @@ openssl_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 	return 0;
 
 qp_setup_cleanup:
-	if (qp)
-		rte_free(qp);
+	rte_free(qp);
 
 	return -1;
 }
diff --git a/drivers/crypto/scheduler/scheduler_pmd_ops.c b/drivers/crypto/scheduler/scheduler_pmd_ops.c
index f61640c9d646..f3a1bd626c6f 100644
--- a/drivers/crypto/scheduler/scheduler_pmd_ops.c
+++ b/drivers/crypto/scheduler/scheduler_pmd_ops.c
@@ -371,10 +371,8 @@ scheduler_pmd_qp_release(struct rte_cryptodev *dev, uint16_t qp_id)
 	if (!qp_ctx)
 		return 0;
 
-	if (qp_ctx->order_ring)
-		rte_ring_free(qp_ctx->order_ring);
-	if (qp_ctx->private_qp_ctx)
-		rte_free(qp_ctx->private_qp_ctx);
+	rte_ring_free(qp_ctx->order_ring);
+	rte_free(qp_ctx->private_qp_ctx);
 
 	rte_free(qp_ctx);
 	dev->data->queue_pairs[qp_id] = NULL;
diff --git a/drivers/crypto/virtio/virtqueue.c b/drivers/crypto/virtio/virtqueue.c
index fd8be581c996..3e2db1ebd250 100644
--- a/drivers/crypto/virtio/virtqueue.c
+++ b/drivers/crypto/virtio/virtqueue.c
@@ -32,10 +32,8 @@ virtqueue_detatch_unused(struct virtqueue *vq)
 		for (idx = 0; idx < vq->vq_nentries; idx++) {
 			cop = vq->vq_descx[idx].crypto_op;
 			if (cop) {
-				if (cop->sym->m_src)
-					rte_pktmbuf_free(cop->sym->m_src);
-				if (cop->sym->m_dst)
-					rte_pktmbuf_free(cop->sym->m_dst);
+				rte_pktmbuf_free(cop->sym->m_src);
+				rte_pktmbuf_free(cop->sym->m_dst);
 				rte_crypto_op_free(cop);
 				vq->vq_descx[idx].crypto_op = NULL;
 			}
-- 
2.34.1


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v3 13/36] event/sw: remove unnecessary NULL checks
  2022-02-09 19:17 ` [PATCH v3 00/36] " Stephen Hemminger
                     ` (11 preceding siblings ...)
  2022-02-09 19:17   ` [PATCH v3 12/36] crypto: " Stephen Hemminger
@ 2022-02-09 19:17   ` Stephen Hemminger
  2022-02-09 19:17   ` [PATCH v3 14/36] net/axgbe: " Stephen Hemminger
                     ` (23 subsequent siblings)
  36 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-02-09 19:17 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Harry van Haaren

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/event/sw/sw_evdev.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/event/sw/sw_evdev.c b/drivers/event/sw/sw_evdev.c
index 6ae613e0f2e7..ba82a80385b6 100644
--- a/drivers/event/sw/sw_evdev.c
+++ b/drivers/event/sw/sw_evdev.c
@@ -526,8 +526,7 @@ sw_dev_configure(const struct rte_eventdev *dev)
 	 * IQ chunk references were cleaned out of the QIDs in sw_stop(), and
 	 * will be reinitialized in sw_start().
 	 */
-	if (sw->chunks)
-		rte_free(sw->chunks);
+	rte_free(sw->chunks);
 
 	sw->chunks = rte_malloc_socket(NULL,
 				       sizeof(struct sw_queue_chunk) *
-- 
2.34.1


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v3 14/36] net/axgbe: remove unnecessary NULL checks
  2022-02-09 19:17 ` [PATCH v3 00/36] " Stephen Hemminger
                     ` (12 preceding siblings ...)
  2022-02-09 19:17   ` [PATCH v3 13/36] event/sw: " Stephen Hemminger
@ 2022-02-09 19:17   ` Stephen Hemminger
  2022-02-09 19:17   ` [PATCH v3 15/36] net/bnx*: " Stephen Hemminger
                     ` (22 subsequent siblings)
  36 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-02-09 19:17 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Chandubabu Namburu

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/axgbe/axgbe_rxtx.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/axgbe/axgbe_rxtx.c b/drivers/net/axgbe/axgbe_rxtx.c
index 6bd41d3002bf..f38bb64fab6b 100644
--- a/drivers/net/axgbe/axgbe_rxtx.c
+++ b/drivers/net/axgbe/axgbe_rxtx.c
@@ -22,8 +22,7 @@ axgbe_rx_queue_release(struct axgbe_rx_queue *rx_queue)
 		sw_ring = rx_queue->sw_ring;
 		if (sw_ring) {
 			for (i = 0; i < rx_queue->nb_desc; i++) {
-				if (sw_ring[i])
-					rte_pktmbuf_free(sw_ring[i]);
+				rte_pktmbuf_free(sw_ring[i]);
 			}
 			rte_free(sw_ring);
 		}
@@ -507,8 +506,7 @@ static void axgbe_tx_queue_release(struct axgbe_tx_queue *tx_queue)
 		sw_ring = tx_queue->sw_ring;
 		if (sw_ring) {
 			for (i = 0; i < tx_queue->nb_desc; i++) {
-				if (sw_ring[i])
-					rte_pktmbuf_free(sw_ring[i]);
+				rte_pktmbuf_free(sw_ring[i]);
 			}
 			rte_free(sw_ring);
 		}
-- 
2.34.1


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v3 15/36] net/bnx*: remove unnecessary NULL checks
  2022-02-09 19:17 ` [PATCH v3 00/36] " Stephen Hemminger
                     ` (13 preceding siblings ...)
  2022-02-09 19:17   ` [PATCH v3 14/36] net/axgbe: " Stephen Hemminger
@ 2022-02-09 19:17   ` Stephen Hemminger
  2022-02-09 19:17   ` [PATCH v3 16/36] net/cnxk: " Stephen Hemminger
                     ` (21 subsequent siblings)
  36 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-02-09 19:17 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Rasesh Mody, Shahed Shaikh, Ajit Khaparde,
	Somnath Kotur

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/bnx2x/bnx2x_rxtx.c | 6 ++----
 drivers/net/bnxt/bnxt_ethdev.c | 3 +--
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/net/bnx2x/bnx2x_rxtx.c b/drivers/net/bnx2x/bnx2x_rxtx.c
index 66b0512c8695..00ddccf151fd 100644
--- a/drivers/net/bnx2x/bnx2x_rxtx.c
+++ b/drivers/net/bnx2x/bnx2x_rxtx.c
@@ -27,8 +27,7 @@ bnx2x_rx_queue_release(struct bnx2x_rx_queue *rx_queue)
 		sw_ring = rx_queue->sw_ring;
 		if (NULL != sw_ring) {
 			for (i = 0; i < rx_queue->nb_rx_desc; i++) {
-				if (NULL != sw_ring[i])
-					rte_pktmbuf_free(sw_ring[i]);
+				rte_pktmbuf_free(sw_ring[i]);
 			}
 			rte_free(sw_ring);
 		}
@@ -172,8 +171,7 @@ bnx2x_tx_queue_release(struct bnx2x_tx_queue *tx_queue)
 		sw_ring = tx_queue->sw_ring;
 		if (NULL != sw_ring) {
 			for (i = 0; i < tx_queue->nb_tx_desc; i++) {
-				if (NULL != sw_ring[i])
-					rte_pktmbuf_free(sw_ring[i]);
+				rte_pktmbuf_free(sw_ring[i]);
 			}
 			rte_free(sw_ring);
 		}
diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 22e015d5aa80..261fe0be56c3 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -5887,8 +5887,7 @@ static void bnxt_free_ctx_mem_buf(struct bnxt_ctx_mem_buf_info *ctx)
 	if (!ctx)
 		return;
 
-	if (ctx->va)
-		rte_free(ctx->va);
+	rte_free(ctx->va);
 
 	ctx->va = NULL;
 	ctx->dma = RTE_BAD_IOVA;
-- 
2.34.1


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v3 16/36] net/cnxk: remove unnecessary NULL checks
  2022-02-09 19:17 ` [PATCH v3 00/36] " Stephen Hemminger
                     ` (14 preceding siblings ...)
  2022-02-09 19:17   ` [PATCH v3 15/36] net/bnx*: " Stephen Hemminger
@ 2022-02-09 19:17   ` Stephen Hemminger
  2022-02-09 19:17   ` [PATCH v3 17/36] net/cxgbe: " Stephen Hemminger
                     ` (20 subsequent siblings)
  36 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-02-09 19:17 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Nithin Dabilpuram, Kiran Kumar K,
	Sunil Kumar Kori, Satha Rao

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/cnxk/cnxk_ethdev.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/cnxk/cnxk_ethdev.c b/drivers/net/cnxk/cnxk_ethdev.c
index 53dfb5eae80e..945600cdaf64 100644
--- a/drivers/net/cnxk/cnxk_ethdev.c
+++ b/drivers/net/cnxk/cnxk_ethdev.c
@@ -934,10 +934,8 @@ nix_restore_queue_cfg(struct rte_eth_dev *eth_dev)
 	for (i = 0; i < eth_dev->data->nb_tx_queues; i++)
 		dev_ops->tx_queue_release(eth_dev, i);
 fail:
-	if (tx_qconf)
-		free(tx_qconf);
-	if (rx_qconf)
-		free(rx_qconf);
+	free(tx_qconf);
+	free(rx_qconf);
 
 	return rc;
 }
-- 
2.34.1


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v3 17/36] net/cxgbe: remove unnecessary NULL checks
  2022-02-09 19:17 ` [PATCH v3 00/36] " Stephen Hemminger
                     ` (15 preceding siblings ...)
  2022-02-09 19:17   ` [PATCH v3 16/36] net/cnxk: " Stephen Hemminger
@ 2022-02-09 19:17   ` Stephen Hemminger
  2022-02-09 19:17   ` [PATCH v3 18/36] net/dpaa*: " Stephen Hemminger
                     ` (19 subsequent siblings)
  36 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-02-09 19:17 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Rahul Lakkireddy

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/cxgbe/cxgbe_main.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/cxgbe/cxgbe_main.c b/drivers/net/cxgbe/cxgbe_main.c
index f1ac32270961..ab06e30a5e0f 100644
--- a/drivers/net/cxgbe/cxgbe_main.c
+++ b/drivers/net/cxgbe/cxgbe_main.c
@@ -463,8 +463,7 @@ void cxgbe_insert_tid(struct tid_info *t, void *data, unsigned int tid,
 static void tid_free(struct tid_info *t)
 {
 	if (t->tid_tab) {
-		if (t->ftid_bmap)
-			rte_bitmap_free(t->ftid_bmap);
+		rte_bitmap_free(t->ftid_bmap);
 
 		if (t->ftid_bmap_array)
 			t4_os_free(t->ftid_bmap_array);
-- 
2.34.1


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v3 18/36] net/dpaa*: remove unnecessary NULL checks
  2022-02-09 19:17 ` [PATCH v3 00/36] " Stephen Hemminger
                     ` (16 preceding siblings ...)
  2022-02-09 19:17   ` [PATCH v3 17/36] net/cxgbe: " Stephen Hemminger
@ 2022-02-09 19:17   ` Stephen Hemminger
  2022-02-09 19:17   ` [PATCH v3 19/36] net/ena: " Stephen Hemminger
                     ` (18 subsequent siblings)
  36 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-02-09 19:17 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Hemant Agrawal, Sachin Saxena

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>
---
 drivers/net/dpaa/dpaa_ethdev.c   | 3 +--
 drivers/net/dpaa/fmlib/fm_lib.c  | 3 +--
 drivers/net/dpaa2/dpaa2_ethdev.c | 3 +--
 drivers/net/dpaa2/dpaa2_mux.c    | 3 +--
 drivers/net/dpaa2/dpaa2_ptp.c    | 3 +--
 5 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index b0c78ac0a14e..bddb3bb15ccc 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -474,8 +474,7 @@ static int dpaa_eth_dev_close(struct rte_eth_dev *dev)
 	}
 
 	/* release configuration memory */
-	if (dpaa_intf->fc_conf)
-		rte_free(dpaa_intf->fc_conf);
+	rte_free(dpaa_intf->fc_conf);
 
 	/* Release RX congestion Groups */
 	if (dpaa_intf->cgr_rx) {
diff --git a/drivers/net/dpaa/fmlib/fm_lib.c b/drivers/net/dpaa/fmlib/fm_lib.c
index 0d1ca12378d8..1d6816050c2f 100644
--- a/drivers/net/dpaa/fmlib/fm_lib.c
+++ b/drivers/net/dpaa/fmlib/fm_lib.c
@@ -408,8 +408,7 @@ fm_port_close(t_handle h_fm_port)
 	_fml_dbg("Calling...\n");
 
 	close(p_dev->fd);
-	if (p_dev->h_user_priv)
-		free(p_dev->h_user_priv);
+	free(p_dev->h_user_priv);
 	free(p_dev);
 
 	_fml_dbg("Finishing.\n");
diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c
index 09105f049e89..e824ae15b5ed 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.c
+++ b/drivers/net/dpaa2/dpaa2_ethdev.c
@@ -508,8 +508,7 @@ dpaa2_free_rx_tx_queues(struct rte_eth_dev *dev)
 		/* cleaning up queue storage */
 		for (i = 0; i < priv->nb_rx_queues; i++) {
 			dpaa2_q = (struct dpaa2_queue *)priv->rx_vq[i];
-			if (dpaa2_q->q_storage)
-				rte_free(dpaa2_q->q_storage);
+			rte_free(dpaa2_q->q_storage);
 		}
 		/* cleanup tx queue cscn */
 		for (i = 0; i < priv->nb_tx_queues; i++) {
diff --git a/drivers/net/dpaa2/dpaa2_mux.c b/drivers/net/dpaa2/dpaa2_mux.c
index cd2f7b8aa544..bd4596b89149 100644
--- a/drivers/net/dpaa2/dpaa2_mux.c
+++ b/drivers/net/dpaa2/dpaa2_mux.c
@@ -353,8 +353,7 @@ dpaa2_create_dpdmux_device(int vdev_fd __rte_unused,
 	return 0;
 
 init_err:
-	if (dpdmux_dev)
-		rte_free(dpdmux_dev);
+	rte_free(dpdmux_dev);
 
 	return -1;
 }
diff --git a/drivers/net/dpaa2/dpaa2_ptp.c b/drivers/net/dpaa2/dpaa2_ptp.c
index 3a4536dd69c1..4e6d375d1cbb 100644
--- a/drivers/net/dpaa2/dpaa2_ptp.c
+++ b/drivers/net/dpaa2/dpaa2_ptp.c
@@ -170,8 +170,7 @@ dpaa2_create_dprtc_device(int vdev_fd __rte_unused,
 	return 0;
 
 init_err:
-	if (dprtc_dev)
-		rte_free(dprtc_dev);
+	rte_free(dprtc_dev);
 
 	return -1;
 }
-- 
2.34.1


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v3 19/36] net/ena: remove unnecessary NULL checks
  2022-02-09 19:17 ` [PATCH v3 00/36] " Stephen Hemminger
                     ` (17 preceding siblings ...)
  2022-02-09 19:17   ` [PATCH v3 18/36] net/dpaa*: " Stephen Hemminger
@ 2022-02-09 19:17   ` Stephen Hemminger
  2022-02-09 19:17   ` [PATCH v3 20/36] net/hinic: " Stephen Hemminger
                     ` (17 subsequent siblings)
  36 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-02-09 19:17 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Marcin Wojtas, Michal Krawczyk, Shai Brandes,
	Evgeny Schemeilin, Igor Chauskin

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/ena/ena_ethdev.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c
index dce26cfa48cf..db2b5ec8e77b 100644
--- a/drivers/net/ena/ena_ethdev.c
+++ b/drivers/net/ena/ena_ethdev.c
@@ -567,16 +567,13 @@ static void ena_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
 	struct ena_ring *ring = dev->data->rx_queues[qid];
 
 	/* Free ring resources */
-	if (ring->rx_buffer_info)
-		rte_free(ring->rx_buffer_info);
+	rte_free(ring->rx_buffer_info);
 	ring->rx_buffer_info = NULL;
 
-	if (ring->rx_refill_buffer)
-		rte_free(ring->rx_refill_buffer);
+	rte_free(ring->rx_refill_buffer);
 	ring->rx_refill_buffer = NULL;
 
-	if (ring->empty_rx_reqs)
-		rte_free(ring->empty_rx_reqs);
+	rte_free(ring->empty_rx_reqs);
 	ring->empty_rx_reqs = NULL;
 
 	ring->configured = 0;
@@ -590,14 +587,11 @@ static void ena_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
 	struct ena_ring *ring = dev->data->tx_queues[qid];
 
 	/* Free ring resources */
-	if (ring->push_buf_intermediate_buf)
-		rte_free(ring->push_buf_intermediate_buf);
+	rte_free(ring->push_buf_intermediate_buf);
 
-	if (ring->tx_buffer_info)
-		rte_free(ring->tx_buffer_info);
+	rte_free(ring->tx_buffer_info);
 
-	if (ring->empty_tx_reqs)
-		rte_free(ring->empty_tx_reqs);
+	rte_free(ring->empty_tx_reqs);
 
 	ring->empty_tx_reqs = NULL;
 	ring->tx_buffer_info = NULL;
-- 
2.34.1


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v3 20/36] net/hinic: remove unnecessary NULL checks
  2022-02-09 19:17 ` [PATCH v3 00/36] " Stephen Hemminger
                     ` (18 preceding siblings ...)
  2022-02-09 19:17   ` [PATCH v3 19/36] net/ena: " Stephen Hemminger
@ 2022-02-09 19:17   ` Stephen Hemminger
  2022-02-09 19:17   ` [PATCH v3 21/36] net/hns3: " Stephen Hemminger
                     ` (16 subsequent siblings)
  36 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-02-09 19:17 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Ziyang Xuan, Xiaoyun Wang, Guoyang Zhou

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/hinic/hinic_pmd_ethdev.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/hinic/hinic_pmd_ethdev.c b/drivers/net/hinic/hinic_pmd_ethdev.c
index e8d9aaba84a6..35788f46eb4c 100644
--- a/drivers/net/hinic/hinic_pmd_ethdev.c
+++ b/drivers/net/hinic/hinic_pmd_ethdev.c
@@ -2662,8 +2662,7 @@ static int hinic_copy_mempool_init(struct hinic_nic_dev *nic_dev)
 
 static void hinic_copy_mempool_uninit(struct hinic_nic_dev *nic_dev)
 {
-	if (nic_dev->cpy_mpool != NULL)
-		rte_mempool_free(nic_dev->cpy_mpool);
+	rte_mempool_free(nic_dev->cpy_mpool);
 }
 
 static int hinic_init_sw_rxtxqs(struct hinic_nic_dev *nic_dev)
-- 
2.34.1


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v3 21/36] net/hns3: remove unnecessary NULL checks
  2022-02-09 19:17 ` [PATCH v3 00/36] " Stephen Hemminger
                     ` (19 preceding siblings ...)
  2022-02-09 19:17   ` [PATCH v3 20/36] net/hinic: " Stephen Hemminger
@ 2022-02-09 19:17   ` Stephen Hemminger
  2022-02-09 19:17   ` [PATCH v3 22/36] net/i*: " Stephen Hemminger
                     ` (15 subsequent siblings)
  36 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-02-09 19:17 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Min Hu, Yisen Zhuang, Lijun Ou

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Min Hu (Connor) <humin29@huawei.com>
---
 drivers/net/hns3/hns3_rxtx.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
index 3b72c2375a60..2d98db377f72 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -86,8 +86,7 @@ hns3_rx_queue_release(void *queue)
 		hns3_rx_queue_release_mbufs(rxq);
 		if (rxq->mz)
 			rte_memzone_free(rxq->mz);
-		if (rxq->sw_ring)
-			rte_free(rxq->sw_ring);
+		rte_free(rxq->sw_ring);
 		rte_free(rxq);
 	}
 }
@@ -100,10 +99,8 @@ hns3_tx_queue_release(void *queue)
 		hns3_tx_queue_release_mbufs(txq);
 		if (txq->mz)
 			rte_memzone_free(txq->mz);
-		if (txq->sw_ring)
-			rte_free(txq->sw_ring);
-		if (txq->free)
-			rte_free(txq->free);
+		rte_free(txq->sw_ring);
+		rte_free(txq->free);
 		rte_free(txq);
 	}
 }
-- 
2.34.1


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v3 22/36] net/i*: remove unnecessary NULL checks
  2022-02-09 19:17 ` [PATCH v3 00/36] " Stephen Hemminger
                     ` (20 preceding siblings ...)
  2022-02-09 19:17   ` [PATCH v3 21/36] net/hns3: " Stephen Hemminger
@ 2022-02-09 19:17   ` Stephen Hemminger
  2022-02-09 19:17   ` [PATCH v3 23/36] net/mlx*: " Stephen Hemminger
                     ` (14 subsequent siblings)
  36 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-02-09 19:17 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Haiyue Wang, Beilei Xing, Jingjing Wu,
	Qiming Yang, Qi Zhang

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Haiyue Wang <haiyue.wang@intel.com>
---
 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(&ethertype_rule->ethertype_list))) {
 		TAILQ_REMOVE(&ethertype_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


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v3 23/36] net/mlx*: remove unnecessary NULL checks
  2022-02-09 19:17 ` [PATCH v3 00/36] " Stephen Hemminger
                     ` (21 preceding siblings ...)
  2022-02-09 19:17   ` [PATCH v3 22/36] net/i*: " Stephen Hemminger
@ 2022-02-09 19:17   ` Stephen Hemminger
  2022-02-09 19:17   ` [PATCH v3 24/36] net/mvpp2: " Stephen Hemminger
                     ` (13 subsequent siblings)
  36 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-02-09 19:17 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Matan Azrad, Viacheslav Ovsiienko

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/mlx4/mlx4_mr.c   | 3 +--
 drivers/net/mlx5/mlx5_flow.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/mlx4/mlx4_mr.c b/drivers/net/mlx4/mlx4_mr.c
index 2274b5df1950..e95f45aa3e95 100644
--- a/drivers/net/mlx4/mlx4_mr.c
+++ b/drivers/net/mlx4/mlx4_mr.c
@@ -471,8 +471,7 @@ mr_free(struct mlx4_mr *mr)
 	DEBUG("freeing MR(%p):", (void *)mr);
 	if (mr->ibv_mr != NULL)
 		claim_zero(mlx4_glue->dereg_mr(mr->ibv_mr));
-	if (mr->ms_bmp != NULL)
-		rte_bitmap_free(mr->ms_bmp);
+	rte_bitmap_free(mr->ms_bmp);
 	rte_free(mr);
 }
 
diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index d7cb1eb89b94..179cc3b30378 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -7008,8 +7008,7 @@ flow_alloc_thread_workspace(void)
 	data->rssq_num = MLX5_RSSQ_DEFAULT_NUM;
 	return data;
 err:
-	if (data->rss_desc.queue)
-		free(data->rss_desc.queue);
+	free(data->rss_desc.queue);
 	free(data);
 	return NULL;
 }
-- 
2.34.1


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v3 24/36] net/mvpp2: remove unnecessary NULL checks
  2022-02-09 19:17 ` [PATCH v3 00/36] " Stephen Hemminger
                     ` (22 preceding siblings ...)
  2022-02-09 19:17   ` [PATCH v3 23/36] net/mlx*: " Stephen Hemminger
@ 2022-02-09 19:17   ` Stephen Hemminger
  2022-02-09 19:17   ` [PATCH v3 25/36] net/netvsc: " Stephen Hemminger
                     ` (12 subsequent siblings)
  36 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-02-09 19:17 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Liron Himi

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Reviewed-by: Liron Himi <lironh@marvell.com>
---
 drivers/net/mvpp2/mrvl_qos.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/mvpp2/mrvl_qos.c b/drivers/net/mvpp2/mrvl_qos.c
index 99f0ee56d1a7..f43217bc589c 100644
--- a/drivers/net/mvpp2/mrvl_qos.c
+++ b/drivers/net/mvpp2/mrvl_qos.c
@@ -945,8 +945,7 @@ setup_tc(struct pp2_ppio_tc_params *param, uint8_t inqs,
 	param->num_in_qs = inqs;
 
 	/* Release old config if necessary. */
-	if (param->inqs_params)
-		rte_free(param->inqs_params);
+	rte_free(param->inqs_params);
 
 	param->inqs_params = inq_params;
 
-- 
2.34.1


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v3 25/36] net/netvsc: remove unnecessary NULL checks
  2022-02-09 19:17 ` [PATCH v3 00/36] " Stephen Hemminger
                     ` (23 preceding siblings ...)
  2022-02-09 19:17   ` [PATCH v3 24/36] net/mvpp2: " Stephen Hemminger
@ 2022-02-09 19:17   ` Stephen Hemminger
  2022-02-09 19:17   ` [PATCH v3 26/36] net/octeontx: " Stephen Hemminger
                     ` (11 subsequent siblings)
  36 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-02-09 19:17 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Long Li, Stephen Hemminger

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Long Li <longli@microsoft.com>
---
 drivers/net/netvsc/hn_rxtx.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/netvsc/hn_rxtx.c b/drivers/net/netvsc/hn_rxtx.c
index 50ca1710ef3e..3e3488f1b87a 100644
--- a/drivers/net/netvsc/hn_rxtx.c
+++ b/drivers/net/netvsc/hn_rxtx.c
@@ -315,8 +315,7 @@ hn_dev_tx_queue_setup(struct rte_eth_dev *dev,
 	}
 
 error:
-	if (txq->txdesc_pool)
-		rte_mempool_free(txq->txdesc_pool);
+	rte_mempool_free(txq->txdesc_pool);
 	rte_memzone_free(txq->tx_rndis_mz);
 	rte_free(txq);
 	return err;
@@ -365,8 +364,7 @@ hn_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
 	if (!txq)
 		return;
 
-	if (txq->txdesc_pool)
-		rte_mempool_free(txq->txdesc_pool);
+	rte_mempool_free(txq->txdesc_pool);
 
 	rte_memzone_free(txq->tx_rndis_mz);
 	rte_free(txq);
-- 
2.34.1


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v3 26/36] net/octeontx: remove unnecessary NULL checks
  2022-02-09 19:17 ` [PATCH v3 00/36] " Stephen Hemminger
                     ` (24 preceding siblings ...)
  2022-02-09 19:17   ` [PATCH v3 25/36] net/netvsc: " Stephen Hemminger
@ 2022-02-09 19:17   ` Stephen Hemminger
  2022-02-09 19:17   ` [PATCH v3 27/36] net/qede: " Stephen Hemminger
                     ` (10 subsequent siblings)
  36 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-02-09 19:17 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Harman Kalra

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/octeontx/octeontx_ethdev.c     | 3 +--
 drivers/net/octeontx/octeontx_ethdev_ops.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/octeontx/octeontx_ethdev.c b/drivers/net/octeontx/octeontx_ethdev.c
index b47472ebbd93..f5ea9de8efe5 100644
--- a/drivers/net/octeontx/octeontx_ethdev.c
+++ b/drivers/net/octeontx/octeontx_ethdev.c
@@ -1037,8 +1037,7 @@ octeontx_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t qidx,
 	return res;
 
 err:
-	if (txq)
-		rte_free(txq);
+	rte_free(txq);
 
 	return res;
 }
diff --git a/drivers/net/octeontx/octeontx_ethdev_ops.c b/drivers/net/octeontx/octeontx_ethdev_ops.c
index 6ec2b71b0672..0b22e28a5625 100644
--- a/drivers/net/octeontx/octeontx_ethdev_ops.c
+++ b/drivers/net/octeontx/octeontx_ethdev_ops.c
@@ -108,8 +108,7 @@ octeontx_dev_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
 	if (rc != 0) {
 		octeontx_log_err("Fail to configure vlan filter entry "
 				 "for port %d", nic->port_id);
-		if (entry)
-			rte_free(entry);
+		rte_free(entry);
 
 		goto done;
 	}
-- 
2.34.1


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v3 27/36] net/qede: remove unnecessary NULL checks
  2022-02-09 19:17 ` [PATCH v3 00/36] " Stephen Hemminger
                     ` (25 preceding siblings ...)
  2022-02-09 19:17   ` [PATCH v3 26/36] net/octeontx: " Stephen Hemminger
@ 2022-02-09 19:17   ` Stephen Hemminger
  2022-02-09 19:17   ` [PATCH v3 28/36] net/txgbe: " Stephen Hemminger
                     ` (9 subsequent siblings)
  36 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-02-09 19:17 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Devendra Singh Rawat, Rasesh Mody

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Devendra Singh Rawat <dsinghrawat@marvell.com>
---
 drivers/net/qede/qede_main.c | 3 +--
 drivers/net/qede/qede_rxtx.c | 6 ++----
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/net/qede/qede_main.c b/drivers/net/qede/qede_main.c
index 2d1f70693a3d..ad101194d613 100644
--- a/drivers/net/qede/qede_main.c
+++ b/drivers/net/qede/qede_main.c
@@ -335,8 +335,7 @@ static int qed_slowpath_start(struct ecore_dev *edev,
 err:
 #ifdef CONFIG_ECORE_BINARY_FW
 	if (IS_PF(edev)) {
-		if (edev->firmware)
-			rte_free(edev->firmware);
+		rte_free(edev->firmware);
 		edev->firmware = NULL;
 	}
 #endif
diff --git a/drivers/net/qede/qede_rxtx.c b/drivers/net/qede/qede_rxtx.c
index 7088c57b501d..1c0a6ba5f1bf 100644
--- a/drivers/net/qede/qede_rxtx.c
+++ b/drivers/net/qede/qede_rxtx.c
@@ -706,12 +706,10 @@ void qede_dealloc_fp_resc(struct rte_eth_dev *eth_dev)
 		}
 	}
 
-	if (qdev->fp_array)
-		rte_free(qdev->fp_array);
+	rte_free(qdev->fp_array);
 	qdev->fp_array = NULL;
 
-	if (qdev->fp_array_cmt)
-		rte_free(qdev->fp_array_cmt);
+	rte_free(qdev->fp_array_cmt);
 	qdev->fp_array_cmt = NULL;
 }
 
-- 
2.34.1


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v3 28/36] net/txgbe: remove unnecessary NULL checks
  2022-02-09 19:17 ` [PATCH v3 00/36] " Stephen Hemminger
                     ` (26 preceding siblings ...)
  2022-02-09 19:17   ` [PATCH v3 27/36] net/qede: " Stephen Hemminger
@ 2022-02-09 19:17   ` Stephen Hemminger
  2022-02-09 19:17   ` [PATCH v3 29/36] net/vdev_netvsc: " Stephen Hemminger
                     ` (8 subsequent siblings)
  36 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-02-09 19:17 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Jiawen Wu, Jian Wang

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/txgbe/txgbe_ethdev.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/net/txgbe/txgbe_ethdev.c b/drivers/net/txgbe/txgbe_ethdev.c
index ac4d4e08f407..6024397072c8 100644
--- a/drivers/net/txgbe/txgbe_ethdev.c
+++ b/drivers/net/txgbe/txgbe_ethdev.c
@@ -821,10 +821,8 @@ static int txgbe_fdir_filter_uninit(struct rte_eth_dev *eth_dev)
 	struct txgbe_hw_fdir_info *fdir_info = TXGBE_DEV_FDIR(eth_dev);
 	struct txgbe_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,
@@ -841,10 +839,8 @@ static int txgbe_l2_tn_filter_uninit(struct rte_eth_dev *eth_dev)
 	struct txgbe_l2_tn_info *l2_tn_info = TXGBE_DEV_L2_TN(eth_dev);
 	struct txgbe_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,
-- 
2.34.1


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v3 29/36] net/vdev_netvsc: remove unnecessary NULL checks
  2022-02-09 19:17 ` [PATCH v3 00/36] " Stephen Hemminger
                     ` (27 preceding siblings ...)
  2022-02-09 19:17   ` [PATCH v3 28/36] net/txgbe: " Stephen Hemminger
@ 2022-02-09 19:17   ` Stephen Hemminger
  2022-02-09 19:17   ` [PATCH v3 30/36] net/virtio: " Stephen Hemminger
                     ` (7 subsequent siblings)
  36 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-02-09 19:17 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Matan Azrad

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/vdev_netvsc/vdev_netvsc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/vdev_netvsc/vdev_netvsc.c b/drivers/net/vdev_netvsc/vdev_netvsc.c
index 55f2a342c5ae..25871951685c 100644
--- a/drivers/net/vdev_netvsc/vdev_netvsc.c
+++ b/drivers/net/vdev_netvsc/vdev_netvsc.c
@@ -717,8 +717,7 @@ vdev_netvsc_vdev_probe(struct rte_vdev_device *dev)
 error:
 	++vdev_netvsc_ctx_inst;
 ignore:
-	if (kvargs)
-		rte_kvargs_free(kvargs);
+	rte_kvargs_free(kvargs);
 	/* Reset alarm if there are device context created */
 	if (vdev_netvsc_ctx_count) {
 		ret = rte_eal_alarm_set(VDEV_NETVSC_PROBE_MS * 1000,
-- 
2.34.1


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v3 30/36] net/virtio: remove unnecessary NULL checks
  2022-02-09 19:17 ` [PATCH v3 00/36] " Stephen Hemminger
                     ` (28 preceding siblings ...)
  2022-02-09 19:17   ` [PATCH v3 29/36] net/vdev_netvsc: " Stephen Hemminger
@ 2022-02-09 19:17   ` Stephen Hemminger
  2022-02-09 19:17   ` [PATCH v3 31/36] net/other: " Stephen Hemminger
                     ` (6 subsequent siblings)
  36 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-02-09 19:17 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Maxime Coquelin, Chenbo Xia

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/virtio/virtio_user_ethdev.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c
index 16eca2f94080..a7d7063c2a88 100644
--- a/drivers/net/virtio/virtio_user_ethdev.c
+++ b/drivers/net/virtio/virtio_user_ethdev.c
@@ -689,14 +689,10 @@ virtio_user_pmd_probe(struct rte_vdev_device *vdev)
 	ret = 0;
 
 end:
-	if (kvlist)
-		rte_kvargs_free(kvlist);
-	if (path)
-		free(path);
-	if (mac_addr)
-		free(mac_addr);
-	if (ifname)
-		free(ifname);
+	rte_kvargs_free(kvlist);
+	free(path);
+	free(mac_addr);
+	free(ifname);
 	return ret;
 }
 
-- 
2.34.1


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v3 31/36] net/other: remove unnecessary NULL checks
  2022-02-09 19:17 ` [PATCH v3 00/36] " Stephen Hemminger
                     ` (29 preceding siblings ...)
  2022-02-09 19:17   ` [PATCH v3 30/36] net/virtio: " Stephen Hemminger
@ 2022-02-09 19:17   ` Stephen Hemminger
  2022-02-09 19:17   ` [PATCH v3 32/36] raw/*: " Stephen Hemminger
                     ` (5 subsequent siblings)
  36 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-02-09 19:17 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Min Hu, Chas Williams, Jakub Grajciar,
	Tetsuya Mukawa, Jasvinder Singh, Cristian Dumitrescu

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Min Hu (Connor) <humin29@huawei.com>
---
 drivers/net/bonding/rte_eth_bond_pmd.c          |  3 +--
 drivers/net/memif/rte_eth_memif.c               |  6 ++----
 drivers/net/null/rte_eth_null.c                 |  3 +--
 drivers/net/softnic/rte_eth_softnic_cli.c       | 12 ++++--------
 drivers/net/softnic/rte_eth_softnic_cryptodev.c |  6 ++----
 drivers/net/softnic/rte_eth_softnic_thread.c    |  6 ++----
 drivers/net/tap/tap_flow.c                      |  9 +++------
 7 files changed, 15 insertions(+), 30 deletions(-)

diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index c72fc64806cf..0289f882fdb5 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -2155,8 +2155,7 @@ bond_ethdev_close(struct rte_eth_dev *dev)
 	 */
 	rte_mempool_free(internals->mode6.mempool);
 
-	if (internals->kvlist != NULL)
-		rte_kvargs_free(internals->kvlist);
+	rte_kvargs_free(internals->kvlist);
 
 	return 0;
 }
diff --git a/drivers/net/memif/rte_eth_memif.c b/drivers/net/memif/rte_eth_memif.c
index d3459c5007c4..cca07cd84d50 100644
--- a/drivers/net/memif/rte_eth_memif.c
+++ b/drivers/net/memif/rte_eth_memif.c
@@ -1712,8 +1712,7 @@ memif_check_socket_filename(const char *filename)
 		ret = -EINVAL;
 	}
 
-	if (dir != NULL)
-		rte_free(dir);
+	rte_free(dir);
 
 	return ret;
 }
@@ -1884,8 +1883,7 @@ rte_pmd_memif_probe(struct rte_vdev_device *vdev)
 			   log2_ring_size, pkt_buffer_size, secret, ether_addr);
 
 exit:
-	if (kvlist != NULL)
-		rte_kvargs_free(kvlist);
+	rte_kvargs_free(kvlist);
 	return ret;
 }
 
diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c
index ca03469d0e6d..bb89c1abc4a2 100644
--- a/drivers/net/null/rte_eth_null.c
+++ b/drivers/net/null/rte_eth_null.c
@@ -717,8 +717,7 @@ rte_pmd_null_probe(struct rte_vdev_device *dev)
 	ret = eth_dev_null_create(dev, &args);
 
 free_kvlist:
-	if (kvlist)
-		rte_kvargs_free(kvlist);
+	rte_kvargs_free(kvlist);
 	return ret;
 }
 
diff --git a/drivers/net/softnic/rte_eth_softnic_cli.c b/drivers/net/softnic/rte_eth_softnic_cli.c
index b04e78c6e0af..7acbeecae7a2 100644
--- a/drivers/net/softnic/rte_eth_softnic_cli.c
+++ b/drivers/net/softnic/rte_eth_softnic_cli.c
@@ -4482,10 +4482,8 @@ parse_free_sym_crypto_param_data(struct rte_table_action_sym_crypto_params *p)
 
 		switch (xform[i]->type) {
 		case RTE_CRYPTO_SYM_XFORM_CIPHER:
-			if (p->cipher_auth.cipher_iv.val)
-				free(p->cipher_auth.cipher_iv.val);
-			if (p->cipher_auth.cipher_iv_update.val)
-				free(p->cipher_auth.cipher_iv_update.val);
+			free(p->cipher_auth.cipher_iv.val);
+			free(p->cipher_auth.cipher_iv_update.val);
 			break;
 		case RTE_CRYPTO_SYM_XFORM_AUTH:
 			if (p->cipher_auth.auth_iv.val)
@@ -4494,10 +4492,8 @@ parse_free_sym_crypto_param_data(struct rte_table_action_sym_crypto_params *p)
 				free(p->cipher_auth.cipher_iv_update.val);
 			break;
 		case RTE_CRYPTO_SYM_XFORM_AEAD:
-			if (p->aead.iv.val)
-				free(p->aead.iv.val);
-			if (p->aead.aad.val)
-				free(p->aead.aad.val);
+			free(p->aead.iv.val);
+			free(p->aead.aad.val);
 			break;
 		default:
 			continue;
diff --git a/drivers/net/softnic/rte_eth_softnic_cryptodev.c b/drivers/net/softnic/rte_eth_softnic_cryptodev.c
index 9a7d006f1a09..e4754055e90b 100644
--- a/drivers/net/softnic/rte_eth_softnic_cryptodev.c
+++ b/drivers/net/softnic/rte_eth_softnic_cryptodev.c
@@ -159,10 +159,8 @@ softnic_cryptodev_create(struct pmd_internals *p,
 	return cryptodev;
 
 error_exit:
-	if (cryptodev->mp_create)
-		rte_mempool_free(cryptodev->mp_create);
-	if (cryptodev->mp_init)
-		rte_mempool_free(cryptodev->mp_init);
+	rte_mempool_free(cryptodev->mp_create);
+	rte_mempool_free(cryptodev->mp_init);
 
 	free(cryptodev);
 
diff --git a/drivers/net/softnic/rte_eth_softnic_thread.c b/drivers/net/softnic/rte_eth_softnic_thread.c
index a8c26a5b2377..1b3b3c33c175 100644
--- a/drivers/net/softnic/rte_eth_softnic_thread.c
+++ b/drivers/net/softnic/rte_eth_softnic_thread.c
@@ -29,11 +29,9 @@ softnic_thread_free(struct pmd_internals *softnic)
 		struct softnic_thread *t = &softnic->thread[i];
 
 		/* MSGQs */
-		if (t->msgq_req)
-			rte_ring_free(t->msgq_req);
+		rte_ring_free(t->msgq_req);
 
-		if (t->msgq_rsp)
-			rte_ring_free(t->msgq_rsp);
+		rte_ring_free(t->msgq_rsp);
 	}
 }
 
diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c
index 76738239458a..a9a55e439efc 100644
--- a/drivers/net/tap/tap_flow.c
+++ b/drivers/net/tap/tap_flow.c
@@ -1465,8 +1465,7 @@ tap_flow_create(struct rte_eth_dev *dev,
 	}
 	return flow;
 fail:
-	if (remote_flow)
-		rte_free(remote_flow);
+	rte_free(remote_flow);
 	if (flow)
 		tap_flow_free(pmd, flow);
 	return NULL;
@@ -1541,8 +1540,7 @@ tap_flow_destroy_pmd(struct pmd_internals *pmd,
 		}
 	}
 end:
-	if (remote_flow)
-		rte_free(remote_flow);
+	rte_free(remote_flow);
 	tap_flow_free(pmd, flow);
 	return ret;
 }
@@ -1764,8 +1762,7 @@ int tap_flow_implicit_create(struct pmd_internals *pmd,
 success:
 	return 0;
 fail:
-	if (remote_flow)
-		rte_free(remote_flow);
+	rte_free(remote_flow);
 	return -1;
 }
 
-- 
2.34.1


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v3 32/36] raw/*: remove unnecessary NULL checks
  2022-02-09 19:17 ` [PATCH v3 00/36] " Stephen Hemminger
                     ` (30 preceding siblings ...)
  2022-02-09 19:17   ` [PATCH v3 31/36] net/other: " Stephen Hemminger
@ 2022-02-09 19:17   ` Stephen Hemminger
  2022-02-10  3:03     ` Xu, Rosen
  2022-02-09 19:17   ` [PATCH v3 33/36] regex/*: " Stephen Hemminger
                     ` (4 subsequent siblings)
  36 siblings, 1 reply; 247+ messages in thread
From: Stephen Hemminger @ 2022-02-09 19:17 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Hemant Agrawal, Jakub Palider,
	Tomasz Duszynski, Nipun Gupta, Rosen Xu, Tianfei zhang

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>
---
 drivers/raw/cnxk_bphy/cnxk_bphy_cgx.c       |  3 +--
 drivers/raw/dpaa2_qdma/dpaa2_qdma.c         | 15 +++++----------
 drivers/raw/ifpga/ifpga_rawdev.c            |  9 +++------
 drivers/raw/skeleton/skeleton_rawdev_test.c |  6 ++----
 4 files changed, 11 insertions(+), 22 deletions(-)

diff --git a/drivers/raw/cnxk_bphy/cnxk_bphy_cgx.c b/drivers/raw/cnxk_bphy/cnxk_bphy_cgx.c
index 0b694e1c03c3..169cbc785531 100644
--- a/drivers/raw/cnxk_bphy/cnxk_bphy_cgx.c
+++ b/drivers/raw/cnxk_bphy/cnxk_bphy_cgx.c
@@ -233,8 +233,7 @@ cnxk_bphy_cgx_fini_queues(struct cnxk_bphy_cgx *cgx)
 	unsigned int i;
 
 	for (i = 0; i < cgx->num_queues; i++) {
-		if (cgx->queues[i].rsp)
-			rte_free(cgx->queues[i].rsp);
+		rte_free(cgx->queues[i].rsp);
 	}
 
 	cgx->num_queues = 0;
diff --git a/drivers/raw/dpaa2_qdma/dpaa2_qdma.c b/drivers/raw/dpaa2_qdma/dpaa2_qdma.c
index ebc2cd5d0ddc..b2260439a4ef 100644
--- a/drivers/raw/dpaa2_qdma/dpaa2_qdma.c
+++ b/drivers/raw/dpaa2_qdma/dpaa2_qdma.c
@@ -1115,11 +1115,9 @@ dpaa2_qdma_reset(struct rte_rawdev *rawdev)
 
 	/* Reset and free virtual queues */
 	for (i = 0; i < qdma_dev->max_vqs; i++) {
-		if (qdma_dev->vqs[i].status_ring)
-			rte_ring_free(qdma_dev->vqs[i].status_ring);
+		rte_ring_free(qdma_dev->vqs[i].status_ring);
 	}
-	if (qdma_dev->vqs)
-		rte_free(qdma_dev->vqs);
+	rte_free(qdma_dev->vqs);
 	qdma_dev->vqs = NULL;
 
 	/* Reset per core info */
@@ -1314,8 +1312,7 @@ dpaa2_qdma_queue_setup(struct rte_rawdev *rawdev,
 
 	if (qdma_dev->vqs[i].hw_queue == NULL) {
 		DPAA2_QDMA_ERR("No H/W queue available for VQ");
-		if (qdma_dev->vqs[i].status_ring)
-			rte_ring_free(qdma_dev->vqs[i].status_ring);
+		rte_ring_free(qdma_dev->vqs[i].status_ring);
 		qdma_dev->vqs[i].status_ring = NULL;
 		rte_spinlock_unlock(&qdma_dev->lock);
 		return -ENODEV;
@@ -1516,14 +1513,12 @@ dpaa2_qdma_queue_release(struct rte_rawdev *rawdev,
 	if (qdma_vq->exclusive_hw_queue)
 		free_hw_queue(qdma_vq->hw_queue);
 	else {
-		if (qdma_vq->status_ring)
-			rte_ring_free(qdma_vq->status_ring);
+		rte_ring_free(qdma_vq->status_ring);
 
 		put_hw_queue(qdma_vq->hw_queue);
 	}
 
-	if (qdma_vq->fle_pool)
-		rte_mempool_free(qdma_vq->fle_pool);
+	rte_mempool_free(qdma_vq->fle_pool);
 
 	memset(qdma_vq, 0, sizeof(struct qdma_virt_queue));
 
diff --git a/drivers/raw/ifpga/ifpga_rawdev.c b/drivers/raw/ifpga/ifpga_rawdev.c
index fdf3c23d2c5f..b73512d3ada5 100644
--- a/drivers/raw/ifpga/ifpga_rawdev.c
+++ b/drivers/raw/ifpga/ifpga_rawdev.c
@@ -836,8 +836,7 @@ rte_fpga_do_pr(struct rte_rawdev *rawdev, int port_id,
 	}
 
 free_buffer:
-	if (buf_to_free)
-		rte_free(buf_to_free);
+	rte_free(buf_to_free);
 close_fd:
 	close(file_fd);
 	file_fd = 0;
@@ -1739,10 +1738,8 @@ ifpga_cfg_probe(struct rte_vdev_device *dev)
 	ret = rte_eal_hotplug_add(RTE_STR(IFPGA_BUS_NAME),
 			dev_name, devargs->args);
 end:
-	if (kvlist)
-		rte_kvargs_free(kvlist);
-	if (name)
-		free(name);
+	rte_kvargs_free(kvlist);
+	free(name);
 
 	return ret;
 }
diff --git a/drivers/raw/skeleton/skeleton_rawdev_test.c b/drivers/raw/skeleton/skeleton_rawdev_test.c
index 484468eeb460..693b24c415de 100644
--- a/drivers/raw/skeleton/skeleton_rawdev_test.c
+++ b/drivers/raw/skeleton/skeleton_rawdev_test.c
@@ -395,13 +395,11 @@ test_rawdev_enqdeq(void)
 	RTE_TEST_ASSERT_EQUAL((unsigned int)ret, count,
 			      "Unable to dequeue buffers");
 
-	if (deq_buffers)
-		free(deq_buffers);
+	free(deq_buffers);
 
 	return TEST_SUCCESS;
 cleanup:
-	if (buffers[0].buf_addr)
-		free(buffers[0].buf_addr);
+	free(buffers[0].buf_addr);
 
 	return TEST_FAILED;
 }
-- 
2.34.1


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v3 33/36] regex/*: remove unnecessary NULL checks
  2022-02-09 19:17 ` [PATCH v3 00/36] " Stephen Hemminger
                     ` (31 preceding siblings ...)
  2022-02-09 19:17   ` [PATCH v3 32/36] raw/*: " Stephen Hemminger
@ 2022-02-09 19:17   ` Stephen Hemminger
  2022-02-09 19:17   ` [PATCH v3 34/36] vdpa/*: " Stephen Hemminger
                     ` (3 subsequent siblings)
  36 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-02-09 19:17 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Liron Himi, Ori Kam

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Reviewed-by: Liron Himi <lironh@marvell.com>
---
 drivers/regex/cn9k/cn9k_regexdev.c          | 6 ++----
 drivers/regex/cn9k/cn9k_regexdev_compiler.c | 3 +--
 drivers/regex/mlx5/mlx5_regex.c             | 3 +--
 drivers/regex/mlx5/mlx5_rxp.c               | 3 +--
 4 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/regex/cn9k/cn9k_regexdev.c b/drivers/regex/cn9k/cn9k_regexdev.c
index 32d20c1be82b..56c862c5a76c 100644
--- a/drivers/regex/cn9k/cn9k_regexdev.c
+++ b/drivers/regex/cn9k/cn9k_regexdev.c
@@ -256,10 +256,8 @@ ree_dev_fini(struct rte_regexdev *dev)
 		cn9k_err("Could not detach queues");
 
 	/* TEMP : should be in lib */
-	if (data->queue_pairs)
-		rte_free(data->queue_pairs);
-	if (data->rules)
-		rte_free(data->rules);
+	rte_free(data->queue_pairs);
+	rte_free(data->rules);
 
 	roc_ree_dev_fini(vf);
 
diff --git a/drivers/regex/cn9k/cn9k_regexdev_compiler.c b/drivers/regex/cn9k/cn9k_regexdev_compiler.c
index 935b8a53b459..60f1c1b4c4d8 100644
--- a/drivers/regex/cn9k/cn9k_regexdev_compiler.c
+++ b/drivers/regex/cn9k/cn9k_regexdev_compiler.c
@@ -214,8 +214,7 @@ cn9k_ree_rule_db_compile_prog(struct rte_regexdev *dev)
 	rxp_free_structs(NULL, NULL, NULL, NULL, NULL, &rof, NULL, &rofi, NULL,
 			1);
 
-	if (rule_db)
-		rte_free(rule_db);
+	rte_free(rule_db);
 
 	return ret;
 }
diff --git a/drivers/regex/mlx5/mlx5_regex.c b/drivers/regex/mlx5/mlx5_regex.c
index e5a12fb3cc4d..48e39f6b8844 100644
--- a/drivers/regex/mlx5/mlx5_regex.c
+++ b/drivers/regex/mlx5/mlx5_regex.c
@@ -127,8 +127,7 @@ mlx5_regex_dev_probe(struct mlx5_common_device *cdev)
 	if (priv->regexdev)
 		rte_regexdev_unregister(priv->regexdev);
 dev_error:
-	if (priv)
-		rte_free(priv);
+	rte_free(priv);
 	return -rte_errno;
 }
 
diff --git a/drivers/regex/mlx5/mlx5_rxp.c b/drivers/regex/mlx5/mlx5_rxp.c
index 5ead3ca341ad..99db1e4a865c 100644
--- a/drivers/regex/mlx5/mlx5_rxp.c
+++ b/drivers/regex/mlx5/mlx5_rxp.c
@@ -166,7 +166,6 @@ mlx5_regex_configure(struct rte_regexdev *dev,
 		DRV_LOG(DEBUG, "Regex config without rules programming!");
 	return 0;
 configure_error:
-	if (priv->qps)
-		rte_free(priv->qps);
+	rte_free(priv->qps);
 	return -rte_errno;
 }
-- 
2.34.1


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v3 34/36] vdpa/*: remove unnecessary NULL checks
  2022-02-09 19:17 ` [PATCH v3 00/36] " Stephen Hemminger
                     ` (32 preceding siblings ...)
  2022-02-09 19:17   ` [PATCH v3 33/36] regex/*: " Stephen Hemminger
@ 2022-02-09 19:17   ` Stephen Hemminger
  2022-02-09 19:17   ` [PATCH v3 35/36] compressdev: " Stephen Hemminger
                     ` (2 subsequent siblings)
  36 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-02-09 19:17 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Chenbo Xia, Xiao Wang, Matan Azrad,
	Viacheslav Ovsiienko

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
---
 drivers/vdpa/ifc/ifcvf_vdpa.c       | 9 +++------
 drivers/vdpa/mlx5/mlx5_vdpa_mem.c   | 3 +--
 drivers/vdpa/mlx5/mlx5_vdpa_virtq.c | 3 +--
 3 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c b/drivers/vdpa/ifc/ifcvf_vdpa.c
index 3853c4cf7e85..9f05595b6b34 100644
--- a/drivers/vdpa/ifc/ifcvf_vdpa.c
+++ b/drivers/vdpa/ifc/ifcvf_vdpa.c
@@ -226,8 +226,7 @@ ifcvf_dma_map(struct ifcvf_internal *internal, bool do_map)
 	}
 
 exit:
-	if (mem)
-		free(mem);
+	free(mem);
 	return ret;
 }
 
@@ -253,8 +252,7 @@ hva_to_gpa(int vid, uint64_t hva)
 	}
 
 exit:
-	if (mem)
-		free(mem);
+	free(mem);
 	return gpa;
 }
 
@@ -661,8 +659,7 @@ m_ifcvf_start(struct ifcvf_internal *internal)
 
 error:
 	for (i = 0; i < nr_vring; i++)
-		if (internal->m_vring[i].desc)
-			rte_free(internal->m_vring[i].desc);
+		rte_free(internal->m_vring[i].desc);
 
 	return -1;
 }
diff --git a/drivers/vdpa/mlx5/mlx5_vdpa_mem.c b/drivers/vdpa/mlx5/mlx5_vdpa_mem.c
index 130d201a85f5..599079500b03 100644
--- a/drivers/vdpa/mlx5/mlx5_vdpa_mem.c
+++ b/drivers/vdpa/mlx5/mlx5_vdpa_mem.c
@@ -283,8 +283,7 @@ mlx5_vdpa_mem_register(struct mlx5_vdpa_priv *priv)
 	priv->gpa_mkey_index = entry->mkey->id;
 	return 0;
 error:
-	if (entry)
-		rte_free(entry);
+	rte_free(entry);
 	mlx5_vdpa_mem_dereg(priv);
 	rte_errno = -ret;
 	return ret;
diff --git a/drivers/vdpa/mlx5/mlx5_vdpa_virtq.c b/drivers/vdpa/mlx5/mlx5_vdpa_virtq.c
index 2f32aef67fbc..3416797d289c 100644
--- a/drivers/vdpa/mlx5/mlx5_vdpa_virtq.c
+++ b/drivers/vdpa/mlx5/mlx5_vdpa_virtq.c
@@ -91,8 +91,7 @@ mlx5_vdpa_virtq_unset(struct mlx5_vdpa_virtq *virtq)
 		if (virtq->umems[i].obj)
 			claim_zero(mlx5_glue->devx_umem_dereg
 							 (virtq->umems[i].obj));
-		if (virtq->umems[i].buf)
-			rte_free(virtq->umems[i].buf);
+		rte_free(virtq->umems[i].buf);
 	}
 	memset(&virtq->umems, 0, sizeof(virtq->umems));
 	if (virtq->eqp.fw_qp)
-- 
2.34.1


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v3 35/36] compressdev: remove unnecessary NULL checks
  2022-02-09 19:17 ` [PATCH v3 00/36] " Stephen Hemminger
                     ` (33 preceding siblings ...)
  2022-02-09 19:17   ` [PATCH v3 34/36] vdpa/*: " Stephen Hemminger
@ 2022-02-09 19:17   ` Stephen Hemminger
  2022-02-09 19:17   ` [PATCH v3 36/36] other: " Stephen Hemminger
  2022-02-12 11:09   ` [PATCH v3 00/36] remove unnecessary null checks Thomas Monjalon
  36 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-02-09 19:17 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Fan Zhang, Ashish Gupta

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Fan Zhang <roy.fan.zhang@intel.com>
---
 lib/compressdev/rte_compressdev.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/compressdev/rte_compressdev.c b/lib/compressdev/rte_compressdev.c
index 2e9218af68f6..d4f7d4d3daf2 100644
--- a/lib/compressdev/rte_compressdev.c
+++ b/lib/compressdev/rte_compressdev.c
@@ -405,8 +405,7 @@ rte_compressdev_queue_pairs_release(struct rte_compressdev *dev)
 			return ret;
 	}
 
-	if (dev->data->queue_pairs != NULL)
-		rte_free(dev->data->queue_pairs);
+	rte_free(dev->data->queue_pairs);
 	dev->data->queue_pairs = NULL;
 	dev->data->nb_queue_pairs = 0;
 
-- 
2.34.1


^ permalink raw reply	[flat|nested] 247+ messages in thread

* [PATCH v3 36/36] other: remove unnecessary NULL checks
  2022-02-09 19:17 ` [PATCH v3 00/36] " Stephen Hemminger
                     ` (34 preceding siblings ...)
  2022-02-09 19:17   ` [PATCH v3 35/36] compressdev: " Stephen Hemminger
@ 2022-02-09 19:17   ` Stephen Hemminger
  2022-02-12 11:09   ` [PATCH v3 00/36] remove unnecessary null checks Thomas Monjalon
  36 siblings, 0 replies; 247+ messages in thread
From: Stephen Hemminger @ 2022-02-09 19:17 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, David Hunt, Jerin Jacob, Kiran Kumar K,
	Nithin Dabilpuram, Konstantin Ananyev, Bernard Iremonger,
	Vladimir Medvedkin, Cristian Dumitrescu, Reshma Pattan

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: David Hunt <david.hunt@intel.com>
---
 lib/graph/graph_stats.c          |  3 +--
 lib/ipsec/ipsec_sad.c            |  3 +--
 lib/port/rte_port_source_sink.c  | 21 +++++++--------------
 lib/power/rte_power_empty_poll.c |  3 +--
 lib/reorder/rte_reorder.c        |  6 ++----
 5 files changed, 12 insertions(+), 24 deletions(-)

diff --git a/lib/graph/graph_stats.c b/lib/graph/graph_stats.c
index aa70929dc32e..65e12d46a313 100644
--- a/lib/graph/graph_stats.c
+++ b/lib/graph/graph_stats.c
@@ -233,8 +233,7 @@ cluster_add(struct cluster *cluster, struct graph *graph)
 static void
 cluster_fini(struct cluster *cluster)
 {
-	if (cluster->graphs)
-		free(cluster->graphs);
+	free(cluster->graphs);
 }
 
 static int
diff --git a/lib/ipsec/ipsec_sad.c b/lib/ipsec/ipsec_sad.c
index 531e1e323cdc..af4b1ce757d2 100644
--- a/lib/ipsec/ipsec_sad.c
+++ b/lib/ipsec/ipsec_sad.c
@@ -440,8 +440,7 @@ rte_ipsec_sad_destroy(struct rte_ipsec_sad *sad)
 	rte_hash_free(sad->hash[RTE_IPSEC_SAD_SPI_DIP]);
 	rte_hash_free(sad->hash[RTE_IPSEC_SAD_SPI_DIP_SIP]);
 	rte_free(sad);
-	if (te != NULL)
-		rte_free(te);
+	rte_free(te);
 }
 
 /*
diff --git a/lib/port/rte_port_source_sink.c b/lib/port/rte_port_source_sink.c
index 68575c98338d..79042d13ff66 100644
--- a/lib/port/rte_port_source_sink.c
+++ b/lib/port/rte_port_source_sink.c
@@ -163,14 +163,10 @@ pcap_source_load(struct rte_port_source *port,
 	return 0;
 
 error_exit:
-	if (pkt_len_aligns)
-		rte_free(pkt_len_aligns);
-	if (port->pkt_len)
-		rte_free(port->pkt_len);
-	if (port->pkts)
-		rte_free(port->pkts);
-	if (port->pkt_buff)
-		rte_free(port->pkt_buff);
+	rte_free(pkt_len_aligns);
+	rte_free(port->pkt_len);
+	rte_free(port->pkts);
+	rte_free(port->pkt_buff);
 
 	return -1;
 }
@@ -242,12 +238,9 @@ rte_port_source_free(void *port)
 	if (p == NULL)
 		return 0;
 
-	if (p->pkt_len)
-		rte_free(p->pkt_len);
-	if (p->pkts)
-		rte_free(p->pkts);
-	if (p->pkt_buff)
-		rte_free(p->pkt_buff);
+	rte_free(p->pkt_len);
+	rte_free(p->pkts);
+	rte_free(p->pkt_buff);
 
 	rte_free(p);
 
diff --git a/lib/power/rte_power_empty_poll.c b/lib/power/rte_power_empty_poll.c
index c4b5de9601cf..2261ce7820f6 100644
--- a/lib/power/rte_power_empty_poll.c
+++ b/lib/power/rte_power_empty_poll.c
@@ -457,8 +457,7 @@ rte_power_empty_poll_stat_free(void)
 
 	RTE_LOG(INFO, POWER, "Close the Empty Poll\n");
 
-	if (ep_params != NULL)
-		rte_free(ep_params);
+	rte_free(ep_params);
 }
 
 int
diff --git a/lib/reorder/rte_reorder.c b/lib/reorder/rte_reorder.c
index 9445853b79cc..bc0241bfb3fd 100644
--- a/lib/reorder/rte_reorder.c
+++ b/lib/reorder/rte_reorder.c
@@ -192,10 +192,8 @@ rte_reorder_free_mbufs(struct rte_reorder_buffer *b)
 
 	/* Free up the mbufs of order buffer & ready buffer */
 	for (i = 0; i < b->order_buf.size; i++) {
-		if (b->order_buf.entries[i])
-			rte_pktmbuf_free(b->order_buf.entries[i]);
-		if (b->ready_buf.entries[i])
-			rte_pktmbuf_free(b->ready_buf.entries[i]);
+		rte_pktmbuf_free(b->order_buf.entries[i]);
+		rte_pktmbuf_free(b->ready_buf.entries[i]);
 	}
 }
 
-- 
2.34.1


^ permalink raw reply	[flat|nested] 247+ messages in thread

* RE: [PATCH v3 09/36] bus/*: remove unnecessary NULL checks
  2022-02-09 19:17   ` [PATCH v3 09/36] bus/*: " Stephen Hemminger
@ 2022-02-10  3:02     ` Xu, Rosen
  0 siblings, 0 replies; 247+ messages in thread
From: Xu, Rosen @ 2022-02-10  3:02 UTC (permalink / raw)
  To: Stephen Hemminger, dev; +Cc: Hemant Agrawal, Sachin Saxena

Hi,

> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Thursday, February 10, 2022 3:17
> To: dev@dpdk.org
> Cc: Stephen Hemminger <stephen@networkplumber.org>; Hemant Agrawal
> <hemant.agrawal@nxp.com>; Sachin Saxena <sachin.saxena@oss.nxp.com>;
> Xu, Rosen <rosen.xu@intel.com>
> Subject: [PATCH v3 09/36] bus/*: remove unnecessary NULL checks
> 
> Remove redundant NULL pointer checks before free functions found by
> nullfree.cocci
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>
> ---
>  drivers/bus/fslmc/fslmc_bus.c            |  6 ++----
>  drivers/bus/fslmc/portal/dpaa2_hw_dpio.c |  6 ++----
>  drivers/bus/ifpga/ifpga_bus.c            | 12 ++++--------
>  drivers/bus/pci/pci_params.c             |  3 +--
>  drivers/bus/pci/windows/pci.c            |  3 +--
>  drivers/bus/pci/windows/pci_netuio.c     |  3 +--
>  6 files changed, 11 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/bus/ifpga/ifpga_bus.c b/drivers/bus/ifpga/ifpga_bus.c
> index c5c8bbd57219..e005f2cb70b3 100644
> --- a/drivers/bus/ifpga/ifpga_bus.c
> +++ b/drivers/bus/ifpga/ifpga_bus.c
> @@ -191,10 +191,8 @@ ifpga_scan_one(struct rte_rawdev *rawdev,
>  	return afu_dev;
> 
>  end:
> -	if (kvlist)
> -		rte_kvargs_free(kvlist);
> -	if (path)
> -		free(path);
> +	rte_kvargs_free(kvlist);
> +	free(path);
>  	if (afu_dev) {
>  		rte_intr_instance_free(afu_dev->intr_handle);
>  		free(afu_dev);
> @@ -254,10 +252,8 @@ ifpga_scan(void)
>  	}
> 
>  end:
> -	if (kvlist)
> -		rte_kvargs_free(kvlist);
> -	if (name)
> -		free(name);
> +	rte_kvargs_free(kvlist);
> +	free(name);
> 
>  	return 0;
>  }
Reviewed-by Rosen Xu <rosen.xu@intel.com>


^ permalink raw reply	[flat|nested] 247+ messages in thread

* RE: [PATCH v3 32/36] raw/*: remove unnecessary NULL checks
  2022-02-09 19:17   ` [PATCH v3 32/36] raw/*: " Stephen Hemminger
@ 2022-02-10  3:03     ` Xu, Rosen
  0 siblings, 0 replies; 247+ messages in thread
From: Xu, Rosen @ 2022-02-10  3:03 UTC (permalink / raw)
  To: Stephen Hemminger, dev
  Cc: Hemant Agrawal, Jakub Palider, Tomasz Duszynski, Nipun Gupta,
	Zhang, Tianfei

Hi,

> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Thursday, February 10, 2022 3:18
> To: dev@dpdk.org
> Cc: Stephen Hemminger <stephen@networkplumber.org>; Hemant Agrawal
> <hemant.agrawal@nxp.com>; Jakub Palider <jpalider@marvell.com>;
> Tomasz Duszynski <tduszynski@marvell.com>; Nipun Gupta
> <nipun.gupta@nxp.com>; Xu, Rosen <rosen.xu@intel.com>; Zhang, Tianfei
> <tianfei.zhang@intel.com>
> Subject: [PATCH v3 32/36] raw/*: remove unnecessary NULL checks
> 
> Remove redundant NULL pointer checks before free functions found by
> nullfree.cocci
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>
> ---
>  drivers/raw/cnxk_bphy/cnxk_bphy_cgx.c       |  3 +--
>  drivers/raw/dpaa2_qdma/dpaa2_qdma.c         | 15 +++++----------
>  drivers/raw/ifpga/ifpga_rawdev.c            |  9 +++------
>  drivers/raw/skeleton/skeleton_rawdev_test.c |  6 ++----
>  4 files changed, 11 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/raw/ifpga/ifpga_rawdev.c
> b/drivers/raw/ifpga/ifpga_rawdev.c
> index fdf3c23d2c5f..b73512d3ada5 100644
> --- a/drivers/raw/ifpga/ifpga_rawdev.c
> +++ b/drivers/raw/ifpga/ifpga_rawdev.c
> @@ -836,8 +836,7 @@ rte_fpga_do_pr(struct rte_rawdev *rawdev, int
> port_id,
>  	}
> 
>  free_buffer:
> -	if (buf_to_free)
> -		rte_free(buf_to_free);
> +	rte_free(buf_to_free);
>  close_fd:
>  	close(file_fd);
>  	file_fd = 0;
> @@ -1739,10 +1738,8 @@ ifpga_cfg_probe(struct rte_vdev_device *dev)
>  	ret = rte_eal_hotplug_add(RTE_STR(IFPGA_BUS_NAME),
>  			dev_name, devargs->args);
>  end:
> -	if (kvlist)
> -		rte_kvargs_free(kvlist);
> -	if (name)
> -		free(name);
> +	rte_kvargs_free(kvlist);
> +	free(name);
> 
>  	return ret;
>  }
Reviewed-by Rosen Xu <rosen.xu@intel.com>



^ permalink raw reply	[flat|nested] 247+ messages in thread

* Re: [PATCH v3 00/36] remove unnecessary null checks
  2022-02-09 19:17 ` [PATCH v3 00/36] " Stephen Hemminger
                     ` (35 preceding siblings ...)
  2022-02-09 19:17   ` [PATCH v3 36/36] other: " Stephen Hemminger
@ 2022-02-12 11:09   ` Thomas Monjalon
  36 siblings, 0 replies; 247+ messages in thread
From: Thomas Monjalon @ 2022-02-12 11:09 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev

09/02/2022 20:17, Stephen Hemminger:
> While working on a new driver, noticed that some drivers always call
> free routines (correct) and others conditionally call free routines
> if not null (redundant check).  The extra if(e != NULL) type check
> is unneeded and adds extra code.  Better to have all the code
> consistent.
> 
> The Linux kernel has automated this kind of fixup using coccinelle,
> and this patchset creates a coccinelle script to do the transformation;
> then has individual patches for each sub component.

There are probably more functions to check, as suggested by this command:
all=$(git grep -ho 'rte_.*_free' lib/**/rte_*.h | sed '/[( ]/d' | sort -u);\
checked=$(grep -o 'rte_.*_free' devtools/cocci/nullfree.cocci | sort -u);\
printf "$all\n$checked" | sort | uniq -u

Applied, thanks.



^ permalink raw reply	[flat|nested] 247+ messages in thread

end of thread, other threads:[~2022-02-12 11:09 UTC | newest]

Thread overview: 247+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-24  0:03 [PATCH 00/82] remove unnecessary null checks Stephen Hemminger
2022-01-24  0:03 ` [PATCH 01/82] devtools/cocci: add script to fix " Stephen Hemminger
2022-01-24  0:03 ` [PATCH 02/82] eal: remove unnecessary NULL checks Stephen Hemminger
2022-01-24  0:03 ` [PATCH 03/82] eal/windows: remove unnecessary NULL checks before free Stephen Hemminger
2022-01-24  0:04 ` [PATCH 04/82] examples/fips_validation: remove unnecessary NULL checks Stephen Hemminger
2022-01-24  0:04 ` [PATCH 05/82] examples/ip_pipeline: " Stephen Hemminger
2022-01-24 10:17   ` Dumitrescu, Cristian
2022-01-24 17:23     ` Stephen Hemminger
2022-01-24  0:04 ` [PATCH 06/82] examples/pipeline/thread: " Stephen Hemminger
2022-01-24 10:18   ` Dumitrescu, Cristian
2022-01-24  0:04 ` [PATCH 07/82] examples/l2fwd-cat: " Stephen Hemminger
2022-01-24  0:04 ` [PATCH 08/82] lib/vhost: " Stephen Hemminger
2022-01-24  0:04 ` [PATCH 09/82] examples/vhost_blk: " Stephen Hemminger
2022-01-24  0:04 ` [PATCH 10/82] app/pdump: " Stephen Hemminger
2022-01-24  0:04 ` [PATCH 11/82] app/test-crypto-perf: " Stephen Hemminger
2022-01-24 16:13   ` Power, Ciara
2022-01-24  0:04 ` [PATCH 12/82] app/test-pmd: " Stephen Hemminger
2022-01-24  0:04 ` [PATCH 13/82] app/test-regex: " Stephen Hemminger
2022-01-24  0:04 ` [PATCH 14/82] app/test: " Stephen Hemminger
2022-01-24  0:04 ` [PATCH 15/82] baseband/acc100 " Stephen Hemminger
2022-01-24  0:04 ` [PATCH 16/82] baseband/la12xx " Stephen Hemminger
2022-01-24  5:05   ` Hemant Agrawal
2022-01-24  0:04 ` [PATCH 17/82] baseband/null " Stephen Hemminger
2022-01-24  0:04 ` [PATCH 18/82] baseband/turbo_sw " Stephen Hemminger
2022-01-24  0:04 ` [PATCH 19/82] bus/fslmc: " Stephen Hemminger
2022-01-24  5:06   ` Hemant Agrawal
2022-01-24  0:04 ` [PATCH 20/82] bus/ifpga: " Stephen Hemminger
2022-01-24  0:04 ` [PATCH 21/82] bus/pci: " Stephen Hemminger
2022-01-24  0:04 ` [PATCH 22/82] common/cpt: " Stephen Hemminger
2022-01-24  0:04 ` [PATCH 23/82] common/dpaax: simplify kernel compat macros Stephen Hemminger
2022-01-24  5:06   ` Hemant Agrawal
2022-01-24  0:04 ` [PATCH 24/82] common/mlx5: remove unnecessary NULL checks Stephen Hemminger
2022-01-24  0:04 ` [PATCH 25/82] common/qat: " Stephen Hemminger
2022-01-24  0:04 ` [PATCH 26/82] compress/mlx5: " Stephen Hemminger
2022-01-24  0:04 ` [PATCH 27/82] compress/octeontx: " Stephen Hemminger
2022-01-24  0:04 ` [PATCH 28/82] crypto/armv8: " Stephen Hemminger
2022-01-24  4:15   ` Ruifeng Wang
2022-01-24  0:04 ` [PATCH 29/82] crypto/ccp: " Stephen Hemminger
2022-01-24  0:04 ` [PATCH 30/82] crypto/cnxk: " Stephen Hemminger
2022-01-24  0:04 ` [PATCH 31/82] crypto/ipsec_mb: " Stephen Hemminger
2022-01-24  0:04 ` [PATCH 32/82] crypto/mvsam: " Stephen Hemminger
2022-01-24  7:44   ` [EXT] " Liron Himi
2022-01-24  0:04 ` [PATCH 33/82] crypto/null: " Stephen Hemminger
2022-01-24  0:04 ` [PATCH 34/82] crypto/octeontx: " Stephen Hemminger
2022-01-24  0:04 ` [PATCH 35/82] crypto/openssl: " Stephen Hemminger
2022-01-24  0:04 ` [PATCH 36/82] crypto/scheduler: " Stephen Hemminger
2022-01-24  0:04 ` [PATCH 37/82] crypto/virtio: " Stephen Hemminger
2022-01-24  0:04 ` [PATCH 38/82] event/sw: " Stephen Hemminger
2022-01-24  0:04 ` [PATCH 39/82] net/axgbe: " Stephen Hemminger
2022-01-24  0:04 ` [PATCH 40/82] net/bnx2x: " Stephen Hemminger
2022-01-24  0:04 ` [PATCH 41/82] net/bnxt: " Stephen Hemminger
2022-01-24  0:04 ` [PATCH 42/82] net/bonding: " Stephen Hemminger
2022-01-24  0:04 ` [PATCH 43/82] net/cnxk: " Stephen Hemminger
2022-01-24  0:04 ` [PATCH 44/82] net/cxgbe: " Stephen Hemminger
2022-01-24  0:04 ` [PATCH 45/82] net/dpaa: " Stephen Hemminger
2022-01-24  5:01   ` Hemant Agrawal
2022-01-24  0:04 ` [PATCH 46/82] net/dpaa2: " Stephen Hemminger
2022-01-24  0:04 ` [PATCH 47/82] net/ena: " Stephen Hemminger
2022-01-24  0:04 ` [PATCH 48/82] net/hinic: " Stephen Hemminger
2022-01-24  0:04 ` [PATCH 49/82] net/hns3: " Stephen Hemminger
2022-01-24  0:04 ` [PATCH 50/82] net/i40e: " Stephen Hemminger
2022-01-24  0:04 ` [PATCH 51/82] net/iavf: " Stephen Hemminger
2022-01-24  0:04 ` [PATCH 52/82] net/ice: " Stephen Hemminger
2022-01-24  0:04 ` [PATCH 53/82] net/igc: " Stephen Hemminger
2022-01-24  0:49   ` Wang, Haiyue
2022-01-24  0:04 ` [PATCH 54/82] net/ixgbe: " Stephen Hemminger
2022-01-24  0:48   ` Wang, Haiyue
2022-01-24  0:04 ` [PATCH 55/82] net/memif: " Stephen Hemminger
2022-01-24  0:04 ` [PATCH 56/82] net/mlx4: " Stephen Hemminger
2022-01-24  0:04 ` [PATCH 57/82] net/mlx5: " Stephen Hemminger
2022-01-24  0:04 ` [PATCH 58/82] net/mvpp2: " Stephen Hemminger
2022-01-24  7:44   ` [EXT] " Liron Himi
2022-01-24  0:04 ` [PATCH 59/82] net/netvsc: " Stephen Hemminger
2022-01-24 20:09   ` Long Li
2022-01-24  0:04 ` [PATCH 60/82] net/null: " Stephen Hemminger
2022-01-24  0:04 ` [PATCH 61/82] net/octeontx: " Stephen Hemminger
2022-01-24  0:04 ` [PATCH 62/82] net/qede: " Stephen Hemminger
2022-01-24  0:04 ` [PATCH 63/82] net/softnic: " Stephen Hemminger
2022-01-24 10:17   ` Dumitrescu, Cristian
2022-01-24  0:05 ` [PATCH 64/82] net/tap: " Stephen Hemminger
2022-01-24  0:05 ` [PATCH 65/82] net/txgbe: " Stephen Hemminger
2022-01-24  0:05 ` [PATCH 66/82] net/vdev_netvsc: " Stephen Hemminger
2022-01-24  0:05 ` [PATCH 67/82] net/virtio: " Stephen Hemminger
2022-01-24  0:05 ` [PATCH 68/82] raw/cnxk_bphy: " Stephen Hemminger
2022-01-24  0:05 ` [PATCH 69/82] raw/dpaa2_qdma: " Stephen Hemminger
2022-01-24  0:05 ` [PATCH 70/82] raw/ifpga: " Stephen Hemminger
2022-01-24  0:05 ` [PATCH 71/82] raw/skeleton: " Stephen Hemminger
2022-01-24  5:00   ` Hemant Agrawal
2022-01-24  0:05 ` [PATCH 72/82] regex/cn9k: " Stephen Hemminger
2022-01-24  7:44   ` [EXT] " Liron Himi
2022-01-24  0:05 ` [PATCH 73/82] regex/mlx5: " Stephen Hemminger
2022-01-24  0:05 ` [PATCH 74/82] vdpa/ifc: " Stephen Hemminger
2022-01-24  0:05 ` [PATCH 75/82] vdpa/mlx5: " Stephen Hemminger
2022-01-24  0:05 ` [PATCH 76/82] compressdev: " Stephen Hemminger
2022-01-24  0:05 ` [PATCH 77/82] ethdev: " Stephen Hemminger
2022-01-24  0:05 ` [PATCH 78/82] graph: " Stephen Hemminger
2022-01-24  0:05 ` [PATCH 79/82] ipsec: " Stephen Hemminger
2022-01-24  0:05 ` [PATCH 80/82] port: " Stephen Hemminger
2022-01-24  0:05 ` [PATCH 81/82] power: " Stephen Hemminger
2022-01-24  0:05 ` [PATCH 82/82] reorder: " Stephen Hemminger
2022-01-24 17:45 ` [PATCH v2 00/83] remove unnecessary null checks Stephen Hemminger
2022-01-24 17:45   ` [PATCH v2 01/83] lib: update documentation of XXX_free() functions Stephen Hemminger
2022-01-28 21:47     ` Thomas Monjalon
2022-01-28 22:51       ` Stephen Hemminger
2022-01-29 18:51         ` Thomas Monjalon
2022-02-08 17:03           ` Thomas Monjalon
2022-01-24 17:45   ` [PATCH v2 02/83] devtools/cocci: add script to fix unnecessary null checks Stephen Hemminger
2022-01-28 21:48     ` Thomas Monjalon
2022-01-24 17:45   ` [PATCH v2 03/83] eal: remove unnecessary NULL checks Stephen Hemminger
2022-01-24 17:46   ` [PATCH v2 04/83] eal/windows: remove unnecessary NULL checks before free Stephen Hemminger
2022-01-24 17:46   ` [PATCH v2 05/83] examples/fips_validation: remove unnecessary NULL checks Stephen Hemminger
2022-01-24 17:46   ` [PATCH v2 06/83] examples/ip_pipeline: " Stephen Hemminger
2022-01-24 17:46   ` [PATCH v2 07/83] examples/pipeline/thread: " Stephen Hemminger
2022-01-24 17:46   ` [PATCH v2 08/83] examples/l2fwd-cat: " Stephen Hemminger
2022-01-24 17:46   ` [PATCH v2 09/83] lib/vhost: " Stephen Hemminger
2022-01-27  5:52     ` Xia, Chenbo
2022-01-24 17:46   ` [PATCH v2 10/83] examples/vhost_blk: " Stephen Hemminger
2022-01-27  5:53     ` Xia, Chenbo
2022-01-24 17:46   ` [PATCH v2 11/83] app/pdump: " Stephen Hemminger
2022-01-24 17:46   ` [PATCH v2 12/83] app/test-crypto-perf: " Stephen Hemminger
2022-01-24 17:46   ` [PATCH v2 13/83] app/test-pmd: " Stephen Hemminger
2022-01-24 17:46   ` [PATCH v2 14/83] app/test-regex: " Stephen Hemminger
2022-01-24 17:46   ` [PATCH v2 15/83] app/test: " Stephen Hemminger
2022-01-24 17:46   ` [PATCH v2 16/83] baseband/acc100 " Stephen Hemminger
2022-01-24 17:46   ` [PATCH v2 17/83] baseband/la12xx " Stephen Hemminger
2022-01-24 17:46   ` [PATCH v2 18/83] baseband/null " Stephen Hemminger
2022-01-24 17:46   ` [PATCH v2 19/83] baseband/turbo_sw " Stephen Hemminger
2022-01-24 17:46   ` [PATCH v2 20/83] bus/fslmc: " Stephen Hemminger
2022-01-24 17:46   ` [PATCH v2 21/83] bus/ifpga: " Stephen Hemminger
2022-01-24 17:46   ` [PATCH v2 22/83] bus/pci: " Stephen Hemminger
2022-01-24 17:46   ` [PATCH v2 23/83] common/cpt: " Stephen Hemminger
2022-01-24 17:46   ` [PATCH v2 24/83] common/dpaax: simplify kernel compat macros Stephen Hemminger
2022-01-24 17:46   ` [PATCH v2 25/83] common/mlx5: remove unnecessary NULL checks Stephen Hemminger
2022-01-24 17:46   ` [PATCH v2 26/83] common/qat: " Stephen Hemminger
2022-01-24 17:46   ` [PATCH v2 27/83] compress/mlx5: " Stephen Hemminger
2022-01-24 17:46   ` [PATCH v2 28/83] compress/octeontx: " Stephen Hemminger
2022-01-24 17:46   ` [PATCH v2 29/83] crypto/armv8: " Stephen Hemminger
2022-01-24 17:46   ` [PATCH v2 30/83] crypto/ccp: " Stephen Hemminger
2022-01-24 17:46   ` [PATCH v2 31/83] crypto/cnxk: " Stephen Hemminger
2022-01-24 17:46   ` [PATCH v2 32/83] crypto/ipsec_mb: " Stephen Hemminger
2022-01-27 11:08     ` Zhang, Roy Fan
2022-01-24 17:46   ` [PATCH v2 33/83] crypto/mvsam: " Stephen Hemminger
2022-01-24 17:46   ` [PATCH v2 34/83] crypto/null: " Stephen Hemminger
2022-01-24 17:46   ` [PATCH v2 35/83] crypto/octeontx: " Stephen Hemminger
2022-01-24 17:46   ` [PATCH v2 36/83] crypto/openssl: " Stephen Hemminger
2022-01-24 17:46   ` [PATCH v2 37/83] crypto/scheduler: " Stephen Hemminger
2022-01-25 10:07     ` Zhang, Roy Fan
2022-01-24 17:46   ` [PATCH v2 38/83] crypto/virtio: " Stephen Hemminger
2022-01-24 17:46   ` [PATCH v2 39/83] event/sw: " Stephen Hemminger
2022-01-24 17:46   ` [PATCH v2 40/83] net/axgbe: " Stephen Hemminger
2022-01-24 17:46   ` [PATCH v2 41/83] net/bnx2x: " Stephen Hemminger
2022-01-24 17:46   ` [PATCH v2 42/83] net/bnxt: " Stephen Hemminger
2022-01-24 17:46   ` [PATCH v2 43/83] net/bonding: " Stephen Hemminger
2022-01-25  0:49     ` Min Hu (Connor)
2022-01-24 17:46   ` [PATCH v2 44/83] net/cnxk: " Stephen Hemminger
2022-01-24 17:46   ` [PATCH v2 45/83] net/cxgbe: " Stephen Hemminger
2022-01-24 17:46   ` [PATCH v2 46/83] net/dpaa: " Stephen Hemminger
2022-01-24 17:46   ` [PATCH v2 47/83] net/dpaa2: " Stephen Hemminger
2022-01-24 17:46   ` [PATCH v2 48/83] net/ena: " Stephen Hemminger
2022-01-24 17:46   ` [PATCH v2 49/83] net/hinic: " Stephen Hemminger
2022-01-24 17:46   ` [PATCH v2 50/83] net/hns3: " Stephen Hemminger
2022-01-25  0:49     ` Min Hu (Connor)
2022-01-24 17:46   ` [PATCH v2 51/83] net/i40e: " Stephen Hemminger
2022-01-24 17:46   ` [PATCH v2 52/83] net/iavf: " Stephen Hemminger
2022-01-24 17:46   ` [PATCH v2 53/83] net/ice: " Stephen Hemminger
2022-01-24 17:46   ` [PATCH v2 54/83] net/igc: " Stephen Hemminger
2022-01-25  0:44     ` Wang, Haiyue
2022-01-24 17:46   ` [PATCH v2 55/83] net/ixgbe: " Stephen Hemminger
2022-01-25  0:43     ` Wang, Haiyue
2022-01-24 17:46   ` [PATCH v2 56/83] net/memif: " Stephen Hemminger
2022-01-24 17:46   ` [PATCH v2 57/83] net/mlx4: " Stephen Hemminger
2022-01-26  7:00     ` Slava Ovsiienko
2022-01-24 17:46   ` [PATCH v2 58/83] net/mlx5: " Stephen Hemminger
2022-01-26  7:00     ` Slava Ovsiienko
2022-01-24 17:46   ` [PATCH v2 59/83] net/mvpp2: " Stephen Hemminger
2022-01-24 17:46   ` [PATCH v2 60/83] net/netvsc: " Stephen Hemminger
2022-01-24 20:11     ` Long Li
2022-01-24 17:46   ` [PATCH v2 61/83] net/null: " Stephen Hemminger
2022-01-24 17:46   ` [PATCH v2 62/83] net/octeontx: " Stephen Hemminger
2022-01-24 17:46   ` [PATCH v2 63/83] net/qede: " Stephen Hemminger
2022-01-25  3:53     ` [EXT] " Devendra Singh Rawat
2022-01-24 17:47   ` [PATCH v2 64/83] net/softnic: " Stephen Hemminger
2022-01-24 17:47   ` [PATCH v2 65/83] net/tap: " Stephen Hemminger
2022-01-24 17:47   ` [PATCH v2 66/83] net/txgbe: " Stephen Hemminger
2022-01-24 17:47   ` [PATCH v2 67/83] net/vdev_netvsc: " Stephen Hemminger
2022-01-24 17:47   ` [PATCH v2 68/83] net/virtio: " Stephen Hemminger
2022-01-24 17:47   ` [PATCH v2 69/83] raw/cnxk_bphy: " Stephen Hemminger
2022-01-24 17:47   ` [PATCH v2 70/83] raw/dpaa2_qdma: " Stephen Hemminger
2022-01-24 18:09     ` Nipun Gupta
2022-01-24 17:47   ` [PATCH v2 71/83] raw/ifpga: " Stephen Hemminger
2022-01-24 17:47   ` [PATCH v2 72/83] raw/skeleton: " Stephen Hemminger
2022-01-24 17:47   ` [PATCH v2 73/83] regex/cn9k: " Stephen Hemminger
2022-01-24 17:47   ` [PATCH v2 74/83] regex/mlx5: " Stephen Hemminger
2022-01-24 17:47   ` [PATCH v2 75/83] vdpa/ifc: " Stephen Hemminger
2022-01-27  5:54     ` Xia, Chenbo
2022-01-24 17:47   ` [PATCH v2 76/83] vdpa/mlx5: " Stephen Hemminger
2022-01-24 17:47   ` [PATCH v2 77/83] compressdev: " Stephen Hemminger
2022-01-27 11:07     ` Zhang, Roy Fan
2022-01-24 17:47   ` [PATCH v2 78/83] ethdev: " Stephen Hemminger
2022-01-24 17:47   ` [PATCH v2 79/83] graph: " Stephen Hemminger
2022-01-24 17:47   ` [PATCH v2 80/83] ipsec: " Stephen Hemminger
2022-01-24 17:47   ` [PATCH v2 81/83] port: " Stephen Hemminger
2022-01-24 17:47   ` [PATCH v2 82/83] power: " Stephen Hemminger
2022-01-25  8:50     ` David Hunt
2022-01-24 17:47   ` [PATCH v2 83/83] reorder: " Stephen Hemminger
2022-01-28 21:49   ` [PATCH v2 00/83] remove unnecessary null checks Thomas Monjalon
2022-01-28 22:14     ` Stephen Hemminger
2022-02-09 19:17 ` [PATCH v3 00/36] " Stephen Hemminger
2022-02-09 19:17   ` [PATCH v3 01/36] lib: update documentation of XXX_free() functions Stephen Hemminger
2022-02-09 19:17   ` [PATCH v3 02/36] devtools/cocci: add script to fix unnecessary null checks Stephen Hemminger
2022-02-09 19:17   ` [PATCH v3 03/36] eal: remove unnecessary NULL checks Stephen Hemminger
2022-02-09 19:17   ` [PATCH v3 04/36] ethdev: " Stephen Hemminger
2022-02-09 19:17   ` [PATCH v3 05/36] examples: " Stephen Hemminger
2022-02-09 19:17   ` [PATCH v3 06/36] vhost: " Stephen Hemminger
2022-02-09 19:17   ` [PATCH v3 07/36] app: " Stephen Hemminger
2022-02-09 19:17   ` [PATCH v3 08/36] baseband/*: " Stephen Hemminger
2022-02-09 19:17   ` [PATCH v3 09/36] bus/*: " Stephen Hemminger
2022-02-10  3:02     ` Xu, Rosen
2022-02-09 19:17   ` [PATCH v3 10/36] common/*: " Stephen Hemminger
2022-02-09 19:17   ` [PATCH v3 11/36] compress/*: " Stephen Hemminger
2022-02-09 19:17   ` [PATCH v3 12/36] crypto: " Stephen Hemminger
2022-02-09 19:17   ` [PATCH v3 13/36] event/sw: " Stephen Hemminger
2022-02-09 19:17   ` [PATCH v3 14/36] net/axgbe: " Stephen Hemminger
2022-02-09 19:17   ` [PATCH v3 15/36] net/bnx*: " Stephen Hemminger
2022-02-09 19:17   ` [PATCH v3 16/36] net/cnxk: " Stephen Hemminger
2022-02-09 19:17   ` [PATCH v3 17/36] net/cxgbe: " Stephen Hemminger
2022-02-09 19:17   ` [PATCH v3 18/36] net/dpaa*: " Stephen Hemminger
2022-02-09 19:17   ` [PATCH v3 19/36] net/ena: " Stephen Hemminger
2022-02-09 19:17   ` [PATCH v3 20/36] net/hinic: " Stephen Hemminger
2022-02-09 19:17   ` [PATCH v3 21/36] net/hns3: " Stephen Hemminger
2022-02-09 19:17   ` [PATCH v3 22/36] net/i*: " Stephen Hemminger
2022-02-09 19:17   ` [PATCH v3 23/36] net/mlx*: " Stephen Hemminger
2022-02-09 19:17   ` [PATCH v3 24/36] net/mvpp2: " Stephen Hemminger
2022-02-09 19:17   ` [PATCH v3 25/36] net/netvsc: " Stephen Hemminger
2022-02-09 19:17   ` [PATCH v3 26/36] net/octeontx: " Stephen Hemminger
2022-02-09 19:17   ` [PATCH v3 27/36] net/qede: " Stephen Hemminger
2022-02-09 19:17   ` [PATCH v3 28/36] net/txgbe: " Stephen Hemminger
2022-02-09 19:17   ` [PATCH v3 29/36] net/vdev_netvsc: " Stephen Hemminger
2022-02-09 19:17   ` [PATCH v3 30/36] net/virtio: " Stephen Hemminger
2022-02-09 19:17   ` [PATCH v3 31/36] net/other: " Stephen Hemminger
2022-02-09 19:17   ` [PATCH v3 32/36] raw/*: " Stephen Hemminger
2022-02-10  3:03     ` Xu, Rosen
2022-02-09 19:17   ` [PATCH v3 33/36] regex/*: " Stephen Hemminger
2022-02-09 19:17   ` [PATCH v3 34/36] vdpa/*: " Stephen Hemminger
2022-02-09 19:17   ` [PATCH v3 35/36] compressdev: " Stephen Hemminger
2022-02-09 19:17   ` [PATCH v3 36/36] other: " Stephen Hemminger
2022-02-12 11:09   ` [PATCH v3 00/36] remove unnecessary null checks Thomas Monjalon

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).