Commit c16eb80d authored by gabime's avatar gabime

Fixed multiple clang-tidy warnings

parent 0c56f98a
...@@ -21,10 +21,10 @@ namespace spdlog { ...@@ -21,10 +21,10 @@ namespace spdlog {
namespace cfg { namespace cfg {
// search for SPDLOG_LEVEL= in the args and use it to init the levels // 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="; 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]; std::string arg = argv[i];
if (arg.find(spdlog_level_prefix) == 0) if (arg.find(spdlog_level_prefix) == 0)
...@@ -36,5 +36,10 @@ void load_argv_levels(int args, char **argv) ...@@ -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<const char**>(argv));
}
} // namespace cfg } // namespace cfg
} // namespace spdlog } // namespace spdlog
...@@ -30,7 +30,11 @@ public: ...@@ -30,7 +30,11 @@ public:
~ansicolor_sink() override = default; ~ansicolor_sink() override = default;
ansicolor_sink(const ansicolor_sink &other) = delete; ansicolor_sink(const ansicolor_sink &other) = delete;
ansicolor_sink(ansicolor_sink &&other) = delete;
ansicolor_sink &operator=(const 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(level::level_enum color_level, string_view_t color);
void set_color_mode(color_mode mode); void set_color_mode(color_mode mode);
bool should_color(); bool should_color();
......
...@@ -21,8 +21,14 @@ class base_sink : public sink ...@@ -21,8 +21,14 @@ class base_sink : public sink
public: public:
base_sink(); base_sink();
explicit base_sink(std::unique_ptr<spdlog::formatter> formatter); explicit base_sink(std::unique_ptr<spdlog::formatter> formatter);
~base_sink() override = default;
base_sink(const base_sink &) = delete; base_sink(const base_sink &) = delete;
base_sink(base_sink &&) = delete;
base_sink &operator=(const 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 log(const details::log_msg &msg) final;
void flush() final; void flush() final;
void set_pattern(const std::string &pattern) final; void set_pattern(const std::string &pattern) final;
......
...@@ -19,8 +19,12 @@ public: ...@@ -19,8 +19,12 @@ public:
using mutex_t = typename ConsoleMutex::mutex_t; using mutex_t = typename ConsoleMutex::mutex_t;
explicit stdout_sink_base(FILE *file); explicit stdout_sink_base(FILE *file);
~stdout_sink_base() override = default; ~stdout_sink_base() override = default;
stdout_sink_base(const stdout_sink_base &other) = delete; 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=(const stdout_sink_base &other) = delete;
stdout_sink_base &operator=(stdout_sink_base &&other) = delete;
void log(const details::log_msg &msg) override; void log(const details::log_msg &msg) override;
void flush() override; void flush() override;
......
...@@ -27,7 +27,7 @@ TEST_CASE("argv1", "[cfg]") ...@@ -27,7 +27,7 @@ TEST_CASE("argv1", "[cfg]")
{ {
spdlog::drop("l1"); spdlog::drop("l1");
const char *argv[] = {"ignore", "SPDLOG_LEVEL=l1=warn"}; const char *argv[] = {"ignore", "SPDLOG_LEVEL=l1=warn"};
load_argv_levels(2, const_cast<char **>(argv)); load_argv_levels(2, argv);
auto l1 = spdlog::create<spdlog::sinks::test_sink_st>("l1"); auto l1 = spdlog::create<spdlog::sinks::test_sink_st>("l1");
REQUIRE(l1->level() == spdlog::level::warn); REQUIRE(l1->level() == spdlog::level::warn);
REQUIRE(spdlog::default_logger()->level() == spdlog::level::info); REQUIRE(spdlog::default_logger()->level() == spdlog::level::info);
...@@ -37,7 +37,7 @@ TEST_CASE("argv2", "[cfg]") ...@@ -37,7 +37,7 @@ TEST_CASE("argv2", "[cfg]")
{ {
spdlog::drop("l1"); spdlog::drop("l1");
const char *argv[] = {"ignore", "SPDLOG_LEVEL=l1=warn,trace"}; const char *argv[] = {"ignore", "SPDLOG_LEVEL=l1=warn,trace"};
load_argv_levels(2, const_cast<char **>(argv)); load_argv_levels(2, argv);
auto l1 = spdlog::create<test_sink_st>("l1"); auto l1 = spdlog::create<test_sink_st>("l1");
REQUIRE(l1->level() == spdlog::level::warn); REQUIRE(l1->level() == spdlog::level::warn);
REQUIRE(spdlog::default_logger()->level() == spdlog::level::trace); REQUIRE(spdlog::default_logger()->level() == spdlog::level::trace);
...@@ -48,7 +48,7 @@ TEST_CASE("argv3", "[cfg]") ...@@ -48,7 +48,7 @@ TEST_CASE("argv3", "[cfg]")
{ {
spdlog::drop("l1"); spdlog::drop("l1");
const char *argv[] = {"ignore", "SPDLOG_LEVEL="}; const char *argv[] = {"ignore", "SPDLOG_LEVEL="};
load_argv_levels(2, const_cast<char **>(argv)); load_argv_levels(2, argv);
auto l1 = spdlog::create<test_sink_st>("l1"); auto l1 = spdlog::create<test_sink_st>("l1");
REQUIRE(l1->level() == spdlog::level::info); REQUIRE(l1->level() == spdlog::level::info);
REQUIRE(spdlog::default_logger()->level() == spdlog::level::info); REQUIRE(spdlog::default_logger()->level() == spdlog::level::info);
...@@ -58,7 +58,7 @@ TEST_CASE("argv4", "[cfg]") ...@@ -58,7 +58,7 @@ TEST_CASE("argv4", "[cfg]")
{ {
spdlog::drop("l1"); spdlog::drop("l1");
const char *argv[] = {"ignore", "SPDLOG_LEVEL=junk"}; const char *argv[] = {"ignore", "SPDLOG_LEVEL=junk"};
load_argv_levels(2, const_cast<char **>(argv)); load_argv_levels(2, argv);
auto l1 = spdlog::create<test_sink_st>("l1"); auto l1 = spdlog::create<test_sink_st>("l1");
REQUIRE(l1->level() == spdlog::level::info); REQUIRE(l1->level() == spdlog::level::info);
} }
...@@ -67,7 +67,7 @@ TEST_CASE("argv5", "[cfg]") ...@@ -67,7 +67,7 @@ TEST_CASE("argv5", "[cfg]")
{ {
spdlog::drop("l1"); spdlog::drop("l1");
const char *argv[] = {"ignore", "ignore", "SPDLOG_LEVEL=l1=warn,trace"}; const char *argv[] = {"ignore", "ignore", "SPDLOG_LEVEL=l1=warn,trace"};
load_argv_levels(3, const_cast<char **>(argv)); load_argv_levels(3, argv);
auto l1 = spdlog::create<test_sink_st>("l1"); auto l1 = spdlog::create<test_sink_st>("l1");
REQUIRE(l1->level() == spdlog::level::warn); REQUIRE(l1->level() == spdlog::level::warn);
REQUIRE(spdlog::default_logger()->level() == spdlog::level::trace); REQUIRE(spdlog::default_logger()->level() == spdlog::level::trace);
...@@ -78,7 +78,7 @@ TEST_CASE("argv6", "[cfg]") ...@@ -78,7 +78,7 @@ TEST_CASE("argv6", "[cfg]")
{ {
spdlog::set_level(spdlog::level::err); spdlog::set_level(spdlog::level::err);
const char *argv[] = {""}; const char *argv[] = {""};
load_argv_levels(1, const_cast<char **>(argv)); load_argv_levels(1, argv);
REQUIRE(spdlog::default_logger()->level() == spdlog::level::err); REQUIRE(spdlog::default_logger()->level() == spdlog::level::err);
spdlog::set_level(spdlog::level::info); spdlog::set_level(spdlog::level::info);
} }
...@@ -87,7 +87,7 @@ TEST_CASE("argv7", "[cfg]") ...@@ -87,7 +87,7 @@ TEST_CASE("argv7", "[cfg]")
{ {
spdlog::set_level(spdlog::level::err); spdlog::set_level(spdlog::level::err);
const char *argv[] = {""}; const char *argv[] = {""};
load_argv_levels(0, const_cast<char **>(argv)); load_argv_levels(0, argv);
REQUIRE(spdlog::default_logger()->level() == spdlog::level::err); REQUIRE(spdlog::default_logger()->level() == spdlog::level::err);
spdlog::set_level(spdlog::level::info); spdlog::set_level(spdlog::level::info);
} }
#include "includes.h" #include "includes.h"
using namespace std::chrono;
using std::chrono::milliseconds; using std::chrono::milliseconds;
using test_clock = std::chrono::high_resolution_clock; using test_clock = std::chrono::high_resolution_clock;
...@@ -13,7 +12,7 @@ TEST_CASE("dequeue-empty-nowait", "[mpmc_blocking_q]") ...@@ -13,7 +12,7 @@ TEST_CASE("dequeue-empty-nowait", "[mpmc_blocking_q]")
size_t q_size = 100; size_t q_size = 100;
milliseconds tolerance_wait(10); milliseconds tolerance_wait(10);
spdlog::details::mpmc_blocking_queue<int> q(q_size); spdlog::details::mpmc_blocking_queue<int> q(q_size);
int popped_item; int popped_item = 0;
auto start = test_clock::now(); auto start = test_clock::now();
auto rv = q.dequeue_for(popped_item, milliseconds::zero()); auto rv = q.dequeue_for(popped_item, milliseconds::zero());
...@@ -32,7 +31,7 @@ TEST_CASE("dequeue-empty-wait", "[mpmc_blocking_q]") ...@@ -32,7 +31,7 @@ TEST_CASE("dequeue-empty-wait", "[mpmc_blocking_q]")
milliseconds tolerance_wait(250); milliseconds tolerance_wait(250);
spdlog::details::mpmc_blocking_queue<int> q(q_size); spdlog::details::mpmc_blocking_queue<int> q(q_size);
int popped_item; int popped_item = 0;
auto start = test_clock::now(); auto start = test_clock::now();
auto rv = q.dequeue_for(popped_item, wait_ms); auto rv = q.dequeue_for(popped_item, wait_ms);
auto delta_ms = millis_from(start); auto delta_ms = millis_from(start);
...@@ -69,7 +68,7 @@ TEST_CASE("bad_queue", "[mpmc_blocking_q]") ...@@ -69,7 +68,7 @@ TEST_CASE("bad_queue", "[mpmc_blocking_q]")
spdlog::details::mpmc_blocking_queue<int> q(q_size); spdlog::details::mpmc_blocking_queue<int> q(q_size);
q.enqueue_nowait(1); q.enqueue_nowait(1);
REQUIRE(q.overrun_counter() == 1); REQUIRE(q.overrun_counter() == 1);
int i; int i = 0;
REQUIRE(q.dequeue_for(i, milliseconds(0)) == false); REQUIRE(q.dequeue_for(i, milliseconds(0)) == false);
} }
...@@ -77,7 +76,7 @@ TEST_CASE("empty_queue", "[mpmc_blocking_q]") ...@@ -77,7 +76,7 @@ TEST_CASE("empty_queue", "[mpmc_blocking_q]")
{ {
size_t q_size = 10; size_t q_size = 10;
spdlog::details::mpmc_blocking_queue<int> q(q_size); spdlog::details::mpmc_blocking_queue<int> q(q_size);
int i; int i = 0;
REQUIRE(q.dequeue_for(i, milliseconds(10)) == false); REQUIRE(q.dequeue_for(i, milliseconds(10)) == false);
} }
...@@ -87,7 +86,7 @@ TEST_CASE("full_queue", "[mpmc_blocking_q]") ...@@ -87,7 +86,7 @@ TEST_CASE("full_queue", "[mpmc_blocking_q]")
spdlog::details::mpmc_blocking_queue<int> q(q_size); spdlog::details::mpmc_blocking_queue<int> q(q_size);
for (int i = 0; i < static_cast<int>(q_size); i++) for (int i = 0; i < static_cast<int>(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); q.enqueue_nowait(123456);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment