-
Notifications
You must be signed in to change notification settings - Fork 272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhance cppcheck usage, fix CI and fix reported errors #1346
Conversation
Scope plugin defined it to an incorrect value (the quotes were missing) and it's likely useful for all code in the repository.
Plugins mustn't use this, so cppcheck doesn't need to go down this path.
It's a lot more comprehensive (although it still lacks a few details) and allows finding more logic errors.
Without this cppcheck actually complains that it's not exhaustive to the point where it exits with an error. This is likely a cppcheck bug, but it's probably OK for us to use the exhaustive mode so let's do this at least for now.
This allows to insert suppressions directly in the code, which is a lot more robust against changes than listing file/line combo, and a lot more fine-grained than disabling an entire check for a whole file or even plugin.
21 minutes might be a tad long… 2 things we could to:
|
OK, I see #1310 now. Well, maybe we could either be OK with this, use a version that doesn't require this (and hope for a fix), or see if playing with other options has a significant impact without drastic check quality reduction (that last option I'm no hopeful about, because I already did play with it a bit).
I tried disabling this in the last commit above, we'll see what it changes -- but I can still revert that if you think it's a bad idea. |
See #1197 for why its needed
... should we switch to C++ where its all built into the compiler and doesn't need another tool to apply spurious checks. I'm serious, remember GCC has switched to C++ even though its a C codebase.
Oh how tempting ..... nah, I'll be nice. 😜 My 2c is that most plugins are so poorly maintained that if you add cppchecking that actually checks much, you will be the one making the patches. You are just adding to your workload. |
I'm on my phone so can't ask git for details, but l just added it here, so either I bluntly missed it somehow, or it got removed in the meantime, which would be concerning for re-adding it here…
That's just the C++ grumpy old guy talking, because it's simply not true 😉
That's clearly quote misuse… but I laughed, so I give it a pass
Hopefully it won't find many more issues in the existing code, but could on new one. Though, it's like with all those imperfect tools, the user has to be able to tell whether a warning is meaningful or not, and how to handle it. |
Or it got removed in the version of #1197 that was eventually merged. Not sure but I think when @eht16 upped the version of cppcheck in CI the
Correct, and that fixes the issues. :-) But for sure using a C++ compiler won't fix malloc/free code, but it will allow to progressively move away from it.
Except for the inevitable improvements (and glitches) with new versions of cppcheck (like above). |
I'm fine with having the suppressions inline. I don't remember if it was me starting to put them into In the CI we used the cppcheck version available in the Ubuntu release the runner is using. This version tends to be a bit outdated. In general I think for static code checkers it is fine to use recent versions and not rely on versions provided by the distribution to benefit from improved and new checks more quickly than the CI runner images are updated.
Good idea, I don't think it gives any value on distcheck.
I don't mind at all if we use So, after all, whatever makes the CI, the builds on Debian Sid and @b4n happy, is fine for me :D. |
Thanks for the replies 😊 And if some code is really too poorly maintained and cppcheck starts showing it, maybe the sane approach is getting rid of it rather than distributing a time bomb. |
And `contents` as well, although it wasn't detected.
It's admittedly hard for a static analyzer to know that if the error pointer is non-NULL, the return value ought to be NULL; but as here the revers is also true we can simply check the value and assume the error is set.
There's no real added value in running cppcheck in the distributed sources as well, and it effectively doubles check times for virtually no gain.
(just updated d0192a3 to use a more precise cppcheck suppression) |
As nobody seemed horrified by this, I merged it so we can get CI working again. If there's any issue with this, we can always fix or revert. |
Let's try to make cppcheck work again, and even report useful stuff.
During the journey it found a few actual issues, which is good. It also found some false-positives, which isn't so good.
We probably could reduce the false positives by not using
--library=gtk
, but that also would reduce the actual issues it can find.There are a few issues that should be reported upstream, but it's harder than it looks… if I could only remember my password on their tracker 😕
Anyway, what do you guys think? Is it good? Are there too many false-positives? Should the suppressions be moved back to
AM_CPPCHECKFLAG
s not to alter the code, although it makes it harder to maintain?