Commit 9f858ac1 authored by Alexander Wachter's avatar Alexander Wachter Committed by Anas Nashif
Browse files

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: default avatarAlexander Wachter <alexander@wachter.cloud>
parent 902dd269
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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");