MCPcopy Create free account
hub / github.com/crosspoint-reader/crosspoint-reader / sanitizeLogHead

Function sanitizeLogHead

lib/Logging/Logging.cpp:89–95  ·  view source on GitHub ↗

Checks whether the RTC log state is consistent: rtcLogMagic must equal LOG_RTC_MAGIC and logHead must be in 0..MAX_LOG_LINES-1. Returns true if corruption is detected, in which case rtcLogMagic is still invalid and logMessages may contain garbage. Callers (e.g. HalSystem::begin on the panic-reboot path) must call clearLastLogs() after a true result to fully reinitialize the ring buffer and stamp t

Source from the content-addressed store, hash-verified

87// panic-reboot path) must call clearLastLogs() after a true result to fully
88// reinitialize the ring buffer and stamp the magic before getLastLogs() is used.
89bool sanitizeLogHead() {
90 if (rtcLogMagic != LOG_RTC_MAGIC || logHead >= MAX_LOG_LINES) {
91 logHead = 0;
92 return true;
93 }
94 return false;
95}
96
97void clearLastLogs() {
98 for (size_t i = 0; i < MAX_LOG_LINES; i++) {

Callers 1

beginFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected