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

if 语句不应被分号隔断

9.1.1 ID_if_semicolon
目录 › next › previous

if 语句不应被分号隔断。

示例:

if (condition);  // Non-compliant, see the semicolon
{
    ....
}

一个分号使整个 if 语句失效,这可能是笔误,也可能是需求变化不再需要条件判断了,在维护过程中加入了分号,形成了令人费解的残留代码,也不能排除是有人恶意篡改了代码,应立即修正。

参考

CWE-670 SEI CERT EXP15-C
Copyright©2024 360 Security Technology Inc., Licensed under the Apache-2.0 license.