LHS 和 RHS 变量都是 uint8_t 变量,但问题被报告为“从 int 转换为 unsigned char”。我不明白这怎么可能是一个问题?
这同样适用于 8 位数字
两个问题中列出的所有变量都是 uint8_t
问题 1)
CID 147563 (#2 of 2): Coding standard violation (CERT INT31-C)3. cert_violation: Casting (uint8_t)apX_compY_bitmask from int to unsigned char without checking its value may result in lost or misinterpreted data.
/* AP_X_Flash_Component_Y_Authenticated */
static uint8_t AP_component_require_auth;
//Local variable:
uint8_t apX_compY_bitmask = 0u, port;
// other operations
AP_component_require_auth |= (uint8_t)apX_compY_bitmask;
问题 2)
CID 148170 (#1 of 1): Coding standard violation (CERT INT31-C)5. cert_violation: Casting major_revision >> 3 from int to unsigned char without checking its value may result in lost or misinterpreted data.
函数参数:
void sb_rollb_prot_AP_FW_in_use_update(uint8_t img_idx, uint8_t port, uint8_t major_revision, bool primary_image)
//Local Variable
uint8_t x_loc, y_loc;
y_loc = major_revision >> 3;