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 AA168A00C2; Sun, 20 Feb 2022 01:51:57 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DE1234114A; Sun, 20 Feb 2022 01:51:49 +0100 (CET) Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) by mails.dpdk.org (Postfix) with ESMTP id 9284F410FA for ; Sun, 20 Feb 2022 01:51:46 +0100 (CET) Received: by mail-pf1-f181.google.com with SMTP id y11so5495174pfa.6 for ; Sat, 19 Feb 2022 16:51:46 -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=53CoHJyLjYlG7I1seb/eB4I35oWbMKh5rP4Ydzd4s4Ic5WR0yMxJF315nbIcMQGhj+ QJ3+XeKl+uCdl5i0plnwM1ETq6/2fCmRBCzI+CF3Y4FJAMd31wmfKgEfOiD6p2hQbtNp i4hkldlq8McjaJvKa3OROB8UD6fwSO6Kd/ELmG21PG/mbzrfSmQX9Eq0Zx7Hq/CRrpx6 IAMTYyriNdnbbW0SwcMHRyHXVv9hErj38MlVZY2g5FRF2kPkfJCw7oN38ITE3R+5iyYk hfBN4lxaplKAW1WfRD9Xnaczl3uuQtAAH2wuxcLb+2TB03PiKb5XwG0q4t7vfLw5s4Yx GRKw== 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=E6Dw+1mYShrHixSefRJIqo4NbjOK0dhAk5nqdmocHbDF2/u9oVnWdlCtqA04MQvTdg uqiW1Pljy0Fh+4miWjOEo3LY1LyncMvaZz5j5bjTTL8yhD7QPEOunWclyrspDCCHQXWw I5OkQcklXpf/vP87DVui03vdAV1HPMgNC4Yedmu/YZzjCa94yP3ChqcrNCpyMhradYFp jlb/6dDBcJN3HsEmYb+vN3CMgqPzeDFCW0urn0XzJS71vcFCRTtx9sUEf0/pE0zPcDjZ +oUC+WKUrxVK6f7QQ5F91wiZbzl4z0rsfTmQd0XDEN4uOA9vHT6U/sHgU0lKLcfyor5v /IMg== X-Gm-Message-State: AOAM531e2PSBgdvBormEzs120D1ktBzvscU5tpZBr3YeNOQFUPtemNBs SoXMBOuRHNp8HOVYtXlUO6j8i7TA89rC/TWl X-Google-Smtp-Source: ABdhPJwv/PpX3uohlJo3ib1zIMrleCUO/DBBxyJZK7jnfJMToN5vo/weYYj94xEQtXk/wXoY+YhHVA== X-Received: by 2002:aa7:88cb:0:b0:4df:7b9e:1cc3 with SMTP id k11-20020aa788cb000000b004df7b9e1cc3mr14387610pff.82.1645318305535; Sat, 19 Feb 2022 16:51:45 -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.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Feb 2022 16:51:44 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Konstantin Ananyev , Cristian Dumitrescu Subject: [PATCH v2 2/7] acl: remove unnecessary null checks Date: Sat, 19 Feb 2022 16:51:35 -0800 Message-Id: <20220220005140.78713-3-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 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