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 BDFC8A00C4; Sun, 20 Feb 2022 00:43:38 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3B7E84114A; Sun, 20 Feb 2022 00:43:30 +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 BD2C7410FA for ; Sun, 20 Feb 2022 00:43:27 +0100 (CET) Received: by mail-pj1-f50.google.com with SMTP id q8-20020a17090a178800b001bc299b8de1so77333pja.1 for ; Sat, 19 Feb 2022 15:43:27 -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=5bkjpeb21Hxzg2D1beclwbDINNIjoRq9zO1peTwQdAd4ViVqf5XFh3fq2uEi71asuR EXIOI8PRMZGyeW6/EKuNr+F3u0xHkzIC1ugXPSGlxn6+27w+UhGoM670WdUuYsUgqXL7 rHxYKY5G1vw9fWey2YzH/mZ5LxanV1W0MRzaJD+DPRNlSz9WuoWi0FIfa5dnpCZvvXIp mkAqA2EfPGP08RuVw/LwcxGY1bP2A6uLxx4Q3Nuw6/Z3foGLGA1rWsgv86iPvcZtrLRd KK+SMo8UmhO7Zc4zw+rO3RtfhYQ0tZISCbP1iKPFSo1gc488wMjYSKDsRgZlHeZ3tQ5Z omKg== 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=lgfPHMLT/jvWzb8XIL8bkUbRI4eLl3OdRdzGwW6Ijl6kU7R8aqk2v92sH4VYwS2AAZ FVdHqt184BzGKNKHSJfRk2YH1axf4NxoZHZyHTf41l2ciCrlxrGSoLjd5qIFSXvhzR31 PAUHDFJrCKdfZP2HcvTji9c71TyQQvQIp9j29s7tyIzMpoS6l7WWISXdWvuBX/YZrJPb pNKPJwhw38mAtAR3cX8R0BK0Zz2UBeNDRvv3H0CYnfKp+kUKng2lBHnzeSd3k9Nt4gh/ OabVPMYNlpZF8AGkyBCz/FSGqkLAOKek5umk8ck+hN4QgRhfegpfrRF2nDCoJe/sBNu5 396A== X-Gm-Message-State: AOAM530jl48axAiSlAGT5VlmLR05BE/sS6o5oV1gUpFNFdWztLq4IFGY UAige7xtqnr26BxwGAruMmpHLCY/6Ni9ilEi X-Google-Smtp-Source: ABdhPJwkFk+6xxrDV+5BtQ53lRsY5aaMiE8T6dWWEwBD7mmGOtYOy7jXs5kC9FxITrRdqy++jdTTVQ== X-Received: by 2002:a17:902:70c8:b0:14f:2d92:baaa with SMTP id l8-20020a17090270c800b0014f2d92baaamr13049800plt.162.1645314206689; Sat, 19 Feb 2022 15:43:26 -0800 (PST) Received: from hermes.local (204-195-112-199.wavecable.com. [204.195.112.199]) by smtp.gmail.com with ESMTPSA id v17-20020a17090a459100b001b93ef45c13sm3057268pjg.55.2022.02.19.15.43.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Feb 2022 15:43:26 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Konstantin Ananyev , Cristian Dumitrescu Subject: [PATCH 2/3] acl: remove unncessary null checks in calls to rte_acl_free() Date: Sat, 19 Feb 2022 15:43:21 -0800 Message-Id: <20220219234322.61309-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220219234322.61309-1-stephen@networkplumber.org> References: <20220219234322.61309-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