Fix Misra 10.8 violations: could not directly cast complex expressions from float to int
@@ -112,8 +112,12 @@ static int toyota_ipas_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) {
if (controls_allowed) {
// add 1 to not false trigger the violation
- int delta_angle_up = (int) ((interpolate(LOOKUP_ANGLE_RATE_UP, speed) * CAN_TO_DEG) + 1.);
- int delta_angle_down = (int) ((interpolate(LOOKUP_ANGLE_RATE_DOWN, speed) * CAN_TO_DEG) + 1.);
+ float delta_angle_float;
+ delta_angle_float = (interpolate(LOOKUP_ANGLE_RATE_UP, speed) * CAN_TO_DEG) + 1.;
+ int delta_angle_up = (int) (delta_angle_float);
+ delta_angle_float = (interpolate(LOOKUP_ANGLE_RATE_DOWN, speed) * CAN_TO_DEG) + 1.;
+ int delta_angle_down = (int) (delta_angle_float);
+
int highest_desired_angle = desired_angle_last + ((desired_angle_last > 0) ? delta_angle_up : delta_angle_down);
int lowest_desired_angle = desired_angle_last - ((desired_angle_last > 0) ? delta_angle_down : delta_angle_up);
if ((desired_angle > highest_desired_angle) ||
