Skip to content
This repository has been archived by the owner on Oct 2, 2024. It is now read-only.

Bug in RtcGetCalendarTime? #1

Open
cdoolin opened this issue Feb 16, 2022 · 0 comments
Open

Bug in RtcGetCalendarTime? #1

cdoolin opened this issue Feb 16, 2022 · 0 comments

Comments

@cdoolin
Copy link

cdoolin commented Feb 16, 2022

I believe there is a bug in RtcGetCalendarTime (in rtc-board.c):

In Lines 198 and 199:

    uint32_t ticks_remainder = value & CLOCK_MS_MASK;
    *milliseconds            = (ticks_remainder >> CLOCK_SHIFT) * 1000;

performing the bit-shift before multiplication will zero the millisecond value, so milliseconds will always be zero. I believe

 *milliseconds            = (ticks_remainder * 1000)  >> CLOCK_SHIFT;

is the correct order of operations, and because of the CLOCK_MS_MASK, should not overflow a uint32_t.

Cheers,

Callum

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant