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:
parent
902dd26908
commit
9f858ac1b6
1 changed files with 2 additions and 0 deletions
|
@ -61,6 +61,8 @@ static void verify_bitrate(struct can_timing *timing, uint32_t bitrate)
|
||||||
uint32_t bitrate_calc;
|
uint32_t bitrate_calc;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
zassert_not_equal(timing->prescaler, 0, "Prescaler is zero");
|
||||||
|
|
||||||
ret = can_get_core_clock(can_dev, &core_clock);
|
ret = can_get_core_clock(can_dev, &core_clock);
|
||||||
zassert_equal(ret, 0, "Unable to get core clock");
|
zassert_equal(ret, 0, "Unable to get core clock");
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue