You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2018/04/07 03:30:18 UTC

[GitHub] ncasaril opened a new pull request #999: os_time: Prevent 0 ticks returned when OS_TICKS_PER_SEC < 1000

ncasaril opened a new pull request #999: os_time: Prevent 0 ticks returned when OS_TICKS_PER_SEC < 1000
URL: https://github.com/apache/mynewt-core/pull/999
 
 
   The os_time_ms_to_ticks assumes the multiplication always proceeds the division in the following piece of code: 
   
   ```
    ticks = (uint64_t)ms * OS_TICKS_PER_SEC / 1000;
   ```
   
   With an OS_TICKS_PER_SEC < 1000 the division could result in 0 and give the wrong number of ticks. This PR adds () to force multiplication before division. Thus:
   
   ```
    ticks = ((uint64_t)ms * OS_TICKS_PER_SEC) / 1000;
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services