From c4f719b1831e35663163e09a0d692c909c09d95f Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 3 Feb 2023 14:42:49 -0500 Subject: Suppress/fix new warnings in clang-tidy 15 --- test/array_test.cpp | 4 ++-- test/build_test.cpp | 22 +++++++++++----------- test/maid_test.cpp | 6 +++--- test/path_test.cpp | 4 ++-- test/ringbuffer_test.cpp | 2 -- test/socket_test.cpp | 8 ++++---- test/symbol_test.cpp | 4 ++-- 7 files changed, 24 insertions(+), 26 deletions(-) diff --git a/test/array_test.cpp b/test/array_test.cpp index e583acd..5f10693 100644 --- a/test/array_test.cpp +++ b/test/array_test.cpp @@ -26,12 +26,12 @@ main() array1.alloc(8, 0); assert(array1.size() == 8); - raul::Array array2(array1); + const raul::Array array2{array1}; for (size_t i = 0; i < array1.size(); ++i) { assert(array2[i] == array1[i]); } - raul::Array array3(8, 47); + const raul::Array array3{8, 47}; assert(array3[0] == 47); assert(array3.size() == 8); diff --git a/test/build_test.cpp b/test/build_test.cpp index 10f4aa3..8449ece 100644 --- a/test/build_test.cpp +++ b/test/build_test.cpp @@ -26,18 +26,18 @@ class NonCopyableThing : public raul::Noncopyable int main() { - raul::Array array; - DeletableThing deletable; - raul::DoubleBuffer double_buffer(0); - raul::Maid maid; - NonCopyableThing non_copyable; - raul::Path path; - raul::RingBuffer ring_buffer(64U); - raul::Semaphore semaphore(0U); - raul::Symbol symbol("foo"); + const raul::Array array; + const DeletableThing deletable; + const raul::DoubleBuffer double_buffer(0); + const raul::Maid maid; + const NonCopyableThing non_copyable; + const raul::Path path; + const raul::RingBuffer ring_buffer(64U); + const raul::Semaphore semaphore(0U); + const raul::Symbol symbol("foo"); try { - raul::Symbol bad_symbol("not a valid symbol!"); + const raul::Symbol bad_symbol("not a valid symbol!"); (void)bad_symbol; } catch (const raul::Exception&) { } @@ -46,7 +46,7 @@ main() const char* cmd[] = {"echo"}; raul::Process::launch(cmd); - raul::Socket socket(raul::Socket::Type::UNIX); + const raul::Socket socket(raul::Socket::Type::UNIX); (void)socket; #endif diff --git a/test/maid_test.cpp b/test/maid_test.cpp index ba9867e..286be2a 100644 --- a/test/maid_test.cpp +++ b/test/maid_test.cpp @@ -62,9 +62,9 @@ test() // Check basic single-threaded correctness { assert(n_junk == 0); - Maid::managed_ptr a = maid.make_managed(1U); + const Maid::managed_ptr a = maid.make_managed(1U); assert(n_junk == 1); - Maid::managed_ptr b = maid.make_managed(2U); + const Maid::managed_ptr b = maid.make_managed(2U); assert(n_junk == 2); } @@ -116,7 +116,7 @@ test() assert(n_junk == 0); // Allocate a new object, then let it and the Maid go out of scope - Maid::managed_ptr c = maid.make_managed(5U); + const Maid::managed_ptr c = maid.make_managed(5U); assert(n_junk == 1); } diff --git a/test/path_test.cpp b/test/path_test.cpp index 573448c..9992cbb 100644 --- a/test/path_test.cpp +++ b/test/path_test.cpp @@ -67,7 +67,7 @@ main() bool valid = true; try { - Path path("/ends/in/slash/"); + const Path path{"/ends/in/slash/"}; } catch (const Path::BadPath& e) { std::cerr << "Caught exception: " << e.what() << std::endl; valid = false; @@ -76,7 +76,7 @@ main() valid = true; try { - Path path(std::string("/has//double/slash")); + const Path path{std::string("/has//double/slash")}; } catch (const Path::BadPath& e) { std::cerr << "Caught exception: " << e.what() << std::endl; valid = false; diff --git a/test/ringbuffer_test.cpp b/test/ringbuffer_test.cpp index 7366bf4..e5d31e3 100644 --- a/test/ringbuffer_test.cpp +++ b/test/ringbuffer_test.cpp @@ -51,7 +51,6 @@ reader(Context& ctx) int ref_msg[MSG_SIZE]; // Reference generated for comparison int read_msg[MSG_SIZE]; // Read from ring - size_t count = 0; int start = gen_msg(ref_msg, 0); for (size_t i = 0; i < ctx.n_writes; ++i) { if (ctx.ring->read_space() >= MSG_SIZE * sizeof(int)) { @@ -59,7 +58,6 @@ reader(Context& ctx) assert(n_read == MSG_SIZE * sizeof(int)); check_msg(ref_msg, read_msg); start = gen_msg(ref_msg, start); - ++count; } } diff --git a/test/socket_test.cpp b/test/socket_test.cpp index ff2e7d7..46d4209 100644 --- a/test/socket_test.cpp +++ b/test/socket_test.cpp @@ -19,8 +19,8 @@ main() { using Socket = raul::Socket; - std::string unix_uri("unix:///tmp/raul_test_sock"); - std::string tcp_uri("tcp://127.0.0.1:12345"); + const std::string unix_uri{"unix:///tmp/raul_test_sock"}; + const std::string tcp_uri{"tcp://127.0.0.1:12345"}; Socket unix_server_sock(Socket::Type::UNIX); Socket tcp_server_sock(Socket::Type::TCP); @@ -58,12 +58,12 @@ main() } if (pfds[0].revents & POLLIN) { - std::shared_ptr conn = unix_server_sock.accept(); + const std::shared_ptr conn = unix_server_sock.accept(); ++n_received; } if (pfds[1].revents & POLLIN) { - std::shared_ptr conn = tcp_server_sock.accept(); + const std::shared_ptr conn = tcp_server_sock.accept(); ++n_received; } } diff --git a/test/symbol_test.cpp b/test/symbol_test.cpp index e9f64da..ee78cea 100644 --- a/test/symbol_test.cpp +++ b/test/symbol_test.cpp @@ -39,7 +39,7 @@ main() bool valid = true; try { - Symbol symbol("0startswithdigit"); + const Symbol symbol{"0startswithdigit"}; } catch (const Symbol::BadSymbol& e) { std::cerr << "Caught exception: " << e.what() << std::endl; valid = false; @@ -48,7 +48,7 @@ main() valid = true; try { - Symbol symbol(std::string("invalid/symbol")); + const Symbol symbol{std::string("invalid/symbol")}; } catch (const Symbol::BadSymbol& e) { std::cerr << "Caught exception: " << e.what() << std::endl; valid = false; -- cgit v1.2.1