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 79A4EA034E; Wed, 9 Feb 2022 20:21:25 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4B9EC4272A; Wed, 9 Feb 2022 20:18:31 +0100 (CET) Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) by mails.dpdk.org (Postfix) with ESMTP id 0C6EA42721 for ; Wed, 9 Feb 2022 20:18:30 +0100 (CET) Received: by mail-pf1-f177.google.com with SMTP id i30so5952824pfk.8 for ; Wed, 09 Feb 2022 11:18:29 -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=zxKrfKaZAsOIdi6KIq1CiCQFpR5nmkR7xI31mKVVYZk=; b=Jzefs837psLn9kSWq6Pp+hHdfFRo8FG7JLVaHGyzpaRiusrHWnAe0uo/gXPBOFQym/ 3ewqI51b8yCzkNTbGtAe43Yg5JnBdt++54kz0/9B2CeDoz6FUJTBoeTeAFuje6OcGIuQ CBOLUWPFR5/ZM8mpPEhOJkREgNE3SWu+YQmF/7eqpbheA/VOHNfZThfQTrl2ZIgydsfM +2+SQ2hOEzTB1ymL+2LVGUk+5FQo84fOVtppu5hch9BsdtvTlsEoF/U1fR+LVipfRFYT rD0viIMiY6kjUXYJ0YlN44tLlJPD0P50AXvl3ozwhTWv1roK4Rsgu9NqlRP0CiFxRrwF ubJQ== 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=zxKrfKaZAsOIdi6KIq1CiCQFpR5nmkR7xI31mKVVYZk=; b=GgXp8KO8W4M8L3exuxiefZpMOGVfYrRLYauY8mQrcH8F6E2vnaj9v9DJB7QtPMFiOG 7xI+HgJDqqgxPI4YqSge2HBNE367vaL1s3HSNVNEZAou/pq0bIS9MeJVZ5XNHWE/bfEi Y/P3BlGd4+9ZplXNBN5y+cegO26CnySnlXLi4S6CMKm2z+MHe4EjfCtJAmZk9h151xqD l+ChpC62oxkgbHptC2VaL2Z1diF/DNeu0DISOyZVuiQAsRv5OrLtu7fWGULuaub7FrJ2 0IuLC3QU9rk0TcuyVJvEAf/RMcFY8MycPlSjsvq7PYrEmbT55W63aJnk2hZSmyyMHRr8 y5DA== X-Gm-Message-State: AOAM531bVW6Hqb2RUZBKeSG0EgzPmzRbz4qsLHQR+B3cKQN2oOqu/tD/ pY59O4mfoSmHq5psJAEijhECOEqIsfu1xOUlXh8= X-Google-Smtp-Source: ABdhPJxUeZTNe7yT4jxXVQwhsxKsIcdlltrEUrHFR+wvK2asZ6UlwdgbbuNfE0zMexV7dN2StDpSRg== X-Received: by 2002:a65:4b8f:: with SMTP id t15mr3141686pgq.140.1644434308913; Wed, 09 Feb 2022 11:18:28 -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.18.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 11:18:28 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Min Hu , Chas Williams , Jakub Grajciar , Tetsuya Mukawa , Jasvinder Singh , Cristian Dumitrescu Subject: [PATCH v3 31/36] net/other: remove unnecessary NULL checks Date: Wed, 9 Feb 2022 11:17:43 -0800 Message-Id: <20220209191748.377729-32-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 Acked-by: Min Hu (Connor) --- drivers/net/bonding/rte_eth_bond_pmd.c | 3 +-- drivers/net/memif/rte_eth_memif.c | 6 ++---- drivers/net/null/rte_eth_null.c | 3 +-- drivers/net/softnic/rte_eth_softnic_cli.c | 12 ++++-------- drivers/net/softnic/rte_eth_softnic_cryptodev.c | 6 ++---- drivers/net/softnic/rte_eth_softnic_thread.c | 6 ++---- drivers/net/tap/tap_flow.c | 9 +++------ 7 files changed, 15 insertions(+), 30 deletions(-) diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c index c72fc64806cf..0289f882fdb5 100644 --- a/drivers/net/bonding/rte_eth_bond_pmd.c +++ b/drivers/net/bonding/rte_eth_bond_pmd.c @@ -2155,8 +2155,7 @@ bond_ethdev_close(struct rte_eth_dev *dev) */ rte_mempool_free(internals->mode6.mempool); - if (internals->kvlist != NULL) - rte_kvargs_free(internals->kvlist); + rte_kvargs_free(internals->kvlist); return 0; } diff --git a/drivers/net/memif/rte_eth_memif.c b/drivers/net/memif/rte_eth_memif.c index d3459c5007c4..cca07cd84d50 100644 --- a/drivers/net/memif/rte_eth_memif.c +++ b/drivers/net/memif/rte_eth_memif.c @@ -1712,8 +1712,7 @@ memif_check_socket_filename(const char *filename) ret = -EINVAL; } - if (dir != NULL) - rte_free(dir); + rte_free(dir); return ret; } @@ -1884,8 +1883,7 @@ rte_pmd_memif_probe(struct rte_vdev_device *vdev) log2_ring_size, pkt_buffer_size, secret, ether_addr); exit: - if (kvlist != NULL) - rte_kvargs_free(kvlist); + rte_kvargs_free(kvlist); return ret; } diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c index ca03469d0e6d..bb89c1abc4a2 100644 --- a/drivers/net/null/rte_eth_null.c +++ b/drivers/net/null/rte_eth_null.c @@ -717,8 +717,7 @@ rte_pmd_null_probe(struct rte_vdev_device *dev) ret = eth_dev_null_create(dev, &args); free_kvlist: - if (kvlist) - rte_kvargs_free(kvlist); + rte_kvargs_free(kvlist); return ret; } diff --git a/drivers/net/softnic/rte_eth_softnic_cli.c b/drivers/net/softnic/rte_eth_softnic_cli.c index b04e78c6e0af..7acbeecae7a2 100644 --- a/drivers/net/softnic/rte_eth_softnic_cli.c +++ b/drivers/net/softnic/rte_eth_softnic_cli.c @@ -4482,10 +4482,8 @@ parse_free_sym_crypto_param_data(struct rte_table_action_sym_crypto_params *p) switch (xform[i]->type) { case RTE_CRYPTO_SYM_XFORM_CIPHER: - if (p->cipher_auth.cipher_iv.val) - free(p->cipher_auth.cipher_iv.val); - if (p->cipher_auth.cipher_iv_update.val) - free(p->cipher_auth.cipher_iv_update.val); + free(p->cipher_auth.cipher_iv.val); + free(p->cipher_auth.cipher_iv_update.val); break; case RTE_CRYPTO_SYM_XFORM_AUTH: if (p->cipher_auth.auth_iv.val) @@ -4494,10 +4492,8 @@ parse_free_sym_crypto_param_data(struct rte_table_action_sym_crypto_params *p) free(p->cipher_auth.cipher_iv_update.val); break; case RTE_CRYPTO_SYM_XFORM_AEAD: - if (p->aead.iv.val) - free(p->aead.iv.val); - if (p->aead.aad.val) - free(p->aead.aad.val); + free(p->aead.iv.val); + free(p->aead.aad.val); break; default: continue; diff --git a/drivers/net/softnic/rte_eth_softnic_cryptodev.c b/drivers/net/softnic/rte_eth_softnic_cryptodev.c index 9a7d006f1a09..e4754055e90b 100644 --- a/drivers/net/softnic/rte_eth_softnic_cryptodev.c +++ b/drivers/net/softnic/rte_eth_softnic_cryptodev.c @@ -159,10 +159,8 @@ softnic_cryptodev_create(struct pmd_internals *p, return cryptodev; error_exit: - if (cryptodev->mp_create) - rte_mempool_free(cryptodev->mp_create); - if (cryptodev->mp_init) - rte_mempool_free(cryptodev->mp_init); + rte_mempool_free(cryptodev->mp_create); + rte_mempool_free(cryptodev->mp_init); free(cryptodev); diff --git a/drivers/net/softnic/rte_eth_softnic_thread.c b/drivers/net/softnic/rte_eth_softnic_thread.c index a8c26a5b2377..1b3b3c33c175 100644 --- a/drivers/net/softnic/rte_eth_softnic_thread.c +++ b/drivers/net/softnic/rte_eth_softnic_thread.c @@ -29,11 +29,9 @@ softnic_thread_free(struct pmd_internals *softnic) struct softnic_thread *t = &softnic->thread[i]; /* MSGQs */ - if (t->msgq_req) - rte_ring_free(t->msgq_req); + rte_ring_free(t->msgq_req); - if (t->msgq_rsp) - rte_ring_free(t->msgq_rsp); + rte_ring_free(t->msgq_rsp); } } diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c index 76738239458a..a9a55e439efc 100644 --- a/drivers/net/tap/tap_flow.c +++ b/drivers/net/tap/tap_flow.c @@ -1465,8 +1465,7 @@ tap_flow_create(struct rte_eth_dev *dev, } return flow; fail: - if (remote_flow) - rte_free(remote_flow); + rte_free(remote_flow); if (flow) tap_flow_free(pmd, flow); return NULL; @@ -1541,8 +1540,7 @@ tap_flow_destroy_pmd(struct pmd_internals *pmd, } } end: - if (remote_flow) - rte_free(remote_flow); + rte_free(remote_flow); tap_flow_free(pmd, flow); return ret; } @@ -1764,8 +1762,7 @@ int tap_flow_implicit_create(struct pmd_internals *pmd, success: return 0; fail: - if (remote_flow) - rte_free(remote_flow); + rte_free(remote_flow); return -1; } -- 2.34.1