On Fri, Feb 17, 2023 at 09:04:53AM +0100, Stefano Brivio wrote:
On Fri, 17 Feb 2023 09:53:28 +1100 David Gibson
wrote: On Thu, Feb 16, 2023 at 07:22:10PM +0100, Stefano Brivio wrote:
The newly introduced die() calls exit(), but cppcheck doesn't see it and warns about possibly invalid arguments used after the check which triggers die(). Add return statements to silence the warnings.
Signed-off-by: Stefano Brivio
Oof, that's super ugly. Any chance that cppcheck will recognize the ((noreturn)) attribute if we added it to die()?
It doesn't. I guess Library::isnoreturn() in lib/library.cpp is fooled by the way we build die with a macro. I couldn't find a corresponding ticket, there's a vaguely related false _negative_ here: https://trac.cppcheck.net/ticket/7933
but I admit I might have missed one from this list: https://trac.cppcheck.net/query?status=!closed&keywords=~valueflow
I see a few alternatives:
- move exit() after the function body, instead of using 'doexit', I couldn't find a "nice" way to do so but it should be possible
I prefer this option - I don't love flags which dramatically change behaviour any way.
- fix the issue in cppcheck
- or... would you prefer if I use a cppcheck-suppress token here?
-- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson