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 AB3D0A00C2; Sun, 20 Feb 2022 01:52:12 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 207234115A; Sun, 20 Feb 2022 01:51:54 +0100 (CET) Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) by mails.dpdk.org (Postfix) with ESMTP id DA95441150 for ; Sun, 20 Feb 2022 01:51:50 +0100 (CET) Received: by mail-pl1-f172.google.com with SMTP id m11so6495276pls.5 for ; Sat, 19 Feb 2022 16:51:50 -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=4GNWOCeECk4W5dvSei/2YWeZW1DAhQYhmlSYIkWYJgY=; b=FqDZH4COVdZ1Vta2yZ8LXV/1plXfxYwC+L41vm916btPiuHhmFvJgXxjoBMBFCufai Y2kdffxB38YkdU5G61qZVGR45XJVj670VGDwhdovRmeuYQtFD95241Dz5jj6cwfHvpGU z5tYa5B/QOKFlEVwojWy6URVSyj+Sq4Tk6ZwPyTGWVQbKywmL6QSVyB5ajK2c7SJdmsE x+TySPB2Rg3Mfv8H1ARrzqtVoQKU1T2ExPd38DmV6arUvYOSSvF+4pPLYzU/XkSWSIJw iuED3fUca1mbj2P5bAB/U36Bx8EUF+SkyMgNk2uETJ7P3x3JhDamPEnO11GFcyjEpLV+ asIQ== 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=4GNWOCeECk4W5dvSei/2YWeZW1DAhQYhmlSYIkWYJgY=; b=nNttPiocrXcmApZNP8ZkakVkAo6qYUITgw7TK7QiYSyi1g2No2gg+lV4CWKGE7SxTJ s85IXZ84HyTT0pCr5dWiJKjVjmekE2+X/ZQ/t+GobeBWtEKC+H/ViJ99LGzfjcdjwX/5 Dp1KLKxWTu1gCZ87gniZOYJSjOSLVrZ/VmpyaFAGhIlh/duVrve+OW6BFlPeMGCHzC1P HynklDdkukSrkBd9b/oxc2Kxw2YlpqWUqldBWTBTdHbePtBlg9SDluak8o42VaF95BCW wZabvMOWtj4xDC5nhHTW/5M0hW1Ee21gVpEuHLJxK9h+8Ejo/zl3hbeNFR3zJALCeMKN q38Q== X-Gm-Message-State: AOAM531/EUjqQGCyde8NWwEqHwLC4Dsm9KhF0iGKud29C65Cqzs9B9H4 eUa5n2Hpr1WBRJv2AD9Hd5TPL3sNtGfSBbq+ X-Google-Smtp-Source: ABdhPJz9J8LhE4yMy9sh3xAEiSFeVGaysgsFx9+KDKkyN4CZtlPnitSauSLgObmpBqjc4UUnSKZCWw== X-Received: by 2002:a17:902:e74d:b0:14f:206d:1860 with SMTP id p13-20020a170902e74d00b0014f206d1860mr13664166plf.59.1645318309720; Sat, 19 Feb 2022 16:51:49 -0800 (PST) Received: from hermes.local (204-195-112-199.wavecable.com. [204.195.112.199]) by smtp.gmail.com with ESMTPSA id f7sm8129695pfc.0.2022.02.19.16.51.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Feb 2022 16:51:49 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Olivier Matz , Akhil Goyal , Fan Zhang , Yipeng Wang , Sameh Gobriel , Bruce Richardson , Vladimir Medvedkin , Andrew Rybchenko , Honnappa Nagarahalli , Konstantin Ananyev , Anatoly Burakov Subject: [PATCH v2 5/7] test: remove unecessary NULL checks before free Date: Sat, 19 Feb 2022 16:51:38 -0800 Message-Id: <20220220005140.78713-6-stephen@networkplumber.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220220005140.78713-1-stephen@networkplumber.org> References: <20220219234322.61309-1-stephen@networkplumber.org> <20220220005140.78713-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 These are all cases in test code where there is unnecessary NULL check before free caught by coccinelle nullfree script. Signed-off-by: Stephen Hemminger --- app/test/test_cmdline_lib.c | 3 +-- app/test/test_cryptodev.c | 9 +++----- app/test/test_cryptodev_asym.c | 30 +++++++++------------------ app/test/test_cryptodev_blockcipher.c | 3 +-- app/test/test_func_reentrancy.c | 3 +-- app/test/test_hash.c | 3 +-- 6 files changed, 17 insertions(+), 34 deletions(-) diff --git a/app/test/test_cmdline_lib.c b/app/test/test_cmdline_lib.c index fcd58cb76af1..87c105936650 100644 --- a/app/test/test_cmdline_lib.c +++ b/app/test/test_cmdline_lib.c @@ -229,8 +229,7 @@ test_cmdline_fns(void) error: printf("Error: function accepted null parameter!\n"); - if (cl != NULL) - cmdline_free(cl); + cmdline_free(cl); return -1; } diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c index a63c199964d4..1d9f615255c4 100644 --- a/app/test/test_cryptodev.c +++ b/app/test/test_cryptodev.c @@ -1451,8 +1451,7 @@ ut_teardown(void) } /* free crypto operation structure */ - if (ut_params->op) - rte_crypto_op_free(ut_params->op); + rte_crypto_op_free(ut_params->op); /* * free mbuf - both obuf and ibuf are usually the same, @@ -11653,8 +11652,7 @@ test_multi_session(void) aes_cbc_iv), "Failed to perform decrypt on request number %u.", i); /* free crypto operation structure */ - if (ut_params->op) - rte_crypto_op_free(ut_params->op); + rte_crypto_op_free(ut_params->op); /* * free mbuf - both obuf and ibuf are usually the same, @@ -11797,8 +11795,7 @@ test_multi_session_random_usage(void) ut_paramz[j].iv), "Failed to perform decrypt on request number %u.", i); - if (ut_paramz[j].ut_params.op) - rte_crypto_op_free(ut_paramz[j].ut_params.op); + rte_crypto_op_free(ut_paramz[j].ut_params.op); /* * free mbuf - both obuf and ibuf are usually the same, diff --git a/app/test/test_cryptodev_asym.c b/app/test/test_cryptodev_asym.c index 7cda8bb081f0..9b4d9db59297 100644 --- a/app/test/test_cryptodev_asym.c +++ b/app/test/test_cryptodev_asym.c @@ -507,8 +507,7 @@ test_cryptodev_asym_op(struct crypto_testsuite_params_asym *ts_params, if (sess != NULL) rte_cryptodev_asym_session_free(dev_id, sess); - if (op != NULL) - rte_crypto_op_free(op); + rte_crypto_op_free(op); rte_free(result); @@ -1114,8 +1113,7 @@ test_dh_gen_shared_sec(struct rte_crypto_asym_xform *xfrm) error_exit: if (sess != NULL) rte_cryptodev_asym_session_free(dev_id, sess); - if (op != NULL) - rte_crypto_op_free(op); + rte_crypto_op_free(op); return status; } @@ -1193,8 +1191,7 @@ test_dh_gen_priv_key(struct rte_crypto_asym_xform *xfrm) error_exit: if (sess != NULL) rte_cryptodev_asym_session_free(dev_id, sess); - if (op != NULL) - rte_crypto_op_free(op); + rte_crypto_op_free(op); return status; } @@ -1283,8 +1280,7 @@ test_dh_gen_pub_key(struct rte_crypto_asym_xform *xfrm) error_exit: if (sess != NULL) rte_cryptodev_asym_session_free(dev_id, sess); - if (op != NULL) - rte_crypto_op_free(op); + rte_crypto_op_free(op); return status; } @@ -1370,8 +1366,7 @@ test_dh_gen_kp(struct rte_crypto_asym_xform *xfrm) error_exit: if (sess != NULL) rte_cryptodev_asym_session_free(dev_id, sess); - if (op != NULL) - rte_crypto_op_free(op); + rte_crypto_op_free(op); return status; } @@ -1481,8 +1476,7 @@ test_mod_inv(void) if (sess) rte_cryptodev_asym_session_free(dev_id, sess); - if (op) - rte_crypto_op_free(op); + rte_crypto_op_free(op); TEST_ASSERT_EQUAL(status, 0, "Test failed"); @@ -1593,8 +1587,7 @@ test_mod_exp(void) if (sess != NULL) rte_cryptodev_asym_session_free(dev_id, sess); - if (op != NULL) - rte_crypto_op_free(op); + rte_crypto_op_free(op); TEST_ASSERT_EQUAL(status, 0, "Test failed"); @@ -1758,8 +1751,7 @@ test_dsa_sign(void) error_exit: if (sess != NULL) rte_cryptodev_asym_session_free(dev_id, sess); - if (op != NULL) - rte_crypto_op_free(op); + rte_crypto_op_free(op); return status; } @@ -1947,8 +1939,7 @@ test_ecdsa_sign_verify(enum curve curve_id) exit: if (sess != NULL) rte_cryptodev_asym_session_free(dev_id, sess); - if (op != NULL) - rte_crypto_op_free(op); + rte_crypto_op_free(op); return status; }; @@ -2109,8 +2100,7 @@ test_ecpm(enum curve curve_id) exit: if (sess != NULL) rte_cryptodev_asym_session_free(dev_id, sess); - if (op != NULL) - rte_crypto_op_free(op); + rte_crypto_op_free(op); return status; } diff --git a/app/test/test_cryptodev_blockcipher.c b/app/test/test_cryptodev_blockcipher.c index 494459195c49..954587ea5b18 100644 --- a/app/test/test_cryptodev_blockcipher.c +++ b/app/test/test_cryptodev_blockcipher.c @@ -811,8 +811,7 @@ test_blockcipher_one_case(const struct blockcipher_test_case *t, rte_free(auth_xform); } - if (op) - rte_crypto_op_free(op); + rte_crypto_op_free(op); rte_pktmbuf_free(obuf); diff --git a/app/test/test_func_reentrancy.c b/app/test/test_func_reentrancy.c index 67e69ad53588..d1ed5d4abcfc 100644 --- a/app/test/test_func_reentrancy.c +++ b/app/test/test_func_reentrancy.c @@ -278,8 +278,7 @@ fbk_clean(unsigned lcore_id) int i; handle = rte_fbk_hash_find_existing("fr_test_once"); - if (handle != NULL) - rte_fbk_hash_free(handle); + rte_fbk_hash_free(handle); for (i = 0; i < MAX_ITER_MULTI; i++) { snprintf(fbk_name, sizeof(fbk_name), "fr_test_%d_%d", lcore_id, i); diff --git a/app/test/test_hash.c b/app/test/test_hash.c index d522cb7f8cbf..3e45afaa67fc 100644 --- a/app/test/test_hash.c +++ b/app/test/test_hash.c @@ -1159,8 +1159,7 @@ fbk_hash_unit_test(void) RETURN_IF_ERROR_FBK(handle == NULL, "fbk hash creation should have succeeded"); tmp = rte_fbk_hash_create(&invalid_params_same_name_2); - if (tmp != NULL) - rte_fbk_hash_free(tmp); + rte_fbk_hash_free(tmp); RETURN_IF_ERROR_FBK(tmp != NULL, "fbk hash creation should have failed"); /* we are not freeing handle here because we need a hash list -- 2.34.1