☰
  • 首页
  • 规则分类
  • 项目介绍
search
•••

不应存在不改变程序流程的跳转语句

9.7.6 ID_redundantJump
目录 › next › previous

不改变程序流程的跳转语句是多余的,往往意味着逻辑错误,也可能是调试或维护痕迹。

goto、return、break、continue 等跳转语句均受本规则约束。

示例:

void foo() {
    goto L;   // Non-compliant, redundant
L:
    ....
}

void bar() {
    ....
    return;   // Non-compliant, redundant
}

void baz() {
    while (cond) {
        ....
        continue;   // Non-compliant, redundant
    }
}

参考

CWE-1164
Copyright©2024 360 Security Technology Inc., Licensed under the Apache-2.0 license.