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 clang-tidy warnings #137

Merged
merged 6 commits into from
Apr 16, 2020
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
4 changes: 2 additions & 2 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ bugprone-*,\
hicpp-*,\
-hicpp-vararg,\
-hicpp-use-auto,\
-hicpp-no-array-decay,\
-hicpp-special-member-functions,\
misc-*,\
-misc-macro-parentheses,\
modernize-*,\
-modernize-use-auto,\
-modernize-pass-by-value,\
-modernize-return-braced-init-list,\
performance-*,\
readability-*,\
-readability-avoid-const-params-in-decls,\
"
HeaderFilterRegex: 'src|test/stdgpu'
...

2 changes: 1 addition & 1 deletion src/stdgpu/contract.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ namespace stdgpu
" File : %s:%d\n" \
" Function : %s\n" \
" Condition : %s\n", \
__FILE__, __LINE__, STDGPU_FUNC, #condition); \
__FILE__, __LINE__, static_cast<const char*>(STDGPU_FUNC), #condition); \
std::terminate(); \
}

Expand Down
4 changes: 2 additions & 2 deletions src/stdgpu/cstdlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ namespace stdgpu
*/
struct sizediv_t
{
std::size_t quot; /**< The quotient */
std::size_t rem; /**< The remainder */
std::size_t quot = {}; /**< The quotient */
std::size_t rem = {}; /**< The remainder */
};

/**
Expand Down
2 changes: 1 addition & 1 deletion src/stdgpu/impl/bitset.inc
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ void
bitset::destroyDeviceObject(bitset& device_object)
{
destroyDeviceArray<block_type>(device_object._bit_blocks);
device_object._bit_blocks = 0;
device_object._bit_blocks = nullptr;
device_object._size = 0;
}

Expand Down
4 changes: 2 additions & 2 deletions src/stdgpu/openmp/impl/memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ dispatch_malloc(const dynamic_memory_type type,
case dynamic_memory_type::host :
case dynamic_memory_type::managed :
{
*array = std::malloc(static_cast<std::size_t>(bytes));
*array = std::malloc(static_cast<std::size_t>(bytes)); // NOLINT(hicpp-no-malloc)
}
break;

Expand All @@ -59,7 +59,7 @@ dispatch_free(const dynamic_memory_type type,
case dynamic_memory_type::host :
case dynamic_memory_type::managed :
{
std::free(array);
std::free(array); // NOLINT(hicpp-no-malloc)
}
break;

Expand Down
11 changes: 8 additions & 3 deletions test/stdgpu/bitset.inc
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@

#include <algorithm>
#include <limits>
#include <random>
#include <unordered_set>
#include <thrust/functional.h>
#include <thrust/logical.h>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/transform.h>

#include <test_utils.h>
#include <stdgpu/bitset.cuh>
#include <stdgpu/iterator.h>
#include <stdgpu/memory.h>
Expand All @@ -45,8 +47,8 @@ class stdgpu_bitset : public ::testing::Test
stdgpu::bitset::destroyDeviceObject(bitset);
}

stdgpu::index_t bitset_size;
stdgpu::bitset bitset;
stdgpu::index_t bitset_size = 0;
stdgpu::bitset bitset = {};
};


Expand Down Expand Up @@ -287,7 +289,10 @@ generate_shuffled_sequence(const stdgpu::index_t size)
}

// Shuffle
std::random_shuffle(host_result, host_result + size);
std::size_t seed = test_utils::random_thread_seed();
std::default_random_engine rng(static_cast<std::default_random_engine::result_type>(seed));

std::shuffle(host_result, host_result + size, rng);

return host_result;
}
Expand Down
4 changes: 2 additions & 2 deletions test/stdgpu/mutex.inc
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ class stdgpu_mutex : public ::testing::Test
stdgpu::mutex_array::destroyDeviceObject(locks);
}

stdgpu::index_t locks_size;
stdgpu::mutex_array locks;
stdgpu::index_t locks_size = 0;
stdgpu::mutex_array locks = {};
};


Expand Down
2 changes: 1 addition & 1 deletion test/stdgpu/unordered_datastructure.inc
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class STDGPU_UNORDERED_DATASTRUCTURE_TEST_CLASS : public ::testing::Test
test_unordered_datastructure::destroyDeviceObject(hash_datastructure);
}

test_unordered_datastructure hash_datastructure;
test_unordered_datastructure hash_datastructure = {};
};


Expand Down