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(-)
@@ -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,
@@ -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);
@@ -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);