From 0dcd84d7912cd72d3aeaad4653007d1f178a1567 Mon Sep 17 00:00:00 2001 From: Commaremote <31535535+commaremote@user.noreply.github.com> Date: Sat, 16 Jun 2018 19:04:30 -0700 Subject: [PATCH] Toyota safety: integer division bug --- board/safety/safety_toyota.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/board/safety/safety_toyota.h b/board/safety/safety_toyota.h index 226ae594f6514a..da4bd388ddd135 100644 --- a/board/safety/safety_toyota.h +++ b/board/safety/safety_toyota.h @@ -36,7 +36,7 @@ static void toyota_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { torque_meas_new = to_signed(torque_meas_new, 16); // scale by dbc_factor - torque_meas_new *= dbc_eps_torque_factor / 100; + torque_meas_new = (torque_meas_new * dbc_eps_torque_factor) / 100; // increase torque_meas by 1 to be conservative on rounding torque_meas_new += (torque_meas_new > 0 ? 1 : -1);