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 9F99FA04AD; Mon, 24 Jan 2022 18:48:53 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A82DE4283F; Mon, 24 Jan 2022 18:47:41 +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 8152E42828 for ; Mon, 24 Jan 2022 18:47:39 +0100 (CET) Received: by mail-pl1-f177.google.com with SMTP id u11so16306490plh.13 for ; Mon, 24 Jan 2022 09:47:39 -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=h5Pna2MDTOK8wd/nT60Fy709Uu76Z0ETdGGNoBNlZoY6ZvjnUfjzQuxSoYt06w+aID XoVma9sdi7pgbYP5uqMJg98D9ncxNegtDF+fpLIuu8Ki4XvZx4Wf6z+5v3OY5NdS8k89 OohQXMeinHeYDvvR1jcoi3EK8t2QkjFlgs62jlfqR8Afq44ylDf1MPsIAWHa33zGlJNd 0HE8ynKwc5bAoZKv7hOtdYKkefa0LegcMPcl3mMsOIqHYf5cMETWMyZV98ilTUTdBXlo 8jatsJuL01rgLy7fY0Oc1PptveRP49GX6LoHJxBWS6WvnI25gJos2519Qb46CBR9KwK7 WmWg== 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=NS+ncmAg+4GRx9cm/ntM1tx23s7MuQwXxis/f52uDpLD4wgmLKjl888v0tJpdU91XS e/9AWs5hMviWN0ckK7oTBV40r2NobQZx4td++YpWELOguBK6VRLM1Usz8enRFIqIV+iC javSObusYZiqKEqluLUn2HvehWgfngJSAg9QDcfHc88twoKhWxeM1M+3NWWYbnaQ6df4 ZYPG3g010Aecavg+wA3SIUEeA92FGesJFBh6W63Wu3L7wrQY+RcMQZ2pwBeMZMPv0ilO gul810/+aztP6aIsTh+GkufigVBTHA3il/GQ/H440t1hSf2LnXSk3EhqDK5+S2bQwxb1 n3Bg== X-Gm-Message-State: AOAM533UKMLZaVjc8BGGdWM3le6m33JSCu9OZveppM/XTCQM3Iaonp6e hX+yQIS+dWHmBQgWpwkMLFfuCXlXSWOn4g== X-Google-Smtp-Source: ABdhPJyqKPuHWd8qUXKerYbvU9U1iF4am1ea6u6e4FmrSSDpGY2xh3+t5TQP9K4RF5u586NT5VFxlQ== X-Received: by 2002:a17:90b:4b42:: with SMTP id mi2mr2999364pjb.243.1643046458443; Mon, 24 Jan 2022 09:47:38 -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.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 09:47:37 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Olivier Matz , Fan Zhang , Ashish Gupta , Akhil Goyal , Declan Doherty , Bruce Richardson , Vladimir Medvedkin , Yipeng Wang , Sameh Gobriel , Honnappa Nagarahalli , Konstantin Ananyev , Andrew Rybchenko , Anatoly Burakov , Chas Williams , "Min Hu (Connor)" , Reshma Pattan Subject: [PATCH v2 15/83] app/test: remove unnecessary NULL checks Date: Mon, 24 Jan 2022 09:46:11 -0800 Message-Id: <20220124174719.14417-16-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 --- 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