Skip to content

Conversation

JordanYates
Copy link
Contributor

In the previous implementation, the next_iter * MSEC_PER_SEC
calculation was operating on two uint32_t's, which resulted in an
integer overflow once the system uptime reached 49.71 days.

Also take the opportunity to make the function slightly more efficient
by minimising conversions back and forth between different time units
(milliseconds and ticks).

@JordanYates JordanYates requested a review from Aeyohan April 2, 2025 12:10
@JordanYates JordanYates force-pushed the bugfix/absolute_overflows branch from 16370e5 to 1cc0f82 Compare April 2, 2025 12:26
Copy link

codecov bot commented Apr 2, 2025

Codecov Report

Attention: Patch coverage is 83.33333% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
subsys/task_runner/auto_iterate.c 83.33% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

Update zephyr fork to add `K_TIMEOUT_ABS_SEC`.

Signed-off-by: Jordan Yates <[email protected]>
In the previous implementation, the `next_iter * MSEC_PER_SEC`
calculation was operating on two `uint32_t`'s, which resulted in an
integer overflow once the system uptime reached 49.71 days. Use the new
`K_TIMEOUT_ABS_SEC` macro to avoid this.

Also take the opportunity to make the function slightly more efficient
by minimising conversions back and forth between different time units
(milliseconds and ticks).

Signed-off-by: Jordan Yates <[email protected]>
Add a test for the auto iterate functionality, which can be configured
to run for arbitrary durations.

Signed-off-by: Jordan Yates <[email protected]>
Transition any tests using `K_TIMEOUT_ABS_MS(1000*x)` to
`K_TIMEOUT_ABS_SEC`.

Signed-off-by: Jordan Yates <[email protected]>
@JordanYates JordanYates force-pushed the bugfix/absolute_overflows branch from 1cc0f82 to fc3c1bb Compare April 3, 2025 01:31
@JordanYates JordanYates merged commit 968a4a4 into main Apr 3, 2025
12 checks passed
@JordanYates JordanYates deleted the bugfix/absolute_overflows branch April 3, 2025 03:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants