diff --git a/include/spdlog/cfg/argv.h b/include/spdlog/cfg/argv.h index ea60949c..6d71864e 100644 --- a/include/spdlog/cfg/argv.h +++ b/include/spdlog/cfg/argv.h @@ -21,10 +21,10 @@ namespace spdlog { namespace cfg { // search for SPDLOG_LEVEL= in the args and use it to init the levels -void load_argv_levels(int args, char **argv) +void load_argv_levels(int argc, const char **argv) { const std::string spdlog_level_prefix = "SPDLOG_LEVEL="; - for (int i = 1; i < args; i++) + for (int i = 1; i < argc; i++) { std::string arg = argv[i]; if (arg.find(spdlog_level_prefix) == 0) @@ -36,5 +36,10 @@ void load_argv_levels(int args, char **argv) } } +void load_argv_levels(int argc, char **argv) +{ + load_argv_levels(argc, const_cast(argv)); +} + } // namespace cfg } // namespace spdlog diff --git a/include/spdlog/sinks/ansicolor_sink.h b/include/spdlog/sinks/ansicolor_sink.h index d3c93284..90b590e6 100644 --- a/include/spdlog/sinks/ansicolor_sink.h +++ b/include/spdlog/sinks/ansicolor_sink.h @@ -30,7 +30,11 @@ public: ~ansicolor_sink() override = default; ansicolor_sink(const ansicolor_sink &other) = delete; + ansicolor_sink(ansicolor_sink &&other) = delete; + ansicolor_sink &operator=(const ansicolor_sink &other) = delete; + ansicolor_sink &operator=(ansicolor_sink &&other) = delete; + void set_color(level::level_enum color_level, string_view_t color); void set_color_mode(color_mode mode); bool should_color(); diff --git a/include/spdlog/sinks/base_sink.h b/include/spdlog/sinks/base_sink.h index bc832763..bf5072f8 100644 --- a/include/spdlog/sinks/base_sink.h +++ b/include/spdlog/sinks/base_sink.h @@ -21,8 +21,14 @@ class base_sink : public sink public: base_sink(); explicit base_sink(std::unique_ptr formatter); + ~base_sink() override = default; + base_sink(const base_sink &) = delete; + base_sink(base_sink &&) = delete; + base_sink &operator=(const base_sink &) = delete; + base_sink &operator=(base_sink &&) = delete; + void log(const details::log_msg &msg) final; void flush() final; void set_pattern(const std::string &pattern) final; diff --git a/include/spdlog/sinks/stdout_sinks.h b/include/spdlog/sinks/stdout_sinks.h index 1cc47bd0..b962e1e2 100644 --- a/include/spdlog/sinks/stdout_sinks.h +++ b/include/spdlog/sinks/stdout_sinks.h @@ -19,8 +19,12 @@ public: using mutex_t = typename ConsoleMutex::mutex_t; explicit stdout_sink_base(FILE *file); ~stdout_sink_base() override = default; + stdout_sink_base(const stdout_sink_base &other) = delete; + stdout_sink_base(stdout_sink_base &&other) = delete; + stdout_sink_base &operator=(const stdout_sink_base &other) = delete; + stdout_sink_base &operator=(stdout_sink_base &&other) = delete; void log(const details::log_msg &msg) override; void flush() override; diff --git a/tests/test_cfg.cpp b/tests/test_cfg.cpp index 8231ff89..436036d3 100644 --- a/tests/test_cfg.cpp +++ b/tests/test_cfg.cpp @@ -27,7 +27,7 @@ TEST_CASE("argv1", "[cfg]") { spdlog::drop("l1"); const char *argv[] = {"ignore", "SPDLOG_LEVEL=l1=warn"}; - load_argv_levels(2, const_cast(argv)); + load_argv_levels(2, argv); auto l1 = spdlog::create("l1"); REQUIRE(l1->level() == spdlog::level::warn); REQUIRE(spdlog::default_logger()->level() == spdlog::level::info); @@ -37,7 +37,7 @@ TEST_CASE("argv2", "[cfg]") { spdlog::drop("l1"); const char *argv[] = {"ignore", "SPDLOG_LEVEL=l1=warn,trace"}; - load_argv_levels(2, const_cast(argv)); + load_argv_levels(2, argv); auto l1 = spdlog::create("l1"); REQUIRE(l1->level() == spdlog::level::warn); REQUIRE(spdlog::default_logger()->level() == spdlog::level::trace); @@ -48,7 +48,7 @@ TEST_CASE("argv3", "[cfg]") { spdlog::drop("l1"); const char *argv[] = {"ignore", "SPDLOG_LEVEL="}; - load_argv_levels(2, const_cast(argv)); + load_argv_levels(2, argv); auto l1 = spdlog::create("l1"); REQUIRE(l1->level() == spdlog::level::info); REQUIRE(spdlog::default_logger()->level() == spdlog::level::info); @@ -58,7 +58,7 @@ TEST_CASE("argv4", "[cfg]") { spdlog::drop("l1"); const char *argv[] = {"ignore", "SPDLOG_LEVEL=junk"}; - load_argv_levels(2, const_cast(argv)); + load_argv_levels(2, argv); auto l1 = spdlog::create("l1"); REQUIRE(l1->level() == spdlog::level::info); } @@ -67,7 +67,7 @@ TEST_CASE("argv5", "[cfg]") { spdlog::drop("l1"); const char *argv[] = {"ignore", "ignore", "SPDLOG_LEVEL=l1=warn,trace"}; - load_argv_levels(3, const_cast(argv)); + load_argv_levels(3, argv); auto l1 = spdlog::create("l1"); REQUIRE(l1->level() == spdlog::level::warn); REQUIRE(spdlog::default_logger()->level() == spdlog::level::trace); @@ -78,7 +78,7 @@ TEST_CASE("argv6", "[cfg]") { spdlog::set_level(spdlog::level::err); const char *argv[] = {""}; - load_argv_levels(1, const_cast(argv)); + load_argv_levels(1, argv); REQUIRE(spdlog::default_logger()->level() == spdlog::level::err); spdlog::set_level(spdlog::level::info); } @@ -87,7 +87,7 @@ TEST_CASE("argv7", "[cfg]") { spdlog::set_level(spdlog::level::err); const char *argv[] = {""}; - load_argv_levels(0, const_cast(argv)); + load_argv_levels(0, argv); REQUIRE(spdlog::default_logger()->level() == spdlog::level::err); spdlog::set_level(spdlog::level::info); } diff --git a/tests/test_mpmc_q.cpp b/tests/test_mpmc_q.cpp index 888240fd..428a85c5 100644 --- a/tests/test_mpmc_q.cpp +++ b/tests/test_mpmc_q.cpp @@ -1,6 +1,5 @@ #include "includes.h" -using namespace std::chrono; using std::chrono::milliseconds; using test_clock = std::chrono::high_resolution_clock; @@ -13,7 +12,7 @@ TEST_CASE("dequeue-empty-nowait", "[mpmc_blocking_q]") size_t q_size = 100; milliseconds tolerance_wait(10); spdlog::details::mpmc_blocking_queue q(q_size); - int popped_item; + int popped_item = 0; auto start = test_clock::now(); auto rv = q.dequeue_for(popped_item, milliseconds::zero()); @@ -32,7 +31,7 @@ TEST_CASE("dequeue-empty-wait", "[mpmc_blocking_q]") milliseconds tolerance_wait(250); spdlog::details::mpmc_blocking_queue q(q_size); - int popped_item; + int popped_item = 0; auto start = test_clock::now(); auto rv = q.dequeue_for(popped_item, wait_ms); auto delta_ms = millis_from(start); @@ -69,7 +68,7 @@ TEST_CASE("bad_queue", "[mpmc_blocking_q]") spdlog::details::mpmc_blocking_queue q(q_size); q.enqueue_nowait(1); REQUIRE(q.overrun_counter() == 1); - int i; + int i = 0; REQUIRE(q.dequeue_for(i, milliseconds(0)) == false); } @@ -77,7 +76,7 @@ TEST_CASE("empty_queue", "[mpmc_blocking_q]") { size_t q_size = 10; spdlog::details::mpmc_blocking_queue q(q_size); - int i; + int i = 0; REQUIRE(q.dequeue_for(i, milliseconds(10)) == false); } @@ -87,7 +86,7 @@ TEST_CASE("full_queue", "[mpmc_blocking_q]") spdlog::details::mpmc_blocking_queue q(q_size); for (int i = 0; i < static_cast(q_size); i++) { - q.enqueue(std::move(i)); + q.enqueue(i+0); // i+0 to force rvalue and avoid tidy warnings on the same time } q.enqueue_nowait(123456);