Skip to content

freertos: Avoid timestamp overflow before widening - #371

Open
bentheredonethat wants to merge 1 commit into
OpenAMP:mainfrom
bentheredonethat:coverity-static-analysis-fixups
Open

bentheredonethat wants to merge 1 commit into
OpenAMP:mainfrom
bentheredonethat:coverity-static-analysis-fixups

Conversation

@bentheredonethat

Copy link
Copy Markdown
Contributor

metal_get_timestamp() returns a 64-bit microsecond timestamp, but on Cortex-R5 FreeRTOS it multiplies the 32-bit tick count in 32-bit arithmetic before widening the result. At 100 Hz, timestamps wrap after 429496 ticks.

Widen the tick count first and convert with configTICK_RATE_HZ. This also avoids portTICK_PERIOD_MS truncation for tick rates that do not divide 1000 evenly.

metal_get_timestamp() returns a 64-bit microsecond timestamp, but on
Cortex-R5 FreeRTOS it multiplies the 32-bit tick count in 32-bit
arithmetic before widening the result. At 100 Hz, timestamps wrap after
429496 ticks.

Widen the tick count first and convert with configTICK_RATE_HZ. This
also avoids portTICK_PERIOD_MS truncation for tick rates that do not
divide 1000 evenly.

Assisted-by: Codex:Claude-Opus-5.5 coverity
Signed-off-by: Ben Levinsky <ben.levinsky@amd.com>
@arnopo
arnopo requested review from a team, arnopo, edmooring and tnmysh and removed request for a team October 22, 2026 07:20

@edmooring edmooring left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to go.

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.

3 participants