Skip to content

Commit 9d761a1

Browse files
bjarki-andreasennashif
authored andcommitted
drivers: rtc: rtc_ll_stm32: coverity 368806 fix
Replace DIV_ROUND_CLOSEST() with a normal division to simplify operation and avoid redundant handling of signed integer rounding as the temp value is an unsigned value. The temp value is in nano precision, so rounding is largely inconsequencial anyway compared to the comparatively low precision sync prescaler. Signed-off-by: Bjarki Arge Andreasen <[email protected]>
1 parent c706b90 commit 9d761a1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/rtc/rtc_ll_stm32.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ static int rtc_stm32_get_time(const struct device *dev, struct rtc_time *timeptr
537537
#if HW_SUBSECOND_SUPPORT
538538
uint64_t temp = ((uint64_t)(cfg->sync_prescaler - rtc_subsecond)) * 1000000000L;
539539

540-
timeptr->tm_nsec = DIV_ROUND_CLOSEST(temp, cfg->sync_prescaler + 1);
540+
timeptr->tm_nsec = temp / (cfg->sync_prescaler + 1);
541541
#else
542542
timeptr->tm_nsec = 0;
543543
#endif

0 commit comments

Comments
 (0)