eal: fix telemetry log type on registration failure
authorDavid Marchand <david.marchand@redhat.com>
Tue, 6 Apr 2021 09:25:45 +0000 (11:25 +0200)
committerDavid Marchand <david.marchand@redhat.com>
Thu, 8 Apr 2021 16:31:58 +0000 (18:31 +0200)
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 <david.marchand@redhat.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
lib/librte_eal/freebsd/eal.c
lib/librte_eal/linux/eal.c

index 32442e5..5544701 100644 (file)
@@ -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)
index abbb537..9b47fef 100644 (file)
@@ -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)