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 504EC42818; Thu, 23 Mar 2023 02:04:40 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 16B4542686; Thu, 23 Mar 2023 02:04:35 +0100 (CET) Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) by mails.dpdk.org (Postfix) with ESMTP id A010840156 for ; Thu, 23 Mar 2023 02:04:32 +0100 (CET) Received: by mail-pl1-f174.google.com with SMTP id w4so12806634plg.9 for ; Wed, 22 Mar 2023 18:04:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; t=1679533471; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bPr8BL2VBsxWx5DY3IF2xqXEdHHjSQDqk+BFBC4P0wE=; b=mwNGTNy7YE8hyktEmwdjBdJ767MOH/X9poPMtVa1FdVtEXm/GFkXA0nVCNrnmh6Fs/ R5UDnP49pBmRptUCqdUDDDa46RussjrH1d3Z05XWZz0QHVv41ZQY7Qj/VFL32BOJrhth ZD4n5ZSuLW8GEETAFYzZEbGvvkjn/ek1ZiwxukNUx+/j4XGKbH4WaB2C1V4v/nooGlxc tkejeo1MSns9WBJBNjd1xsA6LiRdsFnP2fA+cPbY/xvFbvkTyHT0/4uXv4gs1KJGG0Qi fXqF+tLmPYrb1i0A3W5soyeHhvGU4bCOkJ54lCM+IG3bA7BzATMDCur0m2Ji+1bazEai BR8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679533471; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bPr8BL2VBsxWx5DY3IF2xqXEdHHjSQDqk+BFBC4P0wE=; b=4JTacN/ihN/pE2rWahADgV6osKu4/IMoFDtN4jJ/Vn1fzNqhnSqqv2JNp/RnoDwUDe UxNueJ0cJKuDOq89FNNb/QCXz14nFnYKMU4Zm0Eetdx6J8Q5ch5peaC2AT5y9W4M9eb1 JJvONMlbxtO4tA75wLkuVRRWNvN5NaJS1stxcK/1ayMBo63vp+DtNohzLNjycIQSwQPB YdZFXxzBA53mqPT/NoQKoRVYta93yeo61KY6I6wa3tAxkfBh612fY5VejoQfhBlFVPMW aLiLI/IkWpiwweH8oraYm9qPtWmKInJdB1fudMdK8HjuD5I0T3HxKn1NCkSXDfQWj6Oe xCFg== X-Gm-Message-State: AO0yUKWMp48a9fi5sCGR6RYcDrLGAAZQUlb13RW1YpzcMB1/vUhO6fPq Lx/Zzq2We/zgkqsUFQ/kQjzgtT2iQymTZ5D/wUDsQg== X-Google-Smtp-Source: AK7set+HXH0oocVfr2rpIKHxqHbrw0gC+/HM9y+A/n7qQ2Y3KbVTO5Z4fgxt/dDI6qblBaAKwFMsBg== X-Received: by 2002:a17:90b:4a11:b0:23d:3c7b:8684 with SMTP id kk17-20020a17090b4a1100b0023d3c7b8684mr5380495pjb.41.1679533471534; Wed, 22 Mar 2023 18:04:31 -0700 (PDT) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id l9-20020a17090b078900b0023b4c0ef8f2sm135206pjz.20.2023.03.22.18.04.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Mar 2023 18:04:31 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Srikanth Yalavarthi Subject: [PATCH 1/4] mldev: remove unnecessary null free checks Date: Wed, 22 Mar 2023 18:04:25 -0700 Message-Id: <20230323010428.64020-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230323010428.64020-1-stephen@networkplumber.org> References: <20230323010428.64020-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 These are places where mldev is doing unnecessary checks for calling free() style functions. Signed-off-by: Stephen Hemminger --- app/test-mldev/test_device_ops.c | 6 ++---- app/test-mldev/test_inference_common.c | 24 ++++++++---------------- app/test-mldev/test_model_ops.c | 6 ++---- lib/mldev/rte_mldev.c | 3 +-- 4 files changed, 13 insertions(+), 26 deletions(-) diff --git a/app/test-mldev/test_device_ops.c b/app/test-mldev/test_device_ops.c index be0c5f0780d9..81b3ca18f36b 100644 --- a/app/test-mldev/test_device_ops.c +++ b/app/test-mldev/test_device_ops.c @@ -70,8 +70,7 @@ test_device_setup(struct ml_test *test, struct ml_options *opt) return 0; error: - if (test_device != NULL) - rte_free(test_device); + rte_free(test_device); return ret; } @@ -84,8 +83,7 @@ test_device_destroy(struct ml_test *test, struct ml_options *opt) RTE_SET_USED(opt); t = ml_test_priv(test); - if (t != NULL) - rte_free(t); + rte_free(t); } static int diff --git a/app/test-mldev/test_inference_common.c b/app/test-mldev/test_inference_common.c index eba37c50e96c..af831fc1bf4c 100644 --- a/app/test-mldev/test_inference_common.c +++ b/app/test-mldev/test_inference_common.c @@ -492,8 +492,7 @@ test_inference_setup(struct ml_test *test, struct ml_options *opt) return 0; error: - if (test_inference != NULL) - rte_free(test_inference); + rte_free(test_inference); return ret; } @@ -506,8 +505,7 @@ test_inference_destroy(struct ml_test *test, struct ml_options *opt) RTE_SET_USED(opt); t = ml_test_priv(test); - if (t != NULL) - rte_free(t); + rte_free(t); } int @@ -748,8 +746,7 @@ ml_inference_iomem_destroy(struct ml_test *test, struct ml_options *opt, uint16_ /* destroy io pool */ sprintf(mp_name, "ml_io_pool_%d", fid); mp = rte_mempool_lookup(mp_name); - if (mp != NULL) - rte_mempool_free(mp); + rte_mempool_free(mp); } int @@ -776,8 +773,7 @@ ml_inference_mem_destroy(struct ml_test *test, struct ml_options *opt) RTE_SET_USED(opt); /* release op pool */ - if (t->op_pool != NULL) - rte_mempool_free(t->op_pool); + rte_mempool_free(t->op_pool); } static bool @@ -1088,11 +1084,9 @@ ml_inference_stats_get(struct ml_test *test, struct ml_options *opt) print_line(80); /* release buffers */ - if (t->xstats_map) - rte_free(t->xstats_map); + rte_free(t->xstats_map); - if (t->xstats_values) - rte_free(t->xstats_values); + rte_free(t->xstats_values); /* print end-to-end stats */ freq = rte_get_tsc_hz(); @@ -1129,11 +1123,9 @@ ml_inference_stats_get(struct ml_test *test, struct ml_options *opt) return 0; error: - if (t->xstats_map) - rte_free(t->xstats_map); + rte_free(t->xstats_map); - if (t->xstats_values) - rte_free(t->xstats_values); + rte_free(t->xstats_values); return ret; } diff --git a/app/test-mldev/test_model_ops.c b/app/test-mldev/test_model_ops.c index 0202b31190f8..5bbbcb1a6c0b 100644 --- a/app/test-mldev/test_model_ops.c +++ b/app/test-mldev/test_model_ops.c @@ -93,8 +93,7 @@ test_model_ops_setup(struct ml_test *test, struct ml_options *opt) return 0; error: - if (test_model_ops != NULL) - rte_free(test_model_ops); + rte_free(test_model_ops); return ret; } @@ -107,8 +106,7 @@ test_model_ops_destroy(struct ml_test *test, struct ml_options *opt) RTE_SET_USED(opt); t = ml_test_priv(test); - if (t != NULL) - rte_free(t); + rte_free(t); } static int diff --git a/lib/mldev/rte_mldev.c b/lib/mldev/rte_mldev.c index 50ebeb1bfe8d..f5904a0d4a90 100644 --- a/lib/mldev/rte_mldev.c +++ b/lib/mldev/rte_mldev.c @@ -836,8 +836,7 @@ rte_ml_op_pool_create(const char *name, unsigned int nb_elts, unsigned int cache void rte_ml_op_pool_free(struct rte_mempool *mempool) { - if (mempool != NULL) - rte_mempool_free(mempool); + rte_mempool_free(mempool); } uint16_t -- 2.39.2