From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4E9CEA034E; Wed, 9 Feb 2022 20:18:35 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6BD0F41180; Wed, 9 Feb 2022 20:18:01 +0100 (CET) Received: from mail-pj1-f52.google.com (mail-pj1-f52.google.com [209.85.216.52]) by mails.dpdk.org (Postfix) with ESMTP id 7874B4116A for ; Wed, 9 Feb 2022 20:17:59 +0100 (CET) Received: by mail-pj1-f52.google.com with SMTP id y9so3015235pjf.1 for ; Wed, 09 Feb 2022 11:17:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dx0GDNS1IEnXCXXkXwkqFDbtlTWkh5y6TU4A4vrKqHs=; b=zA91HEtSvp6wtfyoNwB5Co9IrhsAgfeVfcwErNK1r087MYfnvcDkQhy1/aCijsFpd8 MjC77KbC75dQA7w+mGC0rm8P9J36wGO6WHAgeB0fCqFYE4HwGxcECtOWK5L0Rba80F8g vNO5ppJFuB4PJzDBs3bI21dTIKQxeRDbCpFluiTUyxPB9FOyNlDh33FeZZWEDiAPFd3a Udi93qw5PdVHlZDovy7kL5lZxtWW2FmhLE1hJiJtVEA/2/tVW24aEnNUiXO+P52HVDQm JwwBKl4HSF2H2MIuutXdgIjatdRkNwU4awRkLeblVASLPI2ebkS9sIz0rbZT+fU/Td7G YlsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dx0GDNS1IEnXCXXkXwkqFDbtlTWkh5y6TU4A4vrKqHs=; b=RKxHnIZ9pFadaqjOlNyjLBp221baLPndgk9nyQyDtl6Wgkp0nBpev/ltwPiBj9XMsB rIe/cnDt5tRdTKQxVSwSVRQgm2JD8B3Etg1ai6ULVhJ5Gj56KzReJDH8CPdVnS3dFxlf 8ihzG2lszOvVBfDs3nzTOxKgJst1gkvCH2bi5OvEsig+xc34H24QTinLadWfzo41lh4D 1lKGXvImJUHy8IuZbUW1m+PvaXFOrPtYBnYDUbnjLnT+V3ciyGaEP1G3JbK9WOclR2Bw CgOdOGk/Zy63cSoo5LWmkKojYRV09m+2Q9QAJhbaNpL2x4rl2piVTe+hDb8HyHDzc3yP naDg== X-Gm-Message-State: AOAM530LaUH6XnKu5c7Bx5rpBUoVohu6CnnlbSr2Iqu29Ebs+/pFCVSU e1KSOmHFaWSfbrE0zMpqwGg/8nLL15+Hq2rq X-Google-Smtp-Source: ABdhPJyDUv56ydk6dVfFcqAtrWg5UlRsqyeNeepHHzR/5Aq5m24YDSiHqrpvFzEg8R16t/fpfcomyw== X-Received: by 2002:a17:90a:1de:: with SMTP id 30mr4211764pjd.177.1644434278463; Wed, 09 Feb 2022 11:17:58 -0800 (PST) Received: from hermes.local (204-195-112-199.wavecable.com. [204.195.112.199]) by smtp.gmail.com with ESMTPSA id u16sm14378401pgh.54.2022.02.09.11.17.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 11:17:57 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Chenbo Xia , Maxime Coquelin Subject: [PATCH v3 06/36] vhost: remove unnecessary NULL checks Date: Wed, 9 Feb 2022 11:17:18 -0800 Message-Id: <20220209191748.377729-7-stephen@networkplumber.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220209191748.377729-1-stephen@networkplumber.org> References: <20220124000518.319850-1-stephen@networkplumber.org> <20220209191748.377729-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Remove redundant NULL pointer checks before free functions found by nullfree.cocci Signed-off-by: Stephen Hemminger Reviewed-by: Chenbo Xia --- 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