From: Andrei Pavel Date: Thu, 19 Jun 2025 07:09:14 +0000 (+0300) Subject: [#3930] Fix cppcheck after adoption of meson X-Git-Tag: Kea-3.0.0~68 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=da77749d06b04a0285b012318d206bf86f8b3488;p=thirdparty%2Fkea.git [#3930] Fix cppcheck after adoption of meson - Was running on build dir which had little to no sources. - Use the compile_commands.json file provided by meson which enables cppcheck to know about compiler flags used in compilation. - Make the cppcheck target write to cppcheck-result.xml which is expected in the cppcheck-htmlreport target. - Add library=googletest so it correctly decodes gtest macros. - Remove suppression list. A lot of the suppressions were fixed with proper use of cppcheck or are no longer reported. --- diff --git a/meson.build b/meson.build index 7e3440cea4..228a6fff1c 100644 --- a/meson.build +++ b/meson.build @@ -921,17 +921,18 @@ if cppcheck.found() 'cppcheck', command: [ cppcheck, - '-I.', - '-I./src/lib', - '-I./src/bin', + '--check-level=exhaustive', + '--enable=all', '--inline-suppr', + '--library=googletest', + '--output-file=cppcheck-result.xml', + '--project=compile_commands.json', '--quiet', - '--max-configs=256', + '--report-progress', f'--suppressions-list=@TOP_SOURCE_DIR@/src/cppcheck-suppress.lst', '--template={file}:{line}: check_fail: {message} ({severity},{id})', '--xml', '--xml-version=2', - '.', ], ) endif @@ -945,6 +946,8 @@ if cppcheck_htmlreport.found() './cppcheck-result.xml', '--report-dir', './report', + '--source-dir', + TOP_SOURCE_DIR, '--title', '"cppcheck report"', ], diff --git a/src/cppcheck-suppress.lst b/src/cppcheck-suppress.lst index 9dc8d99619..7c2557233f 100644 --- a/src/cppcheck-suppress.lst +++ b/src/cppcheck-suppress.lst @@ -1,28 +1,6 @@ -// On some systems cppcheck produces false alarms about 'missing includes'. -// the following two will suppress, depending on the cppcheck version -debug -missingInclude +// Supress errors that are often false positives. +missingIncludeSystem -// Please don't add any suppressions here. We now use inline -// suppressions (in the .cc files) so that we don't have to -// maintain line numbers in this file. -// -// See the cppcheck manual for syntax. It is something like: -// -// // cppcheck-suppress duplicateExpression -// EXPECT_FALSE(small_name < small_name); - -// With cppcheck 1.56, there are a number of false positives, which -// All of these should be checked and hopefully removed after upgrading -// cppcheck past 1.56 - -// eraseDereference: This is a known false positive, which has been -// fixed in the current development version of cppcheck -eraseDereference - -// Unused functions: there suddenly are a lot of unused function errors -// We could address those by adding for instance early declarations or -// (unnecessary) header files, but they were all somewhat false positives -// When we upgrade past 1.56, we should re-check this, and perhaps enable -// unused-functions again. -unusedFunction +// Supress errors from external sources. +*:/usr/include/* +*:/usr/src/googletest/*