分支控制R-1-4-2强制

禁止条件分支为空

例外: 使用空语句 ; 并随后加以 /* no deal with */ 注释说明。

条件分支为空
test.c
1void foo(int x)
2{
3 int y = 3;
4 if (x > 0)
5 {
6 y = 1;
7 }
8 else;
禁止条件分支为空 [gjb8114-r-1-4-2]
9 if (y > 1)
10 {
11 y *= 2;
12 }
13 else if (y == 1)
14 {
15 ;
禁止条件分支为空 [gjb8114-r-1-4-2]
16 }
17 else if (y == 0)
18 {
禁止条件分支为空 [gjb8114-r-1-4-2]
19 }
20 else
21 {
禁止条件分支为空 [gjb8114-r-1-4-2]
22 /* no deal with */
23 }
24}
条件分支有注释
test.c
1void foo(int x)
2{
3 int y = 3;
4 if (x > 0)
5 {
6 y = 1;
7 }
8 else
9 ; /* no deal with */
10 if (y > 1)
11 {
12 y *= 2;
13 }
14 else if (y == 1)
15 {
16 ; /* no deal with */
17 }
18 else if (y == 0)
19 {
20 ; /* no deal with */
21 }
22 else
23 {
24 ; /* no deal with */
25 }
26}