Skip to content

Commit

Permalink
Fix compilation warnings when RMP_TICKLESS_DEBUG is defined
Browse files Browse the repository at this point in the history
  • Loading branch information
arkq committed Jun 14, 2023
1 parent 4e9d26e commit d7dbc8e
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions src/messaging/ReliableMessageMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ void ReliableMessageMgr::Shutdown()
mSystemLayer = nullptr;
}

#if defined(RMP_TICKLESS_DEBUG)
void ReliableMessageMgr::TicklessDebugDumpRetransTable(const char * log)
{
ChipLogDetail(ExchangeManager, log);
#if defined(RMP_TICKLESS_DEBUG)
ChipLogDetail(ExchangeManager, "%s", log);

mRetransTable.ForEachActiveObject([&](auto * entry) {
ChipLogDetail(ExchangeManager,
Expand All @@ -89,17 +89,15 @@ void ReliableMessageMgr::TicklessDebugDumpRetransTable(const char * log)
entry->nextRetransTime.count());
return Loop::Continue;
});
#endif
}
#else
void ReliableMessageMgr::TicklessDebugDumpRetransTable(const char * log) {}
#endif // RMP_TICKLESS_DEBUG

void ReliableMessageMgr::ExecuteActions()
{
System::Clock::Timestamp now = System::SystemClock().GetMonotonicTimestamp();

#if defined(RMP_TICKLESS_DEBUG)
ChipLogDetail(ExchangeManager, "ReliableMessageMgr::ExecuteActions at % " PRIu64 "ms", now.count());
ChipLogDetail(ExchangeManager, "ReliableMessageMgr::ExecuteActions at %" PRIu64 "ms", now.count());
#endif

ExecuteForAllContext([&](ReliableMessageContext * rc) {
Expand Down Expand Up @@ -180,7 +178,7 @@ void ReliableMessageMgr::Timeout(System::Layer * aSystemLayer, void * aAppState)
VerifyOrDie((aSystemLayer != nullptr) && (manager != nullptr));

#if defined(RMP_TICKLESS_DEBUG)
ChipLogDetail(ExchangeManager, "ReliableMessageMgr::Timeout\n");
ChipLogDetail(ExchangeManager, "ReliableMessageMgr::Timeout");
#endif

// Execute any actions that are due this tick
Expand Down Expand Up @@ -392,24 +390,24 @@ void ReliableMessageMgr::StartTimer()
return Loop::Continue;
});

StopTimer();

if (nextWakeTime != System::Clock::Timestamp::max())
{
#if defined(RMP_TICKLESS_DEBUG)
ChipLogDetail(ExchangeManager, "ReliableMessageMgr::StartTimer wake at %" PRIu64 "ms", nextWakeTime);
#endif

StopTimer();

const System::Clock::Timestamp now = System::SystemClock().GetMonotonicTimestamp();
const auto nextWakeDelay = (nextWakeTime > now) ? nextWakeTime - now : 0_ms;

#if defined(RMP_TICKLESS_DEBUG)
ChipLogDetail(ExchangeManager, "ReliableMessageMgr::StartTimer at %" PRIu64 "ms wake at %" PRIu64 "ms (in %" PRIu64 "ms)",
now.count(), nextWakeTime.count(), nextWakeDelay.count());
#endif
VerifyOrDie(mSystemLayer->StartTimer(nextWakeDelay, Timeout, this) == CHIP_NO_ERROR);
}
else
{
#if defined(RMP_TICKLESS_DEBUG)
ChipLogDetail(ExchangeManager, "ReliableMessageMgr skipped timer");
#endif
StopTimer();
}

TicklessDebugDumpRetransTable("ReliableMessageMgr::StartTimer Dumping mRetransTable entries after setting wakeup times");
Expand Down

0 comments on commit d7dbc8e

Please sign in to comment.