for 循环体应该用大括号括起来
9.2.10 ID_for_brace
for 循环体应为大括号括起来的复合语句,即使该复合语句只包含一条语句。
示例:
int a = 0;
for (int i = 0; i < 10; i++) // Non-compliant
a += i;
应改为:
int a = 0;
for (int i = 0; i < 10; i++) { // Compliant
a += i;
}
参考
MISRA C 2004 14.8
MISRA C 2012 15.6
MISRA C++ 2008 6-3-1
SEI CERT EXP19-C