remove unnecessary null checks
Subsystems (7)
PATCH v3 9/36 bus/*: remove unnecessary NULL checks
In reply to Stephen HemmingerRemove redundant NULL pointer checks before free functions found by nullfree.cocci
--- 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(-)
drivers/bus/fslmc/fslmc_bus.c +2 -4
@@ -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);
drivers/bus/fslmc/portal/dpaa2_hw_dpio.c +2 -4
@@ -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]); } }
drivers/bus/ifpga/ifpga_bus.c +4 -8
@@ -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 ; }
drivers/bus/pci/pci_params.c +1 -2
@@ -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;
drivers/bus/pci/windows/pci.c +1 -2
@@ -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; }
drivers/bus/pci/windows/pci_netuio.c +1 -2
@@ -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);
Signature · 1 line
2.34.1
RE: [PATCH v3 09/36] bus/*: remove unnecessary NULL checks
Hi,
Quoted 43 lines
-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Thursday, February 10, 2022 3:17
To: [email protected]
Cc: Stephen Hemminger <[email protected]>; Hemant Agrawal <[email protected]>; Sachin Saxena <[email protected]>; Xu, Rosen <[email protected]>
Subject: [PATCH v3 09/36] bus/*: remove unnecessary NULL checksRemove redundant NULL pointer checks before free functions found by
nullfree.cocciSigned-off-by Stephen Hemminger <[email protected]>Acked-by Hemant Agrawal <[email protected]>--- 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(-)drivers/bus/ifpga/ifpga_bus.c +2
-4@@ -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) }
drivers/bus/ifpga/ifpga_bus.c ifpga_scan(void) · line 259
Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c +2
-4end: -if (kvlist) -rte_kvargs_free (kvlist); -if (name) -free (name); +rte_kvargs_free (kvlist); +free (name);return 0 ; }
Reviewed-by Rosen Xu <[email protected]>
PATCH v3 10/36 common/*: remove unnecessary NULL checks
In reply to Stephen HemmingerRemove redundant NULL pointer checks before free functions found by nullfree.cocci
--- 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(-)
drivers/common/cpt/cpt_ucode_asym.h +2 -4
@@ -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 */
drivers/common/dpaax/compat.h +2 -9
@@ -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) {
drivers/common/mlx5/mlx5_common_mr.c +1 -2
@@ -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); }
drivers/common/mlx5/mlx5_common_pci.c +1 -2
@@ -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 ; }
drivers/common/qat/qat_qp.c +3 -6
@@ -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);
Signature · 1 line
2.34.1
PATCH v3 11/36 compress/*: remove unnecessary NULL checks
In reply to Stephen HemmingerRemove redundant NULL pointer checks before free functions found by nullfree.cocci
--- drivers/compress/mlx5/mlx5_compress.c | 3 +-- drivers/compress/octeontx/otx_zip_pmd.c | 9 +++------ 2 files changed, 4 insertions(+), 8 deletions(-)
drivers/compress/mlx5/mlx5_compress.c +1 -2
@@ -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);
drivers/compress/octeontx/otx_zip_pmd.c +3 -6
@@ -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 ; }
Signature · 1 line
2.34.1
PATCH v3 12/36 crypto: remove unnecessary NULL checks
In reply to Stephen HemmingerRemove redundant NULL pointer checks before free functions found by nullfree.cocci
--- 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(-)
drivers/crypto/armv8/rte_armv8_pmd_ops.c +1 -2
@@ -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 ; }
drivers/crypto/ccp/ccp_dev.c +1 -2
@@ -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 ; }
drivers/crypto/ccp/ccp_pmd_ops.c +1 -2
@@ -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 ; }
drivers/crypto/cnxk/cnxk_ae.h +2 -4
@@ -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 */
drivers/crypto/ipsec_mb/ipsec_mb_ops.c +1 -2
@@ -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)
drivers/crypto/mvsam/rte_mrvl_pmd_ops.c +2 -4
@@ -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 ; }
drivers/crypto/null/null_crypto_pmd_ops.c +2 -4
@@ -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 ; }
drivers/crypto/octeontx/otx_cryptodev_ops.c +1 -2
@@ -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 ());
drivers/crypto/openssl/rte_openssl_pmd_ops.c +2 -4
@@ -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 ; }
drivers/crypto/scheduler/scheduler_pmd_ops.c +2 -4
@@ -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 ;
drivers/crypto/virtio/virtqueue.c +2 -4
@@ -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 ; }
Signature · 1 line
2.34.1
PATCH v3 13/36 event/sw: remove unnecessary NULL checks
In reply to Stephen HemmingerRemove redundant NULL pointer checks before free functions found by nullfree.cocci
--- drivers/event/sw/sw_evdev.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/event/sw/sw_evdev.c +1 -2
@@ -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) *
Signature · 1 line
2.34.1
PATCH v3 14/36 net/axgbe: remove unnecessary NULL checks
In reply to Stephen HemmingerRemove redundant NULL pointer checks before free functions found by nullfree.cocci
--- drivers/net/axgbe/axgbe_rxtx.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/net/axgbe/axgbe_rxtx.c +2 -4
@@ -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); }
Signature · 1 line
2.34.1
PATCH v3 15/36 net/bnx*: remove unnecessary NULL checks
In reply to Stephen HemmingerRemove redundant NULL pointer checks before free functions found by nullfree.cocci
--- drivers/net/bnx2x/bnx2x_rxtx.c | 6 ++---- drivers/net/bnxt/bnxt_ethdev.c | 3 +-- 2 files changed, 3 insertions(+), 6 deletions(-)
drivers/net/bnx2x/bnx2x_rxtx.c +2 -4
@@ -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); }
drivers/net/bnxt/bnxt_ethdev.c +1 -2
@@ -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 ;
Signature · 1 line
2.34.1
PATCH v3 16/36 net/cnxk: remove unnecessary NULL checks
In reply to Stephen HemmingerRemove redundant NULL pointer checks before free functions found by nullfree.cocci
--- drivers/net/cnxk/cnxk_ethdev.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/net/cnxk/cnxk_ethdev.c +2 -4
@@ -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; }
Signature · 1 line
2.34.1
PATCH v3 17/36 net/cxgbe: remove unnecessary NULL checks
In reply to Stephen HemmingerRemove redundant NULL pointer checks before free functions found by nullfree.cocci
--- drivers/net/cxgbe/cxgbe_main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/cxgbe/cxgbe_main.c +1 -2
@@ -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);
Signature · 1 line
2.34.1
PATCH v3 18/36 net/dpaa*: remove unnecessary NULL checks
In reply to Stephen HemmingerRemove redundant NULL pointer checks before free functions found by nullfree.cocci
--- 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(-)
drivers/net/dpaa/dpaa_ethdev.c +1 -2
@@ -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) {
drivers/net/dpaa/fmlib/fm_lib.c +1 -2
@@ -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" );
drivers/net/dpaa2/dpaa2_ethdev.c +1 -2
@@ -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++) {
drivers/net/dpaa2/dpaa2_mux.c +1 -2
@@ -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 ; }
drivers/net/dpaa2/dpaa2_ptp.c +1 -2
@@ -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 ; }
Signature · 1 line
2.34.1
PATCH v3 19/36 net/ena: remove unnecessary NULL checks
In reply to Stephen HemmingerRemove redundant NULL pointer checks before free functions found by nullfree.cocci
--- drivers/net/ena/ena_ethdev.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-)
drivers/net/ena/ena_ethdev.c +6 -12
@@ -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 ;
Signature · 1 line
2.34.1
PATCH v3 20/36 net/hinic: remove unnecessary NULL checks
In reply to Stephen HemmingerRemove redundant NULL pointer checks before free functions found by nullfree.cocci
--- drivers/net/hinic/hinic_pmd_ethdev.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/hinic/hinic_pmd_ethdev.c +1 -2
@@ -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)
Signature · 1 line
2.34.1
PATCH v3 21/36 net/hns3: remove unnecessary NULL checks
In reply to Stephen HemmingerRemove redundant NULL pointer checks before free functions found by nullfree.cocci
--- drivers/net/hns3/hns3_rxtx.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/net/hns3/hns3_rxtx.c +3 -6
@@ -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); } }
Signature · 1 line
2.34.1
PATCH v3 22/36 net/i*: remove unnecessary NULL checks
In reply to Stephen HemmingerRemove redundant NULL pointer checks before free functions found by nullfree.cocci
--- 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(-)
drivers/net/i40e/i40e_ethdev.c +9 -18
@@ -1781,10 +1781,8 @@ i40e_rm_ethtype_filter_list(struct i40e_pf *pf) ethertype_rule = &pf->ethertype;/* Remove all ethertype filter rules and hash */ -if (ethertype_rule->hash_map) -rte_free (ethertype_rule->hash_map); -if (ethertype_rule->hash_table) -rte_hash_free (ethertype_rule->hash_table); +rte_free (ethertype_rule->hash_map); +rte_hash_free (ethertype_rule->hash_table);while ((p_ethertype =TAILQ_FIRST (ðertype_rule->ethertype_list))) { TAILQ_REMOVE(ðertype_rule->ethertype_list,
@@ -1801,10 +1799,8 @@ i40e_rm_tunnel_filter_list(struct i40e_pf *pf) tunnel_rule = &pf->tunnel;/* Remove all tunnel director rules and hash */ -if (tunnel_rule->hash_map) -rte_free (tunnel_rule->hash_map); -if (tunnel_rule->hash_table) -rte_hash_free (tunnel_rule->hash_table); +rte_free (tunnel_rule->hash_map); +rte_hash_free (tunnel_rule->hash_table);while ((p_tunnel =TAILQ_FIRST (&tunnel_rule->tunnel_list))) {TAILQ_REMOVE (&tunnel_rule->tunnel_list, p_tunnel, rules);
@@ -1833,16 +1829,11 @@ i40e_fdir_memory_cleanup(struct i40e_pf *pf) fdir_info = &pf->fdir;/* flow director memory cleanup */ -if (fdir_info->hash_map) -rte_free (fdir_info->hash_map); -if (fdir_info->hash_table) -rte_hash_free (fdir_info->hash_table); -if (fdir_info->fdir_flow_pool.bitmap) -rte_free (fdir_info->fdir_flow_pool.bitmap); -if (fdir_info->fdir_flow_pool.pool) -rte_free (fdir_info->fdir_flow_pool.pool); -if (fdir_info->fdir_filter_array) -rte_free (fdir_info->fdir_filter_array); +rte_free (fdir_info->hash_map); +rte_hash_free (fdir_info->hash_table); +rte_free (fdir_info->fdir_flow_pool.bitmap); +rte_free (fdir_info->fdir_flow_pool.pool); +rte_free (fdir_info->fdir_filter_array); }void i40e_flex_payload_reg_set_default (struct i40e_hw *hw)
drivers/net/i40e/i40e_rxtx.c +1 -2
@@ -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 ;
drivers/net/iavf/iavf_rxtx.c +1 -2
@@ -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 ;
drivers/net/ice/ice_fdir_filter.c +2 -4
@@ -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 ;
drivers/net/igc/igc_flow.c +1 -4
@@ -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." );
drivers/net/ixgbe/ixgbe_ethdev.c +4 -8
@@ -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,
drivers/net/ixgbe/ixgbe_rxtx.c +1 -2
@@ -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 ;
Signature · 1 line
2.34.1
PATCH v3 23/36 net/mlx*: remove unnecessary NULL checks
In reply to Stephen HemmingerRemove redundant NULL pointer checks before free functions found by nullfree.cocci
--- drivers/net/mlx4/mlx4_mr.c | 3 +-- drivers/net/mlx5/mlx5_flow.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-)
drivers/net/mlx4/mlx4_mr.c +1 -2
@@ -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); }
drivers/net/mlx5/mlx5_flow.c +1 -2
@@ -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 ; }
Signature · 1 line
2.34.1
PATCH v3 24/36 net/mvpp2: remove unnecessary NULL checks
In reply to Stephen HemmingerRemove redundant NULL pointer checks before free functions found by nullfree.cocci
--- drivers/net/mvpp2/mrvl_qos.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/mvpp2/mrvl_qos.c +1 -2
@@ -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;
Signature · 1 line
2.34.1
PATCH v3 25/36 net/netvsc: remove unnecessary NULL checks
In reply to Stephen HemmingerRemove redundant NULL pointer checks before free functions found by nullfree.cocci
--- drivers/net/netvsc/hn_rxtx.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/net/netvsc/hn_rxtx.c +2 -4
@@ -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);
Signature · 1 line
2.34.1
PATCH v3 26/36 net/octeontx: remove unnecessary NULL checks
In reply to Stephen HemmingerRemove redundant NULL pointer checks before free functions found by nullfree.cocci
--- drivers/net/octeontx/octeontx_ethdev.c | 3 +-- drivers/net/octeontx/octeontx_ethdev_ops.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-)
drivers/net/octeontx/octeontx_ethdev.c +1 -2
@@ -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; }
drivers/net/octeontx/octeontx_ethdev_ops.c +1 -2
@@ -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; }
Signature · 1 line
2.34.1
PATCH v3 27/36 net/qede: remove unnecessary NULL checks
In reply to Stephen HemmingerRemove redundant NULL pointer checks before free functions found by nullfree.cocci
--- drivers/net/qede/qede_main.c | 3 +-- drivers/net/qede/qede_rxtx.c | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-)
drivers/net/qede/qede_main.c +1 -2
@@ -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
drivers/net/qede/qede_rxtx.c +2 -4
@@ -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 ; }
Signature · 1 line
2.34.1
PATCH v3 28/36 net/txgbe: remove unnecessary NULL checks
In reply to Stephen HemmingerRemove redundant NULL pointer checks before free functions found by nullfree.cocci
--- drivers/net/txgbe/txgbe_ethdev.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/net/txgbe/txgbe_ethdev.c +4 -8
@@ -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,
Signature · 1 line
2.34.1
PATCH v3 29/36 net/vdev_netvsc: remove unnecessary NULL checks
In reply to Stephen HemmingerRemove redundant NULL pointer checks before free functions found by nullfree.cocci
--- drivers/net/vdev_netvsc/vdev_netvsc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/vdev_netvsc/vdev_netvsc.c +1 -2
@@ -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,
Signature · 1 line
2.34.1
PATCH v3 30/36 net/virtio: remove unnecessary NULL checks
In reply to Stephen HemmingerRemove redundant NULL pointer checks before free functions found by nullfree.cocci
--- drivers/net/virtio/virtio_user_ethdev.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/net/virtio/virtio_user_ethdev.c +4 -8
@@ -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; }
Signature · 1 line
2.34.1
PATCH v3 31/36 net/other: remove unnecessary NULL checks
In reply to Stephen HemmingerRemove redundant NULL pointer checks before free functions found by nullfree.cocci
--- 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(-)
drivers/net/bonding/rte_eth_bond_pmd.c +1 -2
@@ -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 ; }
drivers/net/memif/rte_eth_memif.c +2 -4
@@ -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; }
drivers/net/null/rte_eth_null.c +1 -2
@@ -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; }
drivers/net/softnic/rte_eth_softnic_cli.c +4 -8
@@ -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 ;
drivers/net/softnic/rte_eth_softnic_cryptodev.c +2 -4
@@ -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);
drivers/net/softnic/rte_eth_softnic_thread.c +2 -4
@@ -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); } }
drivers/net/tap/tap_flow.c +3 -6
@@ -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 ; }
Signature · 1 line
2.34.1
PATCH v3 32/36 raw/*: remove unnecessary NULL checks
In reply to Stephen HemmingerRemove redundant NULL pointer checks before free functions found by nullfree.cocci
--- 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(-)
drivers/raw/cnxk_bphy/cnxk_bphy_cgx.c +1 -2
@@ -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 ;
drivers/raw/dpaa2_qdma/dpaa2_qdma.c +5 -10
@@ -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 ));
drivers/raw/ifpga/ifpga_rawdev.c +3 -6
@@ -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; }
drivers/raw/skeleton/skeleton_rawdev_test.c +2 -4
@@ -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 ; }
Signature · 1 line
2.34.1
RE: [PATCH v3 32/36] raw/*: remove unnecessary NULL checks
Hi,
Quoted 42 lines
-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Thursday, February 10, 2022 3:18
To: [email protected]
Cc: Stephen Hemminger <[email protected]>; Hemant Agrawal <[email protected]>; Jakub Palider <[email protected]>; Tomasz Duszynski <[email protected]>; Nipun Gupta <[email protected]>; Xu, Rosen <[email protected]>; Zhang, Tianfei <[email protected]>
Subject: [PATCH v3 32/36] raw/*: remove unnecessary NULL checksRemove redundant NULL pointer checks before free functions found by
nullfree.cocciSigned-off-by Stephen Hemminger <[email protected]>Acked-by Hemant Agrawal <[email protected]>--- 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(-)drivers/raw/ifpga/ifpga_rawdev.c +1
-2@@ -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);drivers/raw/ifpga/ifpga_rawdev.c +0
-0file_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);
drivers/raw/ifpga/ifpga_rawdev.c ifpga_cfg_probe(struct rte_vdev_device *dev) · line 1745
Quoted 10 lines
drivers/raw/ifpga/ifpga_rawdev.c +2
-4end: -if (kvlist) -rte_kvargs_free (kvlist); -if (name) -free (name); +rte_kvargs_free (kvlist); +free (name);return ret; }
Reviewed-by Rosen Xu <[email protected]>
PATCH v3 33/36 regex/*: remove unnecessary NULL checks
In reply to Stephen HemmingerRemove redundant NULL pointer checks before free functions found by nullfree.cocci
--- 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(-)
drivers/regex/cn9k/cn9k_regexdev.c +2 -4
@@ -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);
drivers/regex/cn9k/cn9k_regexdev_compiler.c +1 -2
@@ -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; }
drivers/regex/mlx5/mlx5_regex.c +1 -2
@@ -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; }
drivers/regex/mlx5/mlx5_rxp.c +1 -2
@@ -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; }
Signature · 1 line
2.34.1
PATCH v3 34/36 vdpa/*: remove unnecessary NULL checks
In reply to Stephen HemmingerRemove redundant NULL pointer checks before free functions found by nullfree.cocci
--- 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(-)
drivers/vdpa/ifc/ifcvf_vdpa.c +3 -6
@@ -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 ; }
drivers/vdpa/mlx5/mlx5_vdpa_mem.c +1 -2
@@ -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;
drivers/vdpa/mlx5/mlx5_vdpa_virtq.c +1 -2
@@ -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)
Signature · 1 line
2.34.1
PATCH v3 35/36 compressdev: remove unnecessary NULL checks
In reply to Stephen HemmingerRemove redundant NULL pointer checks before free functions found by nullfree.cocci
--- lib/compressdev/rte_compressdev.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
lib/compressdev/rte_compressdev.c +1 -2
@@ -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 ;
Signature · 1 line
2.34.1
PATCH v3 36/36 other: remove unnecessary NULL checks
In reply to Stephen HemmingerRemove redundant NULL pointer checks before free functions found by nullfree.cocci
--- 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(-)
lib/graph/graph_stats.c +1 -2
@@ -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
lib/ipsec/ipsec_sad.c +1 -2
@@ -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); }/*
lib/port/rte_port_source_sink.c +7 -14
@@ -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);
lib/power/rte_power_empty_poll.c +1 -2
@@ -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
lib/reorder/rte_reorder.c +2 -4
@@ -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]); } }
Signature · 1 line
2.34.1
Thomas Monjalon
Applied09/02/2022 20:17, Stephen Hemminger:
Quoted 9 lines
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.