Menu

1.75: Lots of new false positives regarding unused functions

versat
2016-08-08
2016-08-09
  • versat

    versat - 2016-08-08

    Hi,
    i've saved the output from my project analysis with cppcheck 1.74 and instantly compared it to the output of 1.75 after the update.
    With 1.75 there now are many false positives regarding unused functions, for example:

            <error id="unusedFunction" severity="style" msg="The function &apos;clock_init&apos; is never used." verbose="The function &apos;clock_init&apos; is never used." cwe="561">
                <location file="E:\my_project\source\clock.c" line="89"/>
            </error>
    

    I've tried to make a very simple version but there the false positives don't occurr.
    My call to cppcheck looks like this:

    "C:\Program Files\Cppcheck/cppcheck" -f --enable=all --check-library  --language=c --library=std_enhanced --library=msp430 --library=msp430fr6989 --library=my_project  -D__COMPILER_VERSION__=4004005 -D__edg_front_end__=1 -D__EDG_PTRDIFF_TYPE__=int -D__EDG_VERSION__=404 -D__LARGE_CODE_MODEL__=1 -D__LARGE_DATA_MODEL__=1 -D__little_endian__=1 -D__MSP430__=1 -D__MSP430FR6989__ -D__MSP430X__ -D__msp430x__ -D__PTRDIFF_T_TYPE__=int -D__SIZE_T_TYPE__=unsigned -D__STDC__=1 -D__STDC_HOSTED__=1 -D__STDC_VERSION__199901L -D__TI_C99_COMPLEX_ENABLED__=1 -D__TI_COMPILER_VERSION__=4004005 -D__TI_EABI__=1 -D__TI_GNU_ATTRIBUTE_SUPPORT__=1 -D__TI_STRICT_ANSI_MODE__=0 -D__TI_STRICT_FP_MODE__=1 -D__TI_WCHAR_T_BITS__=16 -D__unsigned_chars__=1 -D_INLINE=1 -D_MPU_ENABLE -D_OPTIMIZE_FOR_SPACE=1 -U__ASM_HEADER__ -U__cplusplus -U__GNUC__ -I "E:\my_project\source/" -I "E:\my_project\source/driverlib/MSP430FR5xx_6xx/" --inconclusive -v --std=c99 --xml --xml-version=2 "E:\my_project\source"  2>my_project_cppcheck_result.xml
    

    All the global functions are declared in according header files and included in the .c files where they get called or are defined.
    Cppcheck 1.74 doesn't report these false positives.
    Any idea what has introduced this with 1.75?
    Best Regards
    Sebastian

     

    Last edit: versat 2016-08-08
  • Daniel Marjamäki

    I would guess it's somehow related to the preprocessor.

    maybe the configurations that are checked are somewhat different.

     
  • Daniel Marjamäki

    I know there is a ticket somewhere .. where an #error caused a FP unused function .. and that was very hard to see why there was a FP. Do you have #error in your code?

     
  • versat

    versat - 2016-08-09

    Yes i have some #error in the code.
    I've commented all #error away but it doesn't change the output.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.