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

除法和求余运算符左右子表达式不应相同

10.3.5 ID_selfDivision
目录 › next › previous

与自身相除的结果总为 1,对自身求余的结果总为 0,往往是某种笔误。

示例:

int foo(int* p) {
    return p[0] % p[0];  // Non-compliant
}

参考

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