From 551b29a714b81733da31a9495aa0d8554448c83a Mon Sep 17 00:00:00 2001 From: David Marchand Date: Tue, 6 Apr 2021 11:25:45 +0200 Subject: [PATCH] eal: fix telemetry log type on registration failure rte_log_register_type_and_pick_level() returns an int. Casting to a uin32_t will make us miss the -1 passed in case of failure. Fallback to EAL log type like RTE_LOG_REGISTER. Fixes: 37b881a96194 ("telemetry: use log function from pointer") Signed-off-by: David Marchand Acked-by: Bruce Richardson --- lib/librte_eal/freebsd/eal.c | 4 +++- lib/librte_eal/linux/eal.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/librte_eal/freebsd/eal.c b/lib/librte_eal/freebsd/eal.c index 32442e5ba6..5544701f20 100644 --- a/lib/librte_eal/freebsd/eal.c +++ b/lib/librte_eal/freebsd/eal.c @@ -941,8 +941,10 @@ rte_eal_init(int argc, char **argv) return -1; } if (!internal_conf->no_telemetry) { - uint32_t tlog = rte_log_register_type_and_pick_level( + int tlog = rte_log_register_type_and_pick_level( "lib.telemetry", RTE_LOG_WARNING); + if (tlog < 0) + tlog = RTE_LOGTYPE_EAL; if (rte_telemetry_init(rte_eal_get_runtime_dir(), rte_version(), &internal_conf->ctrl_cpuset, rte_log, tlog) != 0) diff --git a/lib/librte_eal/linux/eal.c b/lib/librte_eal/linux/eal.c index abbb537746..9b47fef6f8 100644 --- a/lib/librte_eal/linux/eal.c +++ b/lib/librte_eal/linux/eal.c @@ -1314,8 +1314,10 @@ rte_eal_init(int argc, char **argv) return -1; } if (!internal_conf->no_telemetry) { - uint32_t tlog = rte_log_register_type_and_pick_level( + int tlog = rte_log_register_type_and_pick_level( "lib.telemetry", RTE_LOG_WARNING); + if (tlog < 0) + tlog = RTE_LOGTYPE_EAL; if (rte_telemetry_init(rte_eal_get_runtime_dir(), rte_version(), &internal_conf->ctrl_cpuset, rte_log, tlog) != 0) -- 2.20.1