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 BEDA1A04A6; Mon, 24 Jan 2022 01:06:47 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 07C494280C; Mon, 24 Jan 2022 01:05:40 +0100 (CET) Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) by mails.dpdk.org (Postfix) with ESMTP id 7F1BB427F9 for ; Mon, 24 Jan 2022 01:05:37 +0100 (CET) Received: by mail-pl1-f177.google.com with SMTP id j16so3364714plx.4 for ; Sun, 23 Jan 2022 16:05:37 -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=hUi3jdycirbvMNlR/2jM4YhZ1CLXWJRlA9QQxRgryBs=; b=1K7lyI06wg/MQWz65eJooIylsgTzmF7peQ+8dD1y95RPRVnPwO8N/DDO1yTwgEa/kE TZ5aG9Da9X5DYmLl3wMVB85xqA9sE7skAIbo6yaToKCHZW1CaUJV4gV3bhP/OZ2FOUAc xyKClYtQwwcAR8ZWVEoWCP8QfGvfOoO4dnmFJL9aWRoOe9h9HgaZlhcrqcfaGIaIVNpV 3ODfqk+iSP+Y9SfvFJ+tlqnbNCtSovTeeJrMIiUmrz+xdGSs/0N1VA3gsmuzgpEQAVNU x7PrasPJY8HxO1PGeGcSIgzzQZN7FkPzjrbK8FeuHeQFc40fDHG/qnB+3VDQCyDCigJf Bwaw== 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=hUi3jdycirbvMNlR/2jM4YhZ1CLXWJRlA9QQxRgryBs=; b=QfxxejNUveqC//yF5uBcTHa4nHiY/FH2x90GP/tCeVnl7zFgmMDIMiN+heRQLfOqq9 eRYuru0V8gxC17KpA9bYmOpOpn+gMGVflbOOUXr6PdychV0hRZNRpTIu5Xu3scTjXwWU bmUz1alzgG0PPaCiGSiFIWjbhv4bpfz8OsalbS1W/cYwPvO/0VN5+XhPo9rN6juYUsy1 6jxAWTxjudCNWlYTyxZjqPcEP6rCATOhD/DauuLlQtWuhvsqBq+GcFzhZAgMxoPSS79Z OvXi5ktAG7SZ27tWb08UzBiM73G1czzk1GSkUydfBQwMbKqlNFjQKyrQY6awCGsGYvcF XzGw== X-Gm-Message-State: AOAM531fgpUR/W9na3/N+H1DwTetJkENLfa3EoE4Q4opAboJOGZTlmvt 11cSKefRSmU6twBgbavxN9BXKHF9pdeMsw== X-Google-Smtp-Source: ABdhPJxJaruFxEFt1NpIN2sjFNitd8TwTgPhnFEiM7OVeJDh3d98H9CdDiuL0BfsuuA/5DCiXPCrOw== X-Received: by 2002:a17:902:74c1:b0:14a:d9fa:d8a3 with SMTP id f1-20020a17090274c100b0014ad9fad8a3mr12476988plt.119.1642982736372; Sun, 23 Jan 2022 16:05:36 -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.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 16:05:35 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Olivier Matz , Fan Zhang , Ashish Gupta , Akhil Goyal , Declan Doherty , Honnappa Nagarahalli , Konstantin Ananyev , Anatoly Burakov , Yipeng Wang , Sameh Gobriel , Bruce Richardson , Vladimir Medvedkin , Andrew Rybchenko , Chas Williams , "Min Hu (Connor)" , Reshma Pattan Subject: [PATCH 14/82] app/test: remove unnecessary NULL checks Date: Sun, 23 Jan 2022 16:04:10 -0800 Message-Id: <20220124000518.319850-15-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 --- app/test/test_cksum.c | 3 +- app/test/test_compressdev.c | 3 +- app/test/test_cryptodev.h | 3 +- app/test/test_cryptodev_asym.c | 3 +- app/test/test_cryptodev_blockcipher.c | 12 +++---- app/test/test_func_reentrancy.c | 15 +++------ app/test/test_hash.c | 15 +++------ app/test/test_hash_perf.c | 7 +---- app/test/test_link_bonding.c | 9 ++---- app/test/test_link_bonding_mode4.c | 3 +- app/test/test_malloc.c | 5 ++- app/test/test_mbuf.c | 45 +++++++++------------------ app/test/test_pcapng.c | 3 +- app/test/test_reorder.c | 15 +++------ app/test/virtual_pmd.c | 3 +- 15 files changed, 47 insertions(+), 97 deletions(-) diff --git a/app/test/test_cksum.c b/app/test/test_cksum.c index cd983d7c01ce..6c15de9a9312 100644 --- a/app/test/test_cksum.c +++ b/app/test/test_cksum.c @@ -218,8 +218,7 @@ test_l4_cksum(struct rte_mempool *pktmbuf_pool, const char *pktdata, size_t len) return 0; fail: - if (m) - rte_pktmbuf_free(m); + rte_pktmbuf_free(m); return -1; } diff --git a/app/test/test_compressdev.c b/app/test/test_compressdev.c index 57c566aa9229..fbecaf9aaad4 100644 --- a/app/test/test_compressdev.c +++ b/app/test/test_compressdev.c @@ -2144,8 +2144,7 @@ test_deflate_comp_decomp(const struct interim_data_params *int_data, if (stream != NULL) rte_compressdev_stream_free(0, stream); - if (all_decomp_data != NULL) - rte_free(all_decomp_data); + rte_free(all_decomp_data); /* Free compress private xforms */ for (i = 0; i < test_priv_data.num_priv_xforms; i++) { diff --git a/app/test/test_cryptodev.h b/app/test/test_cryptodev.h index 70f23a3f67d0..29a7d4db2b10 100644 --- a/app/test/test_cryptodev.h +++ b/app/test/test_cryptodev.h @@ -230,8 +230,7 @@ create_segmented_mbuf(struct rte_mempool *mbuf_pool, int pkt_len, return mbuf; fail: - if (mbuf) - rte_pktmbuf_free(mbuf); + rte_pktmbuf_free(mbuf); return NULL; } diff --git a/app/test/test_cryptodev_asym.c b/app/test/test_cryptodev_asym.c index 68f4d8e7a6f9..8c68a12d74b2 100644 --- a/app/test/test_cryptodev_asym.c +++ b/app/test/test_cryptodev_asym.c @@ -518,8 +518,7 @@ test_cryptodev_asym_op(struct crypto_testsuite_params_asym *ts_params, if (op != NULL) rte_crypto_op_free(op); - if (result != NULL) - rte_free(result); + rte_free(result); return status; } diff --git a/app/test/test_cryptodev_blockcipher.c b/app/test/test_cryptodev_blockcipher.c index 5688a45377b2..127e2a53d379 100644 --- a/app/test/test_cryptodev_blockcipher.c +++ b/app/test/test_cryptodev_blockcipher.c @@ -805,20 +805,16 @@ test_blockcipher_one_case(const struct blockcipher_test_case *t, rte_cryptodev_sym_session_clear(dev_id, sess); rte_cryptodev_sym_session_free(sess); } - if (cipher_xform) - rte_free(cipher_xform); - if (auth_xform) - rte_free(auth_xform); + rte_free(cipher_xform); + rte_free(auth_xform); } if (op) rte_crypto_op_free(op); - if (obuf) - rte_pktmbuf_free(obuf); + rte_pktmbuf_free(obuf); - if (ibuf) - rte_pktmbuf_free(ibuf); + rte_pktmbuf_free(ibuf); return status; } diff --git a/app/test/test_func_reentrancy.c b/app/test/test_func_reentrancy.c index ce40c3ce9631..64f27e20370f 100644 --- a/app/test/test_func_reentrancy.c +++ b/app/test/test_func_reentrancy.c @@ -89,15 +89,13 @@ ring_clean(unsigned int lcore_id) int i; rp = rte_ring_lookup("fr_test_once"); - if (rp != NULL) - rte_ring_free(rp); + rte_ring_free(rp); for (i = 0; i < MAX_ITER_MULTI; i++) { snprintf(ring_name, sizeof(ring_name), "fr_test_%d_%d", lcore_id, i); rp = rte_ring_lookup(ring_name); - if (rp != NULL) - rte_ring_free(rp); + rte_ring_free(rp); } } @@ -152,15 +150,13 @@ mempool_clean(unsigned int lcore_id) int i; mp = rte_mempool_lookup("fr_test_once"); - if (mp != NULL) - rte_mempool_free(mp); + rte_mempool_free(mp); for (i = 0; i < MAX_ITER_MULTI; i++) { snprintf(mempool_name, sizeof(mempool_name), "fr_test_%d_%d", lcore_id, i); mp = rte_mempool_lookup(mempool_name); - if (mp != NULL) - rte_mempool_free(mp); + rte_mempool_free(mp); } } @@ -215,8 +211,7 @@ hash_clean(unsigned lcore_id) int i; handle = rte_hash_find_existing("fr_test_once"); - if (handle != NULL) - rte_hash_free(handle); + rte_hash_free(handle); for (i = 0; i < MAX_ITER_MULTI; i++) { snprintf(hash_name, sizeof(hash_name), "fr_test_%d_%d", lcore_id, i); diff --git a/app/test/test_hash.c b/app/test/test_hash.c index b99e8de1db71..d522cb7f8cbf 100644 --- a/app/test/test_hash.c +++ b/app/test/test_hash.c @@ -1654,8 +1654,7 @@ test_hash_add_delete_jhash2(void) ret = 0; fail_jhash2: - if (handle != NULL) - rte_hash_free(handle); + rte_hash_free(handle); return ret; } @@ -1689,8 +1688,7 @@ test_hash_add_delete_2_jhash2(void) ret = 0; fail_2_jhash2: - if (handle != NULL) - rte_hash_free(handle); + rte_hash_free(handle); return ret; } @@ -1754,8 +1752,7 @@ test_hash_add_delete_jhash_1word(void) ret = 0; fail_jhash_1word: - if (handle != NULL) - rte_hash_free(handle); + rte_hash_free(handle); return ret; } @@ -1789,8 +1786,7 @@ test_hash_add_delete_jhash_2word(void) ret = 0; fail_jhash_2word: - if (handle != NULL) - rte_hash_free(handle); + rte_hash_free(handle); return ret; } @@ -1824,8 +1820,7 @@ test_hash_add_delete_jhash_3word(void) ret = 0; fail_jhash_3word: - if (handle != NULL) - rte_hash_free(handle); + rte_hash_free(handle); return ret; } diff --git a/app/test/test_hash_perf.c b/app/test/test_hash_perf.c index 76cdac5d5320..287f486316f1 100644 --- a/app/test/test_hash_perf.c +++ b/app/test/test_hash_perf.c @@ -106,12 +106,7 @@ create_table(unsigned int with_data, unsigned int table_index, ut_params.key_len = hashtest_key_lens[table_index]; ut_params.socket_id = rte_socket_id(); h[table_index] = rte_hash_find_existing(name); - if (h[table_index] != NULL) - /* - * If table was already created, free it to create it again, - * so we force it is empty - */ - rte_hash_free(h[table_index]); + rte_hash_free(h[table_index]); h[table_index] = rte_hash_create(&ut_params); if (h[table_index] == NULL) { printf("Error creating table\n"); diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c index dc6fc46b9c93..82a9b8e01a82 100644 --- a/app/test/test_link_bonding.c +++ b/app/test/test_link_bonding.c @@ -1639,8 +1639,7 @@ test_roundrobin_rx_burst_on_single_slave(void) /* free mbufs */ for (i = 0; i < MAX_PKT_BURST; i++) { - if (rx_pkt_burst[i] != NULL) - rte_pktmbuf_free(rx_pkt_burst[i]); + rte_pktmbuf_free(rx_pkt_burst[i]); } @@ -1722,8 +1721,7 @@ test_roundrobin_rx_burst_on_multiple_slaves(void) /* free mbufs */ for (i = 0; i < MAX_PKT_BURST; i++) { - if (rx_pkt_burst[i] != NULL) - rte_pktmbuf_free(rx_pkt_burst[i]); + rte_pktmbuf_free(rx_pkt_burst[i]); } /* Clean up and remove slaves from bonded device */ @@ -2010,8 +2008,7 @@ test_roundrobin_verify_slave_link_status_change_behaviour(void) /* free mbufs */ for (i = 0; i < MAX_PKT_BURST; i++) { - if (rx_pkt_burst[i] != NULL) - rte_pktmbuf_free(rx_pkt_burst[i]); + rte_pktmbuf_free(rx_pkt_burst[i]); } /* Clean up and remove slaves from bonded device */ diff --git a/app/test/test_link_bonding_mode4.c b/app/test/test_link_bonding_mode4.c index 351129de2f9b..d9b9c323c7f8 100644 --- a/app/test/test_link_bonding_mode4.c +++ b/app/test/test_link_bonding_mode4.c @@ -194,8 +194,7 @@ free_pkts(struct rte_mbuf **pkts, uint16_t count) uint16_t i; for (i = 0; i < count; i++) { - if (pkts[i] != NULL) - rte_pktmbuf_free(pkts[i]); + rte_pktmbuf_free(pkts[i]); } } diff --git a/app/test/test_malloc.c b/app/test/test_malloc.c index 6d9249f831be..d424d7808af3 100644 --- a/app/test/test_malloc.c +++ b/app/test/test_malloc.c @@ -812,7 +812,7 @@ test_zero_aligned_alloc(void) err_return: /*clean up */ - if (p1) rte_free(p1); + rte_free(p1); return -1; } @@ -865,8 +865,7 @@ test_malloc_bad_params(void) err_return: /* clean up pointer */ - if (bad_ptr) - rte_free(bad_ptr); + rte_free(bad_ptr); return -1; } diff --git a/app/test/test_mbuf.c b/app/test/test_mbuf.c index f54d1d7c006a..daebf09d44b7 100644 --- a/app/test/test_mbuf.c +++ b/app/test/test_mbuf.c @@ -304,8 +304,7 @@ test_one_pktmbuf(struct rte_mempool *pktmbuf_pool) return 0; fail: - if (m) - rte_pktmbuf_free(m); + rte_pktmbuf_free(m); return -1; } @@ -416,12 +415,9 @@ testclone_testupdate_testdetach(struct rte_mempool *pktmbuf_pool, return 0; fail: - if (m) - rte_pktmbuf_free(m); - if (clone) - rte_pktmbuf_free(clone); - if (clone2) - rte_pktmbuf_free(clone2); + rte_pktmbuf_free(m); + rte_pktmbuf_free(clone); + rte_pktmbuf_free(clone2); return -1; } @@ -572,12 +568,9 @@ test_pktmbuf_copy(struct rte_mempool *pktmbuf_pool, return 0; fail: - if (m) - rte_pktmbuf_free(m); - if (copy) - rte_pktmbuf_free(copy); - if (copy2) - rte_pktmbuf_free(copy2); + rte_pktmbuf_free(m); + rte_pktmbuf_free(copy); + rte_pktmbuf_free(copy2); return -1; } @@ -679,12 +672,9 @@ test_attach_from_different_pool(struct rte_mempool *pktmbuf_pool, return 0; fail: - if (m) - rte_pktmbuf_free(m); - if (clone) - rte_pktmbuf_free(clone); - if (clone2) - rte_pktmbuf_free(clone2); + rte_pktmbuf_free(m); + rte_pktmbuf_free(clone); + rte_pktmbuf_free(clone2); return -1; } @@ -722,8 +712,7 @@ test_pktmbuf_pool(struct rte_mempool *pktmbuf_pool) } /* free them */ for (i=0; i