Commit 1fda43b
authored
fix: improve misra.py for missing prototype false positives (#8805)
The MISRA addon reported false positives for Rules 8.4 and 17.3 in cases
involving valid prototypes and function-pointer calls. We identified
these issues by comparing its results with reports previously generated
by our company’s internal tool on the same software.
The fix improves prototype and function-call detection in
addons/misra.py and adds a regression test covering both cases.
The bug report would have looked like below, but I don't have access to
"issues" panel.
# MISRA addon reports false positives for Rules 8.4 and 17.3
## Description
The MISRA addon reports false positives for Rules 8.4 and 17.3 when
valid function prototypes or function-pointer calls are present. The
issue was identified by comparing cppcheck results with reports
generated by our company's internal tool on the same software.
## Reproduction
```c
int regression_function(int value);
int regression_function(int value)
{
return value;
}
int main(void)
{
int local_prototype(int value);
int (*callback)(int) = regression_function;
return callback(0);
}
```
Run the MISRA addon on this file with Rules 8.4 and 17.3 enabled:
```bash
cppcheck --enable=all --addon=addons/misra.py \
addons/test/misra/misra-regression-prototypes.c
```
## Expected result
No Rule 8.4 or Rule 17.3 violation is reported.
## Actual result
The addon reports violations for valid prototype and function-pointer
constructs.1 parent 9a500c8 commit 1fda43b
3 files changed
Lines changed: 49 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
538 | 538 | | |
539 | 539 | | |
540 | 540 | | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
541 | 555 | | |
542 | 556 | | |
543 | 557 | | |
| |||
803 | 817 | | |
804 | 818 | | |
805 | 819 | | |
806 | | - | |
| 820 | + | |
| 821 | + | |
807 | 822 | | |
808 | 823 | | |
809 | 824 | | |
| |||
2248 | 2263 | | |
2249 | 2264 | | |
2250 | 2265 | | |
| 2266 | + | |
| 2267 | + | |
2251 | 2268 | | |
2252 | 2269 | | |
2253 | 2270 | | |
| |||
3497 | 3514 | | |
3498 | 3515 | | |
3499 | 3516 | | |
3500 | | - | |
3501 | | - | |
| 3517 | + | |
| 3518 | + | |
| 3519 | + | |
3502 | 3520 | | |
3503 | 3521 | | |
3504 | 3522 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
93 | 94 | | |
94 | 95 | | |
95 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
96 | 111 | | |
97 | 112 | | |
98 | 113 | | |
| |||
0 commit comments