I understand that this would solve it but it is not great. Imagine a list API functions being with some not being called depending on configuration. Polluting the API with #ifdef wouldn't be an my first choice.
I am looking for a confirmation whether this cppcheck behavior is intended or not and whether author's conviction is strong.
Last edit: Dzid 2024-06-03
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yes Cppcheck does not normally perform a "combined" analysis of configurations it checks each configuration individually.
However for the whole program analysis we probably don't distinguish configurations properly so I imagine that if the function is used in one configuration that cppcheck analyses there will not be a warning.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
/cppcheck--enable=all--addon=misra1.c--forceChecking1.c...1.c:3:9:style:structmember'X::x'isneverused.[unusedStructMember]intx;^Checking1.c:A...1.c:2:1:style:misraviolation(use--rule-texts=<file>togetproperoutput)[misra-c2012-2.3]typedefstruct{^nofile:0:0:information:Activecheckers:107/802(use--checkers-report=<filename> to see details) [checkersReport]
Last edit: Dzid 2024-06-14
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I do consider that to be a false positive. However it's more difficult to fix. Most checkers checks 1 configuration at a time and if there is a problem in 1 configuration the warning will be shown.
For undefined behavior checks it's totally fine to warn if the problem only exists in 1 configuration. But yes in many "style" checks it would be better to check all configurations first.
Feel free to report some bugs in trac.
👍
1
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
In the following example
unusedFunction
violation is raised even when Cppcheck is called with--force
:This does not make sense to me because
--force
ineed explores the configuration (A
) when thefunc
is used.Last edit: Dzid 2024-06-03
I think you need to have:
That way there is no unused function even when A is ndef.
I understand that this would solve it but it is not great. Imagine a list API functions being with some not being called depending on configuration. Polluting the API with
#ifdef
wouldn't be an my first choice.I am looking for a confirmation whether this cppcheck behavior is intended or not and whether author's conviction is strong.
Last edit: Dzid 2024-06-03
I think idea of --force` is to warn if any ifdef configuration has a problem, not just if all of them do.
Yes Cppcheck does not normally perform a "combined" analysis of configurations it checks each configuration individually.
However for the whole program analysis we probably don't distinguish configurations properly so I imagine that if the function is used in one configuration that cppcheck analyses there will not be a warning.
I would expect that the warning is not shown if
--force
is used. And it works for me:Thank you for this. I got the same.
I need to reconsider my issues.
It seems it behaves differently for some other checks, e.g
unusedStructMember
:Last edit: Dzid 2024-06-14
I do consider that to be a false positive. However it's more difficult to fix. Most checkers checks 1 configuration at a time and if there is a problem in 1 configuration the warning will be shown.
For undefined behavior checks it's totally fine to warn if the problem only exists in 1 configuration. But yes in many "style" checks it would be better to check all configurations first.
Feel free to report some bugs in trac.