Mohamed Ayman commented on a discussion on bsps/arm/stm32h7/start/bspstart.c: https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1144#note_146022 > /* Get number of milliseconds elapsed since startup */ > uint32_t HAL_GetTick(void) > { > - return rtems_clock_get_ticks_since_boot() * > - rtems_configuration_get_milliseconds_per_tick(); > + return (uint32_t)( > + (uint64_t) rtems_clock_get_ticks_since_boot() * > + rtems_configuration_get_milliseconds_per_tick() > +); hi kinsey, The previous implementation performed the multiplication in 32-bit, which could overflow before the result was returned. By castng to uint64_t, the multiplication is performed in 64-bit, avoiding intermediate overflow. The final cast back to uint32_t ensures the result still wraps as expected for a millisecond tick counter. -- View it on GitLab: https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1144#note_146022 You're receiving this email because of your account on gitlab.rtems.org.
_______________________________________________ bugs mailing list [email protected] http://lists.rtems.org/mailman/listinfo/bugs
