Skip to content

Commit 9f858ac

Browse files
alexanderwachternashif
authored andcommitted
tests: drivers: can: timing: Fix potential div by zero
If the prescaler is zero in the test, a div by zero would happen. Add an assert to check for zero prescaler. Fix CID 216790 Signed-off-by: Alexander Wachter <[email protected]>
1 parent 902dd26 commit 9f858ac

File tree

1 file changed

+2
-0
lines changed
  • tests/drivers/can/timing/src

1 file changed

+2
-0
lines changed

tests/drivers/can/timing/src/main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ static void verify_bitrate(struct can_timing *timing, uint32_t bitrate)
6161
uint32_t bitrate_calc;
6262
int ret;
6363

64+
zassert_not_equal(timing->prescaler, 0, "Prescaler is zero");
65+
6466
ret = can_get_core_clock(can_dev, &core_clock);
6567
zassert_equal(ret, 0, "Unable to get core clock");
6668

0 commit comments

Comments
 (0)