From b66f212cdce336a024244a7278b557e0daffe39e Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Mon, 24 Oct 2016 20:42:54 +0200 Subject: Ensure log_message_t contents are always initialised --- src/Log.cpp | 7 ++----- src/Log.h | 6 ++++-- 2 files changed, 6 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/Log.cpp b/src/Log.cpp index 77687fc..4780f58 100644 --- a/src/Log.cpp +++ b/src/Log.cpp @@ -68,10 +68,7 @@ void Logger::log(log_level_t level, const char* fmt, ...) void Logger::logstr(log_level_t level, std::string message) { - log_message_t m; - m.level = level; - m.message = message; - + log_message_t m(level, message); m_message_queue.push(std::move(m)); } @@ -86,7 +83,7 @@ void Logger::io_process() auto message = m.message; - if (m.level == debug and m.message.empty()) { + if (m.level == trace and m.message.empty()) { // Special message to stop thread break; } diff --git a/src/Log.h b/src/Log.h index 0714835..3a588f4 100644 --- a/src/Log.h +++ b/src/Log.h @@ -138,7 +138,9 @@ struct log_message_t { level(_level), message(_message) {} - log_message_t() {} + log_message_t() : + level(debug), + message("") {} log_level_t level; std::string message; @@ -154,7 +156,7 @@ class Logger { const Logger& operator=(const Logger& other) = delete; ~Logger() { // Special message to stop the thread - log_message_t m(debug, ""); + log_message_t m(trace, ""); m_message_queue.push(m); m_io_thread.join(); -- cgit v1.2.3