From 1427f12adf8092b8ab7c9963f16f3e4683c81498 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Wed, 22 Sep 2021 20:08:35 -0700 Subject: 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 Reviewed-on: https://review.coreboot.org/c/coreboot/+/57868 Tested-by: build bot (Jenkins) Reviewed-by: Jack Rosenthal Reviewed-by: Furquan Shaikh Reviewed-by: Paul Menzel --- util/cbfstool/eventlog.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'util') diff --git a/util/cbfstool/eventlog.c b/util/cbfstool/eventlog.c index 8b03686ecd..3ea352e6eb 100644 --- a/util/cbfstool/eventlog.c +++ b/util/cbfstool/eventlog.c @@ -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]; -- cgit v1.2.3