Try to fix warning again that printf might exceed buffer.

The last fix worked on GCC 11 & 12 but broke GCC 8.
pull/3538/head
Doug Nazar 2022-07-22 12:00:42 -04:00
parent cfa4cdc9a3
commit 3b69a51ff8
1 changed files with 3 additions and 2 deletions

View File

@ -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;
}