diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/.clang-tidy | 1 | ||||
-rw-r--r-- | test/btree_test.c | 14 | ||||
-rw-r--r-- | test/ring_test.c | 8 | ||||
-rw-r--r-- | test/sem_test.c | 4 | ||||
-rw-r--r-- | test/sorted_array_test.c | 7 | ||||
-rw-r--r-- | test/tree_test.c | 10 |
6 files changed, 23 insertions, 21 deletions
diff --git a/test/.clang-tidy b/test/.clang-tidy index dc7dbc4..ecef880 100644 --- a/test/.clang-tidy +++ b/test/.clang-tidy @@ -13,7 +13,6 @@ Checks: > -cert-msc50-cpp, -clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling, -cppcoreguidelines-avoid-non-const-global-variables, - -cppcoreguidelines-init-variables, -google-readability-casting, -hicpp-multiway-paths-covered, -llvm-header-guard, diff --git a/test/btree_test.c b/test/btree_test.c index 5c32020..8b43aed 100644 --- a/test/btree_test.c +++ b/test/btree_test.c @@ -300,7 +300,8 @@ stress(const unsigned test_num, const size_t n_elems) ZixBTreeIter* next = NULL; for (size_t e = 0; e < n_elems; e++) { r = ith_elem(test_num, n_elems, e); - uintptr_t removed; + + uintptr_t removed = 0; if (zix_btree_remove(t, (void*)r, (void**)&removed, &next)) { return test_fail(t, "Error removing item %" PRIuPTR "\n", (uintptr_t)r); } @@ -342,8 +343,8 @@ stress(const unsigned test_num, const size_t n_elems) // Delete elements that don't exist for (size_t e = 0; e < n_elems; e++) { - r = ith_elem(test_num, n_elems * 3, n_elems + e); - uintptr_t removed; + r = ith_elem(test_num, n_elems * 3, n_elems + e); + uintptr_t removed = 0; if (!zix_btree_remove(t, (void*)r, (void**)&removed, &next)) { return test_fail( t, "Non-existant deletion of %" PRIuPTR " succeeded\n", (uintptr_t)r); @@ -360,7 +361,7 @@ stress(const unsigned test_num, const size_t n_elems) // Delete some elements towards the end for (size_t e = 0; e < n_elems / 4; e++) { r = ith_elem(test_num, n_elems, n_elems - (n_elems / 4) + e); - uintptr_t removed; + uintptr_t removed = 0; if (zix_btree_remove(t, (void*)r, (void**)&removed, &next)) { return test_fail(t, "Deletion of %" PRIuPTR " failed\n", (uintptr_t)r); } @@ -394,8 +395,9 @@ stress(const unsigned test_num, const size_t n_elems) // Delete some elements in a random order for (size_t e = 0; e < zix_btree_size(t) / 2; e++) { r = ith_elem(test_num, n_elems, rand() % n_elems); - uintptr_t removed; - ZixStatus rst = zix_btree_remove(t, (void*)r, (void**)&removed, &next); + + uintptr_t removed = 0; + ZixStatus rst = zix_btree_remove(t, (void*)r, (void**)&removed, &next); if (rst != ZIX_STATUS_SUCCESS && rst != ZIX_STATUS_NOT_FOUND) { return test_fail(t, "Error deleting %" PRIuPTR "\n", (uintptr_t)r); } diff --git a/test/ring_test.c b/test/ring_test.c index 915d099..1a26cd3 100644 --- a/test/ring_test.c +++ b/test/ring_test.c @@ -144,12 +144,12 @@ main(int argc, char** argv) zix_ring_mlock(ring); - ZixThread reader_thread; + ZixThread reader_thread; // NOLINT if (zix_thread_create(&reader_thread, MSG_SIZE * 4, reader, NULL)) { return failure("Failed to create reader thread\n"); } - ZixThread writer_thread; + ZixThread writer_thread; // NOLINT if (zix_thread_create(&writer_thread, MSG_SIZE * 4, writer, NULL)) { return failure("Failed to create writer thread\n"); } @@ -172,8 +172,8 @@ main(int argc, char** argv) zix_ring_write(ring, "a", 1); zix_ring_write(ring, "b", 1); - char buf; - uint32_t n = zix_ring_peek(ring, &buf, 1); + char buf = 0; + uint32_t n = zix_ring_peek(ring, &buf, 1); if (n != 1) { return failure("Peek n (%u) != 1\n", n); } diff --git a/test/sem_test.c b/test/sem_test.c index 5db7c08..a1f2a0e 100644 --- a/test/sem_test.c +++ b/test/sem_test.c @@ -68,13 +68,13 @@ main(int argc, char** argv) return 1; } - ZixThread reader_thread; + ZixThread reader_thread; // NOLINT if (zix_thread_create(&reader_thread, 128, reader, NULL)) { fprintf(stderr, "Failed to create reader thread\n"); return 1; } - ZixThread writer_thread; + ZixThread writer_thread; // NOLINT if (zix_thread_create(&writer_thread, 128, writer, NULL)) { fprintf(stderr, "Failed to create writer thread\n"); return 1; diff --git a/test/sorted_array_test.c b/test/sorted_array_test.c index d991784..a782db4 100644 --- a/test/sorted_array_test.c +++ b/test/sorted_array_test.c @@ -58,8 +58,8 @@ test_fail(void) static int stress(unsigned test_num, unsigned n_elems) { - intptr_t r; - ZixSortedArrayIter ti; + intptr_t r = 0; + ZixSortedArrayIter ti = NULL; ZixSortedArray* t = zix_sorted_array_new(true, int_cmp, NULL, sizeof(intptr_t)); @@ -126,7 +126,8 @@ stress(unsigned test_num, unsigned n_elems) // Delete all elements for (unsigned e = 0; e < n_elems; e++) { r = ith_elem(test_num, n_elems, e); - ZixSortedArrayIter item; + + ZixSortedArrayIter item = NULL; if (zix_sorted_array_find(t, &r, &item) != ZIX_STATUS_SUCCESS) { fprintf(stderr, "Failed to find item to remove\n"); return test_fail(); diff --git a/test/tree_test.c b/test/tree_test.c index 08913e8..d1e710e 100644 --- a/test/tree_test.c +++ b/test/tree_test.c @@ -59,10 +59,9 @@ test_fail(void) static int stress(unsigned test_num, size_t n_elems) { - intptr_t r; - ZixTreeIter* ti; - - ZixTree* t = zix_tree_new(true, int_cmp, NULL, NULL); + intptr_t r = 0; + ZixTreeIter* ti = NULL; + ZixTree* t = zix_tree_new(true, int_cmp, NULL, NULL); srand(seed); @@ -152,7 +151,8 @@ stress(unsigned test_num, size_t n_elems) // Delete all elements for (size_t e = 0; e < n_elems; e++) { r = ith_elem(test_num, n_elems, e); - ZixTreeIter* item; + + ZixTreeIter* item = NULL; if (zix_tree_find(t, (void*)r, &item) != ZIX_STATUS_SUCCESS) { fprintf(stderr, "Failed to find item to remove\n"); return test_fail(); |