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 4040643000; Mon, 7 Aug 2023 22:43:16 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EF938410D3; Mon, 7 Aug 2023 22:43:14 +0200 (CEST) Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) by mails.dpdk.org (Postfix) with ESMTP id DDF3440A8B for ; Mon, 7 Aug 2023 22:43:13 +0200 (CEST) Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-1bbff6b2679so31987515ad.1 for ; Mon, 07 Aug 2023 13:43:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20221208.gappssmtp.com; s=20221208; t=1691440992; x=1692045792; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=sOpO5vWkqHQaK3h6DZOKMW5yTfhD4vkBBmi4dbVMc54=; b=CqpvCwVC74oU5ACi4cF/ihJIoCvzMyERR4uZcKDLLmaSU2otboOu7ERRfPjHCE59r3 0MbkoTBjABtAjEN6JohdlRgwFDndRkumIkNEuqXZd1SfEhIc9ekHnN8YDRagHA5M6l1t P6QtjG/jU8S3wf82+WoZelNlKeyChkmzWJTXe1MYTwc6IjzqsARbEHs/rJCJ6bX73+OJ ZJA0c0/oNHUE/abv369NGRx1szbdQBwLs5Heu4lk4459xGJ9AgUg6FY3m4Jc4HQGDzq9 c7YqZ2XA7ft6RWtT7xDo1XZSyyZMK0kwN7klyW7+0DPYAqi49cY7xXEqYzTubLkt+zG+ c+0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691440992; x=1692045792; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=sOpO5vWkqHQaK3h6DZOKMW5yTfhD4vkBBmi4dbVMc54=; b=LMyKyD0yboYJY4V1aq+0QOylZirgD/aW49D69AIX5OkL+oVeldF9kY+NmWvwxYpfMo x7SwHw6BavP+fm0TdQFGAAcjg9gK/fbBxwH37zCEaOYLQaevAHZIKSc5szoC/gAoijZA 14TheCfGjyLoGndz8BI9diNb250+R2O/H74ICbSry8ykhvYv372I9MYLKq1HhdgrdoSQ wmI7MUQWvhMWaygzyK6o6ZytRz2r/Qh/NDC+MGS/5UVDv3ZwZDj4g49Luu4zwNqR9ZZ3 TLVZPx+jLwAU2UM4oAGYrrcr0Yw6Xe0xiTq7p4YeG8jWvVLz6B26mZk4YR9zTy32gM5t bEzA== X-Gm-Message-State: AOJu0Yx3WsKGhWCjd1ur01MwmvUdEidOyKDa5WXSPfxs9ZP3nUYnC/fm 9wEW3E7JSeAmvDSjXPYnTkyo2VfSIcIu3fr0a0oFSzMJ X-Google-Smtp-Source: AGHT+IFlmwoy1V/ZDzs/tNFsAwo9TxtLgyvkirUFTUeVKnMw3KCq2ckcLpoIIfOYsO1OyBgInpC3xQ== X-Received: by 2002:a17:902:c103:b0:1b1:753a:49ce with SMTP id 3-20020a170902c10300b001b1753a49cemr7335978pli.53.1691440992504; Mon, 07 Aug 2023 13:43:12 -0700 (PDT) Received: from hermes.lan (204-195-127-207.wavecable.com. [204.195.127.207]) by smtp.gmail.com with ESMTPSA id v12-20020a170902b7cc00b001ac741dfd29sm7307556plz.295.2023.08.07.13.43.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 13:43:12 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [PATCH] app/proc-info: remove unnecessary rte_malloc Date: Mon, 7 Aug 2023 13:43:10 -0700 Message-Id: <20230807204310.117986-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.2 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 Better to use malloc() which is faster and has more error checking, as is done already for statistics. Fixes: 077c546704da ("app/proc_info: add metrics displaying") Signed-off-by: Stephen Hemminger --- app/proc-info/main.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/app/proc-info/main.c b/app/proc-info/main.c index 88cee0ca487b..7bc43b8c793e 100644 --- a/app/proc-info/main.c +++ b/app/proc-info/main.c @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include @@ -909,24 +908,23 @@ metrics_display(int port_id) return; } - metrics = rte_malloc("proc_info_metrics", - sizeof(struct rte_metric_value) * len, 0); + metrics = malloc(sizeof(struct rte_metric_value) * len); if (metrics == NULL) { printf("Cannot allocate memory for metrics\n"); return; } - names = rte_malloc(NULL, sizeof(struct rte_metric_name) * len, 0); + names = malloc(sizeof(struct rte_metric_name) * len); if (names == NULL) { printf("Cannot allocate memory for metrics names\n"); - rte_free(metrics); + free(metrics); return; } if (len != rte_metrics_get_names(names, len)) { printf("Cannot get metrics names\n"); - rte_free(metrics); - rte_free(names); + free(metrics); + free(names); return; } @@ -938,8 +936,8 @@ metrics_display(int port_id) ret = rte_metrics_get_values(port_id, metrics, len); if (ret < 0 || ret > len) { printf("Cannot get metrics values\n"); - rte_free(metrics); - rte_free(names); + free(metrics); + free(names); return; } @@ -948,8 +946,8 @@ metrics_display(int port_id) printf("%s: %"PRIu64"\n", names[i].name, metrics[i].value); printf("%s############################\n", nic_stats_border); - rte_free(metrics); - rte_free(names); + free(metrics); + free(names); } #endif -- 2.39.2