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 6DA80A04A6; Mon, 24 Jan 2022 01:06:13 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BA96C427E8; Mon, 24 Jan 2022 01:05:33 +0100 (CET) Received: from mail-pg1-f179.google.com (mail-pg1-f179.google.com [209.85.215.179]) by mails.dpdk.org (Postfix) with ESMTP id CBF37427D3 for ; Mon, 24 Jan 2022 01:05:30 +0100 (CET) Received: by mail-pg1-f179.google.com with SMTP id e16so4333304pgn.4 for ; Sun, 23 Jan 2022 16:05:30 -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=+E32WGsBAf6jw7FOSwCo+w81VRzmciXgJ29ENrL+4k0=; b=Kxdzujw8Ywucyxhcf+s4nlW00u/dIFc1fH9bwH+Mkoa9UJvh1JWn5cNF3sI/fEpbgv 2AH9EN+dd+9TD/7BxsWDZkr6WcIIbYrU4RO+mUInrEOECX1WVQltUQFDWlP2TMWuUQ/g FhvhoVauD5bJz6TrRKebM+hsfyei6rzxKoPSY/UjRpc2Qep3Taqb7l4zNJOOaX9EfIeL PHli651GV9h3H8cLeriCPrH4h5TW0R8EnPb9fCj/jkzJn4rumVBrf1fqezXL4gb+/uoo q3qxu3EOXzsA/uDLZmq1gTeZiLfs02t1FNnA5Lgb7ev+aZW0ApTIduVt0FjLbqRMfguG /BxA== 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=+E32WGsBAf6jw7FOSwCo+w81VRzmciXgJ29ENrL+4k0=; b=MSiD/sTEz16HqrYAhBV46KINCpj5PKo4COYwPulVkzkHtgiuWE9q8QLiD08XbOzr+F MvNdAYZKt8iDaSkcPQK6WrlZ7sAa4FtD224ZjH2DeUKp1LeqibnCYHe5cBdURLl+PUs+ qkeVS8IcVv12nRWFFPtdAEBTKETJp6ZjjXdK/Ny3/HepBi0udgaCe3usMmeLxFJMJcHx PsfAELTg78yDUwg4NXe2OPCu9Eh2kB3R3XiI1VyA237zlyRdjFoHfPpanPhHrQYyTBKP r3usC/7RTJfTPHmxgwIhV9WvfKF+fPpNqNRaO+zA0k2/QpzzBTo+DJnQqs8i+giVS6aj EKJQ== X-Gm-Message-State: AOAM530LyeyJIO3T/s6RKN5gH1JY9LIxfMSllMfGZk4ah73T3aG9nfKB 93z1QRhdv7dtyyYUrjyOMHWWctBsdR1CPA== X-Google-Smtp-Source: ABdhPJzJVMcc2khhBJO1pgeCYp1I1N+ie1pUHvW57p+95GzfsWOz5EZYHnoe+afCd8m3zkYdeieadA== X-Received: by 2002:a05:6a00:2444:b0:4a3:239f:d58a with SMTP id d4-20020a056a00244400b004a3239fd58amr11824079pfj.85.1642982729795; Sun, 23 Jan 2022 16:05:29 -0800 (PST) Received: from hermes.local (204-195-112-199.wavecable.com. [204.195.112.199]) by smtp.gmail.com with ESMTPSA id ck21sm10935350pjb.51.2022.01.23.16.05.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 16:05:29 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Maxime Coquelin , Chenbo Xia Subject: [PATCH 08/82] lib/vhost: remove unnecessary NULL checks Date: Sun, 23 Jan 2022 16:04:04 -0800 Message-Id: <20220124000518.319850-9-stephen@networkplumber.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220124000518.319850-1-stephen@networkplumber.org> References: <20220124000518.319850-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 --- 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