rtc: Use time_t for passing and returning time offsets
commit5ec008a2bd7e928d41d2a158120223311742d860
authorPeter Maydell <peter.maydell@linaro.org>
Thu, 31 Aug 2023 08:45:18 +0000 (31 09:45 +0100)
committerPeter Maydell <peter.maydell@linaro.org>
Thu, 31 Aug 2023 08:45:18 +0000 (31 09:45 +0100)
treeaba2e0b060a084f4624fb6779eefb5f845deb8cb
parentc0a63857282afebaeed606a3dca803bb3bfb6aa3
rtc: Use time_t for passing and returning time offsets

The functions qemu_get_timedate() and qemu_timedate_diff() take
and return a time offset as an integer. Coverity points out that
means that when an RTC device implementation holds an offset
as a time_t, as the m48t59 does, the time_t will get truncated.
(CID 15071571517772).

The functions work with time_t internally, so make them use that type
in their APIs.

Note that this won't help any Y2038 issues where either the device
model itself is keeping the offset in a 32-bit integer, or where the
hardware under emulation has Y2038 or other rollover problems.  If we
missed any cases of the former then hopefully Coverity will warn us
about them since after this patch we'd be truncating a time_t in
assignments from qemu_timedate_diff().)

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
include/sysemu/rtc.h
softmmu/rtc.c