From 3731e08438a1380edf70e0f76e63cca13145fd7e Mon Sep 17 00:00:00 2001 From: Lars Erik Wik Date: Thu, 21 Nov 2024 16:24:43 +0100 Subject: [PATCH] Fixed compiler warning -Werror=enum-int-mismatch The function LogToSystemLog now takes an int as the log level, although the desired type would be the enum "LogLevel". For some C compilers, the last required argument must be self-promoting: that is, the default promotions must not change its type (this is actually an ISO C requirement). However, enums promote to an int. Thus, we cannot use them and must use int instead. Ticket: None Changelog: None Signed-off-by: Lars Erik Wik Co-authored-by: Craig Comstock --- libutils/logging.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libutils/logging.h b/libutils/logging.h index 1eed9b4f..2a77951f 100644 --- a/libutils/logging.h +++ b/libutils/logging.h @@ -141,10 +141,18 @@ void LogToSystemLog(const char *msg, LogLevel level); * log level argument and added to the structured log message. * @note Only the formatted string from the pair with the "MESSAGE" key is * logged on platforms that does not support structured logging. + * + * The function takes an int as the log level, although the desired type + * would be the enum "LogLevel". For some C compilers, the last required + * argument must be self-promoting: that is, the default promotions must + * not change its type (this is actually an ISO C requirement). However, + * enums promote to an int. Thus, we cannot use them and must use int + * instead. + * * @param[in] level Log level. * @param[in] vararg Variable-length argument containing key-value pairs. */ -void LogToSystemLogStructured(LogLevel level, ...); +void LogToSystemLogStructured(int level, ...); /** * This function is here, in order to help implement a CodeQL query for