Skip to content

Commit 5426f51

Browse files
Some corrections and thoughts
1 parent 4ea0ac9 commit 5426f51

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

README.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,15 @@ firefox localhost:8001
6060
## Summary
6161

6262
I would call this somewhat simple or straightforward code, so we cannot accept many false positives.
63-
Luckily with running clang-tidy + Semgrep + CodeQL none / very few false positives were found.
63+
Still a few FPs were reported from running clang-tidy + Semgrep + CodeQL.
64+
65+
19 (11+8) FPs, 16 (12+2+2) TPs, in addition to 6 duplicate TPs.
66+
67+
Note that many of the FPs were of the same type and easily ignored (Semgrep) or (mainly for for clang-tidy)
68+
some were reasonable complaints that is not a problem in the specific context / already checked indirectly later ...
69+
and thus the critique to check them directly or more clearly could very well be valid.
70+
71+
This also highlights that these static code analysis tools should be present from the start of development, to force a better code pattern (or a pattern more in line with the tool..?) thoughout.
6472

6573
### GCC
6674
No warnings from GCC
@@ -80,8 +88,8 @@ It is a bit scary that each of the three tools gave different warnings, with ver
8088
So running fewer tools we would not have found all these faults, what are we missing that we could find with other tools?
8189

8290
#### clang-tidy/clang-sa (CodeChecker)
83-
CodeChecker reports a few useful errors, no real false positives.
84-
Although we get some less important warnings as we use --enable sensitive.
91+
CodeChecker reports many useful errors (memory errors and other important problems), but some false positives.
92+
As we use its sensitive setting, we get a few extra LOW and MEDIUM warnings (can be tweaked a lot).
8593

8694
```
8795
-----------------------------------------------------------------------
@@ -135,6 +143,7 @@ Interesting that we get a narrowing conversion warning not caught by -Wconversio
135143

136144
Semgrep gave 16 warnings, with many false positives (a bit gray area).
137145
Semgrep seems very basic, atleast with the relatively few default rulesets for C.
146+
However, as I understand the benefit with Semgrep is the ease of writing new rules.
138147
So far it has only complained on the use of unsafe standard functions, some are FPs or not a big deal, but still
139148
good input that other tools largely ignored.
140149

@@ -173,6 +182,7 @@ CodeQL found three bugs, none of which were discovered by clang-tidy (or vice-ve
173182
Unique
174183
[High] advent2021/3/3.c:77 //Comparison of narrow type with wide type in loop condition
175184
[High] advent2021/3/3.c:43
185+
//afaik comparison is usually ok but in certain loop expressions there's the possibility of infinite loop (even if the smaller variable is promoted).
176186
//Interesting that this was not discovered by GCC -Wsign-compare, or by clang-tidy.
177187
178188
Detected by other tools

0 commit comments

Comments
 (0)