From patchwork Sun Feb 20 18:21:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 107871 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 5E46CA00C2; Sun, 20 Feb 2022 19:21:59 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E2B82410FA; Sun, 20 Feb 2022 19:21: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 72D7340395 for ; Sun, 20 Feb 2022 19:21:52 +0100 (CET) Received: by mail-pl1-f172.google.com with SMTP id m11so7604259pls.5 for ; Sun, 20 Feb 2022 10:21:52 -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=MkNXUUiZPIU2HM85TN+00W31datUK0jxa0w2IpiHT7g=; b=HASJX05c05doK/Oci8P+AGWLnvxVRH316+8SEo8WGudT6Gz/PSJnseRZpFJgMpMqim nKH14Z25BiM71k+AwFOqb3td4ATEMJBGBaE879+KL2wxBwDwbXKV/8GzTm4zMoojhyB6 vX4sKySI646qE68LZZj9NMfWlTYaQy3Ou6DJQNITwurx6v0S9oFKkuXRlUcRVIidcQTE buTDGexvdrYGl8/bb9biqfGtBpAXyZyEI6pFXPpDYluSlLZXJqCjUDAuXpcG2w23ISqu 48xcC853phJjWEL/sJkDeQ53uGpA6AFqSkMug8XZy1qqfcxZgqWeydKYI4OrLO1x/mwV MKkg== 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=MkNXUUiZPIU2HM85TN+00W31datUK0jxa0w2IpiHT7g=; b=ZXYJLSyVbVkUgTx3iPVDa6XogdVftxShm1hKGV/VtNSM/i/Zx3kUv0RxHqdseZI9AN FRHeMWBK8gUq3Baf3Uan35M0BlUkP8Fa9Po7WreKV1QmF6mkLyOQaHpB17XzBlJTXTfK JY3Pt2FfbrNwbw7sYmzMCzEXRAOWX9BaBoeSNNP61DbPTwiFR7nRbu8S4sJmornISaph 0Wip9DdpnQNiGVfa0ULG/wt4gk41Mx1Wm+jWvHJGsHti/thjagEhZWyF0aCcjR8onTep PY5qebN35QNvUMd8asJooajregHj1fh58WrIgTvObmkfxOeUk2CgTTdMxtsHf6KtgSJG J9ag== X-Gm-Message-State: AOAM530iPFetfSlGzmRZp3BsSvGGCgXMLPmJIB2nPMwZu1iMVs1pTGoQ D9CS84xrMAj54RSTh7L6JecBGHoY2yIqfCQQ X-Google-Smtp-Source: ABdhPJxMzWJrPV7nYaW5ULnrFmJCxsuHf5DlL/iZ5/Rtg/Kzwcjsf/XeUdYWAAZZiJyuB0u7eTqdQA== X-Received: by 2002:a17:90a:6404:b0:1b9:28a8:935f with SMTP id g4-20020a17090a640400b001b928a8935fmr17975154pjj.197.1645381311135; Sun, 20 Feb 2022 10:21:51 -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.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Feb 2022 10:21:50 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [PATCH v3 1/8] cocci/nullfree: add more functions Date: Sun, 20 Feb 2022 10:21:40 -0800 Message-Id: <20220220182147.9750-2-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 There are more functions in DPDK which have the semantics as free() when passed NULL pointer. Also, put the checks in alpha order. Signed-off-by: Stephen Hemminger --- devtools/cocci/nullfree.cocci | 108 ++++++++++++++++++++++++++++++++-- 1 file changed, 102 insertions(+), 6 deletions(-) diff --git a/devtools/cocci/nullfree.cocci b/devtools/cocci/nullfree.cocci index 363b6149ac28..9ca3fc286497 100644 --- a/devtools/cocci/nullfree.cocci +++ b/devtools/cocci/nullfree.cocci @@ -7,27 +7,123 @@ expression E; @@ ( +- if (E != NULL) cmdline_free(E); ++ cmdline_free(E); +| - if (E != NULL) free(E); + free(E); | +- if (E != NULL) rte_acl_free(E); ++ rte_acl_free(E); +| - if (E != NULL) rte_bitmap_free(E); + rte_bitmap_free(E); | +- if (E != NULL) rte_comp_op_free(E); ++ rte_comp_op_free(E); +| +- if (E != NULL) rte_crypto_op_free(E); ++ rte_crypto_op_free(E); +| +- if (E != NULL) rte_efd_free(E); ++ rte_efd_free(E); +| +- if (E != NULL) rte_event_ring_free(E); ++ rte_event_ring_free(E); +| +- if (E != NULL) rte_fib_free(E); ++ rte_fib_free(E); +| +- if (E != NULL) rte_fib6_free(E); ++ rte_fib6_free(E); +| +- if (E != NULL) rte_flow_classifier_free(E); ++ rte_flow_classifier_free(E); +| - if (E != NULL) rte_free(E); + rte_free(E); | +- if (E != NULL) rte_fbk_hash_free(E); ++ rte_fbk_hash_free(E); +| +- if (E != NULL) rte_gpu_mem_free(E); ++ rte_gpu_mem_free(E); +| - if (E != NULL) rte_hash_free(E); + rte_hash_free(E); | -- if (E != NULL) rte_ring_free(E); -+ rte_ring_free(E); +- if (E != NULL) rte_intr_instance_free(E); ++ rte_intr_instance_free(E); | -- if (E != NULL) rte_pktmbuf_free(E); -+ rte_pktmbuf_free(E); +- if (E != NULL) rte_intr_vec_list_free(E); ++ rte_intr_vec_list_free(E); +| +- if (E != NULL) rte_kvargs_free(E); ++ rte_kvargs_free(E); +| +- if (E != NULL) rte_lpm_free(E); ++ rte_lpm_free(E); +| +- if (E != NULL) rte_lpm6_free(E); ++ rte_lpm6_free(E); +| +- if (E != NULL) rte_member_free(E); ++ rte_member_free(E); | - if (E != NULL) rte_mempool_free(E); + rte_mempool_free(E); | -- if (E != NULL) rte_kvargs_free(E); -+ rte_kvargs_free(E); +- if (E != NULL) rte_pktmbuf_free(E); ++ rte_pktmbuf_free(E); +| +- if (E != NULL) rte_rib_free(E); ++ rte_rib_free(E); +| +- if (E != NULL) rte_rib6_free(E); ++ rte_rib6_free(E); +| +- if (E != NULL) rte_reorder_free(E); ++ rte_reorder_free(E); +| +- if (E != NULL) rte_ring_free(E); ++ rte_ring_free(E); +| +- if (E != NULL) rte_port_in_action_free(E); ++ rte_port_in_action_free(E); +| +- if (E != NULL) rte_port_in_action_profile_free(E); ++ rte_port_in_action_profile_free(E); +| +- if (E != NULL) rte_sched_port_free(E); ++ rte_sched_port_free(E); +| +- if (E != NULL) rte_stack_free(E); ++ rte_stack_free(E); +| +- if (E != NULL) rte_stats_bitrate_free(E); ++ rte_stats_bitrate_free(E); +| +- if (E != NULL) rte_swx_ctl_pipeline_free(E); ++ rte_swx_ctl_pipeline_free(E); +| +- if (E != NULL) rte_swx_pipeline_free(E); ++ rte_swx_pipeline_free(E); +| +- if (E != NULL) rte_swx_table_learner_free(E); ++ rte_swx_table_learner_free(E); +| +- if (E != NULL) rte_swx_table_selector_free(E); ++ rte_swx_table_selector_free(E); +| +- if (E != NULL) rte_table_action_free(E); ++ rte_table_action_free(E); +| +- if (E != NULL) rte_table_action_profile_free(E); ++ rte_table_action_profile_free(E); +| +- if (E != NULL) rte_tel_data_free(E); ++ rte_tel_data_free(E); +| +- if (E != NULL) trie_free(E); ++ trie_free(E); ) From patchwork Sun Feb 20 18:21:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 107872 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 C144BA00C2; Sun, 20 Feb 2022 19:22:04 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D1D2141148; Sun, 20 Feb 2022 19:21:55 +0100 (CET) Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) by mails.dpdk.org (Postfix) with ESMTP id A68D240E78 for ; Sun, 20 Feb 2022 19:21:53 +0100 (CET) Received: by mail-pj1-f53.google.com with SMTP id cp23-20020a17090afb9700b001bbfe0fbe94so3291859pjb.3 for ; Sun, 20 Feb 2022 10:21:53 -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=Q1rfFuy7cjfKewQwHuGQMrYytPjTVfBBJ2JNwLdtTUg=; b=dHFykZqM3UIPV8qZff+1UrLSphv796ONuvQuQPVrS62um5Ey91vFO08uHYfEicUVgj EujbuOZHVdSWEweqDkz6vwNxhImX3MfZLMsr8OwKdsHdjI+Whji5qnFjAdqe4MnsEnto c4lFLrYILQwGA/TaxwQ4w4tpDpLv2udIZNYJGaXnR8imIQMld+0NeBqsL7IlQoBjquZA gHNKv6nAfNHSfa0L6Ob5iKhDq3cfLAjart6zDWbUz7oUaDSZEgS0VmG4+Wcx/sLBQy57 6icNWiXcFyKXX/0nejFBsIqTUrTjhvyaWirMjBv3IIbywdkjvcl33QMCkxxC3RW24As+ HZkQ== 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=Q1rfFuy7cjfKewQwHuGQMrYytPjTVfBBJ2JNwLdtTUg=; b=iMlpEpLvbnY5h+CMPij6jBHI5ONUam1/L6Y50zgA6pKocNsi0AY375yTFS5+RCkiOp 8QWY8begH0LOasyz8EopvNBGw52ubx2l/84e9h1rpTAIfuzOoeKFA1gTCxRALhe/WBBH NH4RONFxuhHr69MFZvW3Y58YcFdnPV/stFcirsoz3pTznAXHiFfONOQZXuRhR0gsAHtc 2N2TOjRDLIFNBJEfqzr33S2qgERTdSeqaNPWnnQMfy8StrkoXXq84hGVu787tW1diupS jEnXavVFakLclOXs66gcINKDcIXHkEUQTGBC+IiOgwlPfyLIW+bOGZltlQiXGTmxvsUd ib/w== X-Gm-Message-State: AOAM53339ZNuxIPqCmOhWCtBuEQAvLd2OXlY2cPSwqnp+OD/MpQyPxgm IfAGwq4jde8tUaxAyBKVDAmxyORGPUpbO2/f X-Google-Smtp-Source: ABdhPJxV2YGdimqZnj7/y6kV2QO1lrZhBRW344EtP2OJ9bTbXqvienF93wEJsG3uNJcHL2fPYvxTmQ== X-Received: by 2002:a17:902:b597:b0:14f:3396:a7a5 with SMTP id a23-20020a170902b59700b0014f3396a7a5mr16035781pls.29.1645381312487; Sun, 20 Feb 2022 10:21:52 -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.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Feb 2022 10:21:51 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Konstantin Ananyev , Cristian Dumitrescu Subject: [PATCH v3 2/8] acl: remove unnecessary null checks Date: Sun, 20 Feb 2022 10:21:41 -0800 Message-Id: <20220220182147.9750-3-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 This function already handles NULL as valid input. Signed-off-by: Stephen Hemminger --- app/test/test_acl.c | 12 ++++-------- lib/acl/rte_acl.h | 1 + lib/table/rte_swx_table_wm.c | 3 +-- lib/table/rte_table_acl.c | 15 +++++---------- 4 files changed, 11 insertions(+), 20 deletions(-) diff --git a/app/test/test_acl.c b/app/test/test_acl.c index 4d51098925c4..623f34682e69 100644 --- a/app/test/test_acl.c +++ b/app/test/test_acl.c @@ -1171,8 +1171,7 @@ test_create_find_add(void) printf("Line %i: Creating context with existing name " "test failed!\n", __LINE__); - if (tmp) - rte_acl_free(tmp); + rte_acl_free(tmp); goto err; } @@ -1182,8 +1181,7 @@ test_create_find_add(void) printf("Line %i: Creating context with existing " "name test 2 failed!\n", __LINE__); - if (tmp) - rte_acl_free(tmp); + rte_acl_free(tmp); goto err; } @@ -1191,16 +1189,14 @@ test_create_find_add(void) tmp = rte_acl_find_existing(acx_name); if (tmp != acx) { printf("Line %i: Finding %s failed!\n", __LINE__, acx_name); - if (tmp) - rte_acl_free(tmp); + rte_acl_free(tmp); goto err; } tmp = rte_acl_find_existing(acx2_name); if (tmp != acx2) { printf("Line %i: Finding %s failed!\n", __LINE__, acx2_name); - if (tmp) - rte_acl_free(tmp); + rte_acl_free(tmp); goto err; } diff --git a/lib/acl/rte_acl.h b/lib/acl/rte_acl.h index f7f5f0870122..c33a688433b1 100644 --- a/lib/acl/rte_acl.h +++ b/lib/acl/rte_acl.h @@ -165,6 +165,7 @@ rte_acl_find_existing(const char *name); * * @param ctx * ACL context to free + * If NULL then, the function does nothing. */ void rte_acl_free(struct rte_acl_ctx *ctx); diff --git a/lib/table/rte_swx_table_wm.c b/lib/table/rte_swx_table_wm.c index e260be106221..c9d42a855249 100644 --- a/lib/table/rte_swx_table_wm.c +++ b/lib/table/rte_swx_table_wm.c @@ -375,8 +375,7 @@ table_free(void *table) if (!t) return; - if (t->acl_ctx) - rte_acl_free(t->acl_ctx); + rte_acl_free(t->acl_ctx); env_free(t, t->total_size); } diff --git a/lib/table/rte_table_acl.c b/lib/table/rte_table_acl.c index 14d54019f0bb..d15f03448796 100644 --- a/lib/table/rte_table_acl.c +++ b/lib/table/rte_table_acl.c @@ -148,8 +148,7 @@ rte_table_acl_free(void *table) } /* Free previously allocated resources */ - if (acl->ctx != NULL) - rte_acl_free(acl->ctx); + rte_acl_free(acl->ctx); rte_free(acl); @@ -320,8 +319,7 @@ rte_table_acl_entry_add( } /* Commit changes */ - if (acl->ctx != NULL) - rte_acl_free(acl->ctx); + rte_acl_free(acl->ctx); acl->ctx = ctx; *key_found = 0; *entry_ptr = &acl->memory[free_pos * acl->entry_size]; @@ -400,8 +398,7 @@ rte_table_acl_entry_delete( } /* Commit changes */ - if (acl->ctx != NULL) - rte_acl_free(acl->ctx); + rte_acl_free(acl->ctx); acl->ctx = ctx; *key_found = 1; @@ -577,8 +574,7 @@ rte_table_acl_entry_add_bulk( } /* Commit changes */ - if (acl->ctx != NULL) - rte_acl_free(acl->ctx); + rte_acl_free(acl->ctx); acl->ctx = ctx; for (i = 0; i < n_keys; i++) { @@ -696,8 +692,7 @@ rte_table_acl_entry_delete_bulk( } /* Commit changes */ - if (acl->ctx != NULL) - rte_acl_free(acl->ctx); + rte_acl_free(acl->ctx); acl->ctx = ctx; for (i = 0; i < n_keys; i++) { From patchwork Sun Feb 20 18:21:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 107873 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 F4135A00C2; Sun, 20 Feb 2022 19:22:09 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D356841151; Sun, 20 Feb 2022 19:21:56 +0100 (CET) Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) by mails.dpdk.org (Postfix) with ESMTP id 4338C41143 for ; Sun, 20 Feb 2022 19:21:55 +0100 (CET) Received: by mail-pj1-f50.google.com with SMTP id qe15so12992034pjb.3 for ; Sun, 20 Feb 2022 10:21:55 -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=HP50AnJLQFaAeX74twilP1G6y4PxcwD69EyDyAwScTU=; b=5HP/L6tCknZbohNLet2+FsxvgjfV2IN0s2HMuToTnb/1QKRV3OjkOmyZMXZcpBaZXj gvFBY2Mp7G09FBokmxFfOY4FHb2n9BanzgGqYqJK/3jEZbUnvObs/dMZctZxeDUVIBVk 8YYwngDCaAzj9ULvOFcrCoam/G/x3Sc5vvIsvNDGo1VwiW/xTtnnaTIAbSnFDVTffcCL CqkXkjVyJCAVY9DqwpXcnwmAPN1tJzIFrV1hyQ0febInN1ujPKzl6Cr3x983Wweoq4my NvcdsKw7QiE2XjaydDlPpKSykMg+TQrS3ga/vs7KczV070vVh29UfMayw1yjGCDJagbi YUoQ== 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=HP50AnJLQFaAeX74twilP1G6y4PxcwD69EyDyAwScTU=; b=OQlo2O5+U82kiQNR8WZZVvE0YX+xkaJ9cFCb7stmPx3fjejkcXx+0hcwM7P3jZFar9 FeokQTtTNfw1mmoybH0zyVh39praQBhR0AKqxJIkFmQ7J8mv7doEvZI9dp4LcVa44i1D z3+eAK9E1q5SM7tfRCyn+IFetQ1RVqx17usAcDEafRupOYk9I2XpagbWLmFRz/z85i+r iSqkSkrfo/Wod4WeQpMD9F+9nsKgy5Xdt9iM3Huy68SJJPTbBCUN+ElbSYoQY3oA/EG4 Xc4LUP/Px5ucWmesGMcgevNkRRELalPcSnVEY4oD2VKg1oHtb/EIwAXk5N7hN7RY+ORm GiUg== X-Gm-Message-State: AOAM5339nch05KqhWBX9nI6N///Jd3JZQZUQIlhRu32mDFUIbiQ9X+oF 6mrMk5jSmPYfWHMvWDM1GtzU4QGJJZT+FvG5 X-Google-Smtp-Source: ABdhPJwV6HYA2DGyr+H/dM3fHw/tKkB/a0zsxnaKQodfdwRIJq7en3jX/0eigGQQY1lctad0UICFyQ== X-Received: by 2002:a17:90a:5402:b0:1b9:68e8:282e with SMTP id z2-20020a17090a540200b001b968e8282emr17730193pjh.62.1645381314089; Sun, 20 Feb 2022 10:21:54 -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.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Feb 2022 10:21:53 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Bruce Richardson , Vladimir Medvedkin , Yipeng Wang , Sameh Gobriel , Anatoly Burakov , Olivier Matz , Andrew Rybchenko , Honnappa Nagarahalli , Konstantin Ananyev Subject: [PATCH v3 3/8] lpm: remove unnecessary NULL checks Date: Sun, 20 Feb 2022 10:21:42 -0800 Message-Id: <20220220182147.9750-4-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 The functions rte_lpm_free() and rte_lpm6_free() already handle NULL pointer case. Signed-off-by: Stephen Hemminger Reviewed-by: Ruifeng Wang Acked-by: Vladimir Medvedkin --- app/test/test_func_reentrancy.c | 3 +-- lib/lpm/rte_lpm.h | 1 + lib/lpm/rte_lpm6.h | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/test/test_func_reentrancy.c b/app/test/test_func_reentrancy.c index da00694daafd..67e69ad53588 100644 --- a/app/test/test_func_reentrancy.c +++ b/app/test/test_func_reentrancy.c @@ -348,8 +348,7 @@ lpm_clean(unsigned int lcore_id) int i; lpm = rte_lpm_find_existing("fr_test_once"); - if (lpm != NULL) - rte_lpm_free(lpm); + rte_lpm_free(lpm); for (i = 0; i < MAX_LPM_ITER_TIMES; i++) { snprintf(lpm_name, sizeof(lpm_name), "fr_test_%d_%d", lcore_id, i); diff --git a/lib/lpm/rte_lpm.h b/lib/lpm/rte_lpm.h index 5eb14c1748e5..a50bf3339fee 100644 --- a/lib/lpm/rte_lpm.h +++ b/lib/lpm/rte_lpm.h @@ -183,6 +183,7 @@ rte_lpm_find_existing(const char *name); * * @param lpm * LPM object handle + * If NULL then, the function does nothing. * @return * None */ diff --git a/lib/lpm/rte_lpm6.h b/lib/lpm/rte_lpm6.h index f96f3372e593..145fd4495a94 100644 --- a/lib/lpm/rte_lpm6.h +++ b/lib/lpm/rte_lpm6.h @@ -73,6 +73,7 @@ rte_lpm6_find_existing(const char *name); * * @param lpm * LPM object handle + * If NULL then, the function does nothing. * @return * None */ From patchwork Sun Feb 20 18:21:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 107874 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 258ACA00C2; Sun, 20 Feb 2022 19:22:16 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3D7C44115B; Sun, 20 Feb 2022 19:21:59 +0100 (CET) Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by mails.dpdk.org (Postfix) with ESMTP id BAF1D4114F for ; Sun, 20 Feb 2022 19:21:56 +0100 (CET) Received: by mail-pl1-f181.google.com with SMTP id u12so11139353plf.13 for ; Sun, 20 Feb 2022 10:21:56 -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=dYG3Kvc6xNkfDGS9Hx7TmjD2kqF8yk5+94R+tRj7po0=; b=61buljdJZ/lA2nm3ZHYCQWRxWh/f2FaWHuR9AGoPj/5JkoH9SiMLVsFw4Wn0Qv7Qi0 Vhl/tGx7qR916e4s004bBK5fDKcmoJ2KRyWUdqN0FspllSLL156urR5AoI1vaXs5zcqb nOzJ4bioSf3RyT5Lykf25jUwlvXIeFvHhR4/noZxbraZ2XaYwaDZQw7jXjpSQpFA9WZQ 4N819n43zR8Qw5gNw6wpvWpF6tb7/mTUK1RzfXb02nOtZ7ObEGPcU4jownw+o2R8GygL DEAur7EezY90SyyrNV/pIgL/hbzgBQ5o6Srpi/23W8Gswli986nWmXbFiqOqzxoGSmC9 +/nQ== 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=dYG3Kvc6xNkfDGS9Hx7TmjD2kqF8yk5+94R+tRj7po0=; b=AGc19t/StJN7C9mrqZntRi7jLuCfadpHhmnhpCuG3J+t1+3tUHA9ZBT7TwRSiSttS5 CfsxxvV/WNXfxKb+8SVaks2ThskJ5SVQWeRyFmgWbfUp0Z9bO0B6jTRUP2I9/Tiu54Pb zSZVRo0+7O2FLJk96l1gwyaUlkh002Or0z7cmxcOnecW0Fi6KjAXgfkBivXKldnPWLFg WFXdyVWzhLbSkW4ng/pTbXEbPdNheFyQttEBP3IniG6YfZTSr2Q1LyLVL62POlmPaxW2 fk26UtsBmmYgSf9/ltR72cjxXeWaRZ1FUzCuvc78A0aCq0HfJ9kiIgWmn8ja5WKHQ5mZ EJ7g== X-Gm-Message-State: AOAM5302QDcDJT9mPjg4tl3+76p9RW21QpE8t9TuJcjZwoiKhH/b1Vhy t63TXWDRacPRz55yiaf9mWm65z3sSKLo3l4v X-Google-Smtp-Source: ABdhPJy1VNopeh66mFSwqIRRFzmlaaqfXkGJ1GEQUrirTkY3jgXftek+vp7atVuRaC4wQ1GxHBvPyg== X-Received: by 2002:a17:902:ce8b:b0:14f:c5ec:9f38 with SMTP id f11-20020a170902ce8b00b0014fc5ec9f38mr104474plg.62.1645381315591; Sun, 20 Feb 2022 10:21:55 -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.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Feb 2022 10:21:55 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Fan Zhang , Ashish Gupta , Akhil Goyal , Harman Kalra , Byron Marohn , Yipeng Wang , Jerin Jacob , Vladimir Medvedkin , Sameh Gobriel , Reshma Pattan , Cristian Dumitrescu , Jasvinder Singh , Olivier Matz , Ciara Power Subject: [PATCH v3 4/8] lib: document existing free functions Date: Sun, 20 Feb 2022 10:21:43 -0800 Message-Id: <20220220182147.9750-5-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 functions all accept NULL as parameter. Signed-off-by: Stephen Hemminger --- lib/bitratestats/rte_bitrate.h | 1 + lib/compressdev/rte_comp.h | 1 + lib/cryptodev/rte_crypto.h | 1 + lib/eal/include/rte_interrupts.h | 4 +++- lib/efd/rte_efd.h | 1 + lib/eventdev/rte_event_ring.h | 1 + lib/fib/rte_fib.h | 1 + lib/fib/rte_fib6.h | 1 + lib/member/rte_member.h | 1 + lib/reorder/rte_reorder.h | 1 + lib/rib/rte_rib.h | 1 + lib/rib/rte_rib6.h | 1 + lib/sched/rte_sched.h | 1 + lib/stack/rte_stack.h | 1 + lib/telemetry/rte_telemetry.h | 2 +- 15 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/bitratestats/rte_bitrate.h b/lib/bitratestats/rte_bitrate.h index e494389b95a0..843baaf10900 100644 --- a/lib/bitratestats/rte_bitrate.h +++ b/lib/bitratestats/rte_bitrate.h @@ -32,6 +32,7 @@ struct rte_stats_bitrates *rte_stats_bitrate_create(void); * * @param bitrate_data * Pointer allocated by rte_stats_bitrate_create() + * If NULL then, the function does nothing. */ void rte_stats_bitrate_free(struct rte_stats_bitrates *bitrate_data); diff --git a/lib/compressdev/rte_comp.h b/lib/compressdev/rte_comp.h index 95306c5d0364..b07434ad39b2 100644 --- a/lib/compressdev/rte_comp.h +++ b/lib/compressdev/rte_comp.h @@ -471,6 +471,7 @@ rte_comp_op_bulk_alloc(struct rte_mempool *mempool, * * @param op * Compress operation + * If NULL then, the function does nothing. */ __rte_experimental void diff --git a/lib/cryptodev/rte_crypto.h b/lib/cryptodev/rte_crypto.h index a864f5036f3a..326764b0f0c0 100644 --- a/lib/cryptodev/rte_crypto.h +++ b/lib/cryptodev/rte_crypto.h @@ -339,6 +339,7 @@ __rte_crypto_op_get_priv_data(struct rte_crypto_op *op, uint32_t size) * be returned to the mempool. * * @param op symmetric crypto operation + * If NULL then, the function does nothing. */ static inline void rte_crypto_op_free(struct rte_crypto_op *op) diff --git a/lib/eal/include/rte_interrupts.h b/lib/eal/include/rte_interrupts.h index edbf0faeeffd..3ef8ab4621fb 100644 --- a/lib/eal/include/rte_interrupts.h +++ b/lib/eal/include/rte_interrupts.h @@ -243,7 +243,8 @@ rte_intr_instance_alloc(uint32_t flags); * resources. * * @param intr_handle - * Interrupt handle address. + * Interrupt handle address. + * If NULL then, the function does nothing. * */ __rte_experimental @@ -746,6 +747,7 @@ rte_intr_vec_list_index_get(const struct rte_intr_handle *intr_handle, * * @param intr_handle * pointer to the interrupt handle. + * If NULL then, the function does nothing. * * @return * - On success, zero diff --git a/lib/efd/rte_efd.h b/lib/efd/rte_efd.h index d3d7befd0c90..afba38a78c8a 100644 --- a/lib/efd/rte_efd.h +++ b/lib/efd/rte_efd.h @@ -146,6 +146,7 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len, * * @param table * Table to free + * If NULL then, the function does nothing. */ void rte_efd_free(struct rte_efd_table *table); diff --git a/lib/eventdev/rte_event_ring.h b/lib/eventdev/rte_event_ring.h index c0861b0ec2db..85c214a678cd 100644 --- a/lib/eventdev/rte_event_ring.h +++ b/lib/eventdev/rte_event_ring.h @@ -233,6 +233,7 @@ rte_event_ring_lookup(const char *name); * * @param r * Ring to free + * If NULL then, the function does nothing. */ void rte_event_ring_free(struct rte_event_ring *r); diff --git a/lib/fib/rte_fib.h b/lib/fib/rte_fib.h index e592d3251af1..5df6e34bde70 100644 --- a/lib/fib/rte_fib.h +++ b/lib/fib/rte_fib.h @@ -124,6 +124,7 @@ rte_fib_find_existing(const char *name); * * @param fib * FIB object handle + * If NULL then, the function does nothing. * @return * None */ diff --git a/lib/fib/rte_fib6.h b/lib/fib/rte_fib6.h index cb133719e175..4029c8f3ee0d 100644 --- a/lib/fib/rte_fib6.h +++ b/lib/fib/rte_fib6.h @@ -115,6 +115,7 @@ rte_fib6_find_existing(const char *name); * * @param fib * FIB object handle + * If NULL then, the function does nothing. * @return * None */ diff --git a/lib/member/rte_member.h b/lib/member/rte_member.h index c0689e233e65..ada3b96e5ec1 100644 --- a/lib/member/rte_member.h +++ b/lib/member/rte_member.h @@ -444,6 +444,7 @@ rte_member_add(const struct rte_member_setsum *setsum, const void *key, * * @param setsum * Pointer to the set summary. + * If NULL then, the function does nothing. */ void rte_member_free(struct rte_member_setsum *setsum); diff --git a/lib/reorder/rte_reorder.h b/lib/reorder/rte_reorder.h index 9de02403746b..ecf83fb5c578 100644 --- a/lib/reorder/rte_reorder.h +++ b/lib/reorder/rte_reorder.h @@ -115,6 +115,7 @@ rte_reorder_reset(struct rte_reorder_buffer *b); * * @param b * reorder buffer instance + * If NULL then, the function does nothing. * @return * None */ diff --git a/lib/rib/rte_rib.h b/lib/rib/rte_rib.h index bebb30f7d7cf..bafd2585ac69 100644 --- a/lib/rib/rte_rib.h +++ b/lib/rib/rte_rib.h @@ -265,6 +265,7 @@ rte_rib_find_existing(const char *name); * * @param rib * RIB object handle + * If NULL then, the function does nothing. * @return * None */ diff --git a/lib/rib/rte_rib6.h b/lib/rib/rte_rib6.h index 6f532265c657..a2e179ccb4b9 100644 --- a/lib/rib/rte_rib6.h +++ b/lib/rib/rte_rib6.h @@ -320,6 +320,7 @@ rte_rib6_find_existing(const char *name); * * @param rib * RIB object handle + * If NULL then, the function does nothing. * @return * None */ diff --git a/lib/sched/rte_sched.h b/lib/sched/rte_sched.h index 3c625ba1698a..d212ad5774e6 100644 --- a/lib/sched/rte_sched.h +++ b/lib/sched/rte_sched.h @@ -330,6 +330,7 @@ rte_sched_port_config(struct rte_sched_port_params *params); * * @param port * Handle to port scheduler instance + * If NULL then, the function does nothing. */ void rte_sched_port_free(struct rte_sched_port *port); diff --git a/lib/stack/rte_stack.h b/lib/stack/rte_stack.h index 321f4cec1a10..8c3bd4862711 100644 --- a/lib/stack/rte_stack.h +++ b/lib/stack/rte_stack.h @@ -215,6 +215,7 @@ rte_stack_create(const char *name, unsigned int count, int socket_id, * * @param s * Stack to free + * If NULL then, the function does nothing. */ void rte_stack_free(struct rte_stack *s); diff --git a/lib/telemetry/rte_telemetry.h b/lib/telemetry/rte_telemetry.h index 7bca8a9a49e2..af95fb4f150b 100644 --- a/lib/telemetry/rte_telemetry.h +++ b/lib/telemetry/rte_telemetry.h @@ -289,7 +289,7 @@ rte_tel_data_alloc(void); * * @param data * Pointer to container. - *. + * If NULL then, the function does nothing. */ void rte_tel_data_free(struct rte_tel_data *data); 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 From patchwork Sun Feb 20 18:21:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 107876 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 E7F66A00C2; Sun, 20 Feb 2022 19:22:25 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 20C7C41161; Sun, 20 Feb 2022 19:22:01 +0100 (CET) Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) by mails.dpdk.org (Postfix) with ESMTP id 4122B4115C for ; Sun, 20 Feb 2022 19:21:59 +0100 (CET) Received: by mail-pf1-f182.google.com with SMTP id i6so6765614pfc.9 for ; Sun, 20 Feb 2022 10:21:59 -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=PpwvHLHd9+fy62V9D2Gu0I2ntjXnX+NovVC5P1oK/eg=; b=gu4ShMwGKFYaCtPWJrNOfWOilKWAACkG2pTQChRs/1J3KVolll1zj4cpxPj9LLTpfe UN8zSxtwprHgEjAyDGEqxrio3hPGlxGvNzmGPirbmA9UBOVnyeIaEbPNkSeTMsaNEG6V Cu0RI9+qvrKW4S/45ehtB+csPjpwKEQ88ZUUTXomOM2dwGxtZwbLmuzwfoWxLibSE2la oAce+umCh/DugXMiBGVgqaniuZjxpeZP26PDYFvgWQvamgoqJMNDaRIoHdlQ0aD0RpE5 hotDpmkNP67BspJ2nFAffAUIHfUuAeLtf8SlExsU6Hw3BbleWXPenK78UQbdTL2lhNWb 0F4w== 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=PpwvHLHd9+fy62V9D2Gu0I2ntjXnX+NovVC5P1oK/eg=; b=Wc+f6nvWkU/QkBEHNxAT+xxRl5jfWfDBNvOcx4tKZxtIwrQnsLZaiZpJQYculCI+jJ qTTmSeyAxa56zj4b88YZemyGr8znJIYkhKOt6F8aLIilXSOcF7SVWYqk5LGH4ok/vzXc L+tPw8mY6esUZVADRgY4nAn/UPGb4QA3SJcfHx+4aM/wdJ6/PZtDbxKLo2AYZv3z9qQ5 VRaYEbT/cQOOHH/HZkn3Mql6bH41ezoGkXh+VgSNSnbyciKR6TMdZz3YlUJUK6SYXytx 631x7dA5GttInzMYiotooq8Klg6+eks+2U0HEs5LAkbNYJ9+wkjjO+VlHIzAJrZSo0Qm qW5A== X-Gm-Message-State: AOAM530IJbOWPLCKLDyWslgjlWxNYUQHx+14xDhD+2Q5rxiPK5LsbebH G7cxm1TY25XdUaDrkQwylXI0lf6mtC6HXcH4 X-Google-Smtp-Source: ABdhPJx9PspilzxsHKXnV8FL/IYwOlJQzvjPwfvfQl2T7Yz6A5/vHA0kq0LCzgUkLNMpHEtik/JN5Q== X-Received: by 2002:a63:c47:0:b0:371:3a2e:32d8 with SMTP id 7-20020a630c47000000b003713a2e32d8mr13278134pgm.281.1645381318214; Sun, 20 Feb 2022 10:21:58 -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.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Feb 2022 10:21:57 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Marko Kovacevic Subject: [PATCH v3 6/8] fips_validation: remove unnecessary NULL check Date: Sun, 20 Feb 2022 10:21:45 -0800 Message-Id: <20220220182147.9750-7-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 No need to check for null pointer here. Signed-off-by: Stephen Hemminger --- examples/fips_validation/fips_dev_self_test.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/fips_validation/fips_dev_self_test.c b/examples/fips_validation/fips_dev_self_test.c index 076e9de099c0..19af134bbe83 100644 --- a/examples/fips_validation/fips_dev_self_test.c +++ b/examples/fips_validation/fips_dev_self_test.c @@ -1523,8 +1523,7 @@ fips_dev_auto_test_uninit(uint8_t dev_id, struct fips_dev_auto_test_env *env) { rte_pktmbuf_free(env->mbuf); - if (env->op) - rte_crypto_op_free(env->op); + rte_crypto_op_free(env->op); rte_mempool_free(env->mpool); rte_mempool_free(env->op_pool); rte_mempool_free(env->sess_pool); From patchwork Sun Feb 20 18:21:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 107877 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 A1334A00C2; Sun, 20 Feb 2022 19:22:30 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2E0E441169; Sun, 20 Feb 2022 19:22:02 +0100 (CET) Received: from mail-pg1-f174.google.com (mail-pg1-f174.google.com [209.85.215.174]) by mails.dpdk.org (Postfix) with ESMTP id 7698140395 for ; Sun, 20 Feb 2022 19:22:00 +0100 (CET) Received: by mail-pg1-f174.google.com with SMTP id w37so5988192pga.7 for ; Sun, 20 Feb 2022 10:22:00 -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=Q8QyYl/xyznlGryI5tblav2fuGxmlHT14wjQN42pbxg=; b=XW2tngJVbaTldoA8aPZABHUYhqe0i1Qu5zV8oontKBCvVPXRiSi85QKSqS+ZfdCAzF YlHH23ogIHSrVeg4GS5CBeQk+k/VrXfQ+kR2pqT4gP558VTx94t995TEWgyH21zBiZpg ia1yKf3O7KkzUv9hCe7+UT4zMYVQIRRhYTNahZ4J60ATW5XKPJ/lkhD2YmGLPHTzNpPs JQMBPg5ZR5trRJEOSLHKtJjNUgDR9yOqqi5MBJwFv/cdSdy6ABJCE/bqAZlKDCZwqWr2 y0ZSLosZbKQCVFlVtLYoLtCG9w8jWfI0zRQm+SB/bcXYm6yPc2NhBlHnYAYCrxrCN3I0 iscA== 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=Q8QyYl/xyznlGryI5tblav2fuGxmlHT14wjQN42pbxg=; b=ZPfUCTilClb4GGQBQw94cBAGDLK/0edeZMcp5YiMgU/+mCnXFMFcSnU85RdmAOgsAW Iey7O284FKcaACxDngulvwLH3FsH73DZEnD14XosiYIsXw1ypn14gzIEwglJKxcVxnU1 VesYQeboXVs+wqiH8wTOWnNX9xAyE/po3CGJJwGhw0WrU60/hrRV8BU4BBG/jSgSdwYT m/YcAAZDT89mHAlE4mNSSMVDQMCfn5tSNa1RQzY50FVpUYLyUNuxh2GuHG6zgGpUCIiF EKSitOz2Lu7RPc+jllSMBdJ6PoUreVbiQS9zMhra0nQ2ySdKbvtnDA2RbADbpyyxLk80 nrdA== X-Gm-Message-State: AOAM533x1hbU0qFofOfU8hVoqo9hmpME4J/HIyTO2cOjtfUjp/nE/BpK CtFoX49K2VtjYERHV7wkUwTJUlusmTH3gOZg X-Google-Smtp-Source: ABdhPJzTMY7osBjJL1B2mQT0XdejQdSj+HaKkflg16ny7jfRS7bxXvKD8d1Lfd9mtjufAlu5zcoi4A== X-Received: by 2002:a65:5b41:0:b0:374:3159:47be with SMTP id y1-20020a655b41000000b00374315947bemr3124446pgr.254.1645381319343; Sun, 20 Feb 2022 10:21:59 -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.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Feb 2022 10:21:58 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Harry van Haaren Subject: [PATCH v3 7/8] event/sw: remove unnecessary NULL check Date: Sun, 20 Feb 2022 10:21:46 -0800 Message-Id: <20220220182147.9750-8-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 The XXX_free() functions already handle NULL pointer. Signed-off-by: Stephen Hemminger --- drivers/event/sw/sw_evdev.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/event/sw/sw_evdev.c b/drivers/event/sw/sw_evdev.c index ba82a80385b6..f93313b31b5c 100644 --- a/drivers/event/sw/sw_evdev.c +++ b/drivers/event/sw/sw_evdev.c @@ -166,8 +166,7 @@ sw_port_setup(struct rte_eventdev *dev, uint8_t port_id, snprintf(buf, sizeof(buf), "sw%d_p%u_%s", dev->data->dev_id, port_id, "rx_worker_ring"); struct rte_event_ring *existing_ring = rte_event_ring_lookup(buf); - if (existing_ring) - rte_event_ring_free(existing_ring); + rte_event_ring_free(existing_ring); p->rx_worker_ring = rte_event_ring_create(buf, MAX_SW_PROD_Q_DEPTH, dev->data->socket_id, @@ -186,8 +185,7 @@ sw_port_setup(struct rte_eventdev *dev, uint8_t port_id, snprintf(buf, sizeof(buf), "sw%d_p%u, %s", dev->data->dev_id, port_id, "cq_worker_ring"); existing_ring = rte_event_ring_lookup(buf); - if (existing_ring) - rte_event_ring_free(existing_ring); + rte_event_ring_free(existing_ring); p->cq_worker_ring = rte_event_ring_create(buf, conf->dequeue_depth, dev->data->socket_id, From patchwork Sun Feb 20 18:21:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 107878 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 7D806A00C2; Sun, 20 Feb 2022 19:22:35 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2BEB741170; Sun, 20 Feb 2022 19:22:04 +0100 (CET) Received: from mail-pg1-f177.google.com (mail-pg1-f177.google.com [209.85.215.177]) by mails.dpdk.org (Postfix) with ESMTP id B2F3441168 for ; Sun, 20 Feb 2022 19:22:01 +0100 (CET) Received: by mail-pg1-f177.google.com with SMTP id 27so7150691pgk.10 for ; Sun, 20 Feb 2022 10:22:01 -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=wiCeMYv7+h2jiWHP785UN56RTEtMBsuqnMSE63mZVu0=; b=czZGQhT/bODICAekyjudC2x8zYsQxA8D+Lk7GrFeELKCqlAy37yqGgMtpagki+wJRG jx6KEjBpllPDFwRpX5naDXuf/paA6uofTbBlGD0W+bUP3KJ2m3Gqcy645Ay0zSUV3LtH y1m5fYtNsaF7qg5ik19UAs9DATIk/GIeZT/qhIErE+94zhNgTmsKZhVLF5Xp7QdQ213Q NFJhetnxVuS6K+RgTG6GDWeonJs0rI2EWw2dmXgCd11SSu7wOLMb6Wa+Gdc4I2TDLWw2 J/6p05vmRopHyiSwE6RUzRSlzyZQEftXPBvQYcBxQgxBXDO0j2bGkJkKK3MOIaiPRMWL QHBg== 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=wiCeMYv7+h2jiWHP785UN56RTEtMBsuqnMSE63mZVu0=; b=oGlTLGJ0psMslvcapRGn6vfIbF7G505XqoLe1+V2CKQi1bO6Plm8RvyAqzH65/alU6 QClT0TARPh1RIB9ytiQfKv5ItKNnzf+fz5JupXhZPHB4vmAVqZBXuS/FlixrXzMA1LM9 qdmZbwO/2lhVBOc0t5HrgQDDzJiWj9oWO65aa46tkxmF72DZZGGfIygI1tkAIY5R72Tj 6KTEzKZUc8Ez9Q22DGl1IrnrJFAe0ZOpiFYX4aXed5k1xSOX5pdk+VLnJsFeL2jM2RtD M+FmGUT8blqSjn7Q+FGFvY+kv1f1YYMp11Tc2AqU4ZdB8kbEsPIr0v35ixHuHarL1HTY EBsA== X-Gm-Message-State: AOAM532527BsNAkoydnCK/7w/J+IpRRURpHyciJNesMn16zh3WFaQvs2 RjwYl2dXOuT0BzDmIZHLw0ZQN3eDuQlgAvnr X-Google-Smtp-Source: ABdhPJwzfe8iyW20ajo/JXDhiVB6X0zBy/snJLXiRNKKx+KlHQ/AMYV/uO2BebfyzttLCrHXgveTPg== X-Received: by 2002:a63:445f:0:b0:373:d43f:2b42 with SMTP id t31-20020a63445f000000b00373d43f2b42mr9841614pgk.125.1645381320610; Sun, 20 Feb 2022 10:22:00 -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.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Feb 2022 10:21:59 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Cristian Dumitrescu Subject: [PATCH v3 8/8] pipeline: remove unnecessary checks for NULL pointer before free Date: Sun, 20 Feb 2022 10:21:47 -0800 Message-Id: <20220220182147.9750-9-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 This library (mostly) uses convention that allows caller to pass NULL. Signed-off-by: Stephen Hemminger --- lib/pipeline/rte_port_in_action.h | 6 ++++-- lib/pipeline/rte_swx_ctl.c | 3 +-- lib/pipeline/rte_swx_ctl.h | 1 + lib/pipeline/rte_swx_pipeline.c | 6 ++---- lib/pipeline/rte_swx_pipeline.h | 1 + 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/pipeline/rte_port_in_action.h b/lib/pipeline/rte_port_in_action.h index d6b063cf58a7..9debb9269297 100644 --- a/lib/pipeline/rte_port_in_action.h +++ b/lib/pipeline/rte_port_in_action.h @@ -181,8 +181,9 @@ rte_port_in_action_profile_create(uint32_t socket_id); * * @param[in] profile * Input port action profile handle (needs to be valid). + * If NULL then, the function does nothing. * @return - * Zero on success, non-zero error code otherwise. + * always zero. */ __rte_experimental int @@ -259,8 +260,9 @@ rte_port_in_action_create(struct rte_port_in_action_profile *profile, * * @param[in] action * Handle to input port action object (needs to be valid). + * If NULL then, the function does nothing. * @return - * Zero on success, non-zero error code otherwise. + * Always zero. */ __rte_experimental int diff --git a/lib/pipeline/rte_swx_ctl.c b/lib/pipeline/rte_swx_ctl.c index f52ccffd75a4..710e89a46a26 100644 --- a/lib/pipeline/rte_swx_ctl.c +++ b/lib/pipeline/rte_swx_ctl.c @@ -1046,8 +1046,7 @@ table_state_free(struct rte_swx_ctl_pipeline *ctl) struct rte_swx_table_state *ts = &ctl->ts_next[selector_base_index + i]; /* Table object. */ - if (ts->obj) - rte_swx_table_selector_free(ts->obj); + rte_swx_table_selector_free(ts->obj); } /* For each learner table, free its table state. */ diff --git a/lib/pipeline/rte_swx_ctl.h b/lib/pipeline/rte_swx_ctl.h index 82e62e70a7c3..501731d54724 100644 --- a/lib/pipeline/rte_swx_ctl.h +++ b/lib/pipeline/rte_swx_ctl.h @@ -1285,6 +1285,7 @@ rte_swx_ctl_meter_stats_read(struct rte_swx_pipeline *p, * * @param[in] ctl * Pipeline control handle. + * If NULL then, the function does nothing. */ __rte_experimental void diff --git a/lib/pipeline/rte_swx_pipeline.c b/lib/pipeline/rte_swx_pipeline.c index 868010303c73..0177a45c4486 100644 --- a/lib/pipeline/rte_swx_pipeline.c +++ b/lib/pipeline/rte_swx_pipeline.c @@ -8672,16 +8672,14 @@ table_state_build_free(struct rte_swx_pipeline *p) struct rte_swx_table_state *ts = &p->table_state[p->n_tables + i]; /* ts->obj. */ - if (ts->obj) - rte_swx_table_selector_free(ts->obj); + rte_swx_table_selector_free(ts->obj); } for (i = 0; i < p->n_learners; i++) { struct rte_swx_table_state *ts = &p->table_state[p->n_tables + p->n_selectors + i]; /* ts->obj. */ - if (ts->obj) - rte_swx_table_learner_free(ts->obj); + rte_swx_table_learner_free(ts->obj); /* ts->default_action_data. */ free(ts->default_action_data); diff --git a/lib/pipeline/rte_swx_pipeline.h b/lib/pipeline/rte_swx_pipeline.h index 77141bd3415b..51817159b154 100644 --- a/lib/pipeline/rte_swx_pipeline.h +++ b/lib/pipeline/rte_swx_pipeline.h @@ -912,6 +912,7 @@ rte_swx_pipeline_flush(struct rte_swx_pipeline *p); * * @param[in] p * Pipeline handle. + * If NULL then, the function does nothing. */ __rte_experimental void