From 3b69a51ff85653586f42dde147158f7b4acde1a6 Mon Sep 17 00:00:00 2001 From: Doug Nazar Date: Fri, 22 Jul 2022 12:00:42 -0400 Subject: [PATCH] Try to fix warning again that printf might exceed buffer. The last fix worked on GCC 11 & 12 but broke GCC 8. --- src/zm_logger.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/zm_logger.cpp b/src/zm_logger.cpp index a4d9e92f8..4db535a78 100644 --- a/src/zm_logger.cpp +++ b/src/zm_logger.cpp @@ -82,8 +82,9 @@ Logger::Logger() : smSyslogPriorities[PANIC] = LOG_ERR; char code[4] = ""; - for (unsigned int i = DEBUG1; i <= DEBUG9; i++) { - snprintf(code, sizeof(code), "DB%u", i); + // Extra comparison against DEBUG1 to ensure GCC knows we are printing a single byte. + for (int i = DEBUG1; i>=DEBUG1 && i <= DEBUG9; i++) { + snprintf(code, sizeof(code), "DB%d", i); smCodes[i] = code; smSyslogPriorities[i] = LOG_DEBUG; }