Skip to content

Commit

Permalink
[time] Exclude LogTime function in release builds (#24408)
Browse files Browse the repository at this point in the history
LogTime function that involves conversion of UTC time to
string is built even if progress logging is disabled.
Fix this.

Signed-off-by: Damian Krolik <[email protected]>

Signed-off-by: Damian Krolik <[email protected]>
  • Loading branch information
Damian-Nordic authored and pull[bot] committed Nov 12, 2023
1 parent 7c3fe0a commit 5336648
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/credentials/LastKnownGoodTime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ constexpr TLV::Tag kLastKnownGoodChipEpochSecondsTag = TLV::ContextTag(0);

void LastKnownGoodTime::LogTime(const char * msg, System::Clock::Seconds32 chipEpochTime)
{
#if CHIP_PROGRESS_LOGGING
char buf[26] = { 0 }; // strlen("00000-000-000T000:000:000") == 25
uint16_t year;
uint8_t month;
Expand All @@ -45,6 +46,10 @@ void LastKnownGoodTime::LogTime(const char * msg, System::Clock::Seconds32 chipE
ChipEpochToCalendarTime(chipEpochTime.count(), year, month, day, hour, minute, second);
snprintf(buf, sizeof(buf), "%04u-%02u-%02uT%02u:%02u:%02u", year, month, day, hour, minute, second);
ChipLogProgress(TimeService, "%s%s", StringOrNullMarker(msg), buf);
#else
IgnoreUnusedVariable(msg);
IgnoreUnusedVariable(chipEpochTime);
#endif
}

CHIP_ERROR LastKnownGoodTime::LoadLastKnownGoodChipEpochTime(System::Clock::Seconds32 & lastKnownGoodChipEpochTime) const
Expand Down

0 comments on commit 5336648

Please sign in to comment.