[gjs: 9/16] CI: Avoid cppcheck false positives
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs: 9/16] CI: Avoid cppcheck false positives
- Date: Mon, 23 Nov 2020 18:24:47 +0000 (UTC)
commit 2fde9dd46394cda25091065d234413af4e75494c
Author: Philip Chimento <philip chimento gmail com>
Date: Fri Nov 20 16:42:45 2020 -0800
CI: Avoid cppcheck false positives
Various changes to avoid false positives in cppcheck.
The 'alternative int' specifier isn't known to cppcheck so always run the
checks as if it is not defined.
Cppcheck has trouble deducing the type of one 'auto' variable, so just
replace it with its real type.
.gitlab-ci.yml | 2 +-
gi/arg.cpp | 2 +-
tools/run_cppcheck.sh | 1 +
3 files changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 8bfc43f8..48211ace 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -136,7 +136,7 @@ cppcheck:
image: uilianries/docker-cppcheck
stage: source_check
script:
- - cppcheck . -v -f -q --error-exitcode=1 --inline-suppr --library=gtk
--enable=warning,performance,portability
+ - cppcheck . -v -f -q -UHAVE_PRINTF_ALTERNATIVE_INT --error-exitcode=1 --inline-suppr --library=gtk
--enable=warning,performance,portability
except:
refs:
- schedules
diff --git a/gi/arg.cpp b/gi/arg.cpp
index 452427a0..5d8954f9 100644
--- a/gi/arg.cpp
+++ b/gi/arg.cpp
@@ -703,7 +703,7 @@ template <typename T>
if constexpr (std::is_same_v<T, char*>)
return g_new0(char*, length);
- auto* array = g_new(T, length);
+ T* array = g_new(T, length);
array[length - 1] = {0};
return array;
}
diff --git a/tools/run_cppcheck.sh b/tools/run_cppcheck.sh
index ab2671d7..1f542141 100755
--- a/tools/run_cppcheck.sh
+++ b/tools/run_cppcheck.sh
@@ -4,4 +4,5 @@
ninja -C _build
cppcheck --project=_build/compile_commands.json --inline-suppr \
--enable=warning,performance,portability,missingInclude \
+ -UHAVE_PRINTF_ALTERNATIVE_INT \
--library=gtk --force --quiet $@
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]