RTEMS | stm32h7/bspstart: avoid overflow in HAL_GetTick calculation (!1144)

Kinsey Moore (@opticron) gitlab at rtems.org
Wed Mar 18 18:32:34 UTC 2026




Kinsey Moore started a new discussion on bsps/arm/stm32h7/start/bspstart.c: https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1144#note_145992

 >  /* 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()
 > +);

Please explain how the behavior of this new code differs from the old code and how overflows are avoided given that it's a simple multiplication and the value is forced back into uint32_t before being returned.

-- 
View it on GitLab: https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1144#note_145992
You're receiving this email because of your account on gitlab.rtems.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/bugs/attachments/20260318/48c1aa1f/attachment-0001.htm>


More information about the bugs mailing list