elogtool: Fix off-by-one error in month in timestamp

elogtool was setting the timestamp with the wrong value in the month.
This CL fixes that by incrementing the month by one. This is needed
since gmtime() returns the month value starting at 0.

TEST=pytest elogtool_test.py (see next CL in relation chain)

Change-Id: I00f89ed99b049caafba2e47feae3c068245f9021
Signed-off-by: Ricardo Quesada <ricardoq@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/57868
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Reviewed-by: Furquan Shaikh <furquan@google.com>
Reviewed-by: Paul Menzel <paulepanter@mailbox.org>
This commit is contained in:
Ricardo Quesada 2021-09-22 20:08:35 -07:00 committed by Patrick Georgi
parent 325f431a91
commit 1427f12adf
1 changed files with 2 additions and 1 deletions

View File

@ -657,8 +657,9 @@ int eventlog_init_event(const struct buffer *buf, uint8_t type,
event->type = type;
gmtime_r(&secs, &tm);
/* Month should be +1, since gmtime uses 0 as first month */
elog_fill_timestamp(event, tm.tm_sec, tm.tm_min, tm.tm_hour,
tm.tm_mday, tm.tm_mon, tm.tm_year);
tm.tm_mday, tm.tm_mon + 1, tm.tm_year);
if (data && data_size) {
uint32_t *ptr = (uint32_t *)&event[1];