From a66bed74e641e4b62b05ef198d3a9102a07d3db1 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Mon, 7 Aug 2023 13:43:10 -0700 Subject: [PATCH] app/procinfo: remove unnecessary rte_malloc [ upstream commit cfe29906c69bedb5f87dadcc02703ce46e80f37e ] Better to use malloc() which is faster than rte_malloc() and has more error checking, as is done already for statistics. Fixes: 077c546704da ("app/proc_info: add metrics displaying") Signed-off-by: Stephen Hemminger Acked-by: Chengwen Feng --- 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 40bfbefad8..befb90a2be 100644 --- a/app/proc-info/main.c +++ b/app/proc-info/main.c @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include @@ -602,24 +601,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; } @@ -631,8 +629,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; } @@ -641,8 +639,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); } static void