Configuration Issue with script generating the CppCheck Reports

Luke Benes lukebenes at hotmail.com
Fri Jun 15 17:21:13 UTC 2018


The weekly updates:
http://document-foundation-mail-archive.969070.n3.nabble.com/CppCheck-Report-Update-td4241678.html

Reports ~7000 Errors, nearly all of which are false positives. By adding  the `--check-config` parameter to analyze includes, I discovered that cppcheck cannot find any of our header files. 

Headers can be included 2 ways

1) -I include/ 
Adding this parameter alone, eliminates ~ 1 thousand false positives, but it leaves out all of the headers in inc/

2)  --includes-file=inc.txt
with this inc.txt file: https://pastebin.com/qGfPRBJ6

Teaching cppcheck about all of our header locations drops the number off errors found from 7K to a few hundred. However it also creats 2 new problems: speed and ~10K "toomanyconfigs" warnings.

An example of 2 configurations defined by A is this:
#ifdef A
    x = y;
#else
    x = z;
#endif
By default cppcheck will check all preprocessor configurations (except those that have #error in them). So the above code will be analyzed both when A is defined and when it is not

We can speed things up by not checking our DEBUG configurations. We can also eliminate even more false positives by not checking configurations that are missing the system header files. For example on Linux, we should add -U_WIN32 to not check Windows configs.

Here is the result of my tweaking:
$ cppcheck -U_WIN32 -i external/ -i workdir/ --includes-file=inc.txt --xml --suppressions-list=cppcheck_supp.txt --enable=all --max-configs=100  ./  2> ./err.xml

This command is not perfect, but it greatly improved the signal-to-noise ratio, only showing a few hundred errors. The run time went from about 1 hour to 8, but I'm sure that can be by further by reducing the number of configurations checked (-D and -U).

All of these commands are explained in detail on the cppcheck manual: http://cppcheck.sourceforge.net/manual.pdf



More information about the LibreOffice mailing list