Skip to content

Commit

Permalink
drivers: can: avoid integer overflow in expression
Browse files Browse the repository at this point in the history
Change the integer arithmetic to divide first before multiply.

The muliplication of sys_clock_hw_cycles_per_sec() by ten leads
to a really big number on boards with high-speed clocking, thus
to the overflow warning, and to errors for integration tests.

(cherry picked from commit e7f399f)

Original-Fixes: #63678
Original-Signed-off-by: Stephan Linz <linz@li-pro.net>
GitOrigin-RevId: e7f399f
Change-Id: I232c13d4b396209a5adae9b21120a0154853bae1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/zephyr/+/4921894
Reviewed-by: Keith Short <keithshort@chromium.org>
Tested-by: Keith Short <keithshort@chromium.org>
Commit-Queue: Keith Short <keithshort@chromium.org>
Tested-by: ChromeOS Prod (Robot) <chromeos-ci-prod@chromeos-bot.iam.gserviceaccount.com>
  • Loading branch information
rexut authored and Chromeos LUCI committed Oct 9, 2023
1 parent 3993815 commit 1cbb1cc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/can/can_stm32_bxcan.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

LOG_MODULE_REGISTER(can_stm32, CONFIG_CAN_LOG_LEVEL);

#define CAN_INIT_TIMEOUT (10 * sys_clock_hw_cycles_per_sec() / MSEC_PER_SEC)
#define CAN_INIT_TIMEOUT (10 * (sys_clock_hw_cycles_per_sec() / MSEC_PER_SEC))

#define DT_DRV_COMPAT st_stm32_bxcan

Expand Down

0 comments on commit 1cbb1cc

Please sign in to comment.