Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src,test: Fix more cppcheck warnings #440

Merged
merged 1 commit into from
Nov 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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