Want query to detect mutual assignment
未关闭
question
- 主要语言
- CodeQL
- 星标
- 10.1k
- 派生
- 2.1k
- 平均合并
- 2 天 15 小时
- 30 天内合并 PR
- 141
描述
**Description of the issue**
Here is a minimal test case showing mutual assignment where we do `b = a;` followed by `a = b;`:
```
int main(void) {
int a = 0;
int b = a;
int c = 1;
a = b;
return a*b*c;
}
```
The statement `a = b;` is redundant. Unless the variables are marked volatile, there should be no legitimate reason for code to do this. We just found an instance of this in OpenZFS:
https://github.com/openzfs/zfs/pull/14565/files#r1124115812
A quick search revealed that PVS Studio has a check for this:
https://pvs-studio.com/en/docs/warnings/v587/
贡献指南
评估
这个 Issue 还没有评估数据。