Skip to content

Commit

Permalink
src,test: Fix more cppcheck warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
stotko committed Nov 16, 2024
1 parent 1b7b2e8 commit c4399c3
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cmake/setup_cppcheck.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down
3 changes: 2 additions & 1 deletion src/stdgpu/impl/memory_detail.h
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,6 @@ template <typename Allocator>
typename allocator_traits<Allocator>::pointer
allocator_traits<Allocator>::allocate(Allocator& a,
typename allocator_traits<Allocator>::index_type n,
// cppcheck-suppress syntaxError
[[maybe_unused]] typename allocator_traits<Allocator>::const_void_pointer hint)
{
return a.allocate(n);
Expand Down Expand Up @@ -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<void>(static_cast<void*>(const_cast<std::remove_cv_t<T>*>(p)),
// cppcheck-suppress sizeofVoid
n * static_cast<index64_t>(sizeof(T)), // NOLINT(bugprone-sizeof-expression)
memory_type);
}
Expand All @@ -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<void>(static_cast<void*>(const_cast<std::remove_cv_t<T>*>(p)),
// cppcheck-suppress sizeofVoid
n * static_cast<index64_t>(sizeof(T)), // NOLINT(bugprone-sizeof-expression)
memory_type);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/stdgpu/algorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ class assignable_float
}

private:
float _f;
float _f = {};
};

TEST_F(stdgpu_algorithm, copy)
Expand Down
2 changes: 0 additions & 2 deletions tests/stdgpu/atomic.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1334,7 +1334,6 @@ public:

private:
stdgpu::atomic<T> _value;
T* _sequence;
T _one_pattern;
};

Expand All @@ -1358,7 +1357,6 @@ public:

private:
stdgpu::atomic<T> _value;
T* _sequence;
T _one_pattern;
};

Expand Down
1 change: 0 additions & 1 deletion tests/stdgpu/functional.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@ enum old_enum : std::int8_t
three = 3
};

// cppcheck-suppress syntaxError
TEST_F(stdgpu_functional, hash_enum)
{
std::unordered_set<std::size_t> hashes;
Expand Down
2 changes: 1 addition & 1 deletion tests/stdgpu/memory.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1972,7 +1972,7 @@ public:
}

private:
float _f;
float _f = {};
};
} // namespace

Expand Down

0 comments on commit c4399c3

Please sign in to comment.