Fix 'usTimeOffset' was not declared error
When enable 'bios-post-code-log' feature will cause 'usTimeOffset'
was not declared error, therefore changing the scope of 'usTimeOffset'
variable.
Tested:
- Tested build OK.
- Check /var/log/redfish OK.
1970-01-01T00:02:38.626333+00:00 OpenBMC.0.1.BIOSPOSTCode,2,0.0000,0x01
1970-01-01T00:02:38.656143+00:00 OpenBMC.0.1.BIOSPOSTCode,2,0.0183,0x02
1970-01-01T00:02:38.664210+00:00 OpenBMC.0.1.BIOSPOSTCode,2,0.0420,0x02
Signed-off-by: Alan Kuo <Alan_Kuo@quantatw.com>
Change-Id: I1d35777e47d507c2bba5b6b6afa72ca70cb23155
diff --git a/src/post_code.cpp b/src/post_code.cpp
index 3633ea2..1fcbe55 100644
--- a/src/post_code.cpp
+++ b/src/post_code.cpp
@@ -88,17 +88,17 @@
else
{
// calculating tsUS so it is monotonic within the same boot
- uint64_t usTimeOffset =
- std::chrono::duration_cast<std::chrono::microseconds>(
- postCodeTimeSteady - firstPostCodeTimeSteady)
- .count();
- tsUS = usTimeOffset + firstPostCodeUsSinceEpoch;
+ tsUS = firstPostCodeUsSinceEpoch +
+ std::chrono::duration_cast<std::chrono::microseconds>(
+ postCodeTimeSteady - firstPostCodeTimeSteady)
+ .count();
}
postCodes.insert(std::make_pair(tsUS, code));
serialize(fs::path(strPostCodeListPath));
#ifdef ENABLE_BIOS_POST_CODE_LOG
+ uint64_t usTimeOffset = tsUS - firstPostCodeUsSinceEpoch;
std::ostringstream hexCode;
hexCode << "0x" << std::setfill('0') << std::setw(2) << std::hex
<< std::get<0>(code);
@@ -114,7 +114,7 @@
phosphor::logging::log<phosphor::logging::level::INFO>(
"BIOS POST Code",
phosphor::logging::entry("REDFISH_MESSAGE_ID=%s",
- "OpenBMC.0.1.BIOSPOSTCode"),
+ "OpenBMC.0.2.BIOSPOSTCode"),
phosphor::logging::entry(
"REDFISH_MESSAGE_ARGS=%d,%s,%s", currentBootCycleIndex,
timeOffsetStr.str().c_str(), hexCode.str().c_str()));