MISRA.CAST.INTNon-trivial integer expression is cast to a wider type, or type with a different signedness. MISRA-C Rule 10.3 (required): The value of a complex expression of integer type shall only be cast to a type of the same signedness that is no wider than the underlying type of the expression.If a cast is to be used on any complex expression, the type of cast that may be applied is severely restricted. As explained in section 6.10, conversions on complex expressions are often a source of confusion and it is therefore wise to be cautious. In order to comply with these rules, it may be necessary to use a temporary variable and introduce an extra statement. Example... (float32_t)(f64a + f64b) /* compliant */ ... (float64_t)(f32a + f32b) /* not compliant */ ... (float64_t)f32a /* compliant */ ... (float64_t)(s32a / s32b) /* not compliant */ ... (float64_t)(s32a > s32b) /* not compliant */ ... (float64_t)s32a / (float32_t)s32b /* compliant */ ... (uint32_t)(u16a + u16b) /* not compliant */ ... (uint32_t)u16a + u16b /* compliant */ ... (uint32_t)u16a + (uint32_t)u16b /* compliant */ ... (int16_t)(s32a - 12345) /* compliant */ ... (uint8_t)(u16a * u16b) /* compliant */ ... (uint16_t)(u8a * u8b) /* not compliant */ ... (int16_t)(s32a * s32b) /* compliant */ ... (int32_t)(s16a * s16b) /* not compliant */ ... (uint16_t)(f64a + f64b) /* not compliant */ ... (float32_t)(u16a + u16b) /* not compliant */ ... (float64_t)foo1(u16a + u16b) /* compliant */ ... (int32_t)buf16a[u16a + u16b] /* compliant */ |