while 循环体应该用大括号括起来
9.3.6 ID_while_brace
while 循环体应为大括号括起来的复合语句,即使该复合语句只包含一条语句。
示例:
while (condition) // Non-compliant
statement;
while (condition) // Non-compliant
statement1;
statement2;
应改为:
while (condition) { // Compliant
statement;
}
while (condition) { // Compliant
statement1;
statement2;
}
相关
参考
MISRA C 2004 14.8
MISRA C 2012 15.6
MISRA C++ 2008 6-3-1
SEI CERT EXP19-C