From 67d52089a1300b86800d897f2b271e0a24cf6dd6 Mon Sep 17 00:00:00 2001 From: George Hotz Date: Tue, 13 Mar 2018 20:33:47 -0700 Subject: [PATCH] fix signedness issue in toyota safety --- VERSION | 2 +- board/safety/safety_toyota.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/VERSION b/VERSION index 2b44e7440bae78..77e86d42394402 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v1.0.8 \ No newline at end of file +v1.0.9 \ No newline at end of file diff --git a/board/safety/safety_toyota.h b/board/safety/safety_toyota.h index 34af1b0a9a32ba..78aaa36973c6fa 100644 --- a/board/safety/safety_toyota.h +++ b/board/safety/safety_toyota.h @@ -32,10 +32,10 @@ uint32_t ts_last = 0; static void toyota_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { // get eps motor torque (0.66 factor in dbc) if ((to_push->RIR>>21) == 0x260) { - int torque_meas_new = (((to_push->RDHR) & 0xFF00) | ((to_push->RDHR >> 16) & 0xFF)); + int16_t torque_meas_new_16 = (((to_push->RDHR) & 0xFF00) | ((to_push->RDHR >> 16) & 0xFF)); // increase torque_meas by 1 to be conservative on rounding - torque_meas_new = (torque_meas_new * dbc_eps_torque_factor / 100) + (torque_meas_new > 0 ? 1 : -1); + int torque_meas_new = ((int)(torque_meas_new_16) * dbc_eps_torque_factor / 100) + (torque_meas_new_16 > 0 ? 1 : -1); // shift the array for (int i = sizeof(torque_meas)/sizeof(torque_meas[0]) - 1; i > 0; i--) {