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 AF181A034E; Wed, 9 Feb 2022 20:18:27 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6C7BC41174; Wed, 9 Feb 2022 20:18:00 +0100 (CET) Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) by mails.dpdk.org (Postfix) with ESMTP id 63D564115F for ; Wed, 9 Feb 2022 20:17:58 +0100 (CET) Received: by mail-pf1-f169.google.com with SMTP id a39so5130072pfx.7 for ; Wed, 09 Feb 2022 11:17:58 -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=m45TUGjqdRgyeXxHVU035qeKJhdMqdSVQ2AjCweQpVk=; b=jewFc2VVZyiSvFVAuPBgQcxuNan6lz3rDU8OG33uW9OwwwAhaDsgxDgAwfQCTkM052 vNWQDmTBP7CwBvFVVSdQK8bJTWESQ1jIz4hIto6IahbKD93q4/Xmi+H+1RQ5MUKdy0oc e5o9AWRFDaQTEbAE2FqRLWkoxoBt0EzvibpFr4j/H1rU/YUD4YiTgL18+QBY6h2c4wLw szGHz2Jv3FR2Kn1Ys20nxsX02Ul49lWt3jTUIbwvr2wFTFJXexy4oQDDZILhPHr2ZSQB B0uFEU4eKc51ti9viRrqACJ7CNeh3tle2mq5XqtZoL4yQRlemKX/FyzlnEIZUTqDos43 C00A== 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=m45TUGjqdRgyeXxHVU035qeKJhdMqdSVQ2AjCweQpVk=; b=uXzjMI1XvMbwdqAWas2gttVbaENij8SNBQK2nH9SWk/UUxLTSV+g1YWaYmDS2fX8Nv yQGbAr97VPe3MfbSZhs3Kgx6SQ6M5+tVZpSnWKPaxA+LkF+OHBCy4zw8TeJIvPDlk1vu zvPVOWt48Hn7dLy0jn4XUPuUb/F5ZiWOI/p83knjgZkLEmQ7wFM/lVZLkavMNAAuF+S9 u++K4hZE9H8eVivIaiKqyChEvmd2kf9DB6LIni87nQIMjseqczBXP1qMEOkVdHZSUEbK Jt/xrai9dU81hFkivZcyssqPgapl8C3jD6JWUUSeZw/S9AgLuUqaK+317YU+BcQZlarD zbiA== X-Gm-Message-State: AOAM532ep52kZsdqlM2YvfG9vPMXi2bkIuwMSH4mtsdSnzeCACfLLWEX /LkaRbb+c3bnCd6ozlrcWuimr5Coe2Z58mdF X-Google-Smtp-Source: ABdhPJy+gT2uvlax86jTVkxvm9xLhbi7E8Q5ZvMUKeIMwaz50NY1V+lkjXC+pLJ7UjJgK2KSBTE7oQ== X-Received: by 2002:a63:fa41:: with SMTP id g1mr3119610pgk.224.1644434277240; Wed, 09 Feb 2022 11:17:57 -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.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 11:17:56 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Marko Kovacevic , Cristian Dumitrescu , Tomasz Kantecki , Maxime Coquelin , Chenbo Xia Subject: [PATCH v3 05/36] examples: remove unnecessary NULL checks Date: Wed, 9 Feb 2022 11:17:17 -0800 Message-Id: <20220209191748.377729-6-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 --- examples/fips_validation/fips_dev_self_test.c | 18 ++++------ examples/fips_validation/fips_validation.c | 3 +- examples/fips_validation/main.c | 36 +++++++------------ examples/ip_pipeline/cli.c | 12 +++---- examples/ip_pipeline/cryptodev.c | 6 ++-- examples/ip_pipeline/thread.c | 6 ++-- examples/l2fwd-cat/cat.c | 3 +- examples/pipeline/thread.c | 6 ++-- examples/vhost_blk/vhost_blk.c | 3 +- 9 files changed, 31 insertions(+), 62 deletions(-) diff --git a/examples/fips_validation/fips_dev_self_test.c b/examples/fips_validation/fips_dev_self_test.c index b4eab05a9851..076e9de099c0 100644 --- a/examples/fips_validation/fips_dev_self_test.c +++ b/examples/fips_validation/fips_dev_self_test.c @@ -1396,8 +1396,7 @@ check_aead_result(struct rte_crypto_op *op, if (!mbuf) return -1; - if (op->sym->aead.aad.data) - rte_free(op->sym->aead.aad.data); + rte_free(op->sym->aead.aad.data); if (dir == self_test_dir_enc_auth_gen) { src = vec->output.data; @@ -1523,18 +1522,13 @@ static void fips_dev_auto_test_uninit(uint8_t dev_id, struct fips_dev_auto_test_env *env) { - if (env->mbuf) - rte_pktmbuf_free(env->mbuf); + rte_pktmbuf_free(env->mbuf); if (env->op) rte_crypto_op_free(env->op); - if (env->mpool) - rte_mempool_free(env->mpool); - if (env->op_pool) - rte_mempool_free(env->op_pool); - if (env->sess_pool) - rte_mempool_free(env->sess_pool); - if (env->sess_priv_pool) - rte_mempool_free(env->sess_priv_pool); + rte_mempool_free(env->mpool); + rte_mempool_free(env->op_pool); + rte_mempool_free(env->sess_pool); + rte_mempool_free(env->sess_priv_pool); rte_cryptodev_stop(dev_id); } diff --git a/examples/fips_validation/fips_validation.c b/examples/fips_validation/fips_validation.c index 52a7bf952d46..94253eaee8bf 100644 --- a/examples/fips_validation/fips_validation.c +++ b/examples/fips_validation/fips_validation.c @@ -344,8 +344,7 @@ fips_test_clear(void) fclose(info.fp_rd); if (info.fp_wr) fclose(info.fp_wr); - if (info.one_line_text) - free(info.one_line_text); + free(info.one_line_text); if (info.nb_vec_lines) { uint32_t i; diff --git a/examples/fips_validation/main.c b/examples/fips_validation/main.c index dc40bffe7d97..e06ae37567fd 100644 --- a/examples/fips_validation/main.c +++ b/examples/fips_validation/main.c @@ -143,12 +143,9 @@ cryptodev_fips_validate_app_int(void) error_exit: rte_mempool_free(env.mpool); - if (env.sess_mpool) - rte_mempool_free(env.sess_mpool); - if (env.sess_priv_mpool) - rte_mempool_free(env.sess_priv_mpool); - if (env.op_pool) - rte_mempool_free(env.op_pool); + rte_mempool_free(env.sess_mpool); + rte_mempool_free(env.sess_priv_mpool); + rte_mempool_free(env.op_pool); return ret; } @@ -523,8 +520,7 @@ prepare_data_mbufs(struct fips_val *val) uint16_t nb_seg; int ret = 0; - if (env.mbuf) - rte_pktmbuf_free(env.mbuf); + rte_pktmbuf_free(env.mbuf); if (total_len > RTE_MBUF_MAX_NB_SEGS) { RTE_LOG(ERR, USER1, "Data len %u too big\n", total_len); @@ -598,8 +594,7 @@ prepare_data_mbufs(struct fips_val *val) return 0; error_exit: - if (head) - rte_pktmbuf_free(head); + rte_pktmbuf_free(head); return ret; } @@ -656,8 +651,7 @@ prepare_auth_op(void) if (ret < 0) return ret; - if (env.digest) - rte_free(env.digest); + rte_free(env.digest); env.digest = rte_zmalloc(NULL, vec.cipher_auth.digest.len, RTE_CACHE_LINE_SIZE); @@ -705,8 +699,7 @@ prepare_aead_op(void) if (ret < 0) return ret; - if (env.digest) - rte_free(env.digest); + rte_free(env.digest); env.digest = rte_zmalloc(NULL, vec.aead.digest.len, RTE_CACHE_LINE_SIZE); if (!env.digest) { @@ -1430,8 +1423,7 @@ fips_mct_tdes_test(void) } } - if (val.val) - free(val.val); + free(val.val); return 0; } @@ -1510,8 +1502,7 @@ fips_mct_aes_ecb_test(void) } } - if (val.val) - free(val.val); + free(val.val); return 0; } @@ -1619,8 +1610,7 @@ fips_mct_aes_test(void) memcpy(vec.iv.val, val.val, AES_BLOCK_SIZE); } - if (val.val) - free(val.val); + free(val.val); return 0; } @@ -1706,8 +1696,7 @@ fips_mct_sha_test(void) rte_free(vec.pt.val); - if (val.val) - free(val.val); + free(val.val); return 0; } @@ -1851,8 +1840,7 @@ fips_test_one_file(void) rte_free(env.digest); env.digest = NULL; } - if (env.mbuf) - rte_pktmbuf_free(env.mbuf); + rte_pktmbuf_free(env.mbuf); return ret; } diff --git a/examples/ip_pipeline/cli.c b/examples/ip_pipeline/cli.c index 0c372675a919..c918f30e06f3 100644 --- a/examples/ip_pipeline/cli.c +++ b/examples/ip_pipeline/cli.c @@ -3773,10 +3773,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) @@ -3785,10 +3783,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/examples/ip_pipeline/cryptodev.c b/examples/ip_pipeline/cryptodev.c index 9997d974563f..cd0f9c3d4eac 100644 --- a/examples/ip_pipeline/cryptodev.c +++ b/examples/ip_pipeline/cryptodev.c @@ -151,10 +151,8 @@ cryptodev_create(const char *name, struct cryptodev_params *params) 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/examples/ip_pipeline/thread.c b/examples/ip_pipeline/thread.c index b2e97327052f..82d5f87c384c 100644 --- a/examples/ip_pipeline/thread.c +++ b/examples/ip_pipeline/thread.c @@ -92,11 +92,9 @@ thread_free(void) continue; /* 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/examples/l2fwd-cat/cat.c b/examples/l2fwd-cat/cat.c index 502c6b32780e..77154c8b7e61 100644 --- a/examples/l2fwd-cat/cat.c +++ b/examples/l2fwd-cat/cat.c @@ -872,8 +872,7 @@ cat_fini(void) #if PQOS_VERSION <= 103 memset(m_sockets, 0, sizeof(m_sockets)); #else - if (m_sockets != NULL) - free(m_sockets); + free(m_sockets); #endif m_sock_count = 0; memset(m_config, 0, sizeof(m_config)); diff --git a/examples/pipeline/thread.c b/examples/pipeline/thread.c index bf11e6144b75..5fe7eae00eb6 100644 --- a/examples/pipeline/thread.c +++ b/examples/pipeline/thread.c @@ -89,11 +89,9 @@ thread_free(void) continue; /* 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/examples/vhost_blk/vhost_blk.c b/examples/vhost_blk/vhost_blk.c index feadacc62ee5..2cab1e6994fe 100644 --- a/examples/vhost_blk/vhost_blk.c +++ b/examples/vhost_blk/vhost_blk.c @@ -849,8 +849,7 @@ static void vhost_blk_ctrlr_destroy(struct vhost_blk_ctrlr *ctrlr) { if (ctrlr->bdev != NULL) { - if (ctrlr->bdev->data != NULL) - rte_free(ctrlr->bdev->data); + rte_free(ctrlr->bdev->data); rte_free(ctrlr->bdev); } -- 2.34.1