Skip to content
Snippets Groups Projects
  • Peter Maydell's avatar
    5ec008a2
    rtc: Use time_t for passing and returning time offsets · 5ec008a2
    Peter Maydell authored
    
    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 1507157, 1517772).
    
    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: default avatarPeter Maydell <peter.maydell@linaro.org>
    Reviewed-by: default avatarPhilippe Mathieu-Daudé <philmd@linaro.org>
    5ec008a2
    History
    rtc: Use time_t for passing and returning time offsets
    Peter Maydell authored
    
    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 1507157, 1517772).
    
    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: default avatarPeter Maydell <peter.maydell@linaro.org>
    Reviewed-by: default avatarPhilippe Mathieu-Daudé <philmd@linaro.org>