diff options
| author | Ed Tanous <ed.tanous@intel.com> | 2019-07-09 16:24:22 -0700 |
|---|---|---|
| committer | Ed Tanous <ed.tanous@intel.com> | 2019-10-10 23:25:26 +0000 |
| commit | 271584ab78b4c1926f766aa26ddfde7da329059f (patch) | |
| tree | 08001912ea542de88b9c31f5d53f195dedd56988 | |
| parent | 70ee8cbd4f3ec5b3e3c18967de221a9f3a70cd38 (diff) | |
| download | bmcweb-271584ab78b4c1926f766aa26ddfde7da329059f.tar.gz bmcweb-271584ab78b4c1926f766aa26ddfde7da329059f.zip | |
Fix a bunch of warnings
using the list of warnings from here:
https://github.com/lefticus/cppbestpractices/blob/e73393f25a85f83fed7399d8b65cb117d00b2231/02-Use_the_Tools_Available.md#L100
Seems like a good place to start, and would improve things a bit
type-wise. This patchset attempts to correct all the issues in one
shot.
Tested:
It builds. Will test various subsystems that have been touched
Signed-off-by: Ed Tanous <ed.tanous@intel.com>
Change-Id: I588c26440e5a97f718a0f0ea74cc84107d53aa1e
50 files changed, 2421 insertions, 2712 deletions
diff --git a/.clang-tidy b/.clang-tidy deleted file mode 100644 index 9a314f1..0000000 --- a/.clang-tidy +++ /dev/null @@ -1,15 +0,0 @@ ---- -Checks: '-*,readability-identifier-naming' -WarningsAsErrors: '' -HeaderFilterRegex: '.*' -AnalyzeTemporaryDtors: false -CheckOptions: - - { key: readability-identifier-naming.NamespaceCase, value: lower_case} - - { key: readability-identifier-naming.ClassCase, value: CamelCase } - - { key: readability-identifier-naming.StructCase, value: CamelCase } - - { key: readability-identifier-naming.FunctionCase, value: camelBack } - - { key: readability-identifier-naming.VariableCase, value: camelBack } - - { key: readability-identifier-naming.GlobalConstantCase, value: camelBack } - - { key: readability-identifier-naming.MemberCase, value: camelBack } -... - diff --git a/CMakeLists.txt b/CMakeLists.txt index 943d956..0268ed8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,7 @@ cmake_minimum_required (VERSION 3.5 FATAL_ERROR) +project (bmc-webserver CXX) + cmake_policy (SET CMP0054 NEW) set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) @@ -58,8 +60,6 @@ option (BMCWEB_INSECURE_ENABLE_REDFISH_FW_TFTP_UPDATE "Enable TFTP based firmware update transactions through Redfish UpdateService.SimpleUpdate." OFF) -project (bmc-webserver CXX) - include (CTest) set (CMAKE_CXX_STANDARD 17) @@ -69,7 +69,43 @@ set (CMAKE_EXPORT_COMPILE_COMMANDS ON) set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -Wall") -set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti") +set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \ + -fno-rtti \ +") + +set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \ +-Wall \ +-Wextra \ +-Wnon-virtual-dtor \ +-Wold-style-cast \ +-Wcast-align \ +-Wunused \ +-Woverloaded-virtual \ +-Wpedantic \ +-Wconversion \ +-Wsign-conversion \ +-Wnull-dereference \ +-Wdouble-promotion \ +-Wformat=2 \ +-Wno-unused-parameter \ +") + +# only set -Werror if we're on a compiler that we know passes +if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.0) + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \ + -Werror \ + -Wduplicated-cond \ + -Wduplicated-branches \ + -Wlogical-op \ + -Wnull-dereference \ + -Wdouble-promotion \ + -Wformat=2 \ + -Wno-unused-parameter \ + ") + endif(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.0) +endif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-rtti") # general @@ -127,30 +163,32 @@ if (NOT ${YOCTO_DEPENDENCIES}) # Download and unpack googletest at configure set (CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}/prefix ${CMAKE_PREFIX_PATH}) endif () +find_package (Boost 1.66 REQUIRED) +include_directories (SYSTEM ${BOOST_SRC_DIR}) + # add_definitions(-DBOOST_ASIO_ENABLE_HANDLER_TRACKING) add_definitions (-DBOOST_ASIO_DISABLE_THREADS) add_definitions (-DBOOST_BEAST_USE_STD_STRING_VIEW) add_definitions (-DBOOST_ERROR_CODE_HEADER_ONLY) add_definitions (-DBOOST_SYSTEM_NO_DEPRECATED) -# Uncomment once Yocto moves to boost 1.70 -# add_definitions (-DBOOST_ASIO_NO_DEPRECATED) +message(BOOST_VERSION = ${Boost_VERSION}) +if ("${Boost_VERSION}" STREQUAL "107100") + add_definitions (-DBOOST_ASIO_NO_DEPRECATED) +endif() add_definitions (-DBOOST_ALL_NO_LIB) add_definitions (-DBOOST_NO_RTTI) add_definitions (-DBOOST_NO_TYPEID) add_definitions (-DBOOST_COROUTINES_NO_DEPRECATION_WARNING) -find_package (Boost 1.66 REQUIRED) -include_directories (${BOOST_SRC_DIR}) - # sdbusplus if (NOT ${YOCTO_DEPENDENCIES}) - include_directories (${CMAKE_BINARY_DIR}/sdbusplus-src) + include_directories (SYSTEM ${CMAKE_BINARY_DIR}/sdbusplus-src) link_directories (${CMAKE_BINARY_DIR}/sdbusplus-src/.libs) endif () # Openssl find_package (OpenSSL REQUIRED) -include_directories (${OPENSSL_INCLUDE_DIR}) +include_directories (SYSTEM ${OPENSSL_INCLUDE_DIR}) message ("OPENSSL_INCLUDE_DIR ${OPENSSL_INCLUDE_DIR}") # bmcweb @@ -168,7 +206,7 @@ include_directories (${CMAKE_CURRENT_SOURCE_DIR}/crow/include) # Zlib find_package (ZLIB REQUIRED) -include_directories (${ZLIB_INCLUDE_DIRS}) +include_directories (SYSTEM ${ZLIB_INCLUDE_DIRS}) # PAM option (WEBSERVER_ENABLE_PAM "enable pam authentication" ON) diff --git a/CMakeLists.txt.in b/CMakeLists.txt.in index ce96647..4e6f6b6 100644 --- a/CMakeLists.txt.in +++ b/CMakeLists.txt.in @@ -36,8 +36,8 @@ externalproject_add ( externalproject_add ( Boost URL - https://dl.bintray.com/boostorg/release/1.69.0/source/boost_1_69_0.tar.gz - URL_MD5 b50944c0c13f81ce2c006802a1186f5a SOURCE_DIR + https://dl.bintray.com/boostorg/release/1.71.0/source/boost_1_71_0.tar.gz + URL_MD5 5f521b41b79bf8616582c4a8a2c10177 SOURCE_DIR "${CMAKE_BINARY_DIR}/boost-src" BINARY_DIR "${CMAKE_BINARY_DIR}/boost-build" CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND mkdir -p "${CMAKE_BINARY_DIR}/prefix/include/" && cp -R diff --git a/crow/include/crow/app.h b/crow/include/crow/app.h index 4bdf9ff..7885c02 100644 --- a/crow/include/crow/app.h +++ b/crow/include/crow/app.h @@ -38,9 +38,9 @@ template <typename... Middlewares> class Crow using server_t = Server<Crow, socket_t, Middlewares...>; #endif - explicit Crow(std::shared_ptr<boost::asio::io_context> io = + explicit Crow(std::shared_ptr<boost::asio::io_context> ioIn = std::make_shared<boost::asio::io_context>()) : - io(std::move(io)) + io(std::move(ioIn)) { } ~Crow() diff --git a/crow/include/crow/http_connection.h b/crow/include/crow/http_connection.h index 78ee70b..5c9be09 100644 --- a/crow/include/crow/http_connection.h +++ b/crow/include/crow/http_connection.h @@ -164,7 +164,7 @@ typename std::enable_if<IsAfterHandleArity3Impl<MW>::value>::type mw.afterHandle(req, res, ctx.template get<MW>()); } -template <int N, typename Context, typename Container, typename CurrentMW, +template <size_t N, typename Context, typename Container, typename CurrentMW, typename... Middlewares> bool middlewareCallHelper(Container& middlewares, Request& req, Response& res, Context& ctx) @@ -194,21 +194,21 @@ bool middlewareCallHelper(Container& middlewares, Request& req, Response& res, return false; } -template <int N, typename Context, typename Container> +template <size_t N, typename Context, typename Container> bool middlewareCallHelper(Container& /*middlewares*/, Request& /*req*/, Response& /*res*/, Context& /*ctx*/) { return false; } -template <int N, typename Context, typename Container> +template <size_t N, typename Context, typename Container> typename std::enable_if<(N < 0)>::type afterHandlersCallHelper(Container& /*middlewares*/, Context& /*Context*/, Request& /*req*/, Response& /*res*/) { } -template <int N, typename Context, typename Container> +template <size_t N, typename Context, typename Container> typename std::enable_if<(N == 0)>::type afterHandlersCallHelper(Container& middlewares, Context& ctx, Request& req, Response& res) @@ -221,7 +221,7 @@ typename std::enable_if<(N == 0)>::type static_cast<parent_context_t&>(ctx)); } -template <int N, typename Context, typename Container> +template <size_t N, typename Context, typename Container> typename std::enable_if<(N > 0)>::type afterHandlersCallHelper(Container& middlewares, Context& ctx, Request& req, Response& res) @@ -248,14 +248,15 @@ template <typename Adaptor, typename Handler, typename... Middlewares> class Connection { public: - Connection(boost::asio::io_context& ioService, Handler* handler, - const std::string& server_name, - std::tuple<Middlewares...>* middlewares, + Connection(boost::asio::io_context& ioService, Handler* handlerIn, + const std::string& ServerNameIn, + std::tuple<Middlewares...>* middlewaresIn, std::function<std::string()>& get_cached_date_str_f, - detail::TimerQueue& timerQueue, Adaptor adaptorIn) : + detail::TimerQueue& timerQueueIn, Adaptor adaptorIn) : adaptor(std::move(adaptorIn)), - handler(handler), serverName(server_name), middlewares(middlewares), - getCachedDateStr(get_cached_date_str_f), timerQueue(timerQueue) + handler(handlerIn), serverName(ServerNameIn), + middlewares(middlewaresIn), getCachedDateStr(get_cached_date_str_f), + timerQueue(timerQueueIn) { parser.emplace(std::piecewise_construct, std::make_tuple()); // Temporarily changed to 30MB; Need to modify uploading/authentication @@ -344,7 +345,7 @@ class Connection req->ioService = static_cast<decltype(req->ioService)>( &adaptor.get_executor().context()); detail::middlewareCallHelper< - 0, decltype(ctx), decltype(*middlewares), Middlewares...>( + 0U, decltype(ctx), decltype(*middlewares), Middlewares...>( *middlewares, *req, res, ctx); if (!res.completed) @@ -413,7 +414,7 @@ class Connection needToCallAfterHandlers = false; // call all afterHandler of middlewares - detail::afterHandlersCallHelper<((int)sizeof...(Middlewares) - 1), + detail::afterHandlersCallHelper<sizeof...(Middlewares) - 1, decltype(ctx), decltype(*middlewares)>( *middlewares, ctx, *req, res); @@ -654,7 +655,7 @@ class Connection const std::string& serverName; - int timerCancelKey{-1}; + size_t timerCancelKey = 0; bool isReading{}; bool isWriting{}; diff --git a/crow/include/crow/http_request.h b/crow/include/crow/http_request.h index ef0bb28..c8551cd 100644 --- a/crow/include/crow/http_request.h +++ b/crow/include/crow/http_request.h @@ -26,12 +26,14 @@ struct Request std::shared_ptr<crow::persistent_data::UserSession> session; - Request(boost::beast::http::request<boost::beast::http::string_body>& req) : - req(req), body(req.body()) + Request( + boost::beast::http::request<boost::beast::http::string_body>& reqIn) : + req(reqIn), + body(reqIn.body()) { } - const boost::beast::http::verb method() const + boost::beast::http::verb method() const { return req.method(); } diff --git a/crow/include/crow/http_server.h b/crow/include/crow/http_server.h index 304f562..2e43056 100644 --- a/crow/include/crow/http_server.h +++ b/crow/include/crow/http_server.h @@ -1,11 +1,11 @@ #pragma once #include <atomic> -#include <boost/asio/deadline_timer.hpp> #include <boost/asio/ip/address.hpp> #include <boost/asio/ip/tcp.hpp> #include <boost/asio/signal_set.hpp> #include <boost/asio/ssl/context.hpp> +#include <boost/asio/steady_timer.hpp> #if BOOST_VERSION >= 107000 #include <boost/beast/ssl/ssl_stream.hpp> #else @@ -44,7 +44,7 @@ class Server ioService(std::move(io)), acceptor(std::move(acceptor)), signals(*ioService, SIGINT, SIGTERM, SIGHUP), tickTimer(*ioService), - handler(handler), adaptorCtx(adaptor_ctx), middlewares(middlewares) + handler(handler), middlewares(middlewares), adaptorCtx(adaptor_ctx) { } @@ -82,8 +82,8 @@ class Server void onTick() { tickFunction(); - tickTimer.expires_from_now( - boost::posix_time::milliseconds(tickInterval.count())); + tickTimer.expires_after( + std::chrono::milliseconds(tickInterval.count())); tickTimer.async_wait([this](const boost::system::error_code& ec) { if (ec) { @@ -95,14 +95,11 @@ class Server void updateDateStr() { - auto lastTimeT = time(0); + time_t lastTimeT = time(0); tm myTm{}; -#ifdef _MSC_VER - gmtime_s(&my_tm, &last_time_t); -#else gmtime_r(&lastTimeT, &myTm); -#endif + dateStr.resize(100); size_t dateStrSz = strftime(&dateStr[0], 99, "%a, %d %b %Y %H:%M:%S GMT", &myTm); @@ -126,8 +123,8 @@ class Server return this->dateStr; }; - boost::asio::deadline_timer timer(*ioService); - timer.expires_from_now(boost::posix_time::seconds(1)); + boost::asio::steady_timer timer(*ioService); + timer.expires_after(std::chrono::seconds(1)); std::function<void(const boost::system::error_code& ec)> timerHandler; timerHandler = [&](const boost::system::error_code& ec) { @@ -136,15 +133,15 @@ class Server return; } timerQueue.process(); - timer.expires_from_now(boost::posix_time::seconds(1)); + timer.expires_after(std::chrono::seconds(1)); timer.async_wait(timerHandler); }; timer.async_wait(timerHandler); if (tickFunction && tickInterval.count() > 0) { - tickTimer.expires_from_now( - boost::posix_time::milliseconds(tickInterval.count())); + tickTimer.expires_after( + std::chrono::milliseconds(tickInterval.count())); tickTimer.async_wait([this](const boost::system::error_code& ec) { if (ec) { @@ -278,7 +275,7 @@ class Server std::function<std::string()> getCachedDateStr; std::unique_ptr<tcp::acceptor> acceptor; boost::asio::signal_set signals; - boost::asio::deadline_timer tickTimer; + boost::asio::steady_timer tickTimer; std::string dateStr; diff --git a/crow/include/crow/logging.h b/crow/include/crow/logging.h index 1d4de57..a608f1f 100644 --- a/crow/include/crow/logging.h +++ b/crow/include/crow/logging.h @@ -12,14 +12,6 @@ namespace crow { enum class LogLevel { -#ifndef ERROR - DEBUG = 0, - INFO, - WARNING, - ERROR, - CRITICAL, -#endif - Debug = 0, Info, Warning, @@ -27,46 +19,30 @@ enum class LogLevel Critical, }; -class ILogHandler -{ - public: - virtual void log(std::string message, LogLevel level) = 0; -}; - -class CerrLogHandler : public ILogHandler -{ - public: - void log(std::string message, LogLevel /*level*/) override - { - std::cerr << message; - } -}; - class logger { private: // static std::string timestamp() { - char date[32]; + std::string date; + date.resize(32, '\0'); time_t t = time(0); tm myTm{}; -#ifdef _MSC_VER - gmtime_s(&my_tm, &t); -#else gmtime_r(&t, &myTm); -#endif - size_t sz = strftime(date, sizeof(date), "%Y-%m-%d %H:%M:%S", &myTm); - return std::string(date, date + sz); + size_t sz = + strftime(date.data(), date.size(), "%Y-%m-%d %H:%M:%S", &myTm); + date.resize(sz); + return date; } public: logger(const std::string& prefix, const std::string& filename, - const size_t line, LogLevel level) : - level(level) + const size_t line, LogLevel levelIn) : + level(levelIn) { #ifdef BMCWEB_ENABLE_LOGGING stringstream << "(" << timestamp() << ") [" << prefix << " " @@ -80,7 +56,7 @@ class logger { #ifdef BMCWEB_ENABLE_LOGGING stringstream << std::endl; - getHandlerRef()->log(stringstream.str(), level); + std::cerr << stringstream.str(); #endif } } @@ -103,11 +79,6 @@ class logger getLogLevelRef() = level; } - static void setHandler(ILogHandler* handler) - { - getHandlerRef() = handler; - } - static LogLevel get_current_log_level() { return getLogLevelRef(); @@ -120,12 +91,6 @@ class logger static auto currentLevel = static_cast<LogLevel>(1); return currentLevel; } - static ILogHandler*& getHandlerRef() - { - static CerrLogHandler defaultHandler; - static ILogHandler* currentHandler = &defaultHandler; - return currentHandler; - } // std::ostringstream stringstream; diff --git a/crow/include/crow/middleware_context.h b/crow/include/crow/middleware_context.h index f109a44..2247ca6 100644 --- a/crow/include/crow/middleware_context.h +++ b/crow/include/crow/middleware_context.h @@ -16,7 +16,7 @@ struct PartialContext { using parent_context = typename black_magic::PopBack< Middlewares...>::template rebind<::crow::detail::PartialContext>; - template <int N> + template <size_t N> using partial = typename std::conditional< N == sizeof...(Middlewares) - 1, PartialContext, typename parent_context::template partial<N>>::type; @@ -29,10 +29,10 @@ struct PartialContext template <> struct PartialContext<> { - template <int> using partial = PartialContext; + template <size_t> using partial = PartialContext; }; -template <int N, typename Context, typename Container, typename CurrentMW, +template <size_t N, typename Context, typename Container, typename CurrentMW, typename... Middlewares> bool middlewareCallHelper(Container& middlewares, Request& req, Response& res, Context& ctx); @@ -41,17 +41,17 @@ template <typename... Middlewares> struct Context : private PartialContext<Middlewares...> // struct Context : private Middlewares::context... // simple but less type-safe { - template <int N, typename Context, typename Container> + template <size_t N, typename Context, typename Container> friend typename std::enable_if<(N == 0)>::type afterHandlersCallHelper(Container& middlewares, Context& ctx, Request& req, Response& res); - template <int N, typename Context, typename Container> + template <size_t N, typename Context, typename Container> friend typename std::enable_if<(N > 0)>::type afterHandlersCallHelper(Container& middlewares, Context& ctx, Request& req, Response& res); - template <int N, typename Context, typename Container, typename CurrentMW, - typename... Middlewares2> + template <size_t N, typename Context, typename Container, + typename CurrentMW, typename... Middlewares2> friend bool middlewareCallHelper(Container& middlewares, Request& req, Response& res, Context& ctx); @@ -60,7 +60,7 @@ struct Context : private PartialContext<Middlewares...> return static_cast<typename T::Context&>(*this); } - template <int N> + template <size_t N> using partial = typename PartialContext<Middlewares...>::template partial<N>; }; diff --git a/crow/include/crow/query_string.h b/crow/include/crow/query_string.h index 553960e..0cd21e4 100644 --- a/crow/include/crow/query_string.h +++ b/crow/include/crow/query_string.h @@ -19,7 +19,7 @@ int qsStrncmp(const char* s, const char* qs, size_t n); * Also decodes the value portion of the k/v pair *in-place*. In a future * enhancement it will also have a compile-time option of sorting qs_kv * alphabetically by key. */ -int qsParse(char* qs, char* qs_kv[], int qs_kv_size); +size_t qsParse(char* qs, char* qs_kv[], size_t qs_kv_size); /* Used by qs_parse to decode the value portion of a k/v pair */ int qsDecode(char* qs); @@ -55,12 +55,13 @@ char* qsScanvalue(const char* key, const char* qs, char* val, size_t val_len); inline int qsStrncmp(const char* s, const char* qs, size_t n) { int i = 0; - unsigned char u1, u2, unyb, lnyb; + char u1, u2; + char unyb, lnyb; while (n-- > 0) { - u1 = static_cast<unsigned char>(*s++); - u2 = static_cast<unsigned char>(*qs++); + u1 = *s++; + u2 = *qs++; if (!BMCWEB_QS_ISQSCHR(u1)) { @@ -77,11 +78,12 @@ inline int qsStrncmp(const char* s, const char* qs, size_t n) } if (u1 == '%') // easier/safer than scanf { - unyb = static_cast<unsigned char>(*s++); - lnyb = static_cast<unsigned char>(*s++); + unyb = static_cast<char>(*s++); + lnyb = static_cast<char>(*s++); if (BMCWEB_QS_ISHEX(unyb) && BMCWEB_QS_ISHEX(lnyb)) { - u1 = (BMCWEB_QS_HEX2DEC(unyb) * 16) + BMCWEB_QS_HEX2DEC(lnyb); + u1 = static_cast<char>((BMCWEB_QS_HEX2DEC(unyb) * 16) + + BMCWEB_QS_HEX2DEC(lnyb)); } else { @@ -95,11 +97,12 @@ inline int qsStrncmp(const char* s, const char* qs, size_t n) } if (u2 == '%') // easier/safer than scanf { - unyb = static_cast<unsigned char>(*qs++); - lnyb = static_cast<unsigned char>(*qs++); + unyb = static_cast<char>(*qs++); + lnyb = static_cast<char>(*qs++); if (BMCWEB_QS_ISHEX(unyb) && BMCWEB_QS_ISHEX(lnyb)) { - u2 = (BMCWEB_QS_HEX2DEC(unyb) * 16) + BMCWEB_QS_HEX2DEC(lnyb); + u2 = static_cast<char>((BMCWEB_QS_HEX2DEC(unyb) * 16) + + BMCWEB_QS_HEX2DEC(lnyb)); } else { @@ -127,9 +130,10 @@ inline int qsStrncmp(const char* s, const char* qs, size_t n) } } -inline int qsParse(char* qs, char* qs_kv[], int qs_kv_size) +inline size_t qsParse(char* qs, char* qs_kv[], size_t qs_kv_size) { - int i, j; + size_t i; + size_t j; char* substrPtr; for (i = 0; i < qs_kv_size; i++) @@ -201,8 +205,8 @@ inline int qsDecode(char* qs) qs[i] = '\0'; return i; } - qs[i] = (BMCWEB_QS_HEX2DEC(qs[j + 1]) * 16) + - BMCWEB_QS_HEX2DEC(qs[j + 2]); + qs[i] = static_cast<char>(BMCWEB_QS_HEX2DEC(qs[j + 1] * 16) + + BMCWEB_QS_HEX2DEC(qs[j + 2])); j += 2; } else @@ -307,7 +311,7 @@ namespace crow class QueryString { public: - static const int maxKeyValuePairsCount = 256; + static const size_t maxKeyValuePairsCount = 256; QueryString() = default; @@ -353,7 +357,8 @@ class QueryString keyValuePairs.resize(maxKeyValuePairsCount); - int count = qsParse(&url[0], &keyValuePairs[0], maxKeyValuePairsCount); + size_t count = + qsParse(&url[0], &keyValuePairs[0], maxKeyValuePairsCount); keyValuePairs.resize(count); } @@ -380,8 +385,8 @@ class QueryString char* get(const std::string& name) const { - char* ret = - qsK2v(name.c_str(), keyValuePairs.data(), keyValuePairs.size()); + char* ret = qsK2v(name.c_str(), keyValuePairs.data(), + static_cast<int>(keyValuePairs.size())); return ret; } @@ -395,7 +400,7 @@ class QueryString while (1) { element = qsK2v(plus.c_str(), keyValuePairs.data(), - keyValuePairs.size(), count++); + static_cast<int>(keyValuePairs.size()), count++); if (element == nullptr) { break; diff --git a/crow/include/crow/routing.h b/crow/include/crow/routing.h index 0be5dbd..6297448 100644 --- a/crow/include/crow/routing.h +++ b/crow/include/crow/routing.h @@ -64,7 +64,7 @@ class BaseRule } #endif - uint32_t getMethods() + size_t getMethods() { return methodsBitfield; } @@ -88,7 +88,8 @@ class BaseRule return false; } - uint32_t methodsBitfield{1 << (int)boost::beast::http::verb::get}; + size_t methodsBitfield{ + 1 << static_cast<size_t>(boost::beast::http::verb::get)}; std::vector<redfish::Privileges> privilegesSet; @@ -384,46 +385,52 @@ template <typename T> struct RuleParameterTraits using self_t = T; WebSocketRule& websocket() { - WebSocketRule* p = new WebSocketRule(((self_t*)this)->rule); - ((self_t*)this)->ruleToUpgrade.reset(p); + self_t* self = static_cast<self_t*>(this); + WebSocketRule* p = new WebSocketRule(self->rule); + self->ruleToUpgrade.reset(p); return *p; } self_t& name(std::string name) noexcept { - ((self_t*)this)->nameStr = std::move(name); - return (self_t&)*this; + self_t* self = static_cast<self_t*>(this); + self->nameStr = std::move(name); + return *self; } self_t& methods(boost::beast::http::verb method) { - ((self_t*)this)->methodsBitfield = 1 << (int)method; - return (self_t&)*this; + self_t* self = static_cast<self_t*>(this); + self->methodsBitfield = 1U << static_cast<size_t>(method); + return *self; } template <typename... MethodArgs> self_t& methods(boost::beast::http::verb method, MethodArgs... args_method) { + self_t* self = static_cast<self_t*>(this); methods(args_method...); - ((self_t*)this)->methodsBitfield |= 1 << (int)method; - return (self_t&)*this; + self->methodsBitfield |= 1U << static_cast<size_t>(method); + return *self; } template <typename... MethodArgs> self_t& requires(std::initializer_list<const char*> l) { - ((self_t*)this)->privilegesSet.emplace_back(l); - return (self_t&)*this; + self_t* self = static_cast<self_t*>(this); + self->privilegesSet.emplace_back(l); + return *self; } template <typename... MethodArgs> self_t& requires(const std::vector<redfish::Privileges>& p) { + self_t* self = static_cast<self_t*>(this); for (const redfish::Privileges& privilege : p) { - ((self_t*)this)->privilegesSet.emplace_back(privilege); + self->privilegesSet.emplace_back(privilege); } - return (self_t&)*this; + return *self; } }; @@ -502,7 +509,7 @@ class TaggedRule : public BaseRule, public: using self_t = TaggedRule<Args...>; - TaggedRule(std::string rule) : BaseRule(std::move(rule)) + TaggedRule(std::string ruleIn) : BaseRule(std::move(ruleIn)) { } @@ -621,14 +628,15 @@ class Trie struct Node { unsigned ruleIndex{}; - std::array<unsigned, (int)ParamType::MAX> paramChildrens{}; + std::array<size_t, static_cast<size_t>(ParamType::MAX)> + paramChildrens{}; boost::container::flat_map<std::string, unsigned> children; bool isSimpleNode() const { return !ruleIndex && std::all_of(std::begin(paramChildrens), std::end(paramChildrens), - [](unsigned x) { return !x; }); + [](size_t x) { return !x; }); } }; @@ -639,7 +647,7 @@ class Trie private: void optimizeNode(Node* node) { - for (unsigned int x : node->paramChildrens) + for (size_t x : node->paramChildrens) { if (!x) continue; @@ -716,14 +724,15 @@ class Trie route_indexes.push_back(child->ruleIndex); } findRouteIndexes(req_url, route_indexes, child, - pos + fragment.size()); + static_cast<unsigned>(pos + fragment.size())); } else { if (req_url.compare(pos, fragment.size(), fragment) == 0) { - findRouteIndexes(req_url, route_indexes, child, - pos + fragment.size()); + findRouteIndexes( + req_url, route_indexes, child, + static_cast<unsigned>(pos + fragment.size())); } } } @@ -731,7 +740,7 @@ class Trie std::pair<unsigned, RoutingParams> find(const std::string_view req_url, const Node* node = nullptr, - unsigned pos = 0, RoutingParams* params = nullptr) const + size_t pos = 0, RoutingParams* params = nullptr) const { RoutingParams empty; if (params == nullptr) @@ -754,7 +763,7 @@ class Trie } }; - if (node->paramChildrens[(int)ParamType::INT]) + if (node->paramChildrens[static_cast<size_t>(ParamType::INT)]) { char c = req_url[pos]; if ((c >= '0' && c <= '9') || c == '+' || c == '-') @@ -766,17 +775,18 @@ class Trie if (errno != ERANGE && eptr != req_url.data() + pos) { params->intParams.push_back(value); - std::pair<unsigned, RoutingParams> ret = - find(req_url, - &nodes[node->paramChildrens[(int)ParamType::INT]], - eptr - req_url.data(), params); + std::pair<unsigned, RoutingParams> ret = find( + req_url, + &nodes[node->paramChildrens[static_cast<size_t>( + ParamType::INT)]], + static_cast<size_t>(eptr - req_url.data()), params); updateFound(ret); params->intParams.pop_back(); } } } - if (node->paramChildrens[(int)ParamType::UINT]) + if (node->paramChildrens[static_cast<size_t>(ParamType::UINT)]) { char c = req_url[pos]; if ((c >= '0' && c <= '9') || c == '+') @@ -788,17 +798,18 @@ class Trie if (errno != ERANGE && eptr != req_url.data() + pos) { params->uintParams.push_back(value); - std::pair<unsigned, RoutingParams> ret = - find(req_url, - &nodes[node->paramChildrens[(int)ParamType::UINT]], - eptr - req_url.data(), params); + std::pair<unsigned, RoutingParams> ret = find( + req_url, + &nodes[node->paramChildrens[static_cast<size_t>( + ParamType::UINT)]], + static_cast<size_t>(eptr - req_url.data()), params); updateFound(ret); params->uintParams.pop_back(); } } } - if (node->paramChildrens[(int)ParamType::DOUBLE]) + if (node->paramChildrens[static_cast<size_t>(ParamType::DOUBLE)]) { char c = req_url[pos]; if ((c >= '0' && c <= '9') || c == '+' || c == '-' || c == '.') @@ -811,15 +822,16 @@ class Trie params->doubleParams.push_back(value); std::pair<unsigned, RoutingParams> ret = find( req_url, - &nodes[node->paramChildrens[(int)ParamType::DOUBLE]], - eptr - req_url.data(), params); + &nodes[node->paramChildrens[static_cast<size_t>( + ParamType::DOUBLE)]], + static_cast<size_t>(eptr - req_url.data()), params); updateFound(ret); params->doubleParams.pop_back(); } } } - if (node->paramChildrens[(int)ParamType::STRING]) + if (node->paramChildrens[static_cast<size_t>(ParamType::STRING)]) { size_t epos = pos; for (; epos < req_url.size(); epos++) @@ -834,14 +846,15 @@ class Trie req_url.substr(pos, epos - pos)); std::pair<unsigned, RoutingParams> ret = find(req_url, - &nodes[node->paramChildrens[(int)ParamType::STRING]], + &nodes[node->paramChildrens[static_cast<size_t>( + ParamType::STRING)]], epos, params); updateFound(ret); params->stringParams.pop_back(); } } - if (node->paramChildrens[(int)ParamType::PATH]) + if (node->paramChildrens[static_cast<size_t>(ParamType::PATH)]) { size_t epos = req_url.size(); @@ -849,9 +862,11 @@ class Trie { params->stringParams.emplace_back( req_url.substr(pos, epos - pos)); - std::pair<unsigned, RoutingParams> ret = find( - req_url, &nodes[node->paramChildrens[(int)ParamType::PATH]], - epos, params); + std::pair<unsigned, RoutingParams> ret = + find(req_url, + &nodes[node->paramChildrens[static_cast<size_t>( + ParamType::PATH)]], + epos, params); updateFound(ret); params->stringParams.pop_back(); } @@ -875,7 +890,7 @@ class Trie void add(const std::string& url, unsigned ruleIndex) { - unsigned idx{0}; + size_t idx = 0; for (unsigned i = 0; i < url.size(); i++) { @@ -897,14 +912,14 @@ class Trie { if (url.compare(i, x.second.size(), x.second) == 0) { - if (!nodes[idx].paramChildrens[(int)x.first]) + size_t index = static_cast<size_t>(x.first); + if (!nodes[idx].paramChildrens[index]) { unsigned newNodeIdx = newNode(); - nodes[idx].paramChildrens[(int)x.first] = - newNodeIdx; + nodes[idx].paramChildrens[index] = newNodeIdx; } - idx = nodes[idx].paramChildrens[(int)x.first]; - i += x.second.size(); + idx = nodes[idx].paramChildrens[index]; + i += static_cast<unsigned>(x.second.size()); break; } } @@ -928,15 +943,15 @@ class Trie } private: - void debugNodePrint(Node* n, int level) + void debugNodePrint(Node* n, size_t level) { - for (int i = 0; i < (int)ParamType::MAX; i++) + for (size_t i = 0; i < static_cast<size_t>(ParamType::MAX); i++) { if (n->paramChildrens[i]) { BMCWEB_LOG_DEBUG << std::string( - 2 * level, ' ') /*<< "("<<n->paramChildrens[i]<<") "*/; - switch ((ParamType)i) + 2U * level, ' ') /*<< "("<<n->paramChildrens[i]<<") "*/; + switch (static_cast<ParamType>(i)) { case ParamType::INT: BMCWEB_LOG_DEBUG << "<int>"; @@ -964,7 +979,7 @@ class Trie for (const std::pair<std::string, unsigned>& kv : n->children) { BMCWEB_LOG_DEBUG - << std::string(2 * level, ' ') /*<< "(" << kv.second << ") "*/ + << std::string(2U * level, ' ') /*<< "(" << kv.second << ") "*/ << kv.first; debugNodePrint(&nodes[kv.second], level + 1); } @@ -973,7 +988,7 @@ class Trie public: void debugPrint() { - debugNodePrint(head(), 0); + debugNodePrint(head(), 0U); } private: @@ -990,7 +1005,7 @@ class Trie unsigned newNode() { nodes.resize(nodes.size() + 1); - return nodes.size() - 1; + return static_cast<unsigned>(nodes.size() - 1); } std::vector<Node> nodes; @@ -1039,14 +1054,16 @@ class Router { perMethods[method].rules.emplace_back(ruleObject); perMethods[method].trie.add( - rule, perMethods[method].rules.size() - 1); + rule, static_cast<unsigned>( + perMethods[method].rules.size() - 1U)); // directory case: // request to `/about' url matches `/about/' rule if (rule.size() > 2 && rule.back() == '/') { perMethods[method].trie.add( rule.substr(0, rule.size() - 1), - perMethods[method].rules.size() - 1); + static_cast<unsigned>(perMethods[method].rules.size() - + 1)); } } } @@ -1074,10 +1091,10 @@ class Router template <typename Adaptor> void handleUpgrade(const Request& req, Response& res, Adaptor&& adaptor) { - if (static_cast<int>(req.method()) >= perMethods.size()) + if (static_cast<size_t>(req.method()) >= perMethods.size()) return; - PerMethod& perMethod = perMethods[(int)req.method()]; + PerMethod& perMethod = perMethods[static_cast<size_t>(req.method())]; Trie& trie = perMethod.trie; std::vector<BaseRule*>& rules = perMethod.rules; @@ -1118,12 +1135,12 @@ class Router return; } - if ((rules[ruleIndex]->getMethods() & (1 << (uint32_t)req.method())) == - 0) + if ((rules[ruleIndex]->getMethods() & + (1U << static_cast<size_t>(req.method()))) == 0) { BMCWEB_LOG_DEBUG << "Rule found but method mismatch: " << req.url << " with " << req.methodString() << "(" - << (uint32_t)req.method() << ") / " + << static_cast<uint32_t>(req.method()) << ") / " << rules[ruleIndex]->getMethods(); res.result(boost::beast::http::status::not_found); res.end(); @@ -1131,7 +1148,7 @@ class Router } BMCWEB_LOG_DEBUG << "Matched rule (upgrade) '" << rules[ruleIndex]->rule - << "' " << (uint32_t)req.method() << " / " + << "' " << static_cast<uint32_t>(req.method()) << " / " << rules[ruleIndex]->getMethods(); // any uncaught exceptions become 500s @@ -1159,9 +1176,9 @@ class Router void handle(const Request& req, Response& res) { - if ((int)req.method() >= perMethods.size()) + if (static_cast<size_t>(req.method()) >= perMethods.size()) return; - PerMethod& perMethod = perMethods[(int)req.method()]; + PerMethod& perMethod = perMethods[static_cast<size_t>(req.method())]; Trie& trie = perMethod.trie; std::vector<BaseRule*>& rules = perMethod.rules; @@ -1214,12 +1231,12 @@ class Router return; } - if ((rules[ruleIndex]->getMethods() & (1 << (uint32_t)req.method())) == - 0) + if ((rules[ruleIndex]->getMethods() & + (1U << static_cast<uint32_t>(req.method()))) == 0) { BMCWEB_LOG_DEBUG << "Rule found but method mismatch: " << req.url << " with " << req.methodString() << "(" - << (uint32_t)req.method() << ") / " + << static_cast<uint32_t>(req.method()) << ") / " << rules[ruleIndex]->getMethods(); res.result(boost::beast::http::status::method_not_allowed); res.end(); @@ -1227,7 +1244,7 @@ class Router } BMCWEB_LOG_DEBUG << "Matched rule '" << rules[ruleIndex]->rule << "' " - << (uint32_t)req.method() << " / " + << static_cast<uint32_t>(req.method()) << " / " << rules[ruleIndex]->getMethods(); redfish::Privileges userPrivileges; @@ -1276,9 +1293,10 @@ class Router void debugPrint() { - for (int i = 0; i < perMethods.size(); i++) + for (size_t i = 0; i < perMethods.size(); i++) { - BMCWEB_LOG_DEBUG << methodName((boost::beast::http::verb)i); + BMCWEB_LOG_DEBUG + << methodName(static_cast<boost::beast::http::verb>(i)); perMethods[i].trie.debugPrint(); } } diff --git a/crow/include/crow/settings.h b/crow/include/crow/settings.h index 8cb1219..959eb95 100644 --- a/crow/include/crow/settings.h +++ b/crow/include/crow/settings.h @@ -2,15 +2,6 @@ // settings for crow // TODO - replace with runtime config. libucl? -/* #ifdef - enables debug mode */ -//#define BMCWEB_ENABLE_DEBUG - -/* #ifdef - enables logging */ -//#define BMCWEB_ENABLE_LOGGING - -/* #ifdef - enables ssl */ -//#define BMCWEB_ENABLE_SSL - /* #define - specifies log level */ /* Debug = 0 @@ -23,13 +14,6 @@ */ #define BMCWEB_LOG_LEVEL 1 -// compiler flags -#if __cplusplus >= 201402L -#define BMCWEB_CAN_USE_CPP14 -#endif - #if defined(_MSC_VER) -#if _MSC_VER < 1900 -#error "MSVC versions betfore VS2015 are not supported" -#endif +#error "MSVC is not supported" #endif diff --git a/crow/include/crow/timer_queue.h b/crow/include/crow/timer_queue.h index bf1e084..35e4048 100644 --- a/crow/include/crow/timer_queue.h +++ b/crow/include/crow/timer_queue.h @@ -20,20 +20,20 @@ class TimerQueue dq.set_capacity(100); } - void cancel(int k) + void cancel(size_t k) { - unsigned int index = static_cast<unsigned int>(k - step); + size_t index = k - step; if (index < dq.size()) { dq[index].second = nullptr; } } - int add(std::function<void()> f) + size_t add(std::function<void()> f) { dq.push_back( std::make_pair(std::chrono::steady_clock::now(), std::move(f))); - int ret = step + dq.size() - 1; + size_t ret = step + dq.size() - 1; BMCWEB_LOG_DEBUG << "timer add inside: " << this << ' ' << ret; return ret; @@ -72,7 +72,7 @@ class TimerQueue // boost::circular_buffer<storage_type> dq{20}; // std::deque<storage_type> dq{}; - int step{}; + size_t step{}; }; } // namespace detail } // namespace crow diff --git a/crow/include/crow/utility.h b/crow/include/crow/utility.h index b402b79..d08d548 100644 --- a/crow/include/crow/utility.h +++ b/crow/include/crow/utility.h @@ -173,8 +173,8 @@ static inline bool isParameterTagCompatible(uint64_t a, uint64_t b) { return a == 0; } - int sa = a % 6; - int sb = a % 6; + uint64_t sa = a % 6; + uint64_t sb = a % 6; if (sa == 5) { sa = 4; @@ -291,7 +291,7 @@ template <typename F, typename... Args> struct CallHelper<F, S<Args...>> static constexpr bool value = sizeof(__test<F, Args...>(0)) == sizeof(char); }; -template <int N> struct SingleTagToType +template <uint64_t N> struct SingleTagToType { }; @@ -360,10 +360,10 @@ struct concat<Seq<I1...>, Seq<I2...>> : Seq<I1..., (sizeof...(I1) + I2)...> template <class S1, class S2> using Concat = Invoke<concat<S1, S2>>; -template <unsigned N> struct gen_seq; -template <unsigned N> using GenSeq = Invoke<gen_seq<N>>; +template <size_t N> struct gen_seq; +template <size_t N> using GenSeq = Invoke<gen_seq<N>>; -template <unsigned N> struct gen_seq : Concat<GenSeq<N / 2>, GenSeq<N - N / 2>> +template <size_t N> struct gen_seq : Concat<GenSeq<N / 2>, GenSeq<N - N / 2>> { }; @@ -388,7 +388,7 @@ struct PopBack //: public PopBackHelper<typename { template <template <typename... Args> class U> using rebind = - typename PopBackHelper<typename gen_seq<sizeof...(T) - 1>::type, + typename PopBackHelper<typename gen_seq<sizeof...(T) - 1UL>::type, std::tuple<T...>>::template rebind<U>; }; @@ -452,19 +452,19 @@ namespace detail template <class T, std::size_t N, class... Args> struct GetIndexOfElementFromTupleByTypeImpl { - static constexpr auto value = N; + static constexpr std::size_t value = N; }; template <class T, std::size_t N, class... Args> struct GetIndexOfElementFromTupleByTypeImpl<T, N, T, Args...> { - static constexpr auto value = N; + static constexpr std::size_t value = N; }; template <class T, std::size_t N, class U, class... Args> struct GetIndexOfElementFromTupleByTypeImpl<T, N, U, Args...> { - static constexpr auto value = + static constexpr std::size_t value = GetIndexOfElementFromTupleByTypeImpl<T, N + 1, Args...>::value; }; @@ -532,29 +532,34 @@ inline static std::string base64encode( auto it = ret.begin(); while (size >= 3) { - *it++ = key[(((unsigned char)*data) & 0xFC) >> 2]; - unsigned char h = (((unsigned char)*data++) & 0x03) << 4; - *it++ = key[h | ((((unsigned char)*data) & 0xF0) >> 4)]; - h = (((unsigned char)*data++) & 0x0F) << 2; - *it++ = key[h | ((((unsigned char)*data) & 0xC0) >> 6)]; - *it++ = key[((unsigned char)*data++) & 0x3F]; + *it++ = key[(static_cast<unsigned char>(*data) & 0xFC) >> 2]; + unsigned char h = static_cast<unsigned char>( + (static_cast<unsigned char>(*data++) & 0x03u) << 4u); + *it++ = key[h | ((static_cast<unsigned char>(*data) & 0xF0) >> 4)]; + h = static_cast<unsigned char>( + (static_cast<unsigned char>(*data++) & 0x0F) << 2u); + *it++ = key[h | ((static_cast<unsigned char>(*data) & 0xC0) >> 6)]; + *it++ = key[static_cast<unsigned char>(*data++) & 0x3F]; size -= 3; } if (size == 1) { - *it++ = key[(((unsigned char)*data) & 0xFC) >> 2]; - unsigned char h = (((unsigned char)*data++) & 0x03) << 4; + *it++ = key[(static_cast<unsigned char>(*data) & 0xFC) >> 2]; + unsigned char h = static_cast<unsigned char>( + (static_cast<unsigned char>(*data++) & 0x03) << 4u); *it++ = key[h]; *it++ = '='; *it++ = '='; } else if (size == 2) { - *it++ = key[(((unsigned char)*data) & 0xFC) >> 2]; - unsigned char h = (((unsigned char)*data++) & 0x03) << 4; - *it++ = key[h | ((((unsigned char)*data) & 0xF0) >> 4)]; - h = (((unsigned char)*data++) & 0x0F) << 2; + *it++ = key[(static_cast<unsigned char>(*data) & 0xFC) >> 2]; + unsigned char h = static_cast<unsigned char>( + (static_cast<unsigned char>(*data++) & 0x03) << 4u); + *it++ = key[h | ((static_cast<unsigned char>(*data) & 0xF0) >> 4)]; + h = static_cast<unsigned char>( + (static_cast<unsigned char>(*data++) & 0x0F) << 2u); *it++ = key[h]; *it++ = '='; } @@ -572,7 +577,7 @@ inline static std::string base64encodeUrlsafe(const char* data, size_t size) // crow inline bool base64Decode(const std::string_view input, std::string& output) { - static const char nop = -1; + static const char nop = static_cast<char>(-1); // See note on encoding_data[] in above function static const char decodingData[] = { nop, nop, nop, nop, nop, nop, nop, nop, nop, nop, nop, nop, nop, nop, @@ -671,7 +676,7 @@ inline void escapeHtml(std::string& data) std::string buffer; // less than 5% of characters should be larger, so reserve a buffer of the // right size - buffer.reserve(data.size() * 1.05); + buffer.reserve(data.size() * 11 / 10); for (size_t pos = 0; pos != data.size(); ++pos) { switch (data[pos]) diff --git a/crow/include/crow/websocket.h b/crow/include/crow/websocket.h index 301f394..7166c82 100644 --- a/crow/include/crow/websocket.h +++ b/crow/include/crow/websocket.h @@ -18,8 +18,8 @@ namespace websocket struct Connection : std::enable_shared_from_this<Connection> { public: - explicit Connection(const crow::Request& req) : - req(req), userdataPtr(nullptr){}; + explicit Connection(const crow::Request& reqIn) : + req(reqIn), userdataPtr(nullptr){}; virtual void sendBinary(const std::string_view msg) = 0; virtual void sendBinary(std::string&& msg) = 0; @@ -48,13 +48,13 @@ template <typename Adaptor> class ConnectionImpl : public Connection { public: ConnectionImpl( - const crow::Request& req, Adaptor adaptorIn, + const crow::Request& reqIn, Adaptor adaptorIn, std::function<void(Connection&)> open_handler, std::function<void(Connection&, const std::string&, bool)> message_handler, std::function<void(Connection&, const std::string&)> close_handler, std::function<void(Connection&)> error_handler) : - Connection(req), + Connection(reqIn), ws(std::move(adaptorIn)), inString(), inBuffer(inString, 131088), openHandler(std::move(open_handler)), messageHandler(std::move(message_handler)), @@ -66,7 +66,8 @@ template <typename Adaptor> class ConnectionImpl : public Connection boost::asio::io_context& get_io_context() override { - return (boost::asio::io_context&)ws.get_executor().context(); + return static_cast<boost::asio::io_context&>( + ws.get_executor().context()); } void start() diff --git a/include/dbus_monitor.hpp b/include/dbus_monitor.hpp index 1b82697..8c46cf4 100644 --- a/include/dbus_monitor.hpp +++ b/include/dbus_monitor.hpp @@ -109,7 +109,7 @@ inline int onPropertyUpdate(sd_bus_message* m, void* userdata, connection->sendText(j.dump()); return 0; -}; +} template <typename... Middlewares> void requestRoutes(Crow<Middlewares...>& app) { @@ -150,7 +150,7 @@ template <typename... Middlewares> void requestRoutes(Crow<Middlewares...>& app) nlohmann::json::iterator paths = j.find("paths"); if (paths != j.end()) { - int interfaceCount = thisSession.interfaces.size(); + size_t interfaceCount = thisSession.interfaces.size(); if (interfaceCount == 0) { interfaceCount = 1; @@ -160,7 +160,7 @@ template <typename... Middlewares> void requestRoutes(Crow<Middlewares...>& app) // PropertiesChanged thisSession.matches.reserve(thisSession.matches.size() + paths->size() * - (1 + interfaceCount)); + (1U + interfaceCount)); } std::string object_manager_match_string; std::string properties_match_string; diff --git a/include/dbus_utility.hpp b/include/dbus_utility.hpp index 2dd3d97..ac5970d 100644 --- a/include/dbus_utility.hpp +++ b/include/dbus_utility.hpp @@ -53,9 +53,9 @@ inline bool getNthStringFromPath(const std::string& path, int index, std::string& result) { int count = 0; - auto first = path.begin(); - auto last = path.end(); - for (auto it = path.begin(); it < path.end(); it++) + std::string::const_iterator first = path.begin(); + std::string::const_iterator last = path.end(); + for (std::string::const_iterator it = path.begin(); it < path.end(); it++) { // skip first character as it's either a leading slash or the first // character in the word @@ -85,7 +85,8 @@ inline bool getNthStringFromPath(const std::string& path, int index, { first++; } - result = path.substr(first - path.begin(), last - first); + result = path.substr(static_cast<size_t>(first - path.begin()), + static_cast<size_t>(last - first)); return true; } diff --git a/include/image_upload.hpp b/include/image_upload.hpp index 867d1bc..529e056 100644 --- a/include/image_upload.hpp +++ b/include/image_upload.hpp @@ -29,10 +29,10 @@ inline void uploadImageHandler(const crow::Request& req, crow::Response& res, return; } // Make this const static so it survives outside this method - static boost::asio::deadline_timer timeout(*req.ioService, - boost::posix_time::seconds(5)); + static boost::asio::steady_timer timeout(*req.ioService, + std::chrono::seconds(5)); - timeout.expires_from_now(boost::posix_time::seconds(15)); + timeout.expires_after(std::chrono::seconds(15)); auto timeoutHandler = [&res](const boost::system::error_code& ec) { fwUpdateMatcher = nullptr; @@ -76,12 +76,7 @@ inline void uploadImageHandler(const crow::Request& req, crow::Response& res, "xyz.openbmc_project.Software.Version"; }) != interfaces.end()) { - boost::system::error_code ec; - timeout.cancel(ec); - if (ec) - { - BMCWEB_LOG_ERROR << "error canceling timer " << ec; - } + timeout.cancel(); std::size_t index = path.str.rfind('/'); if (index != std::string::npos) diff --git a/include/kvm_websocket.hpp b/include/kvm_websocket.hpp index db42ab8..9fc3926 100644 --- a/include/kvm_websocket.hpp +++ b/include/kvm_websocket.hpp @@ -17,7 +17,7 @@ class KvmSession { public: explicit KvmSession(crow::websocket::Connection& conn) : - conn(conn), doingWrite(false), hostSocket(conn.get_io_context()) + conn(conn), hostSocket(conn.get_io_context()), doingWrite(false) { boost::asio::ip::tcp::endpoint endpoint( boost::asio::ip::make_address("::1"), 5900); diff --git a/include/obmc_console.hpp b/include/obmc_console.hpp index ca723d3..25f3b39 100644 --- a/include/obmc_console.hpp +++ b/include/obmc_console.hpp @@ -44,7 +44,7 @@ void doWrite() if (ec == boost::asio::error::eof) { - for (auto session : sessions) + for (crow::websocket::Connection* session : sessions) { session->close("Error in reading to host port"); } @@ -70,14 +70,14 @@ void doRead() { BMCWEB_LOG_ERROR << "Couldn't read from host serial port: " << ec; - for (auto session : sessions) + for (crow::websocket::Connection* session : sessions) { session->close("Error in connecting to host port"); } return; } std::string_view payload(outputBuffer.data(), bytesRead); - for (auto session : sessions) + for (crow::websocket::Connection* session : sessions) { session->sendBinary(payload); } @@ -90,7 +90,7 @@ void connectHandler(const boost::system::error_code& ec) if (ec) { BMCWEB_LOG_ERROR << "Couldn't connect to host serial port: " << ec; - for (auto session : sessions) + for (crow::websocket::Connection* session : sessions) { session->close("Error in connecting to host port"); } diff --git a/include/openbmc_dbus_rest.hpp b/include/openbmc_dbus_rest.hpp index 7839e65..775e6e1 100644 --- a/include/openbmc_dbus_rest.hpp +++ b/include/openbmc_dbus_rest.hpp @@ -564,8 +564,8 @@ int convertJsonToDbus(sd_bus_message *m, const std::string &arg_type, { return -1; } - r = sd_bus_message_append_basic(m, argCode[0], - (void *)stringValue->c_str()); + r = sd_bus_message_append_basic( + m, argCode[0], static_cast<const void *>(stringValue->data())); if (r < 0) { return r; @@ -1640,8 +1640,8 @@ void handleEnumerate(crow::Response &res, const std::string &objectPath) }, "xyz.openbmc_project.ObjectMapper", "/xyz/openbmc_project/object_mapper", - "xyz.openbmc_project.ObjectMapper", "GetSubTree", objectPath, - static_cast<int32_t>(0), std::array<const char *, 0>()); + "xyz.openbmc_project.ObjectMapper", "GetSubTree", objectPath, 0, + std::array<const char *, 0>()); } void handleGet(crow::Response &res, std::string &objectPath, @@ -2500,14 +2500,15 @@ template <typename... Middlewares> void requestRoutes(Crow<Middlewares...> &app) propertiesObj[name]; crow::connections::systemBus->async_send( m, [&propertyItem, asyncResp]( - boost::system::error_code &ec, - sdbusplus::message::message &m) { - if (ec) + boost::system::error_code &e, + sdbusplus::message::message &msg) { + if (e) { return; } - convertDBusToJSON("v", m, propertyItem); + convertDBusToJSON("v", msg, + propertyItem); }); } property = property->NextSiblingElement("property"); diff --git a/include/pam_authenticate.hpp b/include/pam_authenticate.hpp index f211a29..1469aef 100644 --- a/include/pam_authenticate.hpp +++ b/include/pam_authenticate.hpp @@ -25,7 +25,7 @@ inline int pamFunctionConversation(int numMsg, const struct pam_message** msg, std::strcpy(pass, appPass); *resp = reinterpret_cast<pam_response*>( - calloc(numMsg, sizeof(struct pam_response))); + calloc(static_cast<size_t>(numMsg), sizeof(struct pam_response))); if (resp == nullptr) { diff --git a/include/persistent_data_middleware.hpp b/include/persistent_data_middleware.hpp index 1162fc5..5d7e97c 100644 --- a/include/persistent_data_middleware.hpp +++ b/include/persistent_data_middleware.hpp @@ -25,7 +25,7 @@ namespace fs = std::filesystem; class Middleware { - int jsonRevision = 1; + uint64_t jsonRevision = 1; public: // todo(ed) should read this from a fixed location somewhere, not CWD @@ -62,7 +62,7 @@ class Middleware void readData() { std::ifstream persistentFile(filename); - int fileRevision = 0; + uint64_t fileRevision = 0; if (persistentFile.is_open()) { // call with exceptions disabled diff --git a/include/sessions.hpp b/include/sessions.hpp index 2900cd5..b183a0e 100644 --- a/include/sessions.hpp +++ b/include/sessions.hpp @@ -362,22 +362,22 @@ class SessionStore // https://www.owasp.org/index.php/Session_Management_Cheat_Sheet#Session_ID_Entropy std::string sessionToken; sessionToken.resize(20, '0'); - std::uniform_int_distribution<int> dist(0, alphanum.size() - 1); - for (int i = 0; i < sessionToken.size(); ++i) + std::uniform_int_distribution<size_t> dist(0, alphanum.size() - 1); + for (size_t i = 0; i < sessionToken.size(); ++i) { sessionToken[i] = alphanum[dist(rd)]; } // Only need csrf tokens for cookie based auth, token doesn't matter std::string csrfToken; csrfToken.resize(20, '0'); - for (int i = 0; i < csrfToken.size(); ++i) + for (size_t i = 0; i < csrfToken.size(); ++i) { csrfToken[i] = alphanum[dist(rd)]; } std::string uniqueId; uniqueId.resize(10, '0'); - for (int i = 0; i < uniqueId.size(); ++i) + for (size_t i = 0; i < uniqueId.size(); ++i) { uniqueId[i] = alphanum[dist(rd)]; } @@ -449,7 +449,7 @@ class SessionStore { return needWrite; } - int getTimeoutInSeconds() const + int64_t getTimeoutInSeconds() const { return std::chrono::seconds(timeoutInMinutes).count(); }; diff --git a/include/ssl_key_handler.hpp b/include/ssl_key_handler.hpp index ce6d9fa..d634d63 100644 --- a/include/ssl_key_handler.hpp +++ b/include/ssl_key_handler.hpp @@ -17,10 +17,7 @@ namespace ensuressl { static void initOpenssl(); -static void cleanupOpenssl(); -static EVP_PKEY *createRsaKey(); static EVP_PKEY *createEcKey(); -static void handleOpensslError(); // Trust chain related errors.` inline bool isTrustChainError(int errnum) @@ -112,7 +109,6 @@ inline bool verifyOpensslKeyCert(const std::string &filepath) if (file != NULL) { EVP_PKEY *pkey = PEM_read_PrivateKey(file, NULL, NULL, NULL); - int rc; if (pkey != nullptr) { RSA *rsa = EVP_PKEY_get1_RSA(pkey); @@ -200,7 +196,7 @@ inline void generateSslCertificate(const std::string &filepath) // number If this is not random, regenerating certs throws broswer // errors std::random_device rd; - int serial = rd(); + int serial = static_cast<int>(rd()); ASN1_INTEGER_set(X509_get_serialNumber(x509), serial); @@ -254,45 +250,6 @@ inline void generateSslCertificate(const std::string &filepath) // cleanup_openssl(); } -EVP_PKEY *createRsaKey() -{ - RSA *pRSA = NULL; -#if OPENSSL_VERSION_NUMBER < 0x00908000L - pRSA = RSA_generate_key(2048, RSA_3, NULL, NULL); -#else - RSA_generate_key_ex(pRSA, 2048, NULL, NULL); -#endif - - EVP_PKEY *pKey = EVP_PKEY_new(); - if ((pRSA != nullptr) && (pKey != nullptr) && - EVP_PKEY_assign_RSA(pKey, pRSA)) - { - /* pKey owns pRSA from now */ - if (RSA_check_key(pRSA) <= 0) - { - fprintf(stderr, "RSA_check_key failed.\n"); - handleOpensslError(); - EVP_PKEY_free(pKey); - pKey = NULL; - } - } - else - { - handleOpensslError(); - if (pRSA != nullptr) - { - RSA_free(pRSA); - pRSA = NULL; - } - if (pKey != nullptr) - { - EVP_PKEY_free(pKey); - pKey = NULL; - } - } - return pKey; -} - EVP_PKEY *createEcKey() { EVP_PKEY *pKey = NULL; @@ -329,20 +286,6 @@ void initOpenssl() #endif } -void cleanupOpenssl() -{ - CRYPTO_cleanup_all_ex_data(); - ERR_free_strings(); -#if OPENSSL_VERSION_NUMBER < 0x10100000L - ERR_remove_thread_state(0); -#endif - EVP_cleanup(); -} - -void handleOpensslError() -{ - ERR_print_errors_fp(stderr); -} inline void ensureOpensslKeyPresentAndValid(const std::string &filepath) { bool pemFileValid = false; diff --git a/include/vm_websocket.hpp b/include/vm_websocket.hpp index 3f229e6..6485920 100644 --- a/include/vm_websocket.hpp +++ b/include/vm_websocket.hpp @@ -23,8 +23,8 @@ static constexpr auto nbdBufferSize = 131088; class Handler : public std::enable_shared_from_this<Handler> { public: - Handler(const std::string& media, boost::asio::io_service& ios) : - pipeOut(ios), pipeIn(ios), media(media), doingWrite(false), + Handler(const std::string& mediaIn, boost::asio::io_context& ios) : + pipeOut(ios), pipeIn(ios), media(mediaIn), doingWrite(false), outputBuffer(new boost::beast::flat_static_buffer<nbdBufferSize>), inputBuffer(new boost::beast::flat_static_buffer<nbdBufferSize>) { diff --git a/redfish-core/include/node.hpp b/redfish-core/include/node.hpp index 5819527..4c78eef 100644 --- a/redfish-core/include/node.hpp +++ b/redfish-core/include/node.hpp @@ -55,7 +55,7 @@ class Node { public: template <typename... Params> - Node(CrowApp& app, std::string&& entityUrl, Params... params) + Node(CrowApp& app, std::string&& entityUrl, Params... paramsIn) { crow::DynamicRule& get = app.routeDynamic(entityUrl.c_str()); getRule = &get; diff --git a/redfish-core/include/privileges.hpp b/redfish-core/include/privileges.hpp index ec6e6a5..09fa05a 100644 --- a/redfish-core/include/privileges.hpp +++ b/redfish-core/include/privileges.hpp @@ -38,10 +38,10 @@ constexpr std::array<const char*, 5> basePrivileges{ "Login", "ConfigureManager", "ConfigureComponents", "ConfigureSelf", "ConfigureUsers"}; -constexpr const int basePrivilegeCount = basePrivileges.size(); +constexpr const size_t basePrivilegeCount = basePrivileges.size(); /** @brief Max number of privileges per type */ -constexpr const int maxPrivilegeCount = 32; +constexpr const size_t maxPrivilegeCount = 32; /** @brief A vector of all privilege names and their indexes */ static const std::vector<std::string> privilegeNames{basePrivileges.begin(), @@ -100,7 +100,7 @@ class Privileges */ bool setSinglePrivilege(const char* privilege) { - for (int searchIndex = 0; searchIndex < privilegeNames.size(); + for (size_t searchIndex = 0; searchIndex < privilegeNames.size(); searchIndex++) { if (privilege == privilegeNames[searchIndex]) @@ -140,8 +140,8 @@ class Privileges { std::vector<const std::string*> activePrivileges; - int searchIndex = 0; - int endIndex = basePrivilegeCount; + size_t searchIndex = 0; + size_t endIndex = basePrivilegeCount; if (type == PrivilegeType::OEM) { searchIndex = basePrivilegeCount - 1; diff --git a/redfish-core/include/registries.hpp b/redfish-core/include/registries.hpp index 6b30be9..411e9a0 100644 --- a/redfish-core/include/registries.hpp +++ b/redfish-core/include/registries.hpp @@ -34,7 +34,7 @@ struct Message const char* description; const char* message; const char* severity; - const int numberOfArgs; + const size_t numberOfArgs; std::array<const char*, 5> paramTypes; const char* resolution; }; diff --git a/redfish-core/include/registries/base_message_registry.hpp b/redfish-core/include/registries/base_message_registry.hpp index 472f51e..1c429c5 100644 --- a/redfish-core/include/registries/base_message_registry.hpp +++ b/redfish-core/include/registries/base_message_registry.hpp @@ -23,945 +23,820 @@ namespace redfish::message_registries::base { const Header header = { - .copyright = "Copyright 2014-2018 DMTF. All rights reserved.", - .type = "#MessageRegistry.v1_0_0.MessageRegistry", - .id = "Base.1.4.0", - .name = "Base Message Registry", - .language = "en", - .description = "This registry defines the base messages for Redfish", - .registryPrefix = "Base", - .registryVersion = "1.4.0", - .owningEntity = "DMTF", + "Copyright 2014-2018 DMTF. All rights reserved.", + "#MessageRegistry.v1_0_0.MessageRegistry", + "Base.1.4.0", + "Base Message Registry", + "en", + "This registry defines the base messages for Redfish", + "Base", + "1.4.0", + "DMTF", }; -const std::array registry = { +const std::array<MessageEntry, 58> registry = { MessageEntry{ "AccessDenied", { - .description = - "Indicates that while attempting to access, connect to or " - "transfer to/from another resource, the service denied access.", - .message = "While attempting to establish a connection to %1, the " - "service denied access.", - .severity = "Critical", - .numberOfArgs = 1, - .paramTypes = - { - "string", - }, - .resolution = "Attempt to ensure that the URI is correct and that " - "the service has the appropriate credentials.", - }}, - MessageEntry{ - "AccountForSessionNoLongerExists", - { - .description = - "Indicates that the account for the session has been removed, " - "thus the session has been removed as well.", - .message = "The account for the current session has been removed, " - "thus the current session has been removed as well.", - .severity = "OK", - .numberOfArgs = 0, - .paramTypes = {}, - .resolution = "Attempt to connect with a valid account.", - }}, - MessageEntry{ - "AccountModified", - { - .description = - "Indicates that the account was successfully modified.", - .message = "The account was successfully modified.", - .severity = "OK", - .numberOfArgs = 0, - .paramTypes = {}, - .resolution = "No resolution is required.", - }}, - MessageEntry{ - "AccountNotModified", - { - .description = "Indicates that the modification requested for the " - "account was not successful.", - .message = "The account modification request failed.", - .severity = "Warning", - .numberOfArgs = 0, - .paramTypes = {}, - .resolution = "The modification may have failed due to permission " - "issues or issues with the request body.", - }}, + "Indicates that while attempting to access, connect to or transfer " + "to/from another resource, the service denied access.", + "While attempting to establish a connection to %1, the service " + "denied access.", + "Critical", + 1, + { + "string", + }, + "Attempt to ensure that the URI is correct and that the service " + "has the appropriate credentials.", + }}, + MessageEntry{"AccountForSessionNoLongerExists", + { + "Indicates that the account for the session has been " + "removed, thus the session has been removed as well.", + "The account for the current session has been removed, " + "thus the current session has been removed as well.", + "OK", + 0, + {}, + "Attempt to connect with a valid account.", + }}, + MessageEntry{"AccountModified", + { + "Indicates that the account was successfully modified.", + "The account was successfully modified.", + "OK", + 0, + {}, + "No resolution is required.", + }}, + MessageEntry{"AccountNotModified", + { + "Indicates that the modification requested for the " + "account was not successful.", + "The account modification request failed.", + "Warning", + 0, + {}, + "The modification may have failed due to permission " + "issues or issues with the request body.", + }}, MessageEntry{"AccountRemoved", { - .description = - "Indicates that the account was successfully removed.", - .message = "The account was successfully removed.", - .severity = "OK", - .numberOfArgs = 0, - .paramTypes = {}, - .resolution = "No resolution is required.", + "Indicates that the account was successfully removed.", + "The account was successfully removed.", + "OK", + 0, + {}, + "No resolution is required.", }}, MessageEntry{ "ActionNotSupported", { - .description = "Indicates that the action supplied with the POST " - "operation is not supported by the resource.", - .message = "The action %1 is not supported by the resource.", - .severity = "Critical", - .numberOfArgs = 1, - .paramTypes = - { - "string", - }, - .resolution = "The action supplied cannot be resubmitted to the " - "implementation. Perhaps the action was invalid, " - "the wrong resource was the target or the " - "implementation documentation may be of assistance.", - }}, - MessageEntry{ - "ActionParameterDuplicate", - { - .description = "Indicates that the action was supplied with a " - "duplicated parameter in the request body.", - .message = "The action %1 was submitted with more than one value " - "for the parameter %2.", - .severity = "Warning", - .numberOfArgs = 2, - .paramTypes = - { - "string", - "string", - }, - .resolution = - "Resubmit the action with only one instance of the parameter " - "in the request body if the operation failed.", - }}, - MessageEntry{ - "ActionParameterMissing", - { - .description = "Indicates that the action requested was missing a " - "parameter that is required to process the action.", - .message = "The action %1 requires the parameter %2 to be present " - "in the request body.", - .severity = "Critical", - .numberOfArgs = 2, - .paramTypes = - { - "string", - "string", - }, - .resolution = "Supply the action with the required parameter in " - "the request body when the request is resubmitted.", - }}, - MessageEntry{ - "ActionParameterNotSupported", - { - .description = "Indicates that the parameter supplied for the " - "action is not supported on the resource.", - .message = "The parameter %1 for the action %2 is not supported on " - "the target resource.", - .severity = "Warning", - .numberOfArgs = 2, - .paramTypes = - { - "string", - "string", - }, - .resolution = "Remove the parameter supplied and resubmit the " - "request if the operation failed.", - }}, + "Indicates that the action supplied with the POST operation is not " + "supported by the resource.", + "The action %1 is not supported by the resource.", + "Critical", + 1, + { + "string", + }, + "The action supplied cannot be resubmitted to the implementation. " + "Perhaps the action was invalid, the wrong resource was the target " + "or the implementation documentation may be of assistance.", + }}, + MessageEntry{"ActionParameterDuplicate", + { + "Indicates that the action was supplied with a duplicated " + "parameter in the request body.", + "The action %1 was submitted with more than one value for " + "the parameter %2.", + "Warning", + 2, + { + "string", + "string", + }, + "Resubmit the action with only one instance of the " + "parameter in the request body if the operation failed.", + }}, + MessageEntry{"ActionParameterMissing", + { + "Indicates that the action requested was missing a " + "parameter that is required to process the action.", + "The action %1 requires the parameter %2 to be present in " + "the request body.", + "Critical", + 2, + { + "string", + "string", + }, + "Supply the action with the required parameter in the " + "request body when the request is resubmitted.", + }}, + MessageEntry{"ActionParameterNotSupported", + { + "Indicates that the parameter supplied for the action is " + "not supported on the resource.", + "The parameter %1 for the action %2 is not supported on " + "the target resource.", + "Warning", + 2, + { + "string", + "string", + }, + "Remove the parameter supplied and resubmit the request " + "if the operation failed.", + }}, MessageEntry{ "ActionParameterUnknown", { - .description = - "Indicates that an action was submitted but a parameter " - "supplied did not match any of the known parameters.", - .message = - "The action %1 was submitted with the invalid parameter %2.", - .severity = "Warning", - .numberOfArgs = 2, - .paramTypes = - { - "string", - "string", - }, - .resolution = "Correct the invalid parameter and resubmit the " - "request if the operation failed.", - }}, - MessageEntry{ - "ActionParameterValueFormatError", - { - .description = - "Indicates that a parameter was given the correct value type " - "but the value of that parameter was not supported. This " - "includes value size/length exceeded.", - .message = "The value %1 for the parameter %2 in the action %3 is " - "of a different format than the parameter can accept.", - .severity = "Warning", - .numberOfArgs = 3, - .paramTypes = - { - "string", - "string", - "string", - }, - .resolution = - "Correct the value for the parameter in the request body and " - "resubmit the request if the operation failed.", - }}, - MessageEntry{ - "ActionParameterValueTypeError", - { - .description = "Indicates that a parameter was given the wrong " - "value type, such as when a number is supplied for " - "a parameter that requires a string.", - .message = "The value %1 for the parameter %2 in the action %3 is " - "of a different type than the parameter can accept.", - .severity = "Warning", - .numberOfArgs = 3, - .paramTypes = - { - "string", - "string", - "string", - }, - .resolution = - "Correct the value for the parameter in the request body and " - "resubmit the request if the operation failed.", - }}, + "Indicates that an action was submitted but a parameter supplied " + "did not match any of the known parameters.", + "The action %1 was submitted with the invalid parameter %2.", + "Warning", + 2, + { + "string", + "string", + }, + "Correct the invalid parameter and resubmit the request if the " + "operation failed.", + }}, + MessageEntry{"ActionParameterValueFormatError", + { + "Indicates that a parameter was given the correct value " + "type but the value of that parameter was not supported. " + "This includes value size/length exceeded.", + "The value %1 for the parameter %2 in the action %3 is of " + "a different format than the parameter can accept.", + "Warning", + 3, + { + "string", + "string", + "string", + }, + "Correct the value for the parameter in the request body " + "and resubmit the request if the operation failed.", + }}, + MessageEntry{"ActionParameterValueTypeError", + { + "Indicates that a parameter was given the wrong value " + "type, such as when a number is supplied for a parameter " + "that requires a string.", + "The value %1 for the parameter %2 in the action %3 is of " + "a different type than the parameter can accept.", + "Warning", + 3, + { + "string", + "string", + "string", + }, + "Correct the value for the parameter in the request body " + "and resubmit the request if the operation failed.", + }}, MessageEntry{ "CouldNotEstablishConnection", { - .description = "Indicates that the attempt to access the " - "resource/file/image at the URI was unsuccessful " - "because a session could not be established.", - .message = - "The service failed to establish a connection with the URI %1.", - .severity = "Critical", - .numberOfArgs = 1, - .paramTypes = - { - "string", - }, - .resolution = - "Ensure that the URI contains a valid and reachable node name, " - "protocol information and other URI components.", + "Indicates that the attempt to access the resource/file/image at " + "the URI was unsuccessful because a session could not be " + "established.", + "The service failed to establish a connection with the URI %1.", + "Critical", + 1, + { + "string", + }, + "Ensure that the URI contains a valid and reachable node name, " + "protocol information and other URI components.", }}, MessageEntry{ "CreateFailedMissingReqProperties", { - .description = - "Indicates that a create was attempted on a resource but that " - "properties that are required for the create operation were " - "missing from the request.", - .message = "The create operation failed because the required " - "property %1 was missing from the request.", - .severity = "Critical", - .numberOfArgs = 1, - .paramTypes = - { - "string", - }, - .resolution = - "Correct the body to include the required property with a " - "valid value and resubmit the request if the operation failed.", - }}, - MessageEntry{ - "CreateLimitReachedForResource", - { - .description = "Indicates that no more resources can be created on " - "the resource as it has reached its create limit.", - .message = "The create operation failed because the resource has " - "reached the limit of possible resources.", - .severity = "Critical", - .numberOfArgs = 0, - .paramTypes = {}, - .resolution = - "Either delete resources and resubmit the request if the " - "operation failed or do not resubmit the request.", - }}, + "Indicates that a create was attempted on a resource but that " + "properties that are required for the create operation were " + "missing from the request.", + "The create operation failed because the required property %1 was " + "missing from the request.", + "Critical", + 1, + { + "string", + }, + "Correct the body to include the required property with a valid " + "value and resubmit the request if the operation failed.", + }}, + MessageEntry{"CreateLimitReachedForResource", + { + "Indicates that no more resources can be created on the " + "resource as it has reached its create limit.", + "The create operation failed because the resource has " + "reached the limit of possible resources.", + "Critical", + 0, + {}, + "Either delete resources and resubmit the request if the " + "operation failed or do not resubmit the request.", + }}, MessageEntry{"Created", { - .description = - "Indicates that all conditions of a successful " - "creation operation have been met.", - .message = "The resource has been created successfully", - .severity = "OK", - .numberOfArgs = 0, - .paramTypes = {}, - .resolution = "None", + "Indicates that all conditions of a successful creation " + "operation have been met.", + "The resource has been created successfully", + "OK", + 0, + {}, + "None", }}, MessageEntry{ "EmptyJSON", { - .description = - "Indicates that the request body contained an empty JSON " - "object when one or more properties are expected in the body.", - .message = "The request body submitted contained an empty JSON " - "object and the service is unable to process it.", - .severity = "Warning", - .numberOfArgs = 0, - .paramTypes = {}, - .resolution = - "Add properties in the JSON object and resubmit the request.", + "Indicates that the request body contained an empty JSON object " + "when one or more properties are expected in the body.", + "The request body submitted contained an empty JSON object and the " + "service is unable to process it.", + "Warning", + 0, + {}, + "Add properties in the JSON object and resubmit the request.", }}, MessageEntry{ "EventSubscriptionLimitExceeded", { - .description = "Indicates that a event subscription establishment " - "has been requested but the operation failed due to " - "the number of simultaneous connection exceeding " - "the limit of the implementation.", - .message = "The event subscription failed due to the number of " - "simultaneous subscriptions exceeding the limit of the " - "implementation.", - .severity = "Critical", - .numberOfArgs = 0, - .paramTypes = {}, - .resolution = - "Reduce the number of other subscriptions before trying to " - "establish the event subscription or increase the limit of " - "simultaneous subscriptions (if supported).", + "Indicates that a event subscription establishment has been " + "requested but the operation failed due to the number of " + "simultaneous connection exceeding the limit of the " + "implementation.", + "The event subscription failed due to the number of simultaneous " + "subscriptions exceeding the limit of the implementation.", + "Critical", + 0, + {}, + "Reduce the number of other subscriptions before trying to " + "establish the event subscription or increase the limit of " + "simultaneous subscriptions (if supported).", }}, MessageEntry{ "GeneralError", { - .description = - "Indicates that a general error has occurred. Use in " - "ExtendedInfo is discouraged. When used in ExtendedInfo, " - "implementations are expected to include a Resolution property " - "with this error to indicate how to resolve the problem.", - .message = "A general error has occurred. See Resolution for " - "information on how to resolve the error.", - .severity = "Critical", - .numberOfArgs = 0, - .paramTypes = {}, - .resolution = "None.", + "Indicates that a general error has occurred. Use in ExtendedInfo " + "is discouraged. When used in ExtendedInfo, implementations are " + "expected to include a Resolution property with this error to " + "indicate how to resolve the problem.", + "A general error has occurred. See Resolution for information on " + "how to resolve the error.", + "Critical", + 0, + {}, + "None.", }}, MessageEntry{ "InsufficientPrivilege", { - .description = "Indicates that the credentials associated with the " - "established session do not have sufficient " - "privileges for the requested operation", - .message = "There are insufficient privileges for the account or " - "credentials associated with the current session to " - "perform the requested operation.", - .severity = "Critical", - .numberOfArgs = 0, - .paramTypes = {}, - .resolution = - "Either abandon the operation or change the associated access " - "rights and resubmit the request if the operation failed.", + "Indicates that the credentials associated with the established " + "session do not have sufficient privileges for the requested " + "operation", + "There are insufficient privileges for the account or credentials " + "associated with the current session to perform the requested " + "operation.", + "Critical", + 0, + {}, + "Either abandon the operation or change the associated access " + "rights and resubmit the request if the operation failed.", }}, MessageEntry{ "InternalError", { - .description = - "Indicates that the request failed for an unknown internal " - "error but that the service is still operational.", - .message = "The request failed due to an internal service error. " - "The service is still operational.", - .severity = "Critical", - .numberOfArgs = 0, - .paramTypes = {}, - .resolution = "Resubmit the request. If the problem persists, " - "consider resetting the service.", - }}, - MessageEntry{ - "InvalidIndex", - { - .description = "The Index is not valid.", - .message = "The Index %1 is not a valid offset into the array.", - .severity = "Warning", - .numberOfArgs = 1, - .paramTypes = - { - "number", - }, - .resolution = "Verify the index value provided is within the " - "bounds of the array.", - }}, + "Indicates that the request failed for an unknown internal error " + "but that the service is still operational.", + "The request failed due to an internal service error. The service " + "is still operational.", + "Critical", + 0, + {}, + "Resubmit the request. If the problem persists, consider " + "resetting the service.", + }}, + MessageEntry{"InvalidIndex", + { + "The Index is not valid.", + "The Index %1 is not a valid offset into the array.", + "Warning", + 1, + { + "number", + }, + "Verify the index value provided is within the bounds of " + "the array.", + }}, MessageEntry{ "InvalidObject", { - .description = "Indicates that the object in question is invalid " - "according to the implementation. Examples include " - "a firmware update malformed URI.", - .message = "The object at %1 is invalid.", - .severity = "Critical", - .numberOfArgs = 1, - .paramTypes = - { - "string", - }, - .resolution = - "Either the object is malformed or the URI is not correct. " - "Correct the condition and resubmit the request if it failed.", - }}, - MessageEntry{ - "MalformedJSON", - { - .description = "Indicates that the request body was malformed " - "JSON. Could be duplicate, syntax error,etc.", - .message = "The request body submitted was malformed JSON and " - "could not be parsed by the receiving service.", - .severity = "Critical", - .numberOfArgs = 0, - .paramTypes = {}, - .resolution = "Ensure that the request body is valid JSON and " - "resubmit the request.", - }}, + "Indicates that the object in question is invalid according to the " + "implementation. Examples include a firmware update malformed " + "URI.", + "The object at %1 is invalid.", + "Critical", + 1, + { + "string", + }, + "Either the object is malformed or the URI is not correct. " + "Correct the condition and resubmit the request if it failed.", + }}, + MessageEntry{"MalformedJSON", + { + "Indicates that the request body was malformed JSON. " + "Could be duplicate, syntax error,etc.", + "The request body submitted was malformed JSON and could " + "not be parsed by the receiving service.", + "Critical", + 0, + {}, + "Ensure that the request body is valid JSON and resubmit " + "the request.", + }}, MessageEntry{ "NoOperation", { - .description = "Indicates that the requested operation will not " - "perform any changes on the service.", - .message = "The request body submitted contain no data to act upon " - "and no changes to the resource took place.", - .severity = "Warning", - .numberOfArgs = 0, - .paramTypes = {}, - .resolution = - "Add properties in the JSON object and resubmit the request.", + "Indicates that the requested operation will not perform any " + "changes on the service.", + "The request body submitted contain no data to act upon and no " + "changes to the resource took place.", + "Warning", + 0, + {}, + "Add properties in the JSON object and resubmit the request.", }}, MessageEntry{ "NoValidSession", { - .description = - "Indicates that the operation failed because a valid session " - "is required in order to access any resources.", - .message = "There is no valid session established with the " - "implementation.", - .severity = "Critical", - .numberOfArgs = 0, - .paramTypes = {}, - .resolution = - "Establish as session before attempting any operations.", - }}, - MessageEntry{ - "PropertyDuplicate", - { - .description = "Indicates that a duplicate property was included " - "in the request body.", - .message = "The property %1 was duplicated in the request.", - .severity = "Warning", - .numberOfArgs = 1, - .paramTypes = - { - "string", - }, - .resolution = "Remove the duplicate property from the request body " - "and resubmit the request if the operation failed.", + "Indicates that the operation failed because a valid session is " + "required in order to access any resources.", + "There is no valid session established with the implementation.", + "Critical", + 0, + {}, + "Establish as session before attempting any operations.", }}, + MessageEntry{"PropertyDuplicate", + { + "Indicates that a duplicate property was included in the " + "request body.", + "The property %1 was duplicated in the request.", + "Warning", + 1, + { + "string", + }, + "Remove the duplicate property from the request body and " + "resubmit the request if the operation failed.", + }}, MessageEntry{ "PropertyMissing", { - .description = "Indicates that a required property was not " - "supplied as part of the request.", - .message = "The property %1 is a required property and must be " - "included in the request.", - .severity = "Warning", - .numberOfArgs = 1, - .paramTypes = - { - "string", - }, - .resolution = - "Ensure that the property is in the request body and has a " - "valid value and resubmit the request if the operation failed.", - }}, - MessageEntry{ - "PropertyNotWritable", - { - .description = - "Indicates that a property was given a value in the request " - "body, but the property is a readonly property.", - .message = "The property %1 is a read only property and cannot be " - "assigned a value.", - .severity = "Warning", - .numberOfArgs = 1, - .paramTypes = - { - "string", - }, - .resolution = "Remove the property from the request body and " - "resubmit the request if the operation failed.", - }}, - MessageEntry{ - "PropertyUnknown", - { - .description = "Indicates that an unknown property was included in " - "the request body.", - .message = "The property %1 is not in the list of valid properties " - "for the resource.", - .severity = "Warning", - .numberOfArgs = 1, - .paramTypes = - { - "string", - }, - .resolution = "Remove the unknown property from the request body " - "and resubmit the request if the operation failed.", - }}, - MessageEntry{ - "PropertyValueFormatError", - { - .description = - "Indicates that a property was given the correct value type " - "but the value of that property was not supported.", - .message = "The value %1 for the property %2 is of a different " - "format than the property can accept.", - .severity = "Warning", - .numberOfArgs = 2, - .paramTypes = - { - "string", - "string", - }, - .resolution = - "Correct the value for the property in the request body and " - "resubmit the request if the operation failed.", - }}, + "Indicates that a required property was not supplied as part of " + "the request.", + "The property %1 is a required property and must be included in " + "the request.", + "Warning", + 1, + { + "string", + }, + "Ensure that the property is in the request body and has a valid " + "value and resubmit the request if the operation failed.", + }}, + MessageEntry{"PropertyNotWritable", + { + "Indicates that a property was given a value in the " + "request body, but the property is a readonly property.", + "The property %1 is a read only property and cannot be " + "assigned a value.", + "Warning", + 1, + { + "string", + }, + "Remove the property from the request body and resubmit " + "the request if the operation failed.", + }}, + MessageEntry{"PropertyUnknown", + { + "Indicates that an unknown property was included in the " + "request body.", + "The property %1 is not in the list of valid properties " + "for the resource.", + "Warning", + 1, + { + "string", + }, + "Remove the unknown property from the request body and " + "resubmit the request if the operation failed.", + }}, + MessageEntry{"PropertyValueFormatError", + { + "Indicates that a property was given the correct value " + "type but the value of that property was not supported.", + "The value %1 for the property %2 is of a different " + "format than the property can accept.", + "Warning", + 2, + { + "string", + "string", + }, + "Correct the value for the property in the request body " + "and resubmit the request if the operation failed.", + }}, MessageEntry{"PropertyValueModified", { - .description = - "Indicates that a property was given the correct " - "value type but the value of that property was " - "modified. Examples are truncated or rounded values.", - .message = "The property %1 was assigned the value %2 due " - "to modification by the service.", - .severity = "Warning", - .numberOfArgs = 2, - .paramTypes = - { - "string", - "string", - }, - .resolution = "No resolution is required.", + "Indicates that a property was given the correct value " + "type but the value of that property was modified. " + "Examples are truncated or rounded values.", + "The property %1 was assigned the value %2 due to " + "modification by the service.", + "Warning", + 2, + { + "string", + "string", + }, + "No resolution is required.", }}, MessageEntry{ "PropertyValueNotInList", { - .description = "Indicates that a property was given the correct " - "value type but the value of that property was not " - "supported. This values not in an enumeration", - .message = "The value %1 for the property %2 is not in the list of " - "acceptable values.", - .severity = "Warning", - .numberOfArgs = 2, - .paramTypes = - { - "string", - "string", - }, - .resolution = "Choose a value from the enumeration list that the " - "implementation can support and resubmit the request " - "if the operation failed.", + "Indicates that a property was given the correct value type but " + "the value of that property was not supported. This values not in " + "an enumeration", + "The value %1 for the property %2 is not in the list of acceptable " + "values.", + "Warning", + 2, + { + "string", + "string", + }, + "Choose a value from the enumeration list that the implementation " + "can support and resubmit the request if the operation failed.", }}, MessageEntry{ "PropertyValueTypeError", { - .description = "Indicates that a property was given the wrong " - "value type, such as when a number is supplied for " - "a property that requires a string.", - .message = "The value %1 for the property %2 is of a different " - "type than the property can accept.", - .severity = "Warning", - .numberOfArgs = 2, - .paramTypes = - { - "string", - "string", - }, - .resolution = - "Correct the value for the property in the request body and " - "resubmit the request if the operation failed.", + "Indicates that a property was given the wrong value type, such as " + "when a number is supplied for a property that requires a string.", + "The value %1 for the property %2 is of a different type than the " + "property can accept.", + "Warning", + 2, + { + "string", + "string", + }, + "Correct the value for the property in the request body and " + "resubmit the request if the operation failed.", }}, MessageEntry{ "QueryNotSupported", { - .description = - "Indicates that query is not supported on the implementation.", - .message = "Querying is not supported by the implementation.", - .severity = "Warning", - .numberOfArgs = 0, - .paramTypes = {}, - .resolution = "Remove the query parameters and resubmit the " - "request if the operation failed.", - }}, - MessageEntry{ - "QueryNotSupportedOnResource", - { - .description = "Indicates that query is not supported on the given " - "resource, such as when a start/count query is " - "attempted on a resource that is not a collection.", - .message = "Querying is not supported on the requested resource.", - .severity = "Warning", - .numberOfArgs = 0, - .paramTypes = {}, - .resolution = "Remove the query parameters and resubmit the " - "request if the operation failed.", + "Indicates that query is not supported on the implementation.", + "Querying is not supported by the implementation.", + "Warning", + 0, + {}, + "Remove the query parameters and resubmit the request if the " + "operation failed.", }}, + MessageEntry{"QueryNotSupportedOnResource", + { + "Indicates that query is not supported on the given " + "resource, such as when a start/count query is attempted " + "on a resource that is not a collection.", + "Querying is not supported on the requested resource.", + "Warning", + 0, + {}, + "Remove the query parameters and resubmit the request if " + "the operation failed.", + }}, MessageEntry{ "QueryParameterOutOfRange", { - .description = "Indicates that a query parameter was supplied that " - "is out of range for the given resource. This can " - "happen with values that are too low or beyond that " - "possible for the supplied resource, such as when a " - "page is requested that is beyond the last page.", - .message = - "The value %1 for the query parameter %2 is out of range %3.", - .severity = "Warning", - .numberOfArgs = 3, - .paramTypes = - { - "string", - "string", - "string", - }, - .resolution = - "Reduce the value for the query parameter to a value that is " - "within range, such as a start or count value that is within " - "bounds of the number of resources in a collection or a page " - "that is within the range of valid pages.", - }}, - MessageEntry{ - "QueryParameterValueFormatError", - { - .description = - "Indicates that a query parameter was given the correct value " - "type but the value of that parameter was not supported. This " - "includes value size/length exceeded.", - .message = "The value %1 for the parameter %2 is of a different " - "format than the parameter can accept.", - .severity = "Warning", - .numberOfArgs = 2, - .paramTypes = - { - "string", - "string", - }, - .resolution = - "Correct the value for the query parameter in the request and " - "resubmit the request if the operation failed.", - }}, - MessageEntry{ - "QueryParameterValueTypeError", - { - .description = - "Indicates that a query parameter was given the wrong value " - "type, such as when a number is supplied for a query parameter " - "that requires a string.", - .message = "The value %1 for the query parameter %2 is of a " - "different type than the parameter can accept.", - .severity = "Warning", - .numberOfArgs = 2, - .paramTypes = - { - "string", - "string", - }, - .resolution = - "Correct the value for the query parameter in the request and " - "resubmit the request if the operation failed.", - }}, - MessageEntry{ - "ResourceAlreadyExists", - { - .description = "Indicates that a resource change or creation was " - "attempted but that the operation cannot proceed " - "because the resource already exists.", - .message = "The requested resource of type %1 with the property %2 " - "with the value %3 already exists.", - .severity = "Critical", - .numberOfArgs = 3, - .paramTypes = - { - "string", - "string", - "string", - }, - .resolution = "Do not repeat the create operation as the resource " - "has already been created.", - }}, + "Indicates that a query parameter was supplied that is out of " + "range for the given resource. This can happen with values that " + "are too low or beyond that possible for the supplied resource, " + "such as when a page is requested that is beyond the last page.", + "The value %1 for the query parameter %2 is out of range %3.", + "Warning", + 3, + { + "string", + "string", + "string", + }, + "Reduce the value for the query parameter to a value that is " + "within range, such as a start or count value that is within " + "bounds of the number of resources in a collection or a page that " + "is within the range of valid pages.", + }}, + MessageEntry{"QueryParameterValueFormatError", + { + "Indicates that a query parameter was given the correct " + "value type but the value of that parameter was not " + "supported. This includes value size/length exceeded.", + "The value %1 for the parameter %2 is of a different " + "format than the parameter can accept.", + "Warning", + 2, + { + "string", + "string", + }, + "Correct the value for the query parameter in the request " + "and resubmit the request if the operation failed.", + }}, + MessageEntry{"QueryParameterValueTypeError", + { + "Indicates that a query parameter was given the wrong " + "value type, such as when a number is supplied for a " + "query parameter that requires a string.", + "The value %1 for the query parameter %2 is of a " + "different type than the parameter can accept.", + "Warning", + 2, + { + "string", + "string", + }, + "Correct the value for the query parameter in the request " + "and resubmit the request if the operation failed.", + }}, + MessageEntry{"ResourceAlreadyExists", + { + "Indicates that a resource change or creation was " + "attempted but that the operation cannot proceed because " + "the resource already exists.", + "The requested resource of type %1 with the property %2 " + "with the value %3 already exists.", + "Critical", + 3, + { + "string", + "string", + "string", + }, + "Do not repeat the create operation as the resource has " + "already been created.", + }}, MessageEntry{ "ResourceAtUriInUnknownFormat", { - .description = - "Indicates that the URI was valid but the resource or image at " - "that URI was in a format not supported by the service.", - .message = "The resource at %1 is in a format not recognized by " - "the service.", - .severity = "Critical", - .numberOfArgs = 1, - .paramTypes = - { - "string", - }, - .resolution = "Place an image or resource or file that is " - "recognized by the service at the URI.", - }}, - MessageEntry{ - "ResourceAtUriUnauthorized", - { - .description = "Indicates that the attempt to access the " - "resource/file/image at the URI was unauthorized.", - .message = "While accessing the resource at %1, the service " - "received an authorization error %2.", - .severity = "Critical", - .numberOfArgs = 2, - .paramTypes = - { - "string", - "string", - }, - .resolution = "Ensure that the appropriate access is provided for " - "the service in order for it to access the URI.", - }}, - MessageEntry{ - "ResourceCannotBeDeleted", - { - .description = "Indicates that a delete operation was attempted on " - "a resource that cannot be deleted.", - .message = "The delete request failed because the resource " - "requested cannot be deleted.", - .severity = "Critical", - .numberOfArgs = 0, - .paramTypes = {}, - .resolution = "Do not attempt to delete a non-deletable resource.", - }}, + "Indicates that the URI was valid but the resource or image at " + "that URI was in a format not supported by the service.", + "The resource at %1 is in a format not recognized by the service.", + "Critical", + 1, + { + "string", + }, + "Place an image or resource or file that is recognized by the " + "service at the URI.", + }}, + MessageEntry{"ResourceAtUriUnauthorized", + { + "Indicates that the attempt to access the " + "resource/file/image at the URI was unauthorized.", + "While accessing the resource at %1, the service received " + "an authorization error %2.", + "Critical", + 2, + { + "string", + "string", + }, + "Ensure that the appropriate access is provided for the " + "service in order for it to access the URI.", + }}, + MessageEntry{"ResourceCannotBeDeleted", + { + "Indicates that a delete operation was attempted on a " + "resource that cannot be deleted.", + "The delete request failed because the resource requested " + "cannot be deleted.", + "Critical", + 0, + {}, + "Do not attempt to delete a non-deletable resource.", + }}, MessageEntry{ "ResourceExhaustion", { - .description = - "Indicates that a resource could not satisfy the request due " - "to some unavailability of resources. An example is that " - "available capacity has been allocated.", - .message = "The resource %1 was unable to satisfy the request due " - "to unavailability of resources.", - .severity = "Critical", - .numberOfArgs = 1, - .paramTypes = - { - "string", - }, - .resolution = "Ensure that the resources are available and " - "resubmit the request.", - }}, - MessageEntry{ - "ResourceInStandby", - { - .description = "Indicates that the request could not be performed " - "because the resource is in standby.", - .message = "The request could not be performed because the " - "resource is in standby.", - .severity = "Critical", - .numberOfArgs = 0, - .paramTypes = {}, - .resolution = "Ensure that the resource is in the correct power " - "state and resubmit the request.", - }}, - MessageEntry{ - "ResourceInUse", - { - .description = "Indicates that a change was requested to a " - "resource but the change was rejected due to the " - "resource being in use or transition.", - .message = "The change to the requested resource failed because " - "the resource is in use or in transition.", - .severity = "Warning", - .numberOfArgs = 0, - .paramTypes = {}, - .resolution = "Remove the condition and resubmit the request if " - "the operation failed.", - }}, + "Indicates that a resource could not satisfy the request due to " + "some unavailability of resources. An example is that available " + "capacity has been allocated.", + "The resource %1 was unable to satisfy the request due to " + "unavailability of resources.", + "Critical", + 1, + { + "string", + }, + "Ensure that the resources are available and resubmit the request.", + }}, + MessageEntry{"ResourceInStandby", + { + "Indicates that the request could not be performed " + "because the resource is in standby.", + "The request could not be performed because the resource " + "is in standby.", + "Critical", + 0, + {}, + "Ensure that the resource is in the correct power state " + "and resubmit the request.", + }}, + MessageEntry{"ResourceInUse", + { + "Indicates that a change was requested to a resource but " + "the change was rejected due to the resource being in use " + "or transition.", + "The change to the requested resource failed because the " + "resource is in use or in transition.", + "Warning", + 0, + {}, + "Remove the condition and resubmit the request if the " + "operation failed.", + }}, MessageEntry{ "ResourceMissingAtURI", { - .description = - "Indicates that the operation expected an image or other " - "resource at the provided URI but none was found. Examples of " - "this are in requests that require URIs like Firmware Update.", - .message = "The resource at the URI %1 was not found.", - .severity = "Critical", - .numberOfArgs = 1, - .paramTypes = - { - "string", - }, - .resolution = "Place a valid resource at the URI or correct the " - "URI and resubmit the request.", + "Indicates that the operation expected an image or other resource " + "at the provided URI but none was found. Examples of this are in " + "requests that require URIs like Firmware Update.", + "The resource at the URI %1 was not found.", + "Critical", + 1, + { + "string", + }, + "Place a valid resource at the URI or correct the URI and resubmit " + "the request.", }}, MessageEntry{ "ResourceNotFound", { - .description = "Indicates that the operation expected a resource " - "identifier that corresponds to an existing " - "resource but one was not found.", - .message = - "The requested resource of type %1 named %2 was not found.", - .severity = "Critical", - .numberOfArgs = 2, - .paramTypes = - { - "string", - "string", - }, - .resolution = - "Provide a valid resource identifier and resubmit the request.", + "Indicates that the operation expected a resource identifier that " + "corresponds to an existing resource but one was not found.", + "The requested resource of type %1 named %2 was not found.", + "Critical", + 2, + { + "string", + "string", + }, + "Provide a valid resource identifier and resubmit the request.", }}, MessageEntry{ "ResourceTypeIncompatible", { - .description = - "Indicates that the resource type of the operation does not " - "match that for the operation destination. Examples of when " - "this can happen include during a POST to a collection using " - "the wrong resource type, an update where the @odata.types do " - "not match or on a major version incompatability.", - .message = "The @odata.type of the request body %1 is incompatible " - "with the @odata.type of the resource which is %2.", - .severity = "Critical", - .numberOfArgs = 2, - .paramTypes = - { - "string", - "string", - }, - .resolution = "Resubmit the request with a payload compatible with " - "the resource's schema.", + "Indicates that the resource type of the operation does not match " + "that for the operation destination. Examples of when this can " + "happen include during a POST to a collection using the wrong " + "resource type, an update where the @odata.types do not match or " + "on a major version incompatability.", + "The @odata.type of the request body %1 is incompatible with the " + "@odata.type of the resource which is %2.", + "Critical", + 2, + { + "string", + "string", + }, + "Resubmit the request with a payload compatible with the " + "resource's schema.", }}, MessageEntry{ "ServiceInUnknownState", { - .description = - "Indicates that the operation failed because the service is in " - "an unknown state and cannot accept additional requests.", - .message = - "The operation failed because the service is in an unknown " - "state and can no longer take incoming requests.", - .severity = "Critical", - .numberOfArgs = 0, - .paramTypes = {}, - .resolution = "Restart the service and resubmit the request if the " - "operation failed.", - }}, - MessageEntry{ - "ServiceShuttingDown", - { - .description = - "Indicates that the operation failed as the service is " - "shutting down, such as when the service reboots.", - .message = "The operation failed because the service is shutting " - "down and can no longer take incoming requests.", - .severity = "Critical", - .numberOfArgs = 0, - .paramTypes = {}, - .resolution = "When the service becomes available, resubmit the " - "request if the operation failed.", - }}, + "Indicates that the operation failed because the service is in an " + "unknown state and cannot accept additional requests.", + "The operation failed because the service is in an unknown state " + "and can no longer take incoming requests.", + "Critical", + 0, + {}, + "Restart the service and resubmit the request if the operation " + "failed.", + }}, + MessageEntry{"ServiceShuttingDown", + { + "Indicates that the operation failed as the service is " + "shutting down, such as when the service reboots.", + "The operation failed because the service is shutting " + "down and can no longer take incoming requests.", + "Critical", + 0, + {}, + "When the service becomes available, resubmit the request " + "if the operation failed.", + }}, MessageEntry{ "ServiceTemporarilyUnavailable", { - .description = "Indicates the service is temporarily unavailable.", - .message = - "The service is temporarily unavailable. Retry in %1 seconds.", - .severity = "Critical", - .numberOfArgs = 1, - .paramTypes = - { - "string", - }, - .resolution = "Wait for the indicated retry duration and retry the " - "operation.", + "Indicates the service is temporarily unavailable.", + "The service is temporarily unavailable. Retry in %1 seconds.", + "Critical", + 1, + { + "string", + }, + "Wait for the indicated retry duration and retry the operation.", }}, MessageEntry{ "SessionLimitExceeded", { - .description = - "Indicates that a session establishment has been requested but " - "the operation failed due to the number of simultaneous " - "sessions exceeding the limit of the implementation.", - .message = "The session establishment failed due to the number of " - "simultaneous sessions exceeding the limit of the " - "implementation.", - .severity = "Critical", - .numberOfArgs = 0, - .paramTypes = {}, - .resolution = "Reduce the number of other sessions before trying " - "to establish the session or increase the limit of " - "simultaneous sessions (if supported).", + "Indicates that a session establishment has been requested but the " + "operation failed due to the number of simultaneous sessions " + "exceeding the limit of the implementation.", + "The session establishment failed due to the number of " + "simultaneous sessions exceeding the limit of the implementation.", + "Critical", + 0, + {}, + "Reduce the number of other sessions before trying to establish " + "the session or increase the limit of simultaneous sessions (if " + "supported).", }}, MessageEntry{ "SessionTerminated", { - .description = - "Indicates that the DELETE operation on the Session resource " - "resulted in the successful termination of the session.", - .message = "The session was successfully terminated.", - .severity = "OK", - .numberOfArgs = 0, - .paramTypes = {}, - .resolution = "No resolution is required.", + "Indicates that the DELETE operation on the Session resource " + "resulted in the successful termination of the session.", + "The session was successfully terminated.", + "OK", + 0, + {}, + "No resolution is required.", }}, MessageEntry{ "SourceDoesNotSupportProtocol", { - .description = - "Indicates that while attempting to access, connect to or " - "transfer a resource/file/image from another location that the " - "other end of the connection did not support the protocol", - .message = "The other end of the connection at %1 does not support " - "the specified protocol %2.", - .severity = "Critical", - .numberOfArgs = 2, - .paramTypes = - { - "string", - "string", - }, - .resolution = "Change protocols or URIs. ", - }}, - MessageEntry{ - "StringValueTooLong", - { - .description = - "Indicates that a string value passed to the given resource " - "exceeded its length limit. An example is when a shorter limit " - "is imposed by an implementation than that allowed by the " - "specification.", - .message = "The string %1 exceeds the length limit %2.", - .severity = "Warning", - .numberOfArgs = 2, - .paramTypes = - { - "string", - "number", - }, - .resolution = - "Resubmit the request with an appropriate string length.", - }}, + "Indicates that while attempting to access, connect to or transfer " + "a resource/file/image from another location that the other end of " + "the connection did not support the protocol", + "The other end of the connection at %1 does not support the " + "specified protocol %2.", + "Critical", + 2, + { + "string", + "string", + }, + "Change protocols or URIs. ", + }}, + MessageEntry{"StringValueTooLong", + { + "Indicates that a string value passed to the given " + "resource exceeded its length limit. An example is when a " + "shorter limit is imposed by an implementation than that " + "allowed by the specification.", + "The string %1 exceeds the length limit %2.", + "Warning", + 2, + { + "string", + "number", + }, + "Resubmit the request with an appropriate string length.", + }}, MessageEntry{"Success", { - .description = "Indicates that all conditions of a " - "successful operation have been met.", - .message = "Successfully Completed Request", - .severity = "OK", - .numberOfArgs = 0, - .paramTypes = {}, - .resolution = "None", + "Indicates that all conditions of a successful operation " + "have been met.", + "Successfully Completed Request", + "OK", + 0, + {}, + "None", }}, MessageEntry{ "UnrecognizedRequestBody", { - .description = "Indicates that the service encountered an " - "unrecognizable request body that could not even be " - "interpreted as malformed JSON.", - .message = "The service detected a malformed request body that it " - "was unable to interpret.", - .severity = "Warning", - .numberOfArgs = 0, - .paramTypes = {}, - .resolution = "Correct the request body and resubmit the request " - "if it failed.", + "Indicates that the service encountered an unrecognizable request " + "body that could not even be interpreted as malformed JSON.", + "The service detected a malformed request body that it was unable " + "to interpret.", + "Warning", + 0, + {}, + "Correct the request body and resubmit the request if it failed.", }}, }; } // namespace redfish::message_registries::base diff --git a/redfish-core/include/registries/openbmc_message_registry.hpp b/redfish-core/include/registries/openbmc_message_registry.hpp index c3ec266..3b57794 100644 --- a/redfish-core/include/registries/openbmc_message_registry.hpp +++ b/redfish-core/include/registries/openbmc_message_registry.hpp @@ -19,1512 +19,1410 @@ namespace redfish::message_registries::openbmc { const Header header = { - .copyright = "Copyright 2018 OpenBMC. All rights reserved.", - .type = "#MessageRegistry.v1_0_0.MessageRegistry", - .id = "OpenBMC.0.1.0", - .name = "OpenBMC Message Registry", - .language = "en", - .description = "This registry defines the base messages for OpenBMC.", - .registryPrefix = "OpenBMC", - .registryVersion = "0.1.0", - .owningEntity = "OpenBMC", + "Copyright 2018 OpenBMC. All rights reserved.", + "#MessageRegistry.v1_0_0.MessageRegistry", + "OpenBMC.0.1.0", + "OpenBMC Message Registry", + "en", + "This registry defines the base messages for OpenBMC.", + "OpenBMC", + "0.1.0", + "OpenBMC", }; -const std::array registry = { +const std::array<MessageEntry, 114> registry = { MessageEntry{ "ADDDCCorrectable", { - .description = "Indicates an ADDDC Correctable Error.", - .message = - "ADDDC Correctable Error.Socket=%1 Channel=%2 DIMM=%3 Rank=%4.", - .severity = "Warning", - .numberOfArgs = 4, - .paramTypes = - { - "number", - "string", - "number", - "number", - }, - .resolution = "None.", + "Indicates an ADDDC Correctable Error.", + "ADDDC Correctable Error.Socket=%1 Channel=%2 DIMM=%3 Rank=%4.", + "Warning", + 4, + { + "number", + "string", + "number", + "number", + }, + "None.", }}, MessageEntry{ "BIOSBoot", { - .description = - "Indicates BIOS has transitioned control to the OS Loader.", - .message = "BIOS System Boot.", - .severity = "OK", - .numberOfArgs = 0, - .paramTypes = {}, - .resolution = "None.", - }}, - MessageEntry{ - "BIOSPOSTError", - { - .description = "Indicates BIOS POST has encountered an error.", - .message = "BIOS POST Error. Error Code=%1", - .severity = "Warning", - .numberOfArgs = 1, - .paramTypes = {"number"}, - .resolution = "None.", + "Indicates BIOS has transitioned control to the OS Loader.", + "BIOS System Boot.", + "OK", + 0, + {}, + "None.", }}, + MessageEntry{"BIOSPOSTError", + { + "Indicates BIOS POST has encountered an error.", + "BIOS POST Error. Error Code=%1", + "Warning", + 1, + {"number"}, + "None.", + }}, MessageEntry{"BIOSRecoveryComplete", { - .description = "Indicates BIOS Recovery has completed.", - .message = "BIOS Recovery Complete.", - .severity = "OK", - .numberOfArgs = 0, - .paramTypes = {}, - .resolution = "None.", + "Indicates BIOS Recovery has completed.", + "BIOS Recovery Complete.", + "OK", + 0, + {}, + "None.", }}, MessageEntry{"BIOSRecoveryStart", { - .description = "Indicates BIOS Recovery has started.", - .message = "BIOS Recovery Start.", - .severity = "Warning", - .numberOfArgs = 0, - .paramTypes = {}, - .resolution = "None.", + "Indicates BIOS Recovery has started.", + "BIOS Recovery Start.", + "Warning", + 0, + {}, + "None.", }}, MessageEntry{"CPUError", { - .description = "Indicates that a CPU Error occurred of " - "the specified type or cause.", - .message = "CPU Error Occurred: %1.", - .severity = "Critical", - .numberOfArgs = 1, - .paramTypes = {"string"}, - .resolution = "None.", + "Indicates that a CPU Error occurred of " + "the specified type or cause.", + "CPU Error Occurred: %1.", + "Critical", + 1, + {"string"}, + "None.", }}, MessageEntry{"CPUThermalTrip", { - .description = "Indicates that the specified CPU thermal " - "trip has been asserted.", - .message = "CPU %1 Thermal Trip.", - .severity = "Critical", - .numberOfArgs = 1, - .paramTypes = {"number"}, - .resolution = "None.", + "Indicates that the specified CPU thermal " + "trip has been asserted.", + "CPU %1 Thermal Trip.", + "Critical", + 1, + {"number"}, + "None.", + }}, + MessageEntry{"DCPowerOff", + { + "Indicates that the system DC power is off.", + "Host system DC power is off", + "OK", + 0, + {}, + "None.", }}, - MessageEntry{ - "DCPowerOff", - { - .description = "Indicates that the system DC power is off.", - .message = "Host system DC power is off", - .severity = "OK", - .numberOfArgs = 0, - .paramTypes = {}, - .resolution = "None.", - }}, MessageEntry{"DCPowerOn", { - .description = "Indicates that the system DC power is on.", - .message = "Host system DC power is on", - .severity = "OK", - .numberOfArgs = 0, - .paramTypes = {}, - .resolution = "None.", + "Indicates that the system DC power is on.", + "Host system DC power is on", + "OK", + 0, + {}, + "None.", + }}, + MessageEntry{"EventLogCleared", + { + "Indicates that the event log has been cleared.", + "Event Log Cleared.", + "OK", + 0, + {}, + "None.", + }}, + MessageEntry{"FanInserted", + { + "Indicates that a system fan has been inserted.", + "%1 inserted.", + "OK", + 1, + {"string"}, + "None.", }}, - MessageEntry{ - "EventLogCleared", - { - .description = "Indicates that the event log has been cleared.", - .message = "Event Log Cleared.", - .severity = "OK", - .numberOfArgs = 0, - .paramTypes = {}, - .resolution = "None.", - }}, - MessageEntry{ - "FanInserted", - { - .description = "Indicates that a system fan has been inserted.", - .message = "%1 inserted.", - .severity = "OK", - .numberOfArgs = 1, - .paramTypes = {"string"}, - .resolution = "None.", - }}, MessageEntry{"FanRedundancyLost", { - .description = - "Indicates that system fan redundancy has been lost.", - .message = "Fan redundancy lost.", - .severity = "Warning", - .numberOfArgs = 0, - .paramTypes = {}, - .resolution = "None.", + "Indicates that system fan redundancy has been lost.", + "Fan redundancy lost.", + "Warning", + 0, + {}, + "None.", + }}, + MessageEntry{"FanRedundancyRegained", + { + "Indicates that system fan redundancy has been regained.", + "Fan redundancy regained.", + "OK", + 0, + {}, + "None.", + }}, + MessageEntry{"FanRemoved", + { + "Indicates that a system fan has been removed.", + "%1 removed.", + "OK", + 1, + {"string"}, + "None.", + }}, + MessageEntry{"FirmwareUpdateCompleted", + { + "Indicates a firmware update has completed successfully.", + "%1 firmware update to version %2 completed " + "successfully.", + "OK", + 2, + {"string", "string"}, + "None.", }}, - MessageEntry{ - "FanRedundancyRegained", - { - .description = - "Indicates that system fan redundancy has been regained.", - .message = "Fan redundancy regained.", - .severity = "OK", - .numberOfArgs = 0, - .paramTypes = {}, - .resolution = "None.", - }}, - MessageEntry{ - "FanRemoved", - { - .description = "Indicates that a system fan has been removed.", - .message = "%1 removed.", - .severity = "OK", - .numberOfArgs = 1, - .paramTypes = {"string"}, - .resolution = "None.", - }}, - MessageEntry{ - "FirmwareUpdateCompleted", - { - .description = - "Indicates a firmware update has completed successfully.", - .message = "%1 firmware update to version %2 completed " - "successfully.", - .severity = "OK", - .numberOfArgs = 2, - .paramTypes = {"string", "string"}, - .resolution = "None.", - }}, MessageEntry{"FirmwareUpdateFailed", { - .description = "Indicates a firmware update has failed.", - .message = "%1 firmware update to version %2 failed.", - .severity = "Warning", - .numberOfArgs = 2, - .paramTypes = {"string", "string"}, - .resolution = "None.", + "Indicates a firmware update has failed.", + "%1 firmware update to version %2 failed.", + "Warning", + 2, + {"string", "string"}, + "None.", }}, MessageEntry{"FirmwareUpdateStarted", { - .description = "Indicates a firmware update has started.", - .message = "%1 firmware update to version %2 started.", - .severity = "OK", - .numberOfArgs = 2, - .paramTypes = {"string", "string"}, - .resolution = "None.", + "Indicates a firmware update has started.", + "%1 firmware update to version %2 started.", + "OK", + 2, + {"string", "string"}, + "None.", }}, MessageEntry{ "GeneralFirmwareSecurityViolation", { - .description = - "Indicates a general firmware security violation has occurred.", - .message = "Firmware security violation: %1.", - .severity = "Critical", - .numberOfArgs = 1, - .paramTypes = {"string"}, - .resolution = "None.", - }}, - MessageEntry{ - "InvalidLoginAttempted", - { - .description = - "Indicates that a login was attempted on the specified " - "interface with an invalid username or password.", - .message = "Invalid username or password attempted on %1.", - .severity = "Warning", - .numberOfArgs = 1, - .paramTypes = {"string"}, - .resolution = "None.", + "Indicates a general firmware security violation has occurred.", + "Firmware security violation: %1.", + "Critical", + 1, + {"string"}, + "None.", }}, + MessageEntry{"InvalidLoginAttempted", + { + "Indicates that a login was attempted on the specified " + "interface with an invalid username or password.", + "Invalid username or password attempted on %1.", + "Warning", + 1, + {"string"}, + "None.", + }}, MessageEntry{ "InventoryAdded", { - .description = - "Indicates that an inventory item with the specified model, " - "type, and serial number was installed.", - .message = "%1 %2 with serial number %3 was installed.", - .severity = "OK", - .numberOfArgs = 3, - .paramTypes = - { - "string", - "string", - "string", - }, - .resolution = "None.", + "Indicates that an inventory item with the specified model, " + "type, and serial number was installed.", + "%1 %2 with serial number %3 was installed.", + "OK", + 3, + + { + "string", + "string", + "string", + }, + "None.", }}, MessageEntry{ "InventoryRemoved", { - .description = - "Indicates that an inventory item with the specified model, " - "type, and serial number was removed.", - .message = "%1 %2 with serial number %3 was removed.", - .severity = "OK", - .numberOfArgs = 3, - .paramTypes = - { - "string", - "string", - "string", - }, - .resolution = "None.", + "Indicates that an inventory item with the specified model, " + "type, and serial number was removed.", + "%1 %2 with serial number %3 was removed.", + "OK", + 3, + + { + "string", + "string", + "string", + }, + "None.", }}, MessageEntry{ "IntelUPILinkWidthReducedToHalf", { - .description = - "Indicates Intel UPI link width has reduced to half width.", - .message = "Intel UPI link width reduced to half. Node=%1.", - .severity = "Warning", - .numberOfArgs = 1, - .paramTypes = - { - "number", - }, - .resolution = "None.", + "Indicates Intel UPI link width has reduced to half width.", + "Intel UPI link width reduced to half. Node=%1.", + "Warning", + 1, + + { + "number", + }, + "None.", }}, MessageEntry{ "IntelUPILinkWidthReducedToQuarter", { - .description = - "Indicates Intel UPI link width has reduced to quarter width.", - .message = "Intel UPI link width reduced to quarter. Node=%1.", - .severity = "Warning", - .numberOfArgs = 1, - .paramTypes = - { - "number", - }, - .resolution = "None.", - }}, + "Indicates Intel UPI link width has reduced to quarter width.", + "Intel UPI link width reduced to quarter. Node=%1.", + "Warning", + 1, - MessageEntry{ - "IPMIWatchdog", - { - .description = "Indicates that there is a host watchdog event.", - .message = "Host Watchdog Event: %1", - .severity = "OK", - .numberOfArgs = 1, - .paramTypes = - { - "string", - }, - .resolution = "None.", + { + "number", + }, + "None.", }}, - MessageEntry{ - "LegacyPCIPERR", - { - .description = "Indicates a Legacy PCI PERR.", - .message = "Legacy PCI PERR. Bus=%1 Device=%2 Function=%3.", - .severity = "Warning", - .numberOfArgs = 3, - .paramTypes = - { - "number", - "number", - "number", - }, - .resolution = "None.", - }}, - MessageEntry{ - "LegacyPCISERR", - { - .description = "Indicates a Legacy PCI SERR.", - .message = "Legacy PCI SERR. Bus=%1 Device=%2 Function=%3.", - .severity = "Critical", - .numberOfArgs = 3, - .paramTypes = - { - "number", - "number", - "number", - }, - .resolution = "None.", - }}, + MessageEntry{"IPMIWatchdog", + { + "Indicates that there is a host watchdog event.", + "Host Watchdog Event: %1", + "OK", + 1, + + { + "string", + }, + "None.", + }}, + + MessageEntry{"LegacyPCIPERR", + { + "Indicates a Legacy PCI PERR.", + "Legacy PCI PERR. Bus=%1 Device=%2 Function=%3.", + "Warning", + 3, + + { + "number", + "number", + "number", + }, + "None.", + }}, + MessageEntry{"LegacyPCISERR", + { + "Indicates a Legacy PCI SERR.", + "Legacy PCI SERR. Bus=%1 Device=%2 Function=%3.", + "Critical", + 3, + + { + "number", + "number", + "number", + }, + "None.", + }}, MessageEntry{"ManufacturingModeEntered", { - .description = "Indicates that Factory, Manufacturing, or " - "Test mode has been entered.", - .message = "Entered Manufacturing Mode.", - .severity = "Warning", - .numberOfArgs = 0, - .paramTypes = {}, - .resolution = "None.", + "Indicates that Factory, Manufacturing, or " + "Test mode has been entered.", + "Entered Manufacturing Mode.", + "Warning", + 0, + {}, + "None.", }}, MessageEntry{"MemoryECCCorrectable", { - .description = "Indicates a Correctable Memory ECC error.", - .message = "Memory ECC correctable error. Socket=%1 " - "Channel=%2 DIMM=%3 Rank=%4.", - .severity = "Warning", - .numberOfArgs = 4, - .paramTypes = - { - "number", - "string", - "number", - "number", - }, - .resolution = "None.", + "Indicates a Correctable Memory ECC error.", + "Memory ECC correctable error. Socket=%1 " + "Channel=%2 DIMM=%3 Rank=%4.", + "Warning", + 4, + + { + "number", + "string", + "number", + "number", + }, + "None.", + }}, + MessageEntry{"MemoryECCUncorrectable", + { + "Indicates an Uncorrectable Memory ECC error.", + "Memory ECC uncorrectable error. Socket=%1 Channel=%2 " + "DIMM=%3 Rank=%4.", + "Critical", + 4, + + { + "number", + "string", + "number", + "number", + }, + "None.", + }}, + MessageEntry{"MemoryParityCommandAndAddress", + { + "Indicates a Command and Address parity error.", + "Command and Address parity error. Socket=%1 Channel=%2 " + "DIMM=%3 ChannelValid=%4 DIMMValid=%5.", + "Critical", + 5, + + { + "number", + "string", + "number", + "number", + "number", + }, + "None.", }}, - MessageEntry{ - "MemoryECCUncorrectable", - { - .description = "Indicates an Uncorrectable Memory ECC error.", - .message = "Memory ECC uncorrectable error. Socket=%1 Channel=%2 " - "DIMM=%3 Rank=%4.", - .severity = "Critical", - .numberOfArgs = 4, - .paramTypes = - { - "number", - "string", - "number", - "number", - }, - .resolution = "None.", - }}, - MessageEntry{ - "MemoryParityCommandAndAddress", - { - .description = "Indicates a Command and Address parity error.", - .message = "Command and Address parity error. Socket=%1 Channel=%2 " - "DIMM=%3 ChannelValid=%4 DIMMValid=%5.", - .severity = "Critical", - .numberOfArgs = 5, - .paramTypes = - { - "number", - "string", - "number", - "number", - "number", - }, - .resolution = "None.", - }}, MessageEntry{"MemoryParityNotKnown", { - .description = "Indicates an unknown parity error.", - .message = "Memory parity error. Socket=%1 Channel=%2 " - "DIMM=%3 ChannelValid=%4 DIMMValid=%5.", - .severity = "Critical", - .numberOfArgs = 5, - .paramTypes = - { - "number", - "string", - "number", - "number", - "number", - }, - .resolution = "None.", + "Indicates an unknown parity error.", + "Memory parity error. Socket=%1 Channel=%2 " + "DIMM=%3 ChannelValid=%4 DIMMValid=%5.", + "Critical", + 5, + + { + "number", + "string", + "number", + "number", + "number", + }, + "None.", + }}, + MessageEntry{"MemoryRASConfigurationDisabled", + { + "Indicates Memory RAS Disabled Configuration Status.", + "Memory RAS Configuration Disabled. Error=%1 Mode=%2.", + "OK", + 2, + + { + "string", + "string", + }, + "None.", + }}, + MessageEntry{"MemoryRASConfigurationEnabled", + { + "Indicates Memory RAS Enabled Configuration Status.", + "Memory RAS Configuration Enabled. Error=%1 Mode=%2.", + "OK", + 2, + + { + "string", + "string", + }, + "None.", + }}, + MessageEntry{"MemoryRASModeDisabled", + { + "Indicates Memory RAS Disabled Mode Selection.", + "Memory RAS Mode Select Disabled. Prior Mode=%1 " + "Selected Mode=%2.", + "OK", + 2, + + { + "string", + "string", + }, + "None.", + }}, + MessageEntry{"MemoryRASModeEnabled", + { + "Indicates Memory RAS Enabled Mode Selection.", + "Memory RAS Mode Select Enabled. Prior Mode=%1 Selected " + "Mode=%2.", + "OK", + 2, + + { + "string", + "string", + }, + "None.", + }}, + MessageEntry{"MemoryThermTrip", + { + "Indicates that the system memory ThermTrip is asserted.", + "Memory ThermTrip asserted.", + "Critical", + 0, + {}, + "None.", + }}, + MessageEntry{"MirroringRedundancyDegraded", + { + "Indicates the mirroring redundancy state is degraded.", + "Mirroring redundancy state degraded. Socket=%1 " + "Channel=%2 DIMM=%3 Pair=%4 Rank=%5.", + "Warning", + 5, + + { + "number", + "string", + "number", + "number", + "number", + }, + "None.", }}, - MessageEntry{ - "MemoryRASConfigurationDisabled", - { - .description = - "Indicates Memory RAS Disabled Configuration Status.", - .message = "Memory RAS Configuration Disabled. Error=%1 Mode=%2.", - .severity = "OK", - .numberOfArgs = 2, - .paramTypes = - { - "string", - "string", - }, - .resolution = "None.", - }}, - MessageEntry{ - "MemoryRASConfigurationEnabled", - { - .description = "Indicates Memory RAS Enabled Configuration Status.", - .message = "Memory RAS Configuration Enabled. Error=%1 Mode=%2.", - .severity = "OK", - .numberOfArgs = 2, - .paramTypes = - { - "string", - "string", - }, - .resolution = "None.", - }}, - MessageEntry{ - "MemoryRASModeDisabled", - { - .description = "Indicates Memory RAS Disabled Mode Selection.", - .message = "Memory RAS Mode Select Disabled. Prior Mode=%1 " - "Selected Mode=%2.", - .severity = "OK", - .numberOfArgs = 2, - .paramTypes = - { - "string", - "string", - }, - .resolution = "None.", - }}, - MessageEntry{ - "MemoryRASModeEnabled", - { - .description = "Indicates Memory RAS Enabled Mode Selection.", - .message = "Memory RAS Mode Select Enabled. Prior Mode=%1 Selected " - "Mode=%2.", - .severity = "OK", - .numberOfArgs = 2, - .paramTypes = - { - "string", - "string", - }, - .resolution = "None.", - }}, - MessageEntry{ - "MemoryThermTrip", - { - .description = - "Indicates that the system memory ThermTrip is asserted.", - .message = "Memory ThermTrip asserted.", - .severity = "Critical", - .numberOfArgs = 0, - .paramTypes = {}, - .resolution = "None.", - }}, - MessageEntry{ - "MirroringRedundancyDegraded", - { - .description = - "Indicates the mirroring redundancy state is degraded.", - .message = "Mirroring redundancy state degraded. Socket=%1 " - "Channel=%2 DIMM=%3 Pair=%4 Rank=%5.", - .severity = "Warning", - .numberOfArgs = 5, - .paramTypes = - { - "number", - "string", - "number", - "number", - "number", - }, - .resolution = "None.", - }}, MessageEntry{ "MirroringRedundancyFull", { - .description = - "Indicates the mirroring redundancy state is fully redundant.", - .message = "Mirroring redundancy state fully redundant. Socket=%1 " - "Channel=%2 DIMM=%3 Pair=%4 Rank=%5.", - .severity = "OK", - .numberOfArgs = 5, - .paramTypes = - { - "number", - "string", - "number", - "number", - "number", - }, - .resolution = "None.", - }}, - MessageEntry{ - "NMIButtonPressed", - { - .description = "Indicates that the NMI button was pressed.", - .message = "NMI Button Pressed.", - .severity = "Critical", - .numberOfArgs = 0, - .paramTypes = {}, - .resolution = "None.", - }}, + "Indicates the mirroring redundancy state is fully redundant.", + "Mirroring redundancy state fully redundant. Socket=%1 " + "Channel=%2 DIMM=%3 Pair=%4 Rank=%5.", + "OK", + 5, + + { + "number", + "string", + "number", + "number", + "number", + }, + "None.", + }}, + MessageEntry{"NMIButtonPressed", + { + "Indicates that the NMI button was pressed.", + "NMI Button Pressed.", + "Critical", + 0, + {}, + "None.", + }}, MessageEntry{"NMIDiagnosticInterrupt", { - .description = "Indicates that an NMI Diagnostic " - "Interrupt has been generated.", - .message = "NMI Diagnostic Interrupt.", - .severity = "Critical", - .numberOfArgs = 0, - .paramTypes = {}, - .resolution = "None.", + "Indicates that an NMI Diagnostic " + "Interrupt has been generated.", + "NMI Diagnostic Interrupt.", + "Critical", + 0, + {}, + "None.", + }}, + MessageEntry{"PCIeCorrectableAdvisoryNonFatal", + { + "Indicates a PCIe Correctable Advisory Non-fatal Error.", + "PCIe Correctable Advisory Non-fatal Error. Bus=%1 " + "Device=%2 Function=%3.", + "Warning", + 3, + + { + "number", + "number", + "number", + }, + "None.", + }}, + MessageEntry{"PCIeCorrectableBadDLLP", + { + "Indicates a PCIe Correctable Bad DLLP Error.", + + "PCIe Correctable Bad DLLP. Bus=%1 Device=%2 Function=%3.", + "Warning", + 3, + + { + "number", + "number", + "number", + }, + "None.", + }}, + MessageEntry{"PCIeCorrectableBadTLP", + { + "Indicates a PCIe Correctable Bad TLP Error.", + + "PCIe Correctable Bad TLP. Bus=%1 Device=%2 Function=%3.", + "Warning", + 3, + + { + "number", + "number", + "number", + }, + "None.", + }}, + MessageEntry{"PCIeCorrectableHeaderLogOverflow", + { + "Indicates a PCIe Correctable Header Log Overflow Error.", + "PCIe Correctable Header Log Overflow. Bus=%1 Device=%2 " + "Function=%3.", + "Warning", + 3, + + { + "number", + "number", + "number", + }, + "None.", + }}, + MessageEntry{"PCIeCorrectableInternal", + { + "Indicates a PCIe Correctable Internal Error.", + "PCIe Correctable Internal Error. Bus=%1 Device=%2 " + "Function=%3.", + "Warning", + 3, + + { + "number", + "number", + "number", + }, + "None.", }}, - MessageEntry{ - "PCIeCorrectableAdvisoryNonFatal", - { - .description = - "Indicates a PCIe Correctable Advisory Non-fatal Error.", - .message = "PCIe Correctable Advisory Non-fatal Error. Bus=%1 " - "Device=%2 Function=%3.", - .severity = "Warning", - .numberOfArgs = 3, - .paramTypes = - { - "number", - "number", - "number", - }, - .resolution = "None.", - }}, - MessageEntry{ - "PCIeCorrectableBadDLLP", - { - .description = "Indicates a PCIe Correctable Bad DLLP Error.", - .message = - "PCIe Correctable Bad DLLP. Bus=%1 Device=%2 Function=%3.", - .severity = "Warning", - .numberOfArgs = 3, - .paramTypes = - { - "number", - "number", - "number", - }, - .resolution = "None.", - }}, - MessageEntry{ - "PCIeCorrectableBadTLP", - { - .description = "Indicates a PCIe Correctable Bad TLP Error.", - .message = - "PCIe Correctable Bad TLP. Bus=%1 Device=%2 Function=%3.", - .severity = "Warning", - .numberOfArgs = 3, - .paramTypes = - { - "number", - "number", - "number", - }, - .resolution = "None.", - }}, - MessageEntry{ - "PCIeCorrectableHeaderLogOverflow", - { - .description = - "Indicates a PCIe Correctable Header Log Overflow Error.", - .message = "PCIe Correctable Header Log Overflow. Bus=%1 Device=%2 " - "Function=%3.", - .severity = "Warning", - .numberOfArgs = 3, - .paramTypes = - { - "number", - "number", - "number", - }, - .resolution = "None.", - }}, - MessageEntry{ - "PCIeCorrectableInternal", - { - .description = "Indicates a PCIe Correctable Internal Error.", - .message = "PCIe Correctable Internal Error. Bus=%1 Device=%2 " - "Function=%3.", - .severity = "Warning", - .numberOfArgs = 3, - .paramTypes = - { - "number", - "number", - "number", - }, - .resolution = "None.", - }}, MessageEntry{"PCIeCorrectableLinkBWChanged", { - .description = - "Indicates a PCIe Correctable Link BW Changed Error.", - .message = "PCIe Correctable Link BW Changed. Bus=%1 " - "Device=%2 Function=%3.", - .severity = "Warning", - .numberOfArgs = 3, - .paramTypes = - { - "number", - "number", - "number", - }, - .resolution = "None.", + "Indicates a PCIe Correctable Link BW Changed Error.", + "PCIe Correctable Link BW Changed. Bus=%1 " + "Device=%2 Function=%3.", + "Warning", + 3, + + { + "number", + "number", + "number", + }, + "None.", + }}, + MessageEntry{"PCIeCorrectableReceiverError", + { + "Indicates a PCIe Correctable Receiver Error.", + "PCIe Correctable Receiver Error. Bus=%1 Device=%2 " + "Function=%3.", + "Warning", + 3, + + { + "number", + "number", + "number", + }, + "None.", + }}, + MessageEntry{"PCIeCorrectableReplayNumRollover", + { + "Indicates a PCIe Correctable Replay Num Rollover.", + "PCIe Correctable Replay Num Rollover. Bus=%1 Device=%2 " + "Function=%3.", + "Warning", + 3, + + { + "number", + "number", + "number", + }, + "None.", + }}, + MessageEntry{"PCIeCorrectableReplayTimerTimeout", + { + "Indicates a PCIe Correctable Replay Timer Timeout.", + "PCIe Correctable Replay Timer Timeout. Bus=%1 " + "Device=%2 Function=%3.", + "Warning", + 3, + + { + "number", + "number", + "number", + }, + "None.", }}, - MessageEntry{ - "PCIeCorrectableReceiverError", - { - .description = "Indicates a PCIe Correctable Receiver Error.", - .message = "PCIe Correctable Receiver Error. Bus=%1 Device=%2 " - "Function=%3.", - .severity = "Warning", - .numberOfArgs = 3, - .paramTypes = - { - "number", - "number", - "number", - }, - .resolution = "None.", - }}, - MessageEntry{ - "PCIeCorrectableReplayNumRollover", - { - .description = "Indicates a PCIe Correctable Replay Num Rollover.", - .message = "PCIe Correctable Replay Num Rollover. Bus=%1 Device=%2 " - "Function=%3.", - .severity = "Warning", - .numberOfArgs = 3, - .paramTypes = - { - "number", - "number", - "number", - }, - .resolution = "None.", - }}, - MessageEntry{ - "PCIeCorrectableReplayTimerTimeout", - { - .description = "Indicates a PCIe Correctable Replay Timer Timeout.", - .message = "PCIe Correctable Replay Timer Timeout. Bus=%1 " - "Device=%2 Function=%3.", - .severity = "Warning", - .numberOfArgs = 3, - .paramTypes = - { - "number", - "number", - "number", - }, - .resolution = "None.", - }}, MessageEntry{"PCIeCorrectableUnspecifiedAERError", { - .description = - "Indicates a PCIe Correctable Unspecified AER Error.", - .message = "PCIe Correctable Unspecified AER Error. " - "Bus=%1 Device=%2 Function=%3.", - .severity = "Warning", - .numberOfArgs = 3, - .paramTypes = - { - "number", - "number", - "number", - }, - .resolution = "None.", + "Indicates a PCIe Correctable Unspecified AER Error.", + "PCIe Correctable Unspecified AER Error. " + "Bus=%1 Device=%2 Function=%3.", + "Warning", + 3, + + { + "number", + "number", + "number", + }, + "None.", + }}, + MessageEntry{"PCIeFatalACSViolation", + { + "Indicates a PCIe ACS Violation Error.", + + "PCIe Fatal ACS Violation. Bus=%1 Device=%2 Function=%3.", + "Error", + 3, + + { + "number", + "number", + "number", + }, + "None.", + }}, + MessageEntry{"PCIeFatalAtomicEgressBlocked", + { + "Indicates a PCIe Atomic Egress Blocked Error.", + "PCIe Fatal Atomic Egress Blocked. Bus=%1 Device=%2 " + "Function=%3.", + "Error", + 3, + + { + "number", + "number", + "number", + }, + "None.", }}, - MessageEntry{ - "PCIeFatalACSViolation", - { - .description = "Indicates a PCIe ACS Violation Error.", - .message = - "PCIe Fatal ACS Violation. Bus=%1 Device=%2 Function=%3.", - .severity = "Error", - .numberOfArgs = 3, - .paramTypes = - { - "number", - "number", - "number", - }, - .resolution = "None.", - }}, - MessageEntry{ - "PCIeFatalAtomicEgressBlocked", - { - .description = "Indicates a PCIe Atomic Egress Blocked Error.", - .message = "PCIe Fatal Atomic Egress Blocked. Bus=%1 Device=%2 " - "Function=%3.", - .severity = "Error", - .numberOfArgs = 3, - .paramTypes = - { - "number", - "number", - "number", - }, - .resolution = "None.", - }}, MessageEntry{ "PCIeFatalCompleterAbort", { - .description = "Indicates a PCIe Completer Abort Error.", - .message = - "PCIe Fatal Completer Abort. Bus=%1 Device=%2 Function=%3.", - .severity = "Error", - .numberOfArgs = 3, - .paramTypes = - { - "number", - "number", - "number", - }, - .resolution = "None.", + "Indicates a PCIe Completer Abort Error.", + + "PCIe Fatal Completer Abort. Bus=%1 Device=%2 Function=%3.", + "Error", + 3, + + { + "number", + "number", + "number", + }, + "None.", }}, MessageEntry{ "PCIeFatalCompletionTimeout", { - .description = "Indicates a PCIe Completion Timeout Error.", - .message = - "PCIe Fatal Completion Timeout. Bus=%1 Device=%2 Function=%3.", - .severity = "Error", - .numberOfArgs = 3, - .paramTypes = - { - "number", - "number", - "number", - }, - .resolution = "None.", + "Indicates a PCIe Completion Timeout Error.", + + "PCIe Fatal Completion Timeout. Bus=%1 Device=%2 Function=%3.", + "Error", + 3, + + { + "number", + "number", + "number", + }, + "None.", }}, MessageEntry{ "PCIeFatalDataLinkLayerProtocol", { - .description = "Indicates a PCIe Data Link Layer Protocol Error.", - .message = - "PCIe Fatal Data Link Layer Protocol Error. Bus=%1 Device=%2 " - "Function=%3.", - .severity = "Error", - .numberOfArgs = 3, - .paramTypes = - { - "number", - "number", - "number", - }, - .resolution = "None.", - }}, - MessageEntry{ - "PCIeFatalECRCError", - { - .description = "Indicates a PCIe ECRC Error.", - .message = "PCIe Fatal ECRC Error. Bus=%1 Device=%2 Function=%3.", - .severity = "Error", - .numberOfArgs = 3, - .paramTypes = - { - "number", - "number", - "number", - }, - .resolution = "None.", - }}, - MessageEntry{ - "PCIeFatalFlowControlProtocol", - { - .description = "Indicates a PCIe Flow Control Protocol Error.", - .message = - "PCIe Fatal Flow Control Protocol Error. Bus=%1 Device=%2 " - "Function=%3.", - .severity = "Error", - .numberOfArgs = 3, - .paramTypes = - { - "number", - "number", - "number", - }, - .resolution = "None.", - }}, + "Indicates a PCIe Data Link Layer Protocol Error.", + + "PCIe Fatal Data Link Layer Protocol Error. Bus=%1 Device=%2 " + "Function=%3.", + "Error", + 3, + + { + "number", + "number", + "number", + }, + "None.", + }}, + MessageEntry{"PCIeFatalECRCError", + { + "Indicates a PCIe ECRC Error.", + "PCIe Fatal ECRC Error. Bus=%1 Device=%2 Function=%3.", + "Error", + 3, + + { + "number", + "number", + "number", + }, + "None.", + }}, + MessageEntry{"PCIeFatalFlowControlProtocol", + { + "Indicates a PCIe Flow Control Protocol Error.", + + "PCIe Fatal Flow Control Protocol Error. Bus=%1 Device=%2 " + "Function=%3.", + "Error", + 3, + + { + "number", + "number", + "number", + }, + "None.", + }}, MessageEntry{ "PCIeFatalMalformedTLP", { - .description = "Indicates a PCIe Malformed TLP Error.", - .message = - "PCIe Fatal Malformed TLP Error. Bus=%1 Device=%2 Function=%3.", - .severity = "Error", - .numberOfArgs = 3, - .paramTypes = - { - "number", - "number", - "number", - }, - .resolution = "None.", + "Indicates a PCIe Malformed TLP Error.", + + "PCIe Fatal Malformed TLP Error. Bus=%1 Device=%2 Function=%3.", + "Error", + 3, + + { + "number", + "number", + "number", + }, + "None.", }}, MessageEntry{"PCIeFatalMCBlockedTLP", { - .description = "Indicates a PCIe MC Blocked TLP Error.", - .message = "PCIe Fatal MC Blocked TLP Error. Bus=%1 " - "Device=%2 Function=%3.", - .severity = "Error", - .numberOfArgs = 3, - .paramTypes = - { - "number", - "number", - "number", - }, - .resolution = "None.", + "Indicates a PCIe MC Blocked TLP Error.", + "PCIe Fatal MC Blocked TLP Error. Bus=%1 " + "Device=%2 Function=%3.", + "Error", + 3, + + { + "number", + "number", + "number", + }, + "None.", }}, MessageEntry{ "PCIeFatalPoisonedTLP", { - .description = "Indicates a PCIe Poisoned TLP Error.", - .message = - "PCIe Fatal Poisoned TLP Error. Bus=%1 Device=%2 Function=%3.", - .severity = "Error", - .numberOfArgs = 3, - .paramTypes = - { - "number", - "number", - "number", - }, - .resolution = "None.", - }}, - MessageEntry{ - "PCIeFatalReceiverBufferOverflow", - { - .description = "Indicates a PCIe Receiver Buffer Overflow Error.", - .message = "PCIe Fatal Receiver Buffer Overflow. Bus=%1 Device=%2 " - "Function=%3.", - .severity = "Error", - .numberOfArgs = 3, - .paramTypes = - { - "number", - "number", - "number", - }, - .resolution = "None.", - }}, + "Indicates a PCIe Poisoned TLP Error.", + + "PCIe Fatal Poisoned TLP Error. Bus=%1 Device=%2 Function=%3.", + "Error", + 3, + + { + "number", + "number", + "number", + }, + "None.", + }}, + MessageEntry{"PCIeFatalReceiverBufferOverflow", + { + "Indicates a PCIe Receiver Buffer Overflow Error.", + "PCIe Fatal Receiver Buffer Overflow. Bus=%1 Device=%2 " + "Function=%3.", + "Error", + 3, + + { + "number", + "number", + "number", + }, + "None.", + }}, MessageEntry{ "PCIeFatalReceivedErrNonFatalMessage", { - .description = - "Indicates a PCIe Received ERR_NONFATAL Message Error.", - .message = - "PCIe Fatal Received ERR_NONFATAL Message. Bus=%1 Device=%2 " - "Function=%3.", - .severity = "Error", - .numberOfArgs = 3, - .paramTypes = - { - "number", - "number", - "number", - }, - .resolution = "None.", + "Indicates a PCIe Received ERR_NONFATAL Message Error.", + + "PCIe Fatal Received ERR_NONFATAL Message. Bus=%1 Device=%2 " + "Function=%3.", + "Error", + 3, + + { + "number", + "number", + "number", + }, + "None.", }}, MessageEntry{"PCIeFatalReceivedFatalMessageFromDownstream", { - .description = "Indicates a PCIe Received Fatal Message " - "From Downstream Error.", - .message = - "PCIe Fatal Received Fatal Message From Downstream. " - "Bus=%1 Device=%2 Function=%3.", - .severity = "Error", - .numberOfArgs = 3, - .paramTypes = - { - "number", - "number", - "number", - }, - .resolution = "None.", + "Indicates a PCIe Received Fatal Message " + "From Downstream Error.", + + "PCIe Fatal Received Fatal Message From Downstream. " + "Bus=%1 Device=%2 Function=%3.", + "Error", + 3, + + { + "number", + "number", + "number", + }, + "None.", + }}, + MessageEntry{"PCIeFatalSurpriseLinkDown", + { + "Indicates a PCIe Surprise Link Down Error.", + "PCIe Fatal Surprise Link Down Error. Bus=%1 Device=%2 " + "Function=%3.", + "Error", + 3, + + { + "number", + "number", + "number", + }, + "None.", + }}, + MessageEntry{"PCIeFatalTLPPrefixBlocked", + { + "Indicates a PCIe TLP Prefix Blocked Error.", + "PCIe Fatal TLP Prefix Blocked Error. Bus=%1 Device=%2 " + "Function=%3.", + "Error", + 3, + + { + "number", + "number", + "number", + }, + "None.", }}, - MessageEntry{ - "PCIeFatalSurpriseLinkDown", - { - .description = "Indicates a PCIe Surprise Link Down Error.", - .message = "PCIe Fatal Surprise Link Down Error. Bus=%1 Device=%2 " - "Function=%3.", - .severity = "Error", - .numberOfArgs = 3, - .paramTypes = - { - "number", - "number", - "number", - }, - .resolution = "None.", - }}, - MessageEntry{ - "PCIeFatalTLPPrefixBlocked", - { - .description = "Indicates a PCIe TLP Prefix Blocked Error.", - .message = "PCIe Fatal TLP Prefix Blocked Error. Bus=%1 Device=%2 " - "Function=%3.", - .severity = "Error", - .numberOfArgs = 3, - .paramTypes = - { - "number", - "number", - "number", - }, - .resolution = "None.", - }}, MessageEntry{ "PCIeFatalUncorrectableInternal", { - .description = "Indicates a PCIe Uncorrectable Internal Error.", - .message = - "PCIe Fatal Uncorrectable Internal Error. Bus=%1 Device=%2 " - "Function=%3.", - .severity = "Error", - .numberOfArgs = 3, - .paramTypes = - { - "number", - "number", - "number", - }, - .resolution = "None.", - }}, - MessageEntry{ - "PCIeFatalUnexpectedCompletion", - { - .description = "Indicates a PCIe Unexpected Completion Error.", - .message = "PCIe Fatal Unexpected Completion. Bus=%1 Device=%2 " - "Function=%3.", - .severity = "Error", - .numberOfArgs = 3, - .paramTypes = - { - "number", - "number", - "number", - }, - .resolution = "None.", - }}, - MessageEntry{ - "PCIeFatalUnspecifiedNonAERFatalError", - { - .description = "Indicates a PCIe Unspecified Non-AER Fatal Error.", - .message = "PCIe Fatal Unspecified Non-AER Fatal Error. Bus=%1 " - "Device=%2 Function=%3.", - .severity = "Error", - .numberOfArgs = 3, - .paramTypes = - { - "number", - "number", - "number", - }, - .resolution = "None.", - }}, + "Indicates a PCIe Uncorrectable Internal Error.", + + "PCIe Fatal Uncorrectable Internal Error. Bus=%1 Device=%2 " + "Function=%3.", + "Error", + 3, + + { + "number", + "number", + "number", + }, + "None.", + }}, + MessageEntry{"PCIeFatalUnexpectedCompletion", + { + "Indicates a PCIe Unexpected Completion Error.", + "PCIe Fatal Unexpected Completion. Bus=%1 Device=%2 " + "Function=%3.", + "Error", + 3, + + { + "number", + "number", + "number", + }, + "None.", + }}, + MessageEntry{"PCIeFatalUnspecifiedNonAERFatalError", + { + "Indicates a PCIe Unspecified Non-AER Fatal Error.", + "PCIe Fatal Unspecified Non-AER Fatal Error. Bus=%1 " + "Device=%2 Function=%3.", + "Error", + 3, + + { + "number", + "number", + "number", + }, + "None.", + }}, MessageEntry{ "PCIeFatalUnsupportedRequest", { - .description = "Indicates a PCIe Unsupported Request Error.", - .message = - "PCIe Fatal Unsupported Request. Bus=%1 Device=%2 Function=%3.", - .severity = "Error", - .numberOfArgs = 3, - .paramTypes = - { - "number", - "number", - "number", - }, - .resolution = "None.", + "Indicates a PCIe Unsupported Request Error.", + + "PCIe Fatal Unsupported Request. Bus=%1 Device=%2 Function=%3.", + "Error", + 3, + + { + "number", + "number", + "number", + }, + "None.", }}, MessageEntry{"ChassisIntrusionDetected", { - .description = "Indicates that a physical security event " - "of the chassis intrusion has occurred.", - .message = "Chassis Intrusion Detected.", - .severity = "Warning", - .numberOfArgs = 0, - .paramTypes = {}, - .resolution = "None.", + "Indicates that a physical security event " + "of the chassis intrusion has occurred.", + "Chassis Intrusion Detected.", + "Warning", + 0, + {}, + "None.", + }}, + MessageEntry{"ChassisIntrusionReset", + { + "Indicates that chassis intrusion status has recovered.", + "Chassis Intrusion Reset.", + "OK", + 0, + {}, + "None.", }}, - MessageEntry{ - "ChassisIntrusionReset", - { - .description = - "Indicates that chassis intrusion status has recovered.", - .message = "Chassis Intrusion Reset.", - .severity = "OK", - .numberOfArgs = 0, - .paramTypes = {}, - .resolution = "None.", - }}, MessageEntry{"LanLost", { - .description = "Indicates that a physical security event " - "of the LAN leash has lost.", - .message = "%1 LAN leash lost.", - .severity = "Warning", - .numberOfArgs = 1, - .paramTypes = - { - "string", - }, - .resolution = "None.", + "Indicates that a physical security event " + "of the LAN leash has lost.", + "%1 LAN leash lost.", + "Warning", + 1, + + { + "string", + }, + "None.", + }}, + MessageEntry{"LanRegained", + { + "Indicates that LAN link status has reconnected.", + "%1 LAN leash regained.", + "OK", + 1, + + { + "string", + }, + "None.", + }}, + MessageEntry{"PowerButtonPressed", + { + "Indicates that the power button was pressed.", + "Power Button Pressed.", + "OK", + 0, + {}, + "None.", }}, - MessageEntry{ - "LanRegained", - { - .description = "Indicates that LAN link status has reconnected.", - .message = "%1 LAN leash regained.", - .severity = "OK", - .numberOfArgs = 1, - .paramTypes = - { - "string", - }, - .resolution = "None.", - }}, - MessageEntry{ - "PowerButtonPressed", - { - .description = "Indicates that the power button was pressed.", - .message = "Power Button Pressed.", - .severity = "OK", - .numberOfArgs = 0, - .paramTypes = {}, - .resolution = "None.", - }}, MessageEntry{"PowerRestorePolicyApplied", { - .description = "Indicates that power was restored and the " - "BMC has applied the restore policy.", - .message = "Power restore policy applied.", - .severity = "OK", - .numberOfArgs = 0, - .paramTypes = {}, - .resolution = "None.", + "Indicates that power was restored and the " + "BMC has applied the restore policy.", + "Power restore policy applied.", + "OK", + 0, + {}, + "None.", + }}, + MessageEntry{"PowerSupplyConfigurationError", + { + "Indicates an error in power supply configuration.", + "Power supply %1 configuration error.", + "Critical", + 1, + {"string"}, + "None.", }}, - MessageEntry{ - "PowerSupplyConfigurationError", - { - .description = "Indicates an error in power supply configuration.", - .message = "Power supply %1 configuration error.", - .severity = "Critical", - .numberOfArgs = 1, - .paramTypes = {"string"}, - .resolution = "None.", - }}, MessageEntry{ "PowerSupplyFanFailed", { - .description = - "Indicates that the specified power supply fan has failed.", - .message = "Power supply %1 fan %2 failed.", - .severity = "Critical", - .numberOfArgs = 2, - .paramTypes = {"string", "string"}, - .resolution = "None.", + "Indicates that the specified power supply fan has failed.", + "Power supply %1 fan %2 failed.", + "Critical", + 2, + {"string", "string"}, + "None.", }}, MessageEntry{ "PowerSupplyFanRecovered", { - .description = - "Indicates that the power supply fan recovered from a failure.", - .message = "Power supply %1 fan %2 recovered.", - .severity = "OK", - .numberOfArgs = 2, - .paramTypes = {"string", "string"}, - .resolution = "None.", + "Indicates that the power supply fan recovered from a failure.", + "Power supply %1 fan %2 recovered.", + "OK", + 2, + {"string", "string"}, + "None.", }}, MessageEntry{"PowerSupplyFailed", { - .description = "Indicates that a power supply has failed.", - .message = "Power supply %1 failed.", - .severity = "Critical", - .numberOfArgs = 1, - .paramTypes = {"string"}, - .resolution = "None.", + "Indicates that a power supply has failed.", + "Power supply %1 failed.", + "Critical", + 1, + {"string"}, + "None.", }}, MessageEntry{"PowerSupplyFailurePredicted", { - .description = - "Indicates that a power supply is predicted to fail.", - .message = "Power supply %1 failure predicted.", - .severity = "Warning", - .numberOfArgs = 1, - .paramTypes = {"string"}, - .resolution = "None.", + "Indicates that a power supply is predicted to fail.", + "Power supply %1 failure predicted.", + "Warning", + 1, + {"string"}, + "None.", + }}, + MessageEntry{"PowerSupplyInserted", + { + "Indicates that a power supply has been inserted.", + "Power supply %1 inserted.", + "OK", + 1, + {"string"}, + "None.", + }}, + MessageEntry{"PowerSupplyPowerGoodFailed", + { + "Indicates that the power supply power good signal " + "failed to assert within the specified time.", + "Power supply power good failed to assert within %1 " + "milliseconds.", + "Critical", + 1, + {"number"}, + "None.", }}, - MessageEntry{ - "PowerSupplyInserted", - { - .description = "Indicates that a power supply has been inserted.", - .message = "Power supply %1 inserted.", - .severity = "OK", - .numberOfArgs = 1, - .paramTypes = {"string"}, - .resolution = "None.", - }}, - MessageEntry{ - "PowerSupplyPowerGoodFailed", - { - .description = "Indicates that the power supply power good signal " - "failed to assert within the specified time.", - .message = "Power supply power good failed to assert within %1 " - "milliseconds.", - .severity = "Critical", - .numberOfArgs = 1, - .paramTypes = {"number"}, - .resolution = "None.", - }}, MessageEntry{"PowerSupplyPowerLost", { - .description = - "Indicates that a power supply has lost input power.", - .message = "Power supply %1 power lost.", - .severity = "Critical", - .numberOfArgs = 1, - .paramTypes = {"string"}, - .resolution = "None.", + "Indicates that a power supply has lost input power.", + "Power supply %1 power lost.", + "Critical", + 1, + {"string"}, + "None.", + }}, + MessageEntry{"PowerSupplyPowerRestored", + { + "Indicates that a power supply input power was restored.", + "Power supply %1 power restored.", + "OK", + 1, + {"string"}, + "None.", }}, - MessageEntry{ - "PowerSupplyPowerRestored", - { - .description = - "Indicates that a power supply input power was restored.", - .message = "Power supply %1 power restored.", - .severity = "OK", - .numberOfArgs = 1, - .paramTypes = {"string"}, - .resolution = "None.", - }}, MessageEntry{"PowerSupplyPredictedFailureRecovered", { - .description = "Indicates that a power supply recovered " - "from a predicted failure.", - .message = "Power supply %1 predicted failure recovered.", - .severity = "OK", - .numberOfArgs = 1, - .paramTypes = {"string"}, - .resolution = "None.", + "Indicates that a power supply recovered " + "from a predicted failure.", + "Power supply %1 predicted failure recovered.", + "OK", + 1, + {"string"}, + "None.", + }}, + MessageEntry{"PowerSupplyRecovered", + { + "Indicates that a power supply recovered from a failure.", + "Power supply %1 recovered.", + "OK", + 1, + {"string"}, + "None.", + }}, + MessageEntry{"PowerSupplyRemoved", + { + "Indicates that a power supply has been removed.", + "Power supply %1 removed.", + "Warning", + 1, + {"string"}, + "None.", + }}, + MessageEntry{"PowerUnitDegradedFromNonRedundant", + { + "Indicates that power unit is come back to redundant from" + "nonredundant but is still not in full redundancy mode.", + "Power Unit degraded from nonredundant.", + "Warning", + 0, + {}, + "None.", }}, - MessageEntry{ - "PowerSupplyRecovered", - { - .description = - "Indicates that a power supply recovered from a failure.", - .message = "Power supply %1 recovered.", - .severity = "OK", - .numberOfArgs = 1, - .paramTypes = {"string"}, - .resolution = "None.", - }}, - MessageEntry{ - "PowerSupplyRemoved", - { - .description = "Indicates that a power supply has been removed.", - .message = "Power supply %1 removed.", - .severity = "Warning", - .numberOfArgs = 1, - .paramTypes = {"string"}, - .resolution = "None.", - }}, - MessageEntry{ - "PowerUnitDegradedFromNonRedundant", - { - .description = - "Indicates that power unit is come back to redundant from" - "nonredundant but is still not in full redundancy mode.", - .message = "Power Unit degraded from nonredundant.", - .severity = "Warning", - .numberOfArgs = 0, - .paramTypes = {}, - .resolution = "None.", - }}, MessageEntry{"PowerUnitDegradedFromRedundant", { - .description = - "Indicates that power unit is degarded from full " - "redundancy mode.", - .message = "Power Unit degraded from redundant.", - .severity = "Warning", - .numberOfArgs = 0, - .paramTypes = {}, - .resolution = "None.", + "Indicates that power unit is degarded from full " + "redundancy mode.", + "Power Unit degraded from redundant.", + "Warning", + 0, + {}, + "None.", + }}, + MessageEntry{"PowerUnitRedundancyDegraded", + { + "Indicates that power unit redundancy has been degraded.", + "Power Unit Redundancy degraded.", + "Warning", + 0, + {}, + "None.", }}, - MessageEntry{ - "PowerUnitRedundancyDegraded", - { - .description = - "Indicates that power unit redundancy has been degraded.", - .message = "Power Unit Redundancy degraded.", - .severity = "Warning", - .numberOfArgs = 0, - .paramTypes = {}, - .resolution = "None.", - }}, MessageEntry{ "PowerUnitNonRedundantFromInsufficient", { - .description = - "Indicates that power unit is not in redundancy mode and get" - "sufficient power to support redundancy from insufficient" - "power.", - .message = - "Power Unit NonRedundant from insufficient to sufficient.", - .severity = "Warning", - .numberOfArgs = 0, - .paramTypes = {}, - .resolution = "None.", - }}, - MessageEntry{ - "PowerUnitNonRedundantInsufficient", - { - .description = "Indicates that power unit do not have sufficient " - "power to support redundancy.", - .message = "Power Unit NonRedundant and has insufficient resource.", - .severity = "Error", - .numberOfArgs = 0, - .paramTypes = {}, - .resolution = "None.", + "Indicates that power unit is not in redundancy mode and get" + "sufficient power to support redundancy from insufficient" + "power.", + + "Power Unit NonRedundant from insufficient to sufficient.", + "Warning", + 0, + {}, + "None.", }}, + MessageEntry{"PowerUnitNonRedundantInsufficient", + { + "Indicates that power unit do not have sufficient " + "power to support redundancy.", + "Power Unit NonRedundant and has insufficient resource.", + "Error", + 0, + {}, + "None.", + }}, MessageEntry{"PowerUnitRedundancyLost", { - .description = - "Indicates that power unit redundancy has been lost.", - .message = "Power Unit Redundancy lost.", - .severity = "Warning", - .numberOfArgs = 0, - .paramTypes = {}, - .resolution = "None.", + "Indicates that power unit redundancy has been lost.", + "Power Unit Redundancy lost.", + "Warning", + 0, + {}, + "None.", }}, MessageEntry{ "PowerUnitRedundancyRegained", { - .description = - "Indicates that power unit full redundancy has been regained.", - .message = "Power Unit Redundancy regained.", - .severity = "OK", - .numberOfArgs = 0, - .paramTypes = {}, - .resolution = "None.", + "Indicates that power unit full redundancy has been regained.", + "Power Unit Redundancy regained.", + "OK", + 0, + {}, + "None.", }}, MessageEntry{ "PowerUnitNonRedundantSufficient", { - .description = - "Indicates that power unit is not in redundancy mode but still" - "has sufficient power to support redundancy.", - .message = "Power Unit Nonredundant but has sufficient resource.", - .severity = "Warning", - .numberOfArgs = 0, - .paramTypes = {}, - .resolution = "None.", - }}, - MessageEntry{ - "ResetButtonPressed", - { - .description = "Indicates that the reset button was pressed.", - .message = "Reset Button Pressed.", - .severity = "OK", - .numberOfArgs = 0, - .paramTypes = {}, - .resolution = "None.", + "Indicates that power unit is not in redundancy mode but still" + "has sufficient power to support redundancy.", + "Power Unit Nonredundant but has sufficient resource.", + "Warning", + 0, + {}, + "None.", }}, + MessageEntry{"ResetButtonPressed", + { + "Indicates that the reset button was pressed.", + "Reset Button Pressed.", + "OK", + 0, + {}, + "None.", + }}, MessageEntry{"SELEntryAdded", { - .description = "Indicates a SEL entry was added using the " - "Add SEL Entry or Platform Event command.", - .message = "SEL Entry Added: %1", - .severity = "OK", - .numberOfArgs = 1, - .paramTypes = - { - "string", - }, - .resolution = "None.", + "Indicates a SEL entry was added using the " + "Add SEL Entry or Platform Event command.", + "SEL Entry Added: %1", + "OK", + 1, + + { + "string", + }, + "None.", + }}, + MessageEntry{"SensorThresholdCriticalHighGoingHigh", + { + "Indicates that a threshold sensor has crossed a " + "critical high threshold going high.", + "%1 sensor crossed a critical high threshold going " + "high. Reading=%2 Threshold=%3.", + "Critical", + 3, + {"string", "number", "number"}, + "Check the sensor or subsystem for errors.", + }}, + MessageEntry{"SensorThresholdCriticalHighGoingLow", + { + "Indicates that a threshold sensor has crossed a " + "critical high threshold going low.", + "%1 sensor crossed a critical high threshold going low. " + "Reading=%2 Threshold=%3.", + "OK", + 3, + {"string", "number", "number"}, + "None.", + }}, + MessageEntry{"SensorThresholdCriticalLowGoingHigh", + { + "Indicates that a threshold sensor has crossed a " + "critical low threshold going high.", + "%1 sensor crossed a critical low threshold going high. " + "Reading=%2 Threshold=%3.", + "OK", + 3, + {"string", "number", "number"}, + "None.", + }}, + MessageEntry{"SensorThresholdCriticalLowGoingLow", + { + "Indicates that a threshold sensor has crossed a " + "critical low threshold going low.", + "%1 sensor crossed a critical low threshold going low. " + "Reading=%2 Threshold=%3.", + "Critical", + 3, + {"string", "number", "number"}, + "Check the sensor or subsystem for errors.", + }}, + MessageEntry{"SensorThresholdWarningHighGoingHigh", + { + "Indicates that a threshold sensor has crossed a " + "warning high threshold going high.", + "%1 sensor crossed a warning high threshold going high. " + "Reading=%2 Threshold=%3.", + "Warning", + 3, + {"string", "number", "number"}, + "Check the sensor or subsystem for errors.", + }}, + MessageEntry{"SensorThresholdWarningHighGoingLow", + { + "Indicates that a threshold sensor has crossed a " + "warning high threshold going low.", + "%1 sensor crossed a warning high threshold going low. " + "Reading=%2 Threshold=%3.", + "OK", + 3, + {"string", "number", "number"}, + "None.", + }}, + MessageEntry{"SensorThresholdWarningLowGoingHigh", + { + "Indicates that a threshold sensor has crossed a " + "warning low threshold going high.", + "%1 sensor crossed a warning low threshold going high. " + "Reading=%2 Threshold=%3.", + "OK", + 3, + {"string", "number", "number"}, + "None.", + }}, + MessageEntry{"SensorThresholdWarningLowGoingLow", + { + "Indicates that a threshold sensor has crossed a " + "warning low threshold going low.", + "%1 sensor crossed a warning low threshold going low. " + "Reading=%2 Threshold=%3.", + "Warning", + 3, + {"string", "number", "number"}, + "Check the sensor or subsystem for errors.", }}, - MessageEntry{ - "SensorThresholdCriticalHighGoingHigh", - { - .description = "Indicates that a threshold sensor has crossed a " - "critical high threshold going high.", - .message = "%1 sensor crossed a critical high threshold going " - "high. Reading=%2 Threshold=%3.", - .severity = "Critical", - .numberOfArgs = 3, - .paramTypes = {"string", "number", "number"}, - .resolution = "Check the sensor or subsystem for errors.", - }}, - MessageEntry{ - "SensorThresholdCriticalHighGoingLow", - { - .description = "Indicates that a threshold sensor has crossed a " - "critical high threshold going low.", - .message = "%1 sensor crossed a critical high threshold going low. " - "Reading=%2 Threshold=%3.", - .severity = "OK", - .numberOfArgs = 3, - .paramTypes = {"string", "number", "number"}, - .resolution = "None.", - }}, - MessageEntry{ - "SensorThresholdCriticalLowGoingHigh", - { - .description = "Indicates that a threshold sensor has crossed a " - "critical low threshold going high.", - .message = "%1 sensor crossed a critical low threshold going high. " - "Reading=%2 Threshold=%3.", - .severity = "OK", - .numberOfArgs = 3, - .paramTypes = {"string", "number", "number"}, - .resolution = "None.", - }}, - MessageEntry{ - "SensorThresholdCriticalLowGoingLow", - { - .description = "Indicates that a threshold sensor has crossed a " - "critical low threshold going low.", - .message = "%1 sensor crossed a critical low threshold going low. " - "Reading=%2 Threshold=%3.", - .severity = "Critical", - .numberOfArgs = 3, - .paramTypes = {"string", "number", "number"}, - .resolution = "Check the sensor or subsystem for errors.", - }}, - MessageEntry{ - "SensorThresholdWarningHighGoingHigh", - { - .description = "Indicates that a threshold sensor has crossed a " - "warning high threshold going high.", - .message = "%1 sensor crossed a warning high threshold going high. " - "Reading=%2 Threshold=%3.", - .severity = "Warning", - .numberOfArgs = 3, - .paramTypes = {"string", "number", "number"}, - .resolution = "Check the sensor or subsystem for errors.", - }}, - MessageEntry{ - "SensorThresholdWarningHighGoingLow", - { - .description = "Indicates that a threshold sensor has crossed a " - "warning high threshold going low.", - .message = "%1 sensor crossed a warning high threshold going low. " - "Reading=%2 Threshold=%3.", - .severity = "OK", - .numberOfArgs = 3, - .paramTypes = {"string", "number", "number"}, - .resolution = "None.", - }}, - MessageEntry{ - "SensorThresholdWarningLowGoingHigh", - { - .description = "Indicates that a threshold sensor has crossed a " - "warning low threshold going high.", - .message = "%1 sensor crossed a warning low threshold going high. " - "Reading=%2 Threshold=%3.", - .severity = "OK", - .numberOfArgs = 3, - .paramTypes = {"string", "number", "number"}, - .resolution = "None.", - }}, - MessageEntry{ - "SensorThresholdWarningLowGoingLow", - { - .description = "Indicates that a threshold sensor has crossed a " - "warning low threshold going low.", - .message = "%1 sensor crossed a warning low threshold going low. " - "Reading=%2 Threshold=%3.", - .severity = "Warning", - .numberOfArgs = 3, - .paramTypes = {"string", "number", "number"}, - .resolution = "Check the sensor or subsystem for errors.", - }}, MessageEntry{"ServiceFailure", { - .description = - "Indicates that a service has exited unsuccessfully.", - .message = "Service %1 has exited unsuccessfully.", - .severity = "Warning", - .numberOfArgs = 1, - .paramTypes = {"string"}, - .resolution = "None.", + "Indicates that a service has exited unsuccessfully.", + "Service %1 has exited unsuccessfully.", + "Warning", + 1, + {"string"}, + "None.", }}, MessageEntry{"SparingRedundancyDegraded", { - .description = - "Indicates the sparing redundancy state is degraded.", - .message = "Sparing redundancy state degraded. Socket=%1 " - "Channel=%2 DIMM=%3 Domain=%4 Rank=%5.", - .severity = "Warning", - .numberOfArgs = 5, - .paramTypes = - { - "number", - "string", - "number", - "string", - "number", - }, - .resolution = "None.", + "Indicates the sparing redundancy state is degraded.", + "Sparing redundancy state degraded. Socket=%1 " + "Channel=%2 DIMM=%3 Domain=%4 Rank=%5.", + "Warning", + 5, + + { + "number", + "string", + "number", + "string", + "number", + }, + "None.", }}, MessageEntry{ "SparingRedundancyFull", { - .description = - "Indicates the sparing redundancy state is fully redundant.", - .message = "Sparing redundancy state fully redundant. Socket=%1 " - "Channel=%2 DIMM=%3 Domain=%4 Rank=%5.", - .severity = "OK", - .numberOfArgs = 5, - .paramTypes = - { - "number", - "string", - "number", - "string", - "number", - }, - .resolution = "None.", - }}, - MessageEntry{ - "SsbThermalTrip", - { - .description = - "Indicates that an SSB Thermal trip has been asserted.", - .message = "SSB Thermal trip.", - .severity = "Critical", - .numberOfArgs = 0, - .paramTypes = {}, - .resolution = "None.", - }}, + "Indicates the sparing redundancy state is fully redundant.", + "Sparing redundancy state fully redundant. Socket=%1 " + "Channel=%2 DIMM=%3 Domain=%4 Rank=%5.", + "OK", + 5, + + { + "number", + "string", + "number", + "string", + "number", + }, + "None.", + }}, + MessageEntry{"SsbThermalTrip", + { + "Indicates that an SSB Thermal trip has been asserted.", + "SSB Thermal trip.", + "Critical", + 0, + {}, + "None.", + }}, MessageEntry{"SystemPowerGoodFailed", { - .description = - "Indicates that the system power good signal failed " - "to assert within the specified time (VR failure).", - .message = "System power good failed to assert within %1 " - "milliseconds (VR failure).", - .severity = "Critical", - .numberOfArgs = 1, - .paramTypes = {"number"}, - .resolution = "None.", + "Indicates that the system power good signal failed " + "to assert within the specified time (VR failure).", + "System power good failed to assert within %1 " + "milliseconds (VR failure).", + "Critical", + 1, + {"number"}, + "None.", }}, MessageEntry{"SystemPowerLost", { - .description = "Indicates that power was lost while the " - "system was powered on.", - .message = "System Power Lost.", - .severity = "Critical", - .numberOfArgs = 0, - .paramTypes = {}, - .resolution = "None.", + "Indicates that power was lost while the " + "system was powered on.", + "System Power Lost.", + "Critical", + 0, + {}, + "None.", + }}, + MessageEntry{"SystemPowerOffFailed", + { + "Indicates that the system failed to power off.", + "System Power-Off Failed.", + "Critical", + 0, + {}, + "None.", + }}, + MessageEntry{"SystemPowerOnFailed", + { + "Indicates that the system failed to power on.", + "System Power-On Failed.", + "Critical", + 0, + {}, + "None.", }}, - MessageEntry{ - "SystemPowerOffFailed", - { - .description = "Indicates that the system failed to power off.", - .message = "System Power-Off Failed.", - .severity = "Critical", - .numberOfArgs = 0, - .paramTypes = {}, - .resolution = "None.", - }}, - MessageEntry{ - "SystemPowerOnFailed", - { - .description = "Indicates that the system failed to power on.", - .message = "System Power-On Failed.", - .severity = "Critical", - .numberOfArgs = 0, - .paramTypes = {}, - .resolution = "None.", - }}, MessageEntry{ "VoltageRegulatorOverheated", { - .description = - "Indicates that the specified voltage regulator overheated.", - .message = "%1 Voltage Regulator Overheated.", - .severity = "Critical", - .numberOfArgs = 1, - .paramTypes = {"string"}, - .resolution = "None.", + "Indicates that the specified voltage regulator overheated.", + "%1 Voltage Regulator Overheated.", + "Critical", + 1, + {"string"}, + "None.", }}, }; } // namespace redfish::message_registries::openbmc diff --git a/redfish-core/include/utils/json_utils.hpp b/redfish-core/include/utils/json_utils.hpp index c36ad3c..cf3227a 100644 --- a/redfish-core/include/utils/json_utils.hpp +++ b/redfish-core/include/utils/json_utils.hpp @@ -139,6 +139,10 @@ bool unpackValue(nlohmann::json& jsonValue, const std::string& key, else if constexpr (std::is_signed_v<Type>) { int64_t* jsonPtr = jsonValue.get_ptr<int64_t*>(); + if (jsonPtr == nullptr) + { + return false; + } if (!checkRange<Type>(*jsonPtr, key, jsonValue, res)) { return false; @@ -150,6 +154,10 @@ bool unpackValue(nlohmann::json& jsonValue, const std::string& key, !std::is_same_v<bool, Type>)) { uint64_t* jsonPtr = jsonValue.get_ptr<uint64_t*>(); + if (jsonPtr == nullptr) + { + return false; + } if (!checkRange<Type>(*jsonPtr, key, jsonValue, res)) { return false; diff --git a/redfish-core/include/utils/systemd_utils.hpp b/redfish-core/include/utils/systemd_utils.hpp index 1c34fca..da1b4e2 100644 --- a/redfish-core/include/utils/systemd_utils.hpp +++ b/redfish-core/include/utils/systemd_utils.hpp @@ -33,9 +33,9 @@ const std::string getUuid() { std::string ret; // This ID needs to match the one in ipmid - sd_id128_t appId = SD_ID128_MAKE(e0, e1, 73, 76, 64, 61, 47, da, a5, 0c, d0, - cc, 64, 12, 45, 78); - sd_id128_t machineId = SD_ID128_NULL; + sd_id128_t appId{{0Xe0, 0Xe1, 0X73, 0X76, 0X64, 0X61, 0X47, 0Xda, 0Xa5, + 0X0c, 0Xd0, 0Xcc, 0X64, 0X12, 0X45, 0X78}}; + sd_id128_t machineId{}; if (sd_id128_get_machine_app_specific(appId, &machineId) == 0) { diff --git a/redfish-core/lib/account_service.hpp b/redfish-core/lib/account_service.hpp index 9dac7e4..a183f68 100644 --- a/redfish-core/lib/account_service.hpp +++ b/redfish-core/lib/account_service.hpp @@ -299,7 +299,7 @@ static void handleRoleMapPatch( << ",LocalRole=" << *localRole; crow::connections::systemBus->async_method_call( - [asyncResp, serverType, index, localRole, + [asyncResp, serverType, localRole, remoteGroup](const boost::system::error_code ec) { if (ec) { @@ -422,43 +422,43 @@ inline void getLDAPConfigData(const std::string& ldapType, for (const auto& property : interface.second) { - const std::string* value = + const std::string* strValue = std::get_if<std::string>( &property.second); - if (value == nullptr) + if (strValue == nullptr) { continue; } if (property.first == "LDAPServerURI") { - confData.uri = *value; + confData.uri = *strValue; } else if (property.first == "LDAPBindDN") { - confData.bindDN = *value; + confData.bindDN = *strValue; } else if (property.first == "LDAPBaseDN") { - confData.baseDN = *value; + confData.baseDN = *strValue; } else if (property.first == "LDAPSearchScope") { - confData.searchScope = *value; + confData.searchScope = *strValue; } else if (property.first == "GroupNameAttribute") { - confData.groupAttribute = *value; + confData.groupAttribute = *strValue; } else if (property.first == "UserNameAttribute") { - confData.userNameAttribute = *value; + confData.userNameAttribute = *strValue; } else if (property.first == "LDAPType") { - confData.serverType = *value; + confData.serverType = *strValue; } } } @@ -469,22 +469,22 @@ inline void getLDAPConfigData(const std::string& ldapType, LDAPRoleMapData roleMapData{}; for (const auto& property : interface.second) { - const std::string* value = + const std::string* strValue = std::get_if<std::string>( &property.second); - if (value == nullptr) + if (strValue == nullptr) { continue; } if (property.first == "GroupName") { - roleMapData.groupName = *value; + roleMapData.groupName = *strValue; } else if (property.first == "Privilege") { - roleMapData.privilege = *value; + roleMapData.privilege = *strValue; } } @@ -1518,7 +1518,7 @@ class ManagerAccount : public Node crow::connections::systemBus->async_method_call( [this, asyncResp, username, password(std::move(password)), roleId(std::move(roleId)), enabled(std::move(enabled)), - newUser{std::string(*newUserName)}, locked(std::move(locked))]( + newUser{*newUserName}, locked(std::move(locked))]( const boost::system::error_code ec) { if (ec) { diff --git a/redfish-core/lib/certificate_service.hpp b/redfish-core/lib/certificate_service.hpp index 111bcec..89d5634 100644 --- a/redfish-core/lib/certificate_service.hpp +++ b/redfish-core/lib/certificate_service.hpp @@ -458,13 +458,7 @@ class CertificateActionGenerateCSR : public Node *crow::connections::systemBus, match, [asyncResp, service, objectPath, certURI](sdbusplus::message::message &m) { - boost::system::error_code ec; - timeout.cancel(ec); - if (ec) - { - BMCWEB_LOG_ERROR << "error canceling timer " << ec; - csrMatcher = nullptr; - } + timeout.cancel(); if (m.is_method_error()) { BMCWEB_LOG_ERROR << "Dbus method error!!!"; @@ -489,7 +483,7 @@ class CertificateActionGenerateCSR : public Node } }); crow::connections::systemBus->async_method_call( - [asyncResp](const boost::system::error_code ec, + [asyncResp](const boost::system::error_code &ec, const std::string &path) { if (ec) { @@ -531,14 +525,16 @@ static void updateCertIssuerOrSubject(nlohmann::json &out, { break; } - const std::string_view key(tokenBegin, i - tokenBegin); + const std::string_view key(tokenBegin, + static_cast<size_t>(i - tokenBegin)); i++; tokenBegin = i; while (i != value.end() && *i != ',') { i++; } - const std::string_view val(tokenBegin, i - tokenBegin); + const std::string_view val(tokenBegin, + static_cast<size_t>(i - tokenBegin)); if (key == "L") { out["City"] = val; diff --git a/redfish-core/lib/chassis.hpp b/redfish-core/lib/chassis.hpp index 8c13414..b08ab25 100644 --- a/redfish-core/lib/chassis.hpp +++ b/redfish-core/lib/chassis.hpp @@ -148,7 +148,7 @@ void getPhysicalSecurityData(std::shared_ptr<AsyncResp> aResp) "xyz.openbmc_project.ObjectMapper", "/xyz/openbmc_project/object_mapper", "xyz.openbmc_project.ObjectMapper", "GetSubTree", - "/xyz/openbmc_project/Intrusion", int32_t(1), + "/xyz/openbmc_project/Intrusion", 1, std::array<const char *, 1>{"xyz.openbmc_project.Chassis.Intrusion"}); } @@ -217,7 +217,7 @@ class ChassisCollection : public Node "xyz.openbmc_project.ObjectMapper", "/xyz/openbmc_project/object_mapper", "xyz.openbmc_project.ObjectMapper", "GetSubTreePaths", - "/xyz/openbmc_project/inventory", int32_t(0), interfaces); + "/xyz/openbmc_project/inventory", 0, interfaces); } }; @@ -397,7 +397,7 @@ class Chassis : public Node "xyz.openbmc_project.ObjectMapper", "/xyz/openbmc_project/object_mapper", "xyz.openbmc_project.ObjectMapper", "GetSubTree", - "/xyz/openbmc_project/inventory", int32_t(0), interfaces); + "/xyz/openbmc_project/inventory", 0, interfaces); getPhysicalSecurityData(asyncResp); } diff --git a/redfish-core/lib/cpudimm.hpp b/redfish-core/lib/cpudimm.hpp index 2e084d4..d8d4191 100644 --- a/redfish-core/lib/cpudimm.hpp +++ b/redfish-core/lib/cpudimm.hpp @@ -63,7 +63,7 @@ void getResourceList(std::shared_ptr<AsyncResp> aResp, "xyz.openbmc_project.ObjectMapper", "/xyz/openbmc_project/object_mapper", "xyz.openbmc_project.ObjectMapper", "GetSubTree", - "/xyz/openbmc_project/inventory", int32_t(0), collectionName); + "/xyz/openbmc_project/inventory", 0, collectionName); } void getCpuDataByInterface(std::shared_ptr<AsyncResp> aResp, @@ -360,8 +360,8 @@ void getCpuData(std::shared_ptr<AsyncResp> aResp, const std::string &cpuId, "xyz.openbmc_project.ObjectMapper", "/xyz/openbmc_project/object_mapper", "xyz.openbmc_project.ObjectMapper", "GetSubTree", - "/xyz/openbmc_project/inventory", int32_t(0), inventoryItems); -}; + "/xyz/openbmc_project/inventory", 0, inventoryItems); +} void getDimmDataByService(std::shared_ptr<AsyncResp> aResp, const std::string &dimmId, const std::string &service, @@ -481,9 +481,9 @@ void getDimmData(std::shared_ptr<AsyncResp> aResp, const std::string &dimmId) "xyz.openbmc_project.ObjectMapper", "/xyz/openbmc_project/object_mapper", "xyz.openbmc_project.ObjectMapper", "GetSubTree", - "/xyz/openbmc_project/inventory", int32_t(0), + "/xyz/openbmc_project/inventory", 0, std::array<const char *, 1>{"xyz.openbmc_project.Inventory.Item.Dimm"}); -}; +} class ProcessorCollection : public Node { diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp index ff37330..b06acf0 100644 --- a/redfish-core/lib/ethernet.hpp +++ b/redfish-core/lib/ethernet.hpp @@ -320,9 +320,10 @@ inline void std::pair< boost::container::flat_set<IPv6AddressData>::iterator, bool> - it = ipv6_config.insert( - {objpath.first.str.substr(ipv6PathStart.size())}); + it = ipv6_config.insert(IPv6AddressData{}); IPv6AddressData &ipv6_address = *it.first; + ipv6_address.id = + objpath.first.str.substr(ipv6PathStart.size()); for (auto &property : interface.second) { if (property.first == "Address") @@ -392,9 +393,10 @@ inline void std::pair< boost::container::flat_set<IPv4AddressData>::iterator, bool> - it = ipv4_config.insert( - {objpath.first.str.substr(ipv4PathStart.size())}); + it = ipv4_config.insert(IPv4AddressData{}); IPv4AddressData &ipv4_address = *it.first; + ipv4_address.id = + objpath.first.str.substr(ipv4PathStart.size()); for (auto &property : interface.second) { if (property.first == "Address") @@ -858,7 +860,7 @@ void getEthernetIfaceData(const std::string ðiface_id, }, "xyz.openbmc_project.Network", "/xyz/openbmc_project/network", "org.freedesktop.DBus.ObjectManager", "GetManagedObjects"); -}; +} /** * Function that retrieves all Ethernet Interfaces available through Network @@ -911,7 +913,7 @@ void getEthernetIfaceList(CallbackFunc &&callback) }, "xyz.openbmc_project.Network", "/xyz/openbmc_project/network", "org.freedesktop.DBus.ObjectManager", "GetManagedObjects"); -}; +} /** * EthernetCollection derived class for delivering Ethernet Collection Schema @@ -1169,7 +1171,7 @@ class EthernetInterface : public Node return; } - int entryIdx = 1; + unsigned entryIdx = 1; // Find the first static IP address currently active on the NIC and // match it to the first JSON element in the IPv4StaticAddresses array. // Match each subsequent JSON element to the next static IP programmed @@ -1201,8 +1203,8 @@ class EthernetInterface : public Node // not explicitly provided are assumed to be unmodified from the // current state of the interface. Merge existing state into the // current request. - const std::string *addr; - const std::string *gw; + const std::string *addr = nullptr; + const std::string *gw = nullptr; uint8_t prefixLength = 0; bool errorInEntry = false; if (address) @@ -1288,6 +1290,13 @@ class EthernetInterface : public Node if (NICIPentry != ipv4Data.cend()) { + if (gw != nullptr || addr != nullptr) + { + // Shouldn't be possible based on errorInEntry, but + // it flags -wmaybe-uninitialized in the compiler, + // so defend against that + return; + } deleteAndCreateIPv4(ifaceId, NICIPentry->id, prefixLength, *gw, *addr, asyncResp); NICIPentry = @@ -1365,7 +1374,7 @@ class EthernetInterface : public Node "IPv6StaticAddresses"); return; } - int entryIdx = 1; + size_t entryIdx = 1; boost::container::flat_set<IPv6AddressData>::const_iterator NICIPentry = GetNextStaticIPEntry(ipv6Data.cbegin(), ipv6Data.cend()); for (nlohmann::json &thisJson : input) @@ -1874,7 +1883,7 @@ class VlanNetworkInterface : public Node // JSON preparation getEthernetIfaceData( params[1], - [this, asyncResp, parentIfaceId{std::string(params[0])}, + [asyncResp, parentIfaceId{std::string(params[0])}, ifaceId{std::string(params[1])}, &vlanEnable, &vlanId]( const bool &success, const EthernetInterfaceData ðData, const boost::container::flat_set<IPv4AddressData> &ipv4Data, @@ -1944,7 +1953,7 @@ class VlanNetworkInterface : public Node // JSON preparation getEthernetIfaceData( params[1], - [this, asyncResp, parentIfaceId{std::string(params[0])}, + [asyncResp, parentIfaceId{std::string(params[0])}, ifaceId{std::string(params[1])}]( const bool &success, const EthernetInterfaceData ðData, const boost::container::flat_set<IPv4AddressData> &ipv4Data, @@ -2090,7 +2099,7 @@ class VlanNetworkInterfaceCollection : public Node { messages::propertyMissing(asyncResp->res, "VLANEnable"); } - if (static_cast<bool>(vlanId) ^ static_cast<bool>(vlanEnable)) + if (static_cast<bool>(vlanId) ^ vlanEnable) { return; } diff --git a/redfish-core/lib/health.hpp b/redfish-core/lib/health.hpp index da4f2d9..930eaee 100644 --- a/redfish-core/lib/health.hpp +++ b/redfish-core/lib/health.hpp @@ -153,8 +153,7 @@ struct HealthPopulate : std::enable_shared_from_this<HealthPopulate> }, "xyz.openbmc_project.ObjectMapper", "/xyz/openbmc_project/object_mapper", - "xyz.openbmc_project.ObjectMapper", "GetSubTreePaths", "/", - int32_t(0), + "xyz.openbmc_project.ObjectMapper", "GetSubTreePaths", "/", 0, std::array<const char *, 1>{ "xyz.openbmc_project.Inventory.Item.Global"}); } diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp index 9fd35a9..7a63162 100644 --- a/redfish-core/lib/log_services.hpp +++ b/redfish-core/lib/log_services.hpp @@ -145,8 +145,8 @@ static int getJournalMetadata(sd_journal *journal, size_t length = 0; int ret = 0; // Get the metadata from the requested field of the journal entry - ret = sd_journal_get_data(journal, field.data(), (const void **)&data, - &length); + ret = sd_journal_get_data(journal, field.data(), + reinterpret_cast<const void **>(&data), &length); if (ret < 0) { return ret; @@ -159,7 +159,7 @@ static int getJournalMetadata(sd_journal *journal, static int getJournalMetadata(sd_journal *journal, const std::string_view &field, const int &base, - int &contents) + long int &contents) { int ret = 0; std::string_view metadata; @@ -205,13 +205,13 @@ static bool getEntryTimestamp(sd_journal *journal, std::string &entryTimestamp) } static bool getSkipParam(crow::Response &res, const crow::Request &req, - long &skip) + uint64_t &skip) { char *skipParam = req.urlParams.get("$skip"); if (skipParam != nullptr) { char *ptr = nullptr; - skip = std::strtol(skipParam, &ptr, 10); + skip = std::strtoul(skipParam, &ptr, 10); if (*skipParam == '\0' || *ptr != '\0') { @@ -219,33 +219,26 @@ static bool getSkipParam(crow::Response &res, const crow::Request &req, "$skip"); return false; } - if (skip < 0) - { - - messages::queryParameterOutOfRange(res, std::to_string(skip), - "$skip", "greater than 0"); - return false; - } } return true; } -static constexpr const long maxEntriesPerPage = 1000; +static constexpr const uint64_t maxEntriesPerPage = 1000; static bool getTopParam(crow::Response &res, const crow::Request &req, - long &top) + uint64_t &top) { char *topParam = req.urlParams.get("$top"); if (topParam != nullptr) { char *ptr = nullptr; - top = std::strtol(topParam, &ptr, 10); + top = std::strtoul(topParam, &ptr, 10); if (*topParam == '\0' || *ptr != '\0') { messages::queryParameterValueTypeError(res, std::string(topParam), "$top"); return false; } - if (top < 1 || top > maxEntriesPerPage) + if (top < 1U || top > maxEntriesPerPage) { messages::queryParameterOutOfRange( @@ -301,7 +294,7 @@ static bool getUniqueEntryID(sd_journal *journal, std::string &entryID, static bool getUniqueEntryID(const std::string &logEntry, std::string &entryID, const bool firstEntry = true) { - static uint64_t prevTs = 0; + static time_t prevTs = 0; static int index = 0; if (firstEntry) { @@ -309,7 +302,7 @@ static bool getUniqueEntryID(const std::string &logEntry, std::string &entryID, } // Get the entry timestamp - uint64_t curTs = 0; + std::time_t curTs = 0; std::tm timeStruct = {}; std::istringstream entryStream(logEntry); if (entryStream >> std::get_time(&timeStruct, "%Y-%m-%dT%H:%M:%S")) @@ -338,7 +331,7 @@ static bool getUniqueEntryID(const std::string &logEntry, std::string &entryID, } static bool getTimestampFromID(crow::Response &res, const std::string &entryID, - uint64_t ×tamp, uint16_t &index) + uint64_t ×tamp, uint64_t &index) { if (entryID.empty()) { @@ -359,12 +352,12 @@ static bool getTimestampFromID(crow::Response &res, const std::string &entryID, { index = std::stoul(std::string(indexStr), &pos); } - catch (std::invalid_argument) + catch (std::invalid_argument &) { messages::resourceMissingAtURI(res, entryID); return false; } - catch (std::out_of_range) + catch (std::out_of_range &) { messages::resourceMissingAtURI(res, entryID); return false; @@ -381,12 +374,12 @@ static bool getTimestampFromID(crow::Response &res, const std::string &entryID, { timestamp = std::stoull(std::string(tsStr), &pos); } - catch (std::invalid_argument) + catch (std::invalid_argument &) { messages::resourceMissingAtURI(res, entryID); return false; } - catch (std::out_of_range) + catch (std::out_of_range &) { messages::resourceMissingAtURI(res, entryID); return false; @@ -685,8 +678,8 @@ class JournalEventLogEntryCollection : public Node const std::vector<std::string> ¶ms) override { std::shared_ptr<AsyncResp> asyncResp = std::make_shared<AsyncResp>(res); - long skip = 0; - long top = maxEntriesPerPage; // Show max entries by default + uint64_t skip = 0; + uint64_t top = maxEntriesPerPage; // Show max entries by default if (!getSkipParam(asyncResp->res, req, skip)) { return; @@ -912,7 +905,6 @@ class DBusEventLogEntryCollection : public Node uint32_t *id; std::time_t timestamp; std::string *severity, *message; - bool *resolved; for (auto &propertyMap : interfaceMap.second) { if (propertyMap.first == "Id") @@ -933,15 +925,16 @@ class DBusEventLogEntryCollection : public Node { messages::propertyMissing(asyncResp->res, "Timestamp"); + continue; } // Retrieve Created property with format: // yyyy-mm-ddThh:mm:ss std::chrono::milliseconds chronoTimeStamp( *millisTimeStamp); - timestamp = - std::chrono::duration_cast< - std::chrono::seconds>(chronoTimeStamp) - .count(); + timestamp = std::chrono::duration_cast< + std::chrono::duration<int>>( + chronoTimeStamp) + .count(); } else if (propertyMap.first == "Severity") { @@ -1038,7 +1031,6 @@ class DBusEventLogEntry : public Node uint32_t *id; std::time_t timestamp; std::string *severity, *message; - bool *resolved; for (auto &propertyMap : resp) { if (propertyMap.first == "Id") @@ -1057,14 +1049,15 @@ class DBusEventLogEntry : public Node { messages::propertyMissing(asyncResp->res, "Timestamp"); + continue; } // Retrieve Created property with format: // yyyy-mm-ddThh:mm:ss std::chrono::milliseconds chronoTimeStamp( *millisTimeStamp); timestamp = - std::chrono::duration_cast<std::chrono::seconds>( - chronoTimeStamp) + std::chrono::duration_cast< + std::chrono::duration<int>>(chronoTimeStamp) .count(); } else if (propertyMap.first == "Severity") @@ -1087,6 +1080,10 @@ class DBusEventLogEntry : public Node } } } + if (id == nullptr || message == nullptr || severity == nullptr) + { + return; + } asyncResp->res.jsonValue = { {"@odata.type", "#LogEntry.v1_4_0.LogEntry"}, {"@odata.context", "/redfish/v1/" @@ -1249,7 +1246,7 @@ static int fillBMCJournalLogEntryJson(const std::string &bmcJournalLogEntryID, } // Get the severity from the PRIORITY field - int severity = 8; // Default to an invalid priority + long int severity = 8; // Default to an invalid priority ret = getJournalMetadata(journal, "PRIORITY", 10, severity); if (ret < 0) { @@ -1302,8 +1299,8 @@ class BMCJournalLogEntryCollection : public Node { std::shared_ptr<AsyncResp> asyncResp = std::make_shared<AsyncResp>(res); static constexpr const long maxEntriesPerPage = 1000; - long skip = 0; - long top = maxEntriesPerPage; // Show max entries by default + uint64_t skip = 0; + uint64_t top = maxEntriesPerPage; // Show max entries by default if (!getSkipParam(asyncResp->res, req, skip)) { return; @@ -1415,7 +1412,7 @@ class BMCJournalLogEntry : public Node const std::string &entryID = params[0]; // Convert the unique ID back to a timestamp to find the entry uint64_t ts = 0; - uint16_t index = 0; + uint64_t index = 0; if (!getTimestampFromID(asyncResp->res, entryID, ts, index)) { return; @@ -1437,7 +1434,7 @@ class BMCJournalLogEntry : public Node std::string idStr; bool firstEntry = true; ret = sd_journal_seek_realtime_usec(journal.get(), ts); - for (int i = 0; i <= index; i++) + for (uint64_t i = 0; i <= index; i++) { sd_journal_next(journal.get()); if (!getUniqueEntryID(journal.get(), idStr, firstEntry)) @@ -1652,7 +1649,7 @@ class CrashdumpEntry : public Node messages::internalError(asyncResp->res); return; } - const uint8_t logId = std::atoi(params[0].c_str()); + const int logId = std::atoi(params[0].c_str()); auto getStoredLogCallback = [asyncResp, logId]( const boost::system::error_code ec, const std::variant<std::string> &resp) { @@ -1728,9 +1725,9 @@ class OnDemandCrashdump : public Node return; } // Make this static so it survives outside this method - static boost::asio::deadline_timer timeout(*req.ioService); + static boost::asio::steady_timer timeout(*req.ioService); - timeout.expires_from_now(boost::posix_time::seconds(30)); + timeout.expires_after(std::chrono::seconds(30)); timeout.async_wait([asyncResp](const boost::system::error_code &ec) { onDemandLogMatcher = nullptr; if (ec) @@ -1751,12 +1748,8 @@ class OnDemandCrashdump : public Node auto onDemandLogMatcherCallback = [asyncResp]( sdbusplus::message::message &m) { BMCWEB_LOG_DEBUG << "OnDemand log available match fired"; - boost::system::error_code ec; - timeout.cancel(ec); - if (ec) - { - BMCWEB_LOG_ERROR << "error canceling timer " << ec; - } + timeout.cancel(); + sdbusplus::message::object_path objPath; boost::container::flat_map< std::string, boost::container::flat_map< @@ -1825,13 +1818,8 @@ class OnDemandCrashdump : public Node { messages::internalError(asyncResp->res); } - boost::system::error_code timeoutec; - timeout.cancel(timeoutec); - if (timeoutec) - { - BMCWEB_LOG_ERROR << "error canceling timer " - << timeoutec; - } + + timeout.cancel(); onDemandLogMatcher = nullptr; return; } diff --git a/redfish-core/lib/managers.hpp b/redfish-core/lib/managers.hpp index 459edad..9d2144e 100644 --- a/redfish-core/lib/managers.hpp +++ b/redfish-core/lib/managers.hpp @@ -278,7 +278,7 @@ static void asyncPopulatePid(const std::string& connection, controller["@odata.id"] = "/redfish/v1/Managers/bmc#/Oem/" "OpenBmc/Fan/StepwiseControllers/" + - std::string(name); + name; controller["@odata.type"] = "#OemManager.StepwiseController"; @@ -307,7 +307,7 @@ static void asyncPopulatePid(const std::string& connection, element["@odata.id"] = "/redfish/v1/Managers/bmc#/Oem/" "OpenBmc/Fan/FanControllers/" + - std::string(name); + name; element["@odata.type"] = "#OemManager.FanController"; @@ -320,7 +320,7 @@ static void asyncPopulatePid(const std::string& connection, element["@odata.id"] = "/redfish/v1/Managers/bmc#/Oem/" "OpenBmc/Fan/PidControllers/" + - std::string(name); + name; element["@odata.type"] = "#OemManager.PidController"; element["@odata.context"] = @@ -1077,8 +1077,8 @@ struct GetPIDValues : std::enable_shared_from_this<GetPIDValues> messages::internalError(self->asyncResp->res); return; } - const std::string* current; - const std::vector<std::string>* supported; + const std::string* current = nullptr; + const std::vector<std::string>* supported = nullptr; for (auto& [key, value] : resp) { if (key == "Current") @@ -1193,9 +1193,9 @@ struct GetPIDValues : std::enable_shared_from_this<GetPIDValues> struct SetPIDValues : std::enable_shared_from_this<SetPIDValues> { - SetPIDValues(const std::shared_ptr<AsyncResp>& asyncResp, + SetPIDValues(const std::shared_ptr<AsyncResp>& asyncRespIn, nlohmann::json& data) : - asyncResp(asyncResp) + asyncResp(asyncRespIn) { std::optional<nlohmann::json> pidControllers; @@ -1231,14 +1231,14 @@ struct SetPIDValues : std::enable_shared_from_this<SetPIDValues> // interface gets more traction crow::connections::systemBus->async_method_call( [self](const boost::system::error_code ec, - dbus::utility::ManagedObjectType& managedObj) { + dbus::utility::ManagedObjectType& mObj) { if (ec) { BMCWEB_LOG_ERROR << "Error communicating to Entity Manager"; messages::internalError(self->asyncResp->res); return; } - self->managedObj = std::move(managedObj); + self->managedObj = std::move(mObj); }, "xyz.openbmc_project.EntityManager", "/", objectManagerIface, "GetManagedObjects"); @@ -1266,7 +1266,7 @@ struct SetPIDValues : std::enable_shared_from_this<SetPIDValues> const boost::system::error_code ec, const boost::container::flat_map< std::string, std::variant<std::vector<std::string>, - std::string>>& resp) { + std::string>>& r) { if (ec) { BMCWEB_LOG_ERROR << "SetPIDValues: Can't get " @@ -1275,9 +1275,9 @@ struct SetPIDValues : std::enable_shared_from_this<SetPIDValues> messages::internalError(self->asyncResp->res); return; } - const std::string* current; - const std::vector<std::string>* supported; - for (auto& [key, value] : resp) + const std::string* current = nullptr; + const std::vector<std::string>* supported = nullptr; + for (auto& [key, value] : r) { if (key == "Current") { diff --git a/redfish-core/lib/message_registries.hpp b/redfish-core/lib/message_registries.hpp index ef443af..96ce0c2 100644 --- a/redfish-core/lib/message_registries.hpp +++ b/redfish-core/lib/message_registries.hpp @@ -257,7 +257,7 @@ class OpenBMCMessageRegistry : public Node if (message.second.numberOfArgs > 0) { nlohmann::json &messageParamArray = obj["ParamTypes"]; - for (int i = 0; i < message.second.numberOfArgs; i++) + for (size_t i = 0; i < message.second.numberOfArgs; i++) { messageParamArray.push_back(message.second.paramTypes[i]); } diff --git a/redfish-core/lib/network_protocol.hpp b/redfish-core/lib/network_protocol.hpp index 71e58cc..75d13d4 100644 --- a/redfish-core/lib/network_protocol.hpp +++ b/redfish-core/lib/network_protocol.hpp @@ -139,7 +139,7 @@ void getEthernetIfaceData(CallbackFunc&& callback) }, "xyz.openbmc_project.Network", "/xyz/openbmc_project/network", "org.freedesktop.DBus.ObjectManager", "GetManagedObjects"); -}; +} class NetworkProtocol : public Node { @@ -230,32 +230,32 @@ class NetworkProtocol : public Node // TODO Get eth0 interface data, and call the below callback for JSON // preparation - getEthernetIfaceData([this, hostName, asyncResp]( - const bool& success, - const std::vector<std::string>& ntpServers, - const std::vector<std::string>& domainNames) { - if (!success) - { - messages::resourceNotFound(asyncResp->res, "EthernetInterface", - "eth0"); - return; - } - asyncResp->res.jsonValue["NTP"]["NTPServers"] = ntpServers; - if (hostName.empty() == false) - { - std::string FQDN = std::move(hostName); - if (domainNames.empty() == false) + getEthernetIfaceData( + [hostName, asyncResp](const bool& success, + const std::vector<std::string>& ntpServers, + const std::vector<std::string>& domainNames) { + if (!success) { - FQDN += "." + domainNames[0]; + messages::resourceNotFound(asyncResp->res, + "EthernetInterface", "eth0"); + return; } - asyncResp->res.jsonValue["FQDN"] = std::move(FQDN); - } - }); + asyncResp->res.jsonValue["NTP"]["NTPServers"] = ntpServers; + if (hostName.empty() == false) + { + std::string FQDN = std::move(hostName); + if (domainNames.empty() == false) + { + FQDN += "." + domainNames[0]; + } + asyncResp->res.jsonValue["FQDN"] = std::move(FQDN); + } + }); crow::connections::systemBus->async_method_call( - [asyncResp](const boost::system::error_code ec, - const std::vector<UnitStruct>& resp) { - if (ec) + [asyncResp](const boost::system::error_code e, + const std::vector<UnitStruct>& r) { + if (e) { asyncResp->res.jsonValue = nlohmann::json::object(); messages::internalError(asyncResp->res); @@ -265,7 +265,7 @@ class NetworkProtocol : public Node {"@odata.id", "/redfish/v1/Managers/bmc/NetworkProtocol/" "HTTPS/Certificates/"}}; - for (auto& unit : resp) + for (auto& unit : r) { for (auto& kv : protocolToDBus) { diff --git a/redfish-core/lib/pcie.hpp b/redfish-core/lib/pcie.hpp index ad61ff4..5b4f5c5 100644 --- a/redfish-core/lib/pcie.hpp +++ b/redfish-core/lib/pcie.hpp @@ -108,7 +108,7 @@ class SystemPCIeDevice : public Node { BMCWEB_LOG_DEBUG << "failed to get PCIe Device properties ec: " - << static_cast<int>(ec.value()) << ": " << ec.message(); + << ec.value() << ": " << ec.message(); if (ec.value() == boost::system::linux_error::bad_request_descriptor) { @@ -221,7 +221,7 @@ class SystemPCIeFunction : public Node { BMCWEB_LOG_DEBUG << "failed to get PCIe Device properties ec: " - << static_cast<int>(ec.value()) << ": " << ec.message(); + << ec.value() << ": " << ec.message(); if (ec.value() == boost::system::linux_error::bad_request_descriptor) { diff --git a/redfish-core/lib/power.hpp b/redfish-core/lib/power.hpp index 8c3927b..eaea5ab 100644 --- a/redfish-core/lib/power.hpp +++ b/redfish-core/lib/power.hpp @@ -62,13 +62,13 @@ class Power : public Node // chassis that implements the Chassis inventory item. This prevents // things like power supplies providing the chassis power limit auto chassisHandler = [sensorAsyncResp]( - const boost::system::error_code ec, + const boost::system::error_code e, const std::vector<std::string>& chassisPaths) { - if (ec) + if (e) { BMCWEB_LOG_ERROR - << "Power Limit GetSubTreePaths handler Dbus error " << ec; + << "Power Limit GetSubTreePaths handler Dbus error " << e; return; } @@ -178,7 +178,7 @@ class Power : public Node } else if (i) { - powerCap = *i; + powerCap = static_cast<double>(*i); } else if (u) { @@ -220,7 +220,7 @@ class Power : public Node std::move(chassisHandler), "xyz.openbmc_project.ObjectMapper", "/xyz/openbmc_project/object_mapper", "xyz.openbmc_project.ObjectMapper", "GetSubTreePaths", - "/xyz/openbmc_project/inventory", int32_t(0), + "/xyz/openbmc_project/inventory", 0, std::array<const char*, 1>{ "xyz.openbmc_project.Inventory.Item.Chassis"}); } diff --git a/redfish-core/lib/sensors.hpp b/redfish-core/lib/sensors.hpp index 76c304f..738edc2 100644 --- a/redfish-core/lib/sensors.hpp +++ b/redfish-core/lib/sensors.hpp @@ -49,11 +49,11 @@ using ManagedObjectsVectorType = std::vector<std::pair< class SensorsAsyncResp { public: - SensorsAsyncResp(crow::Response& response, const std::string& chassisId, - const std::vector<const char*> types, + SensorsAsyncResp(crow::Response& response, const std::string& chassisIdIn, + const std::vector<const char*> typesIn, const std::string& subNode) : res(response), - chassisId(chassisId), types(types), chassisSubNode(subNode) + chassisId(chassisIdIn), types(typesIn), chassisSubNode(subNode) { } @@ -340,12 +340,12 @@ void getChassis(std::shared_ptr<SensorsAsyncResp> sensorsAsyncResp, std::string sensorPath = *chassisPath + "/all_sensors"; crow::connections::systemBus->async_method_call( [sensorsAsyncResp, callback{std::move(callback)}]( - const boost::system::error_code ec, + const boost::system::error_code& e, const std::variant<std::vector<std::string>>& variantEndpoints) { - if (ec) + if (e) { - if (ec.value() != EBADR) + if (e.value() != EBADR) { messages::internalError(sensorsAsyncResp->res); return; @@ -381,7 +381,7 @@ void getChassis(std::shared_ptr<SensorsAsyncResp> sensorsAsyncResp, respHandler, "xyz.openbmc_project.ObjectMapper", "/xyz/openbmc_project/object_mapper", "xyz.openbmc_project.ObjectMapper", "GetSubTreePaths", - "/xyz/openbmc_project/inventory", int32_t(0), interfaces); + "/xyz/openbmc_project/inventory", 0, interfaces); BMCWEB_LOG_DEBUG << "getChassis exit"; } @@ -452,8 +452,7 @@ void getObjectManagerPaths(std::shared_ptr<SensorsAsyncResp> SensorsAsyncResp, crow::connections::systemBus->async_method_call( std::move(respHandler), "xyz.openbmc_project.ObjectMapper", "/xyz/openbmc_project/object_mapper", - "xyz.openbmc_project.ObjectMapper", "GetSubTree", "/", int32_t(0), - interfaces); + "xyz.openbmc_project.ObjectMapper", "GetSubTree", "/", 0, interfaces); BMCWEB_LOG_DEBUG << "getObjectManagerPaths exit"; } @@ -803,10 +802,10 @@ void objectInterfacesToJson( auto interfaceProperties = interfacesDict.find(std::get<0>(p)); if (interfaceProperties != interfacesDict.end()) { - auto valueIt = interfaceProperties->second.find(std::get<1>(p)); - if (valueIt != interfaceProperties->second.end()) + auto thisValueIt = interfaceProperties->second.find(std::get<1>(p)); + if (thisValueIt != interfaceProperties->second.end()) { - const SensorVariant& valueVariant = valueIt->second; + const SensorVariant& valueVariant = thisValueIt->second; // The property we want to set may be nested json, so use // a json_pointer for easy indexing into the json structure. @@ -820,7 +819,7 @@ void objectInterfacesToJson( double temp = 0.0; if (int64Value != nullptr) { - temp = *int64Value; + temp = static_cast<double>(*int64Value); } else if (doubleValue != nullptr) { @@ -878,10 +877,10 @@ static void const std::string& owner = objDict.begin()->first; crow::connections::systemBus->async_method_call( [path, owner, - sensorsAsyncResp](const boost::system::error_code ec, + sensorsAsyncResp](const boost::system::error_code e, std::variant<std::vector<std::string>> variantEndpoints) { - if (ec) + if (e) { return; // if they don't have an association we // can't tell what chassis is @@ -911,13 +910,13 @@ static void } crow::connections::systemBus->async_method_call( [path, sensorsAsyncResp]( - const boost::system::error_code ec, + const boost::system::error_code& err, const boost::container::flat_map< std::string, std::variant<uint8_t, std::vector<std::string>, std::string>>& ret) { - if (ec) + if (err) { return; // don't have to have this // interface @@ -1016,15 +1015,16 @@ static void } } - auto& resp = sensorsAsyncResp->res - .jsonValue["Redundancy"]; - resp.push_back( + nlohmann::json& jResp = + sensorsAsyncResp->res + .jsonValue["Redundancy"]; + jResp.push_back( {{"@odata.id", "/refish/v1/Chassis/" + sensorsAsyncResp->chassisId + "/" + sensorsAsyncResp->chassisSubNode + "#/Redundancy/" + - std::to_string(resp.size())}, + std::to_string(jResp.size())}, {"@odata.type", "#Redundancy.v1_3_2.Redundancy"}, {"MinNumNeeded", @@ -1314,7 +1314,7 @@ static void getInventoryItemsData( std::shared_ptr<boost::container::flat_set<std::string>> invConnections, std::shared_ptr<boost::container::flat_map<std::string, std::string>> objectMgrPaths, - Callback&& callback, int invConnectionsIndex = 0) + Callback&& callback, size_t invConnectionsIndex = 0) { BMCWEB_LOG_DEBUG << "getInventoryItemsData enter"; @@ -1800,7 +1800,7 @@ void getSensorData( } else { - const char* fieldName = nullptr; + std::string fieldName; if (sensorType == "temperature") { fieldName = "Temperatures"; @@ -1978,7 +1978,7 @@ void getChassisData(std::shared_ptr<SensorsAsyncResp> SensorsAsyncResp) // Get set of sensors in chassis getChassis(SensorsAsyncResp, std::move(getChassisCb)); BMCWEB_LOG_DEBUG << "getChassisData exit"; -}; +} /** * @brief Find the requested sensorName in the list of all sensors supplied by diff --git a/redfish-core/lib/update_service.hpp b/redfish-core/lib/update_service.hpp index a3d7196..da88271 100644 --- a/redfish-core/lib/update_service.hpp +++ b/redfish-core/lib/update_service.hpp @@ -29,7 +29,7 @@ static std::unique_ptr<sdbusplus::bus::match::match> fwUpdateMatcher; // Only allow one update at a time static bool fwUpdateInProgress = false; // Timer for software available -static std::unique_ptr<boost::asio::deadline_timer> fwAvailableTimer; +static std::unique_ptr<boost::asio::steady_timer> fwAvailableTimer; static void cleanUp() { @@ -148,10 +148,9 @@ static void monitorForSoftwareAvailable(std::shared_ptr<AsyncResp> asyncResp, } fwAvailableTimer = - std::make_unique<boost::asio::deadline_timer>(*req.ioService); + std::make_unique<boost::asio::steady_timer>(*req.ioService); - fwAvailableTimer->expires_from_now( - boost::posix_time::seconds(timeoutTimeSeconds)); + fwAvailableTimer->expires_after(std::chrono::seconds(timeoutTimeSeconds)); fwAvailableTimer->async_wait( [asyncResp](const boost::system::error_code &ec) { @@ -485,10 +484,6 @@ class SoftwareInventoryCollection : public Node for (auto &obj : subtree) { - const std::vector< - std::pair<std::string, std::vector<std::string>>> - &connections = obj.second; - // if can't parse fw id then return std::size_t idPos; if ((idPos = obj.first.rfind("/")) == std::string::npos) @@ -511,7 +506,8 @@ class SoftwareInventoryCollection : public Node }, "xyz.openbmc_project.ObjectMapper", "/xyz/openbmc_project/object_mapper", - "xyz.openbmc_project.ObjectMapper", "GetSubTree", "/", int32_t(0), + "xyz.openbmc_project.ObjectMapper", "GetSubTree", "/", + static_cast<int32_t>(0), std::array<const char *, 1>{ "xyz.openbmc_project.Software.Version"}); } @@ -719,7 +715,8 @@ class SoftwareInventory : public Node }, "xyz.openbmc_project.ObjectMapper", "/xyz/openbmc_project/object_mapper", - "xyz.openbmc_project.ObjectMapper", "GetSubTree", "/", int32_t(0), + "xyz.openbmc_project.ObjectMapper", "GetSubTree", "/", + static_cast<int32_t>(0), std::array<const char *, 1>{ "xyz.openbmc_project.Software.Version"}); } diff --git a/scripts/parse_registries.py b/scripts/parse_registries.py index 3eff312..572fe7e 100644 --- a/scripts/parse_registries.py +++ b/scripts/parse_registries.py @@ -41,7 +41,7 @@ namespace redfish::message_registries::{} SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__)) -include_path = os.path.realpath(os.path.join(SCRIPT_DIR, "..", "redfish-core", "include")) +include_path = os.path.realpath(os.path.join(SCRIPT_DIR, "..", "redfish-core", "include", "registries")) proxies = { 'https': os.environ.get("https_proxy", None) @@ -65,15 +65,15 @@ for file, json, namespace in files: registry.write(REGISTRY_HEADER.format(namespace)) # Parse the Registry header info registry.write("const Header header = {") - registry.write(".copyright = \"{}\",".format(json["@Redfish.Copyright"])) - registry.write(".type = \"{}\",".format(json["@odata.type"])) - registry.write(".id = \"{}\",".format(json["Id"])) - registry.write(".name = \"{}\",".format(json["Name"])) - registry.write(".language = \"{}\",".format(json["Language"])) - registry.write(".description = \"{}\",".format(json["Description"])) - registry.write(".registryPrefix = \"{}\",".format(json["RegistryPrefix"])) - registry.write(".registryVersion = \"{}\",".format(json["RegistryVersion"])) - registry.write(".owningEntity = \"{}\",".format(json["OwningEntity"])) + registry.write("\"{}\",".format(json["@Redfish.Copyright"])) + registry.write("\"{}\",".format(json["@odata.type"])) + registry.write("\"{}\",".format(json["Id"])) + registry.write(".\"{}\",".format(json["Name"])) + registry.write("\"{}\",".format(json["Language"])) + registry.write("\"{}\",".format(json["Description"])) + registry.write(".\"{}\",".format(json["RegistryPrefix"])) + registry.write("\"{}\",".format(json["RegistryVersion"])) + registry.write("\"{}\",".format(json["OwningEntity"])) registry.write("};") # Parse each Message entry @@ -82,17 +82,17 @@ for file, json, namespace in files: registry.write("MessageEntry{") registry.write("\"{}\",".format(messageId)) registry.write("{") - registry.write(".description = \"{}\",".format(message["Description"])) - registry.write(".message = \"{}\",".format(message["Message"])) - registry.write(".severity = \"{}\",".format(message["Severity"])) - registry.write(".numberOfArgs = {},".format(message["NumberOfArgs"])) - registry.write(".paramTypes = {") + registry.write("\"{}\",".format(message["Description"])) + registry.write("\"{}\",".format(message["Message"])) + registry.write("\"{}\",".format(message["Severity"])) + registry.write("{},".format(message["NumberOfArgs"])) + registry.write("{") paramTypes = message.get("ParamTypes") if paramTypes: for paramType in paramTypes: registry.write("\"{}\",".format(paramType)) registry.write("},") - registry.write(".resolution = \"{}\",".format(message["Resolution"])) + registry.write("\"{}\",".format(message["Resolution"])) registry.write("}},") registry.write("};}\n") - subprocess.check_call(["clang-format", "-i", file]) + subprocess.check_call(["clang-format-6.0", "-i", file]) diff --git a/src/crow_test.cpp b/src/crow_test.cpp index beefdee..f427a2f 100644 --- a/src/crow_test.cpp +++ b/src/crow_test.cpp @@ -5,8 +5,6 @@ #include "crow.h" #include "gtest/gtest.h" -#undef BMCWEB_LOG_LEVEL -#define BMCWEB_LOG_LEVEL 0 using namespace std; using namespace crow; diff --git a/src/webserver_main.cpp b/src/webserver_main.cpp index 602c216..c477581 100644 --- a/src/webserver_main.cpp +++ b/src/webserver_main.cpp @@ -56,7 +56,7 @@ void setupSocket(crow::Crow<Middlewares...>& app) int main(int argc, char** argv) { - crow::logger::setLogLevel(crow::LogLevel::DEBUG); + crow::logger::setLogLevel(crow::LogLevel::Debug); auto io = std::make_shared<boost::asio::io_context>(); CrowApp app(io); |

