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 <alexander@wachter.cloud>
This commit is contained in:
Alexander Wachter 2021-02-10 17:18:16 +01:00 committed by Anas Nashif
parent 902dd26908
commit 9f858ac1b6

View file

@ -61,6 +61,8 @@ static void verify_bitrate(struct can_timing *timing, uint32_t bitrate)
uint32_t bitrate_calc;
int ret;
zassert_not_equal(timing->prescaler, 0, "Prescaler is zero");
ret = can_get_core_clock(can_dev, &core_clock);
zassert_equal(ret, 0, "Unable to get core clock");