From bb5862f9d0f31dc551dfa6bf09b2e3b95271b979 Mon Sep 17 00:00:00 2001 From: kongr45gpen <electrovesta@gmail.com> Date: Wed, 14 Aug 2019 00:28:34 +0300 Subject: [PATCH] Ignore some random MISRA false positives Apply suggestion to inc/Logger.hpp Be explicit about the type used in the LogLevel enumeration This makes LogLevel an unscoped strongly-type enumeration, making sure there is consistency between the expected log level of uint8_t --- inc/Logger.hpp | 9 +++++---- src/Platform/x86/Logger.cpp | 6 +++--- src/Platform/x86/Service.cpp | 3 ++- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/inc/Logger.hpp b/inc/Logger.hpp index f1319550..f1ec6c95 100644 --- a/inc/Logger.hpp +++ b/inc/Logger.hpp @@ -107,7 +107,7 @@ public: * * Each severity is tied to a number. The higher the number, the higher the severity. */ - enum LogLevel { + enum LogLevel : LogLevelType { trace = 32, ///< Very detailed information, useful for tracking the individual steps of an operation debug = 64, ///< General debugging information info = 96, ///< Noteworthy or periodical events @@ -121,9 +121,10 @@ public: /** * A class that defines a log message. * - * Instead of using this class, prefer one of the above macros - */ - struct LogEntry { + * Instead of using this class, prefer one of the above macros + * @internal + */ + struct LogEntry { String<LOGGER_MAX_MESSAGE_SIZE> message = ""; ///< The current log message itself, starting from a blank slate etl::format_spec format; ///< ETL's string format specification LogLevel level; ///< The log level of this message diff --git a/src/Platform/x86/Logger.cpp b/src/Platform/x86/Logger.cpp index ed4fe3a0..57af7a38 100644 --- a/src/Platform/x86/Logger.cpp +++ b/src/Platform/x86/Logger.cpp @@ -44,11 +44,11 @@ void Logger::log(Logger::LogLevel level, String<LOGGER_MAX_MESSAGE_SIZE> & messa std::ostringstream ss; // A string stream to create the log message ss << "\033" "[0;90m" << std::put_time(&tm, "%FT%T%z") << "\033" "[0m "; // The date - ss << "[\033" "[1;" << colour << "m" << std::setfill(' ') << std::setw(7) << std::right - << name << std::setw(0) << "\033" "[0m] "; // The log level + ss << "[\033" "[1;" << colour << "m" << std::setfill(' ') << std::setw(7) << std::right // Ignore-MISRA + << name << std::setw(0) << "\033" "[0m] "; // The log level // Ignore-MISRA if (keepColour) { - ss << "\033" "[0;" << colour << "m"; + ss << "\033" "[0;" << colour << "m"; // Ignore-MISRA } ss << message.c_str(); // The message itself if (keepColour) { diff --git a/src/Platform/x86/Service.cpp b/src/Platform/x86/Service.cpp index c44acb96..60786fc6 100644 --- a/src/Platform/x86/Service.cpp +++ b/src/Platform/x86/Service.cpp @@ -13,7 +13,8 @@ void Service::storeMessage(Message& message) { // Just print it to the screen ss << "New " << ((message.packetType == Message::TM) ? "TM" : "TC") << "[" << std::hex - << static_cast<int>(message.serviceType) << "," << static_cast<int>(message.messageType) + << static_cast<int>(message.serviceType) << "," // Ignore-MISRA + << static_cast<int>(message.messageType) // Ignore-MISRA << "] message! "; for (unsigned int i = 0; i < message.dataSize; i++) { -- GitLab