ccollins476ad commented on issue #1093: timeout/tick / int32_t vs uint32_t URL: https://github.com/apache/mynewt-core/issues/1093#issuecomment-391811318 I don't know how I feel about adding `os_ticks_t`; I don't necessarily disagree, but I need to give it more thought. However, I think you make a very good point. Improperly comparing time values yields some nasty bugs, and I think Mynewt needs to do more to make time comparisons less error prone. The problem with this class of bugs is that they remain hidden until a device is up and running for a long time. Specifically, I'm thinking of code which compares time values like this: ``` if (now >= timer_expiry) { /* ... */ } ``` Since these time values roll over eventually, this type of naive comparison is buggy. Instead, the user needs to use the `OS_TIME_TICK_[...]` macros (or equivalent). Do you think the addition of `os_[s]ticks_t` would help prevent bugs like this? C doesn't help out much here; `os_time_t`, `os_ticks_t`, and `uint32_t` would all be interchangeable. By the way, the `os_time_t`/`os_stime_t` naming scheme is based on the standard `size_t/ssize_t` types. It is not logical to have a negative size, but I have not seen people use `ssize_t` inappropriately.
---------------------------------------------------------------- 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: [email protected] With regards, Apache Git Services
