Skip to content

Commit

Permalink
[log-source-app] Compilation errors (#17311)
Browse files Browse the repository at this point in the history
  • Loading branch information
vivien-apple authored Apr 14, 2022
1 parent 4ee7cc4 commit 21024aa
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions examples/log-source-app/linux/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ DiagnosticLogsCommandHandler & GetLogProvider()
return LogProvider;
}

void LoggingCallback(const char * module, uint8_t category, const char * msg, va_list args)
void ENFORCE_FORMAT(3, 0) LoggingCallback(const char * module, uint8_t category, const char * msg, va_list args)
{
// Print the log on console for debug
va_list argsCopy;
Expand All @@ -75,7 +75,9 @@ void LoggingCallback(const char * module, uint8_t category, const char * msg, va
char buffer2[kMaxLogMessageLength];
int s1 = vsnprintf(buffer1, sizeof(buffer1), msg, args);
int s2 = snprintf(buffer2, sizeof(buffer2), "%s:%.*s", module, s1, buffer1);
GetLogProvider().PushLog(chip::ByteSpan(reinterpret_cast<uint8_t *>(buffer2), s2));

size_t len = chip::CanCastTo<size_t>(s2) ? static_cast<size_t>(s2) : SIZE_MAX;
GetLogProvider().PushLog(chip::ByteSpan(reinterpret_cast<uint8_t *>(buffer2), len));
}

int main(int argc, char * argv[])
Expand Down

0 comments on commit 21024aa

Please sign in to comment.