From patchwork Sun Feb 20 18:21:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 107875 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 50FF6A00C2; Sun, 20 Feb 2022 19:22:21 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 390D04115C; Sun, 20 Feb 2022 19:22:00 +0100 (CET) Received: from mail-pg1-f171.google.com (mail-pg1-f171.google.com [209.85.215.171]) by mails.dpdk.org (Postfix) with ESMTP id 1204641159 for ; Sun, 20 Feb 2022 19:21:58 +0100 (CET) Received: by mail-pg1-f171.google.com with SMTP id f8so12363981pgc.8 for ; Sun, 20 Feb 2022 10:21:57 -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=WSFzEuBg/lJ64MxMKQpjsiyoqjacyV+cPCG6wbpOEUVv49J0ppfxXcEMusk541RQMu n7c1050Equ2XVqey5WO/91d+shRv3l6zqvAS1btnjNzN0mVh5BcIhyBnCJ3IqvLMZquy +8rGjL8umFpYo12k7qN9iVrBETz1Le5PCyKWgdMxPW9XDY3ZE6YO73R71yNdK/nNykuD 2XqoVdwtciXOb4KZoyfn5i3pvv1PJN07eiG4mPKTESscYjYAoXsT4zSNP2cFdNH3L8pH Nea4ZpiB0mDuj642diND5zRXY5yyIu3O/dLLR0DTh5plRff3M34MwzxPEdz1t5poKrVD yfDQ== 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=PLIF2caCHw/0hsi1368gBW0kb2Kl+YelT1coeLJIchdvtp1GyDTQj1ytino1oWfSgU A5BZStRQzKl2OkxwXK07UMlVbwng2y4qyUOKAZvEddcIjqfsC1UPd4W0bP3IsDFBJ1EI sFPgkFnk+7tWzCToSBTsoiZPin1ZG/5whWn2phD60kJnVfT2G9VIorzr8ZwvXBf1lml7 bnNh+kxxLAH2a4DtohlxeFw8a95RZ7uEYIf04ilMKgOOwfH9YpwN+HTA6H0u/vNpN9w2 EBbWS5wuRkQwKOTEMnDT306hHDDYkFEhyuPJ44EvEAMKKbepCfiJ5qIFBe3sZsfz3mpi wkdw== X-Gm-Message-State: AOAM530oVQrNeIm3zyWaYKasoXRlMzsks47e8844y3rWbRsVi2QFmMd8 XvkX1AD3ALBUtEaE4WN75GnM9Hssk0Nemggs X-Google-Smtp-Source: ABdhPJyo4QdiIV2iakc5s7fobgLGxeVUcLnA2Dq1vLcAQHQBoCCxq918ENODNxiH6rBiI+iNsAd3Sg== X-Received: by 2002:a05:6a00:10c9:b0:4ce:146e:6edf with SMTP id d9-20020a056a0010c900b004ce146e6edfmr17069141pfu.6.1645381316907; Sun, 20 Feb 2022 10:21:56 -0800 (PST) Received: from hermes.local (204-195-112-199.wavecable.com. [204.195.112.199]) by smtp.gmail.com with ESMTPSA id u8sm13528107pgf.83.2022.02.20.10.21.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Feb 2022 10:21:56 -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 , Honnappa Nagarahalli , Konstantin Ananyev , Anatoly Burakov , Andrew Rybchenko Subject: [PATCH v3 5/8] test: remove unnecessary NULL checks before free Date: Sun, 20 Feb 2022 10:21:44 -0800 Message-Id: <20220220182147.9750-6-stephen@networkplumber.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220220182147.9750-1-stephen@networkplumber.org> References: <20220219234322.61309-1-stephen@networkplumber.org> <20220220182147.9750-1-stephen@networkplumber.org> MIME-Version: 1.0 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