From c4399c3fb3d7141e9ef4164e8254216815a7d289 Mon Sep 17 00:00:00 2001 From: Patrick Stotko Date: Sat, 16 Nov 2024 18:05:47 +0100 Subject: [PATCH] src,test: Fix more cppcheck warnings --- cmake/setup_cppcheck.cmake | 2 +- src/stdgpu/impl/memory_detail.h | 3 ++- tests/stdgpu/algorithm.cpp | 2 +- tests/stdgpu/atomic.inc | 2 -- tests/stdgpu/functional.cpp | 1 - tests/stdgpu/memory.inc | 2 +- 6 files changed, 5 insertions(+), 7 deletions(-) diff --git a/cmake/setup_cppcheck.cmake b/cmake/setup_cppcheck.cmake index 6214a6d78..429dc52da 100644 --- a/cmake/setup_cppcheck.cmake +++ b/cmake/setup_cppcheck.cmake @@ -2,7 +2,7 @@ function(stdgpu_setup_cppcheck STDGPU_OUTPUT_PROPERTY_CPPCHECK) find_package(Cppcheck REQUIRED) # Do not enable noisy "style" checks - set(${STDGPU_OUTPUT_PROPERTY_CPPCHECK} "${CPPCHECK_EXECUTABLE}" "--enable=warning,performance,portability" "--force" "--inline-suppr" "--quiet") + set(${STDGPU_OUTPUT_PROPERTY_CPPCHECK} "${CPPCHECK_EXECUTABLE}" "--enable=warning,performance,portability" "--force" "--inline-suppr" "--suppress=preprocessorErrorDirective" "--quiet") if(NOT DEFINED STDGPU_COMPILE_WARNING_AS_ERROR) message(FATAL_ERROR "STDGPU_COMPILE_WARNING_AS_ERROR not defined.") diff --git a/src/stdgpu/impl/memory_detail.h b/src/stdgpu/impl/memory_detail.h index 8b54bf1bb..4dca683e1 100644 --- a/src/stdgpu/impl/memory_detail.h +++ b/src/stdgpu/impl/memory_detail.h @@ -600,7 +600,6 @@ template typename allocator_traits::pointer allocator_traits::allocate(Allocator& a, typename allocator_traits::index_type n, - // cppcheck-suppress syntaxError [[maybe_unused]] typename allocator_traits::const_void_pointer hint) { return a.allocate(n); @@ -823,6 +822,7 @@ register_memory(T* p, index64_t n, dynamic_memory_type memory_type) { // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion) register_memory(static_cast(const_cast*>(p)), + // cppcheck-suppress sizeofVoid n * static_cast(sizeof(T)), // NOLINT(bugprone-sizeof-expression) memory_type); } @@ -837,6 +837,7 @@ deregister_memory(T* p, index64_t n, dynamic_memory_type memory_type) { // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion) deregister_memory(static_cast(const_cast*>(p)), + // cppcheck-suppress sizeofVoid n * static_cast(sizeof(T)), // NOLINT(bugprone-sizeof-expression) memory_type); } diff --git a/tests/stdgpu/algorithm.cpp b/tests/stdgpu/algorithm.cpp index 8633cbfb3..aa19481d6 100644 --- a/tests/stdgpu/algorithm.cpp +++ b/tests/stdgpu/algorithm.cpp @@ -405,7 +405,7 @@ class assignable_float } private: - float _f; + float _f = {}; }; TEST_F(stdgpu_algorithm, copy) diff --git a/tests/stdgpu/atomic.inc b/tests/stdgpu/atomic.inc index 5fc417897..ebbe745ab 100644 --- a/tests/stdgpu/atomic.inc +++ b/tests/stdgpu/atomic.inc @@ -1334,7 +1334,6 @@ public: private: stdgpu::atomic _value; - T* _sequence; T _one_pattern; }; @@ -1358,7 +1357,6 @@ public: private: stdgpu::atomic _value; - T* _sequence; T _one_pattern; }; diff --git a/tests/stdgpu/functional.cpp b/tests/stdgpu/functional.cpp index 2a675fb7d..0b0ebc211 100644 --- a/tests/stdgpu/functional.cpp +++ b/tests/stdgpu/functional.cpp @@ -256,7 +256,6 @@ enum old_enum : std::int8_t three = 3 }; -// cppcheck-suppress syntaxError TEST_F(stdgpu_functional, hash_enum) { std::unordered_set hashes; diff --git a/tests/stdgpu/memory.inc b/tests/stdgpu/memory.inc index 68b87118f..5bc0d596c 100644 --- a/tests/stdgpu/memory.inc +++ b/tests/stdgpu/memory.inc @@ -1972,7 +1972,7 @@ public: } private: - float _f; + float _f = {}; }; } // namespace