From 7e8446e98419a66477346dc8f5d5ce43f2eaef3a Mon Sep 17 00:00:00 2001 From: George Kiagiadakis Date: Wed, 22 Sep 2021 15:07:10 +0300 Subject: [PATCH] coverity: fix multiple source code parse errors Coverity scans the source code for static analysis, but its parser has a couple of flaws... The most common one is the failure to parse deprecation macros in enum definitions, like: ``` G_PARAM_PRIVATE GLIB_DEPRECATED_ENUMERATOR_IN_2_26 = G_PARAM_STATIC_NAME, ^ SD_JOURNAL_SYSTEM_ONLY _sd_deprecated_ = SD_JOURNAL_SYSTEM /* old name */ ^ ``` but also recent gcc built-in macros, like: ``` #if __has_builtin(__builtin_is_constant_evaluated) ^ #if _GLIBCXX_HAS_BUILTIN(__has_unique_object_representations) ^ ``` The solution is to replace the code with regular expressions at an earlier stage. This can be configured directly in coverity with cov-configure --- .gitlab-ci.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ff81dca8e..675b48faf 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -254,7 +254,15 @@ build_with_coverity: -Dvulkan=enabled -Dsdl2=enabled -Dsndfile=enabled - - cov-build --dir cov-int ninja -C "$BUILD_DIR" + - cov-configure --config coverity_conf.xml + --comptype gcc --compiler cc --template + --xml-option=append_arg@C:--ppp_translator + --xml-option=append_arg@C:"replace/_sd_deprecated_\s+=/ =" + --xml-option=append_arg@C:--ppp_translator + --xml-option=append_arg@C:"replace/GLIB_(DEPRECATED|AVAILABLE)_ENUMERATOR_IN_\d_\d\d(_FOR\(\w+\)|)\s+=/ =" + --xml-option=append_arg@C:--ppp_translator + --xml-option=append_arg@C:"replace/(__has_builtin|_GLIBCXX_HAS_BUILTIN)\(\w+\)/1" + - cov-build --dir cov-int --config coverity_conf.xml ninja -C "$BUILD_DIR" - tar czf cov-int.tar.gz cov-int - curl https://scan.coverity.com/builds?project=$COVERITY_SCAN_PROJECT_NAME --form token=$COVERITY_SCAN_TOKEN --form email=$GITLAB_USER_EMAIL