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 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 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 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++) { -- 2.34.1