]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
logging: move severity_chars to fix compiler warning
authorLuke Valenta <lvalenta@cloudflare.com>
Tue, 7 Nov 2023 19:39:40 +0000 (14:39 -0500)
committerMiroslav Lichvar <mlichvar@redhat.com>
Wed, 8 Nov 2023 14:09:03 +0000 (15:09 +0100)
logging.c

index b929fcbd94757ed9cac9f5fec01f3ad8ab471617..ec9ec53882c0305ad23144517c8a635f056af0a6 100644 (file)
--- a/logging.c
+++ b/logging.c
@@ -68,9 +68,6 @@ static struct LogFile logfiles[MAX_FILELOGS];
 /* Global prefix for debug messages */
 static char *debug_prefix;
 
-/* Log severity to character mapping (debug, info, warn, err, fatal) */
-static const char severity_chars[LOGS_FATAL - LOGS_DEBUG + 1] = {'D', 'I', 'W', 'E', 'F'};
-
 /* ================================================== */
 /* Init function */
 
@@ -159,9 +156,13 @@ void LOG_Message(LOG_Severity severity,
       fprintf(file_log, "%s ", buf);
     }
 #if DEBUG > 0
-    if (log_min_severity <= LOGS_DEBUG)
+    if (log_min_severity <= LOGS_DEBUG) {
+      /* Log severity to character mapping (debug, info, warn, err, fatal) */
+      const char severity_chars[LOGS_FATAL - LOGS_DEBUG + 1] = {'D', 'I', 'W', 'E', 'F'};
+
       fprintf(file_log, "%c:%s%s:%d:(%s) ", severity_chars[severity - LOGS_DEBUG],
               debug_prefix, filename, line_number, function_name);
+    }
 #endif
   }