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 C7D81A04AD; Mon, 24 Jan 2022 18:48:17 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0899742817; Mon, 24 Jan 2022 18:47:36 +0100 (CET) Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) by mails.dpdk.org (Postfix) with ESMTP id 1CB9E427FC for ; Mon, 24 Jan 2022 18:47:32 +0100 (CET) Received: by mail-pl1-f173.google.com with SMTP id z5so2412963plg.8 for ; Mon, 24 Jan 2022 09:47:32 -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=eRuGLCuRAy6fQMCpIqWkToAxIbQbwC5h9C+IWnpbMYg7ztrdcZLwHKokgrXTGEm3ju ojWovEvAo+0NPekh6dskoYFM0BntLMozveLY9WlxeZp0HTMxkOrHDyMI7DxVYINQxf4b c85p5mHszVN4yVTMMYho+LH6eK8v7A2YPX1i9nfANJD9UunSc7P08AO9SrJMYLFDF2B3 iO/axmSSKVTSqpIzzwYE64YnGB9l/77AXkQjrxoh1/OlQOx7/X09q1tlyVyUAJY2b1A1 Z/eXVpRniFA2/asFXQD57wqRxdiXrqfinrsezVALCNuOkT1T7J8Jq3ZxSDwRYQkBrozp KLnA== 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=v2LChapTLereqLVLUzp/fjbREjBvNti2aBzI8WTAufLlxzTqLLoa5VcSz57jIb5PRU 51iO5B55ZKxzGTsEMjikN6buLjvIDkfLc9IEt3KomokmwURIgz0nIcmmLW/ESDQexFJ/ Y+H+09xcf1og/Nl1j3cn0VbGSYhKFOtXPSIaiIwYLvC0OcdNjTTVUUQrEH1bX6xOjxRt 2HYkRFv5sQS19obsdQHgZg+iwcI/B2CeDtG98NhBi/nNI4emWNh3Pl7GHj5Rpgi2zJ7e 8BHtykdrdxMrtjnq55h+U/j+erEKCZN7SHVB2QPUEV/81iZAgRCrQ9H8h4exC5Gzxtzx RPcg== X-Gm-Message-State: AOAM530jeTjVhR7RsOsrpzh8azCRBcdnAuLz1WZaGkwApC4U4CTGJY9M 86NM+weYTs/h5k+uj/gx4PaofRMWhbgSvg== X-Google-Smtp-Source: ABdhPJxMxR5ILCN3hDrrtrYyteP62GHq8RS3TJiEb04xSLlX9MtRDuMAnKeK2rMaVdEVQ5KHO+HnGg== X-Received: by 2002:a17:90a:b387:: with SMTP id e7mr2942050pjr.190.1643046451080; Mon, 24 Jan 2022 09:47:31 -0800 (PST) Received: from hermes.local (204-195-112-199.wavecable.com. [204.195.112.199]) by smtp.gmail.com with ESMTPSA id q7sm15835082pfs.37.2022.01.24.09.47.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 09:47:30 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Maxime Coquelin , Chenbo Xia Subject: [PATCH v2 09/83] lib/vhost: remove unnecessary NULL checks Date: Mon, 24 Jan 2022 09:46:05 -0800 Message-Id: <20220124174719.14417-10-stephen@networkplumber.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220124174719.14417-1-stephen@networkplumber.org> References: <20220124000518.319850-1-stephen@networkplumber.org> <20220124174719.14417-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