Skip to content

Commit

Permalink
Merge pull request #20220 from LP-HAW/fix-benchmark-overflow
Browse files Browse the repository at this point in the history
sys/benchmark: fix integer overflow in benchmark_print_time()
  • Loading branch information
benpicco authored Jan 3, 2024
2 parents b47771c + 568cbc0 commit 519f825
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion sys/benchmark/benchmark.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
void benchmark_print_time(uint32_t time, unsigned long runs, const char *name)
{
uint32_t full = (time / runs);
uint32_t div = (time - (full * runs)) * 1000 / runs;
uint32_t div = (uint32_t)(((uint64_t)(time - (full * runs))) * 1000 / runs);

uint32_t per_sec = (uint32_t)(((uint64_t)US_PER_SEC * runs) / time);

Expand Down

0 comments on commit 519f825

Please sign in to comment.