summaryrefslogtreecommitdiff
path: root/src/commonlib/bsd
diff options
context:
space:
mode:
authorRicardo Quesada <ricardoq@google.com>2021-09-21 13:55:53 -0700
committerPatrick Georgi <pgeorgi@google.com>2021-09-23 06:26:19 +0000
commit425fdeb2f9e530ff3670a68a25a668bb47d66dde (patch)
tree97ebb2b9ee28dd750ba8897e75d1628b5ced2d7a /src/commonlib/bsd
parent10f2faacea0739e0fa84837cf8b79dbb9e0ec8e4 (diff)
elog: calculate year correctly in timestamp
This CL uses a 16-bit value (instead of an 8-bit value) for the year. This is needed because the function internally does a "year % 100", so the year should not be truncated to 8-bit before applying the modulo. This fixes a regression introduced in commit e929a75. BUG=b:200538760 TEST=deployed coreboot. Manually verified that year is correct using "elogtool list" TEST=test_that -b $BOARD $DUT firmware_EventLog Change-Id: I17578ff99af5b31b216ac53c22e53b1b70df5084 Signed-off-by: Ricardo Quesada <ricardoq@google.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/57816 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Furquan Shaikh <furquan@google.com>
Diffstat (limited to 'src/commonlib/bsd')
-rw-r--r--src/commonlib/bsd/elog.c2
-rw-r--r--src/commonlib/bsd/include/commonlib/bsd/elog.h2
2 files changed, 2 insertions, 2 deletions
diff --git a/src/commonlib/bsd/elog.c b/src/commonlib/bsd/elog.c
index a5e644c4af..8151d70698 100644
--- a/src/commonlib/bsd/elog.c
+++ b/src/commonlib/bsd/elog.c
@@ -50,7 +50,7 @@ const void *event_get_data(const struct event_header *event)
/* Populate timestamp in event header with given time. */
void elog_fill_timestamp(struct event_header *event, uint8_t sec, uint8_t min,
- uint8_t hour, uint8_t mday, uint8_t mon, uint8_t year)
+ uint8_t hour, uint8_t mday, uint8_t mon, uint16_t year)
{
event->second = bin2bcd(sec);
event->minute = bin2bcd(min);
diff --git a/src/commonlib/bsd/include/commonlib/bsd/elog.h b/src/commonlib/bsd/include/commonlib/bsd/elog.h
index ab3fa4b5e6..7e564fca21 100644
--- a/src/commonlib/bsd/include/commonlib/bsd/elog.h
+++ b/src/commonlib/bsd/include/commonlib/bsd/elog.h
@@ -318,7 +318,7 @@ enum cb_err elog_verify_header(const struct elog_header *header);
const struct event_header *elog_get_next_event(const struct event_header *event);
const void *event_get_data(const struct event_header *event);
void elog_fill_timestamp(struct event_header *event, uint8_t sec, uint8_t min,
- uint8_t hour, uint8_t mday, uint8_t mon, uint8_t year);
+ uint8_t hour, uint8_t mday, uint8_t mon, uint16_t year);
/* Update the checksum at the last byte. */
void elog_update_checksum(struct event_header *event, uint8_t checksum);
/* Simple byte checksum for events. */