[PATCH v2 09/83] lib/vhost: remove unnecessary NULL checks
Stephen Hemminger
stephen at networkplumber.org
Mon Jan 24 18:46:05 CET 2022
Remove redundant NULL pointer checks before free functions
found by nullfree.cocci
Signed-off-by: Stephen Hemminger <stephen at 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
More information about the dev
mailing list