Enable clang warnings
This commit enables clang warnings, and fixes all warnings that were
found. Most of these fall into a couple categories:
Variable shadow issues were fixed by renaming variables
unused parameter warnings were resolved by either checking error codes
that had been ignored, or removing the name of the variable from the
scope.
Other various warnings were fixed in the best way I was able to come up
with.
Note, the redfish Node class is especially insidious, as it causes all
imlementers to have variables for parameters, regardless of whether or
not they are used. Deprecating the Node class is on my list of things
to do, as it adds extra overhead, and in general isn't a useful
abstraction. For now, I have simply fixed all the handlers.
Tested:
Added the current meta-clang meta layer into bblayers.conf, and added
TOOLCHAIN_pn-bmcweb = "clang" to my local.conf
Signed-off-by: Ed Tanous <ed@tanous.net>
Change-Id: Ia75b94010359170159c703e535d1c1af182fe700
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 50483ad..847a43e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -189,7 +189,6 @@
-Wnull-dereference \
-Wdouble-promotion \
-Wformat=2 \
- -Wno-unused-parameter \
"
)
@@ -212,6 +211,36 @@
endif (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.0)
endif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
+if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
+ if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 9.0)
+ set (
+ CMAKE_CXX_FLAGS
+ "${CMAKE_CXX_FLAGS} \
+ -Werror \
+ -Weverything \
+ -Wno-c++98-compat \
+ -Wno-c++98-compat-pedantic \
+ -Wno-global-constructors \
+ -Wno-exit-time-destructors \
+ -Wno-shadow \
+ -Wno-used-but-marked-unused \
+ -Wno-documentation-unknown-command \
+ -Wno-weak-vtables \
+ -Wno-documentation \
+ -Wno-padded \
+ -Wno-unused-parameter \
+ -Wcovered-switch-default \
+ -Wcomma \
+ -Wextra-semi \
+ -Wzero-as-null-pointer-constant \
+ -Wswitch-enum \
+ -Wnull-dereference \
+ -Wdouble-promotion \
+ -Wformat=2 \
+ "
+ )
+ 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
diff --git a/http/app.h b/http/app.h
index dfd5304..b810374 100644
--- a/http/app.h
+++ b/http/app.h
@@ -97,13 +97,13 @@
#ifdef BMCWEB_ENABLE_SSL
if (-1 == socketFd)
{
- sslServer = std::move(std::make_unique<ssl_server_t>(
- this, bindaddrStr, portUint, sslContext, io));
+ sslServer = std::make_unique<ssl_server_t>(
+ this, bindaddrStr, portUint, sslContext, io);
}
else
{
- sslServer = std::move(
- std::make_unique<ssl_server_t>(this, socketFd, sslContext, io));
+ sslServer =
+ std::make_unique<ssl_server_t>(this, socketFd, sslContext, io);
}
sslServer->setTickFunction(tickInterval, tickFunction);
sslServer->run();
diff --git a/http/common.h b/http/common.h
index 77db63c..95cc763 100644
--- a/http/common.h
+++ b/http/common.h
@@ -12,33 +12,6 @@
namespace crow
{
-inline std::string methodName(boost::beast::http::verb method)
-{
- switch (method)
- {
- case boost::beast::http::verb::delete_:
- return "DELETE";
- case boost::beast::http::verb::get:
- return "GET";
- case boost::beast::http::verb::head:
- return "HEAD";
- case boost::beast::http::verb::post:
- return "POST";
- case boost::beast::http::verb::put:
- return "PUT";
- case boost::beast::http::verb::connect:
- return "CONNECT";
- case boost::beast::http::verb::options:
- return "OPTIONS";
- case boost::beast::http::verb::trace:
- return "TRACE";
- case boost::beast::http::verb::patch:
- return "PATCH";
- default:
- return "invalid";
- }
-}
-
enum class ParamType
{
INT,
diff --git a/http/http_client.hpp b/http/http_client.hpp
index e6a7db1..c455c7b 100644
--- a/http/http_client.hpp
+++ b/http/http_client.hpp
@@ -302,8 +302,6 @@
sendMessage(data);
break;
}
- default:
- break;
}
}
diff --git a/http/http_connection.h b/http/http_connection.h
index 609d4a1..855cc11 100644
--- a/http/http_connection.h
+++ b/http/http_connection.h
@@ -176,7 +176,7 @@
bool isKeyUsageKeyAgreement = false;
ASN1_BIT_STRING* usage = static_cast<ASN1_BIT_STRING*>(
- X509_get_ext_d2i(peerCert, NID_key_usage, NULL, NULL));
+ X509_get_ext_d2i(peerCert, NID_key_usage, nullptr, nullptr));
if (usage == nullptr)
{
@@ -208,8 +208,9 @@
// Determine that ExtendedKeyUsage includes Client Auth
- stack_st_ASN1_OBJECT* extUsage = static_cast<stack_st_ASN1_OBJECT*>(
- X509_get_ext_d2i(peerCert, NID_ext_key_usage, NULL, NULL));
+ stack_st_ASN1_OBJECT* extUsage =
+ static_cast<stack_st_ASN1_OBJECT*>(X509_get_ext_d2i(
+ peerCert, NID_ext_key_usage, nullptr, nullptr));
if (extUsage == nullptr)
{
@@ -348,7 +349,7 @@
if (!isInvalidRequest)
{
- req->socket = [this, self = shared_from_this()]() -> Adaptor& {
+ req->socket = [self = shared_from_this()]() -> Adaptor& {
return self->socket();
};
diff --git a/http/http_response.h b/http/http_response.h
index 7be6b09..68e3f2d 100644
--- a/http/http_response.h
+++ b/http/http_response.h
@@ -104,7 +104,7 @@
void preparePayload()
{
stringResponse->prepare_payload();
- };
+ }
void clear()
{
diff --git a/http/http_server.h b/http/http_server.h
index c87ddd4..0099274 100644
--- a/http/http_server.h
+++ b/http/http_server.h
@@ -31,14 +31,14 @@
class Server
{
public:
- Server(Handler* handler, std::unique_ptr<tcp::acceptor>&& acceptor,
+ Server(Handler* handlerIn, std::unique_ptr<tcp::acceptor>&& acceptor,
std::shared_ptr<boost::asio::ssl::context> adaptor_ctx,
std::shared_ptr<boost::asio::io_context> io =
std::make_shared<boost::asio::io_context>()) :
ioService(std::move(io)),
acceptor(std::move(acceptor)),
signals(*ioService, SIGINT, SIGTERM, SIGHUP), tickTimer(*ioService),
- timer(*ioService), handler(handler), adaptorCtx(adaptor_ctx)
+ timer(*ioService), handler(handlerIn), adaptorCtx(adaptor_ctx)
{}
Server(Handler* handler, const std::string& bindaddr, uint16_t port,
@@ -93,7 +93,7 @@
size_t dateStrSz =
strftime(&dateStr[0], 99, "%a, %d %b %Y %H:%M:%S GMT", &myTm);
dateStr.resize(dateStrSz);
- };
+ }
void run()
{
diff --git a/http/routing.h b/http/routing.h
index 2f90c07..1af1b2b 100644
--- a/http/routing.h
+++ b/http/routing.h
@@ -219,7 +219,7 @@
template <typename Req, typename... Args>
struct ReqHandlerWrapper
{
- ReqHandlerWrapper(Func f) : f(std::move(f))
+ ReqHandlerWrapper(Func fIn) : f(std::move(fIn))
{}
void operator()(const Request& req, Response& res, Args... args)
@@ -315,7 +315,7 @@
using self_t = WebSocketRule;
public:
- WebSocketRule(std::string rule) : BaseRule(std::move(rule))
+ WebSocketRule(std::string ruleIn) : BaseRule(std::move(ruleIn))
{}
void validate() override
@@ -428,7 +428,7 @@
}
template <typename... MethodArgs>
- self_t& requires(std::initializer_list<const char*> l)
+ self_t& privileges(std::initializer_list<const char*> l)
{
self_t* self = static_cast<self_t*>(this);
self->privilegesSet.emplace_back(l);
@@ -436,7 +436,7 @@
}
template <typename... MethodArgs>
- self_t& requires(const std::vector<redfish::Privileges>& p)
+ self_t& privileges(const std::vector<redfish::Privileges>& p)
{
self_t* self = static_cast<self_t*>(this);
for (const redfish::Privileges& privilege : p)
@@ -450,7 +450,7 @@
class DynamicRule : public BaseRule, public RuleParameterTraits<DynamicRule>
{
public:
- DynamicRule(std::string rule) : BaseRule(std::move(rule))
+ DynamicRule(std::string ruleIn) : BaseRule(std::move(ruleIn))
{}
void validate() override
@@ -982,7 +982,7 @@
case ParamType::PATH:
BMCWEB_LOG_DEBUG << "<path>";
break;
- default:
+ case ParamType::MAX:
BMCWEB_LOG_DEBUG << "<ERROR>";
break;
}
@@ -1203,9 +1203,9 @@
// Check to see if this url exists at any verb
for (const PerMethod& p : perMethods)
{
- const std::pair<unsigned, RoutingParams>& found =
+ const std::pair<unsigned, RoutingParams>& found2 =
p.trie.find(req.url);
- if (found.first > 0)
+ if (found2.first > 0)
{
res.result(boost::beast::http::status::method_not_allowed);
res.end();
@@ -1340,7 +1340,7 @@
}
}
- // Get the user privileges from the role
+ // Get the userprivileges from the role
redfish::Privileges userPrivileges =
redfish::getUserPrivileges(userRole);
@@ -1349,10 +1349,10 @@
// value from any previous use of this session.
req.session->isConfigureSelfOnly = passwordExpired;
- // Modify privileges if isConfigureSelfOnly.
+ // Modifyprivileges if isConfigureSelfOnly.
if (req.session->isConfigureSelfOnly)
{
- // Remove all privileges except ConfigureSelf
+ // Remove allprivileges except ConfigureSelf
userPrivileges = userPrivileges.intersection(
redfish::Privileges{"ConfigureSelf"});
BMCWEB_LOG_DEBUG << "Operation limited to ConfigureSelf";
@@ -1384,8 +1384,8 @@
{
for (size_t i = 0; i < perMethods.size(); i++)
{
- BMCWEB_LOG_DEBUG
- << methodName(static_cast<boost::beast::http::verb>(i));
+ BMCWEB_LOG_DEBUG << boost::beast::http::to_string(
+ static_cast<boost::beast::http::verb>(i));
perMethods[i].trie.debugPrint();
}
}
diff --git a/http/utility.h b/http/utility.h
index 8254091..fad212f 100644
--- a/http/utility.h
+++ b/http/utility.h
@@ -39,7 +39,8 @@
}
constexpr char operator[](unsigned i) const
{
- return requiresInRange(i, sizeUint), beginPtr[i];
+ requiresInRange(i, sizeUint);
+ return beginPtr[i];
}
constexpr operator const char*() const
@@ -760,9 +761,8 @@
inline void convertToLinks(std::string& s)
{
// Convert anything with a redfish path into a link
- const static std::regex redfishPath{
- "("((.*))"[ \\n]*:[ "
- "\\n]*)("((?!")/redfish/.*)")"};
+ const std::regex redfishPath{"("((.*))"[ \\n]*:[ "
+ "\\n]*)("((?!")/redfish/.*)")"};
s = std::regex_replace(s, redfishPath, "$1<a href=\"$5\">$4</a>");
}
diff --git a/http/websocket.h b/http/websocket.h
index 7670196..5ec6d0f 100644
--- a/http/websocket.h
+++ b/http/websocket.h
@@ -22,10 +22,12 @@
{
public:
explicit Connection(const crow::Request& reqIn) :
- req(reqIn.req), userdataPtr(nullptr){};
+ req(reqIn.req), userdataPtr(nullptr)
+ {}
explicit Connection(const crow::Request& reqIn, std::string user) :
- req(reqIn.req), userName{std::move(user)}, userdataPtr(nullptr){};
+ req(reqIn.req), userName{std::move(user)}, userdataPtr(nullptr)
+ {}
virtual void sendBinary(const std::string_view msg) = 0;
virtual void sendBinary(std::string&& msg) = 0;
diff --git a/include/async_resp.hpp b/include/async_resp.hpp
index f596dcd..8267c47 100644
--- a/include/async_resp.hpp
+++ b/include/async_resp.hpp
@@ -31,7 +31,7 @@
}
crow::Response& res;
- std::function<void()> func = 0;
+ std::function<void()> func;
};
} // namespace bmcweb
diff --git a/include/dbus_monitor.hpp b/include/dbus_monitor.hpp
index 3630ecf..4a5c7c6 100644
--- a/include/dbus_monitor.hpp
+++ b/include/dbus_monitor.hpp
@@ -114,10 +114,10 @@
return 0;
}
-void requestRoutes(App& app)
+inline void requestRoutes(App& app)
{
BMCWEB_ROUTE(app, "/subscribe")
- .requires({"Login"})
+ .privileges({"Login"})
.websocket()
.onopen([&](crow::websocket::Connection& conn,
std::shared_ptr<bmcweb::AsyncResp> asyncResp) {
diff --git a/include/dump_offload.hpp b/include/dump_offload.hpp
index 1777dfe..bc885cf 100644
--- a/include/dump_offload.hpp
+++ b/include/dump_offload.hpp
@@ -31,10 +31,10 @@
class Handler : public std::enable_shared_from_this<Handler>
{
public:
- Handler(const std::string& media, boost::asio::io_context& ios,
- const std::string& entryID) :
+ Handler(const std::string& mediaIn, boost::asio::io_context& ios,
+ const std::string& entryIDIn) :
pipeOut(ios),
- pipeIn(ios), media(media), entryID(entryID), doingWrite(false),
+ pipeIn(ios), media(mediaIn), entryID(entryIDIn), doingWrite(false),
negotiationDone(false), writeonnbd(false),
outputBuffer(std::make_unique<
boost::beast::flat_static_buffer<nbdBufferSize>>()),
@@ -224,9 +224,9 @@
boost::asio::async_write(
*stream, outputBuffer->data(),
- [this](const boost::system::error_code& ec,
+ [this](const boost::system::error_code& ec2,
std::size_t bytes_transferred) {
- if (ec)
+ if (ec2)
{
BMCWEB_LOG_DEBUG << "Error while writing on socket";
doClose();
diff --git a/include/http_utility.hpp b/include/http_utility.hpp
index 88b0247..e0166e3 100644
--- a/include/http_utility.hpp
+++ b/include/http_utility.hpp
@@ -51,4 +51,4 @@
return escaped.str();
}
-} // namespace http_helpers
\ No newline at end of file
+} // namespace http_helpers
diff --git a/include/ibm/management_console_rest.hpp b/include/ibm/management_console_rest.hpp
index 7cb744e..db1e9f3 100644
--- a/include/ibm/management_console_rest.hpp
+++ b/include/ibm/management_console_rest.hpp
@@ -579,7 +579,7 @@
// allowed only for admin
BMCWEB_ROUTE(app, "/ibm/v1/")
- .requires({"ConfigureComponents", "ConfigureManager"})
+ .privileges({"ConfigureComponents", "ConfigureManager"})
.methods(boost::beast::http::verb::get)(
[](const crow::Request& req, crow::Response& res) {
res.jsonValue["@odata.type"] =
@@ -597,7 +597,7 @@
});
BMCWEB_ROUTE(app, "/ibm/v1/Host/ConfigFiles")
- .requires({"ConfigureComponents", "ConfigureManager"})
+ .privileges({"ConfigureComponents", "ConfigureManager"})
.methods(boost::beast::http::verb::get)(
[](const crow::Request& req, crow::Response& res) {
handleConfigFileList(res);
@@ -605,28 +605,28 @@
BMCWEB_ROUTE(app,
"/ibm/v1/Host/ConfigFiles/Actions/IBMConfigFiles.DeleteAll")
- .requires({"ConfigureComponents", "ConfigureManager"})
+ .privileges({"ConfigureComponents", "ConfigureManager"})
.methods(boost::beast::http::verb::post)(
[](const crow::Request& req, crow::Response& res) {
deleteConfigFiles(res);
});
BMCWEB_ROUTE(app, "/ibm/v1/Host/ConfigFiles/<path>")
- .requires({"ConfigureComponents", "ConfigureManager"})
+ .privileges({"ConfigureComponents", "ConfigureManager"})
.methods(boost::beast::http::verb::put, boost::beast::http::verb::get,
boost::beast::http::verb::delete_)(
[](const crow::Request& req, crow::Response& res,
const std::string& path) { handleFileUrl(req, res, path); });
BMCWEB_ROUTE(app, "/ibm/v1/HMC/LockService")
- .requires({"ConfigureComponents", "ConfigureManager"})
+ .privileges({"ConfigureComponents", "ConfigureManager"})
.methods(boost::beast::http::verb::get)(
[](const crow::Request& req, crow::Response& res) {
getLockServiceData(res);
});
BMCWEB_ROUTE(app, "/ibm/v1/HMC/LockService/Actions/LockService.AcquireLock")
- .requires({"ConfigureComponents", "ConfigureManager"})
+ .privileges({"ConfigureComponents", "ConfigureManager"})
.methods(boost::beast::http::verb::post)(
[](const crow::Request& req, crow::Response& res) {
std::vector<nlohmann::json> body;
@@ -640,7 +640,7 @@
handleAcquireLockAPI(req, res, body);
});
BMCWEB_ROUTE(app, "/ibm/v1/HMC/LockService/Actions/LockService.ReleaseLock")
- .requires({"ConfigureComponents", "ConfigureManager"})
+ .privileges({"ConfigureComponents", "ConfigureManager"})
.methods(boost::beast::http::verb::post)([](const crow::Request& req,
crow::Response& res) {
std::string type;
@@ -670,7 +670,7 @@
}
});
BMCWEB_ROUTE(app, "/ibm/v1/HMC/LockService/Actions/LockService.GetLockList")
- .requires({"ConfigureComponents", "ConfigureManager"})
+ .privileges({"ConfigureComponents", "ConfigureManager"})
.methods(boost::beast::http::verb::post)(
[](const crow::Request& req, crow::Response& res) {
ListOfSessionIds listSessionIds;
@@ -686,7 +686,7 @@
});
BMCWEB_ROUTE(app, "/ibm/v1/HMC/BroadcastService")
- .requires({"ConfigureComponents", "ConfigureManager"})
+ .privileges({"ConfigureComponents", "ConfigureManager"})
.methods(boost::beast::http::verb::post)(
[](const crow::Request& req, crow::Response& res) {
handleBroadcastService(req, res);
diff --git a/include/image_upload.hpp b/include/image_upload.hpp
index af7aeac..a135af9 100644
--- a/include/image_upload.hpp
+++ b/include/image_upload.hpp
@@ -16,7 +16,7 @@
namespace image_upload
{
-std::unique_ptr<sdbusplus::bus::match::match> fwUpdateMatcher;
+static std::unique_ptr<sdbusplus::bus::match::match> fwUpdateMatcher;
inline void uploadImageHandler(const crow::Request& req, crow::Response& res,
const std::string& filename)
@@ -109,10 +109,10 @@
timeout.async_wait(timeoutHandler);
}
-void requestRoutes(App& app)
+inline void requestRoutes(App& app)
{
BMCWEB_ROUTE(app, "/upload/image/<str>")
- .requires({"ConfigureComponents", "ConfigureManager"})
+ .privileges({"ConfigureComponents", "ConfigureManager"})
.methods(boost::beast::http::verb::post, boost::beast::http::verb::put)(
[](const crow::Request& req, crow::Response& res,
const std::string& filename) {
@@ -120,7 +120,7 @@
});
BMCWEB_ROUTE(app, "/upload/image")
- .requires({"ConfigureComponents", "ConfigureManager"})
+ .privileges({"ConfigureComponents", "ConfigureManager"})
.methods(boost::beast::http::verb::post, boost::beast::http::verb::put)(
[](const crow::Request& req, crow::Response& res) {
uploadImageHandler(req, res, "");
diff --git a/include/kvm_websocket.hpp b/include/kvm_websocket.hpp
index 4b56f23..f83c95b 100644
--- a/include/kvm_websocket.hpp
+++ b/include/kvm_websocket.hpp
@@ -16,13 +16,13 @@
class KvmSession
{
public:
- explicit KvmSession(crow::websocket::Connection& conn) :
- conn(conn), hostSocket(conn.get_io_context()), doingWrite(false)
+ explicit KvmSession(crow::websocket::Connection& connIn) :
+ conn(connIn), hostSocket(conn.get_io_context()), doingWrite(false)
{
boost::asio::ip::tcp::endpoint endpoint(
boost::asio::ip::make_address("127.0.0.1"), 5900);
hostSocket.async_connect(
- endpoint, [this, &conn](const boost::system::error_code& ec) {
+ endpoint, [this, &connIn](const boost::system::error_code& ec) {
if (ec)
{
BMCWEB_LOG_ERROR
@@ -30,7 +30,7 @@
<< ", Couldn't connect to KVM socket port: " << ec;
if (ec != boost::asio::error::operation_aborted)
{
- conn.close("Error in connecting to KVM port");
+ connIn.close("Error in connecting to KVM port");
}
return;
}
@@ -159,7 +159,7 @@
sessions.reserve(maxSessions);
BMCWEB_ROUTE(app, "/kvm/0")
- .requires({"ConfigureComponents", "ConfigureManager"})
+ .privileges({"ConfigureComponents", "ConfigureManager"})
.websocket()
.onopen([](crow::websocket::Connection& conn,
std::shared_ptr<bmcweb::AsyncResp> asyncResp) {
diff --git a/include/login_routes.hpp b/include/login_routes.hpp
index bd335e3..55a240e 100644
--- a/include/login_routes.hpp
+++ b/include/login_routes.hpp
@@ -17,7 +17,7 @@
namespace login_routes
{
-void requestRoutes(App& app)
+inline void requestRoutes(App& app)
{
BMCWEB_ROUTE(app, "/login")
.methods(boost::beast::http::verb::post)([](const crow::Request& req,
diff --git a/include/obmc_console.hpp b/include/obmc_console.hpp
index af02dde..036fe5a 100644
--- a/include/obmc_console.hpp
+++ b/include/obmc_console.hpp
@@ -21,7 +21,7 @@
static bool doingWrite = false;
-void doWrite()
+inline void doWrite()
{
if (doingWrite)
{
@@ -59,7 +59,7 @@
});
}
-void doRead()
+inline void doRead()
{
BMCWEB_LOG_DEBUG << "Reading from socket";
host_socket->async_read_some(
@@ -85,7 +85,7 @@
});
}
-void connectHandler(const boost::system::error_code& ec)
+inline void connectHandler(const boost::system::error_code& ec)
{
if (ec)
{
@@ -101,10 +101,10 @@
doRead();
}
-void requestRoutes(App& app)
+inline void requestRoutes(App& app)
{
BMCWEB_ROUTE(app, "/console0")
- .requires({"ConfigureComponents", "ConfigureManager"})
+ .privileges({"ConfigureComponents", "ConfigureManager"})
.websocket()
.onopen([](crow::websocket::Connection& conn,
std::shared_ptr<bmcweb::AsyncResp> asyncResp) {
diff --git a/include/openbmc_dbus_rest.hpp b/include/openbmc_dbus_rest.hpp
index 26904d9..57bfc88 100644
--- a/include/openbmc_dbus_rest.hpp
+++ b/include/openbmc_dbus_rest.hpp
@@ -36,23 +36,29 @@
std::pair<std::string,
std::vector<std::pair<std::string, std::vector<std::string>>>>>;
-const char* notFoundMsg = "404 Not Found";
-const char* badReqMsg = "400 Bad Request";
-const char* methodNotAllowedMsg = "405 Method Not Allowed";
-const char* forbiddenMsg = "403 Forbidden";
-const char* methodFailedMsg = "500 Method Call Failed";
-const char* methodOutputFailedMsg = "500 Method Output Error";
-const char* notFoundDesc =
+const constexpr char* notFoundMsg = "404 Not Found";
+const constexpr char* badReqMsg = "400 Bad Request";
+const constexpr char* methodNotAllowedMsg = "405 Method Not Allowed";
+const constexpr char* forbiddenMsg = "403 Forbidden";
+const constexpr char* methodFailedMsg = "500 Method Call Failed";
+const constexpr char* methodOutputFailedMsg = "500 Method Output Error";
+const constexpr char* notFoundDesc =
"org.freedesktop.DBus.Error.FileNotFound: path or object not found";
-const char* propNotFoundDesc = "The specified property cannot be found";
-const char* noJsonDesc = "No JSON object could be decoded";
-const char* methodNotFoundDesc = "The specified method cannot be found";
-const char* methodNotAllowedDesc = "Method not allowed";
-const char* forbiddenPropDesc = "The specified property cannot be created";
-const char* forbiddenResDesc = "The specified resource cannot be created";
+const constexpr char* propNotFoundDesc =
+ "The specified property cannot be found";
+const constexpr char* noJsonDesc = "No JSON object could be decoded";
+const constexpr char* methodNotFoundDesc =
+ "The specified method cannot be found";
+const constexpr char* methodNotAllowedDesc = "Method not allowed";
+const constexpr char* forbiddenPropDesc =
+ "The specified property cannot be created";
+const constexpr char* forbiddenResDesc =
+ "The specified resource cannot be created";
-void setErrorResponse(crow::Response& res, boost::beast::http::status result,
- const std::string& desc, const std::string_view msg)
+inline void setErrorResponse(crow::Response& res,
+ boost::beast::http::status result,
+ const std::string& desc,
+ const std::string_view msg)
{
res.result(result);
res.jsonValue = {{"data", {{"description", desc}}},
@@ -60,9 +66,9 @@
{"status", "error"}};
}
-void introspectObjects(const std::string& processName,
- const std::string& objectPath,
- std::shared_ptr<bmcweb::AsyncResp> transaction)
+inline void introspectObjects(const std::string& processName,
+ const std::string& objectPath,
+ std::shared_ptr<bmcweb::AsyncResp> transaction)
{
if (transaction->res.jsonValue.is_null())
{
@@ -122,10 +128,9 @@
"Introspect");
}
-void getPropertiesForEnumerate(const std::string& objectPath,
- const std::string& service,
- const std::string& interface,
- std::shared_ptr<bmcweb::AsyncResp> asyncResp)
+inline void getPropertiesForEnumerate(
+ const std::string& objectPath, const std::string& service,
+ const std::string& interface, std::shared_ptr<bmcweb::AsyncResp> asyncResp)
{
BMCWEB_LOG_DEBUG << "getPropertiesForEnumerate " << objectPath << " "
<< service << " " << interface;
@@ -163,7 +168,7 @@
// Find any results that weren't picked up by ObjectManagers, to be
// called after all ObjectManagers are searched for and called.
-void findRemainingObjectsForEnumerate(
+inline void findRemainingObjectsForEnumerate(
const std::string& objectPath, std::shared_ptr<GetSubTreeType> subtree,
std::shared_ptr<bmcweb::AsyncResp> asyncResp)
{
@@ -196,10 +201,10 @@
struct InProgressEnumerateData
{
- InProgressEnumerateData(const std::string& objectPath,
- std::shared_ptr<bmcweb::AsyncResp> asyncResp) :
- objectPath(objectPath),
- asyncResp(asyncResp)
+ InProgressEnumerateData(const std::string& objectPathIn,
+ std::shared_ptr<bmcweb::AsyncResp> asyncRespIn) :
+ objectPath(objectPathIn),
+ asyncResp(asyncRespIn)
{}
~InProgressEnumerateData()
@@ -212,7 +217,7 @@
std::shared_ptr<bmcweb::AsyncResp> asyncResp;
};
-void getManagedObjectsForEnumerate(
+inline void getManagedObjectsForEnumerate(
const std::string& object_name, const std::string& object_manager_path,
const std::string& connection_name,
std::shared_ptr<InProgressEnumerateData> transaction)
@@ -273,7 +278,7 @@
"org.freedesktop.DBus.ObjectManager", "GetManagedObjects");
}
-void findObjectManagerPathForEnumerate(
+inline void findObjectManagerPathForEnumerate(
const std::string& object_name, const std::string& connection_name,
std::shared_ptr<InProgressEnumerateData> transaction)
{
@@ -317,7 +322,8 @@
// Uses GetObject to add the object info about the target /enumerate path to
// the results of GetSubTree, as GetSubTree will not return info for the
// target path, and then continues on enumerating the rest of the tree.
-void getObjectAndEnumerate(std::shared_ptr<InProgressEnumerateData> transaction)
+inline void
+ getObjectAndEnumerate(std::shared_ptr<InProgressEnumerateData> transaction)
{
using GetObjectType =
std::vector<std::pair<std::string, std::vector<std::string>>>;
@@ -395,7 +401,8 @@
// Structure for storing data on an in progress action
struct InProgressActionData
{
- InProgressActionData(crow::Response& res) : res(res){};
+ InProgressActionData(crow::Response& resIn) : res(resIn)
+ {}
~InProgressActionData()
{
// Methods could have been called across different owners
@@ -456,7 +463,7 @@
nlohmann::json arguments;
};
-std::vector<std::string> dbusArgSplit(const std::string& string)
+inline std::vector<std::string> dbusArgSplit(const std::string& string)
{
std::vector<std::string> ret;
if (string.empty())
@@ -504,8 +511,8 @@
return ret;
}
-int convertJsonToDbus(sd_bus_message* m, const std::string& arg_type,
- const nlohmann::json& input_json)
+inline int convertJsonToDbus(sd_bus_message* m, const std::string& arg_type,
+ const nlohmann::json& input_json)
{
int r = 0;
BMCWEB_LOG_DEBUG << "Converting " << input_json.dump()
@@ -657,11 +664,6 @@
{
return -1;
}
- if ((*intValue < std::numeric_limits<int64_t>::lowest()) ||
- (*intValue > std::numeric_limits<int64_t>::max()))
- {
- return -ERANGE;
- }
r = sd_bus_message_append_basic(m, argCode[0], intValue);
if (r < 0)
{
@@ -675,8 +677,7 @@
{
return -1;
}
- if ((*uintValue < std::numeric_limits<uint8_t>::lowest()) ||
- (*uintValue > std::numeric_limits<uint8_t>::max()))
+ if (*uintValue > std::numeric_limits<uint8_t>::max())
{
return -ERANGE;
}
@@ -690,8 +691,7 @@
{
return -1;
}
- if ((*uintValue < std::numeric_limits<uint16_t>::lowest()) ||
- (*uintValue > std::numeric_limits<uint16_t>::max()))
+ if (*uintValue > std::numeric_limits<uint16_t>::max())
{
return -ERANGE;
}
@@ -705,8 +705,7 @@
{
return -1;
}
- if ((*uintValue < std::numeric_limits<uint32_t>::lowest()) ||
- (*uintValue > std::numeric_limits<uint32_t>::max()))
+ if (*uintValue > std::numeric_limits<uint32_t>::max())
{
return -ERANGE;
}
@@ -720,11 +719,6 @@
{
return -1;
}
- if ((*uintValue < std::numeric_limits<uint64_t>::lowest()) ||
- (*uintValue > std::numeric_limits<uint64_t>::max()))
- {
- return -ERANGE;
- }
r = sd_bus_message_append_basic(m, argCode[0], uintValue);
}
else if (argCode == "d")
@@ -885,9 +879,9 @@
int convertDBusToJSON(const std::string& returnType,
sdbusplus::message::message& m, nlohmann::json& response);
-int readDictEntryFromMessage(const std::string& typeCode,
- sdbusplus::message::message& m,
- nlohmann::json& object)
+inline int readDictEntryFromMessage(const std::string& typeCode,
+ sdbusplus::message::message& m,
+ nlohmann::json& object)
{
std::vector<std::string> types = dbusArgSplit(typeCode);
if (types.size() != 2)
@@ -944,8 +938,9 @@
return 0;
}
-int readArrayFromMessage(const std::string& typeCode,
- sdbusplus::message::message& m, nlohmann::json& data)
+inline int readArrayFromMessage(const std::string& typeCode,
+ sdbusplus::message::message& m,
+ nlohmann::json& data)
{
if (typeCode.size() < 2)
{
@@ -1024,8 +1019,9 @@
return 0;
}
-int readStructFromMessage(const std::string& typeCode,
- sdbusplus::message::message& m, nlohmann::json& data)
+inline int readStructFromMessage(const std::string& typeCode,
+ sdbusplus::message::message& m,
+ nlohmann::json& data)
{
if (typeCode.size() < 3)
{
@@ -1065,7 +1061,8 @@
return 0;
}
-int readVariantFromMessage(sdbusplus::message::message& m, nlohmann::json& data)
+inline int readVariantFromMessage(sdbusplus::message::message& m,
+ nlohmann::json& data)
{
const char* containerType;
int r = sd_bus_message_peek_type(m.get(), nullptr, &containerType);
@@ -1100,8 +1097,9 @@
return 0;
}
-int convertDBusToJSON(const std::string& returnType,
- sdbusplus::message::message& m, nlohmann::json& response)
+inline int convertDBusToJSON(const std::string& returnType,
+ sdbusplus::message::message& m,
+ nlohmann::json& response)
{
int r = 0;
const std::vector<std::string> returnTypes = dbusArgSplit(returnType);
@@ -1256,9 +1254,10 @@
return 0;
}
-void handleMethodResponse(std::shared_ptr<InProgressActionData> transaction,
- sdbusplus::message::message& m,
- const std::string& returnType)
+inline void
+ handleMethodResponse(std::shared_ptr<InProgressActionData> transaction,
+ sdbusplus::message::message& m,
+ const std::string& returnType)
{
nlohmann::json data;
@@ -1320,8 +1319,9 @@
}
}
-void findActionOnInterface(std::shared_ptr<InProgressActionData> transaction,
- const std::string& connectionName)
+inline void
+ findActionOnInterface(std::shared_ptr<InProgressActionData> transaction,
+ const std::string& connectionName)
{
BMCWEB_LOG_DEBUG << "findActionOnInterface for connection "
<< connectionName;
@@ -1444,12 +1444,12 @@
crow::connections::systemBus->async_send(
m, [transaction, returnType](
- boost::system::error_code ec,
- sdbusplus::message::message& m) {
- if (ec)
+ boost::system::error_code ec2,
+ sdbusplus::message::message& m2) {
+ if (ec2)
{
transaction->methodFailed = true;
- const sd_bus_error* e = m.get_error();
+ const sd_bus_error* e = m2.get_error();
if (e)
{
@@ -1475,7 +1475,7 @@
transaction->methodPassed = true;
}
- handleMethodResponse(transaction, m,
+ handleMethodResponse(transaction, m2,
returnType);
});
break;
@@ -1490,8 +1490,9 @@
"org.freedesktop.DBus.Introspectable", "Introspect");
}
-void handleAction(const crow::Request& req, crow::Response& res,
- const std::string& objectPath, const std::string& methodName)
+inline void handleAction(const crow::Request& req, crow::Response& res,
+ const std::string& objectPath,
+ const std::string& methodName)
{
BMCWEB_LOG_DEBUG << "handleAction on path: " << objectPath << " and method "
<< methodName;
@@ -1555,8 +1556,8 @@
std::array<std::string, 0>());
}
-void handleDelete(const crow::Request& req, crow::Response& res,
- const std::string& objectPath)
+inline void handleDelete(const crow::Request& req, crow::Response& res,
+ const std::string& objectPath)
{
BMCWEB_LOG_DEBUG << "handleDelete on path: " << objectPath;
@@ -1592,8 +1593,8 @@
std::array<const char*, 0>());
}
-void handleList(crow::Response& res, const std::string& objectPath,
- int32_t depth = 0)
+inline void handleList(crow::Response& res, const std::string& objectPath,
+ int32_t depth = 0)
{
crow::connections::systemBus->async_method_call(
[&res](const boost::system::error_code ec,
@@ -1617,7 +1618,7 @@
depth, std::array<std::string, 0>());
}
-void handleEnumerate(crow::Response& res, const std::string& objectPath)
+inline void handleEnumerate(crow::Response& res, const std::string& objectPath)
{
BMCWEB_LOG_DEBUG << "Doing enumerate on " << objectPath;
auto asyncResp = std::make_shared<bmcweb::AsyncResp>(res);
@@ -1655,8 +1656,8 @@
std::array<const char*, 0>());
}
-void handleGet(crow::Response& res, std::string& objectPath,
- std::string& destProperty)
+inline void handleGet(crow::Response& res, std::string& objectPath,
+ std::string& destProperty)
{
BMCWEB_LOG_DEBUG << "handleGet: " << objectPath << " prop:" << destProperty;
std::shared_ptr<std::string> propertyName =
@@ -1681,7 +1682,7 @@
std::make_shared<nlohmann::json>(nlohmann::json::object());
// The mapper should never give us an empty interface names
// list, but check anyway
- for (const std::pair<std::string, std::vector<std::string>>
+ for (const std::pair<std::string, std::vector<std::string>>&
connection : object_names)
{
const std::vector<std::string>& interfaceNames =
@@ -1704,12 +1705,12 @@
m.append(interface);
crow::connections::systemBus->async_send(
m, [&res, response,
- propertyName](const boost::system::error_code ec,
+ propertyName](const boost::system::error_code ec2,
sdbusplus::message::message& msg) {
- if (ec)
+ if (ec2)
{
BMCWEB_LOG_ERROR << "Bad dbus request error: "
- << ec;
+ << ec2;
}
else
{
@@ -1770,7 +1771,7 @@
struct AsyncPutRequest
{
- AsyncPutRequest(crow::Response& res) : res(res)
+ AsyncPutRequest(crow::Response& resIn) : res(resIn)
{}
~AsyncPutRequest()
{
@@ -1795,8 +1796,9 @@
nlohmann::json propertyValue;
};
-void handlePut(const crow::Request& req, crow::Response& res,
- const std::string& objectPath, const std::string& destProperty)
+inline void handlePut(const crow::Request& req, crow::Response& res,
+ const std::string& objectPath,
+ const std::string& destProperty)
{
if (destProperty.empty())
{
@@ -1835,9 +1837,9 @@
std::vector<std::pair<std::string, std::vector<std::string>>>;
crow::connections::systemBus->async_method_call(
- [transaction](const boost::system::error_code ec,
+ [transaction](const boost::system::error_code ec2,
const GetObjectType& object_names) {
- if (!ec && object_names.size() <= 0)
+ if (!ec2 && object_names.size() <= 0)
{
setErrorResponse(transaction->res,
boost::beast::http::status::not_found,
@@ -1845,20 +1847,20 @@
return;
}
- for (const std::pair<std::string, std::vector<std::string>>
+ for (const std::pair<std::string, std::vector<std::string>>&
connection : object_names)
{
const std::string& connectionName = connection.first;
crow::connections::systemBus->async_method_call(
[connectionName{std::string(connectionName)},
- transaction](const boost::system::error_code ec,
+ transaction](const boost::system::error_code ec3,
const std::string& introspectXml) {
- if (ec)
+ if (ec3)
{
BMCWEB_LOG_ERROR
<< "Introspect call failed with error: "
- << ec.message()
+ << ec3.message()
<< " on process: " << connectionName;
transaction->setErrorStatus("Unexpected Error");
return;
@@ -1951,12 +1953,12 @@
boost::system::error_code
ec,
sdbusplus::message::message&
- m) {
+ m2) {
BMCWEB_LOG_DEBUG << "sent";
if (ec)
{
const sd_bus_error* e =
- m.get_error();
+ m2.get_error();
setErrorResponse(
transaction->res,
boost::beast::http::
@@ -2072,10 +2074,10 @@
res.end();
}
-void requestRoutes(App& app)
+inline void requestRoutes(App& app)
{
BMCWEB_ROUTE(app, "/bus/")
- .requires({"Login"})
+ .privileges({"Login"})
.methods(boost::beast::http::verb::get)(
[](const crow::Request& req, crow::Response& res) {
res.jsonValue = {{"buses", {{{"name", "system"}}}},
@@ -2084,7 +2086,7 @@
});
BMCWEB_ROUTE(app, "/bus/system/")
- .requires({"Login"})
+ .privileges({"Login"})
.methods(boost::beast::http::verb::get)(
[](const crow::Request& req, crow::Response& res) {
auto myCallback = [&res](const boost::system::error_code ec,
@@ -2113,14 +2115,14 @@
});
BMCWEB_ROUTE(app, "/list/")
- .requires({"Login"})
+ .privileges({"Login"})
.methods(boost::beast::http::verb::get)(
[](const crow::Request& req, crow::Response& res) {
handleList(res, "/");
});
BMCWEB_ROUTE(app, "/xyz/<path>")
- .requires({"Login"})
+ .privileges({"Login"})
.methods(boost::beast::http::verb::get)([](const crow::Request& req,
crow::Response& res,
const std::string& path) {
@@ -2129,7 +2131,7 @@
});
BMCWEB_ROUTE(app, "/xyz/<path>")
- .requires({"ConfigureComponents", "ConfigureManager"})
+ .privileges({"ConfigureComponents", "ConfigureManager"})
.methods(boost::beast::http::verb::put, boost::beast::http::verb::post,
boost::beast::http::verb::delete_)(
[](const crow::Request& req, crow::Response& res,
@@ -2139,7 +2141,7 @@
});
BMCWEB_ROUTE(app, "/org/<path>")
- .requires({"Login"})
+ .privileges({"Login"})
.methods(boost::beast::http::verb::get)([](const crow::Request& req,
crow::Response& res,
const std::string& path) {
@@ -2148,7 +2150,7 @@
});
BMCWEB_ROUTE(app, "/org/<path>")
- .requires({"ConfigureComponents", "ConfigureManager"})
+ .privileges({"ConfigureComponents", "ConfigureManager"})
.methods(boost::beast::http::verb::put, boost::beast::http::verb::post,
boost::beast::http::verb::delete_)(
[](const crow::Request& req, crow::Response& res,
@@ -2158,7 +2160,7 @@
});
BMCWEB_ROUTE(app, "/download/dump/<str>/")
- .requires({"ConfigureManager"})
+ .privileges({"ConfigureManager"})
.methods(boost::beast::http::verb::get)([](const crow::Request& req,
crow::Response& res,
const std::string& dumpId) {
@@ -2226,7 +2228,7 @@
});
BMCWEB_ROUTE(app, "/bus/system/<str>/")
- .requires({"Login"})
+ .privileges({"Login"})
.methods(boost::beast::http::verb::get)(
[](const crow::Request& req, crow::Response& res,
@@ -2236,7 +2238,7 @@
});
BMCWEB_ROUTE(app, "/bus/system/<str>/<path>")
- .requires({"ConfigureComponents", "ConfigureManager"})
+ .privileges({"ConfigureComponents", "ConfigureManager"})
.methods(
boost::beast::http::verb::get,
boost::beast::http::verb::post)([](const crow::Request& req,
diff --git a/include/redfish_v1.hpp b/include/redfish_v1.hpp
index 429fb08..cb7af8f 100644
--- a/include/redfish_v1.hpp
+++ b/include/redfish_v1.hpp
@@ -6,7 +6,7 @@
{
namespace redfish
{
-void requestRoutes(App& app)
+inline void requestRoutes(App& app)
{
BMCWEB_ROUTE(app, "/redfish/")
.methods(boost::beast::http::verb::get)(
diff --git a/include/sessions.hpp b/include/sessions.hpp
index 3a787fc..f0de8c9 100644
--- a/include/sessions.hpp
+++ b/include/sessions.hpp
@@ -184,7 +184,7 @@
}
return index;
- };
+ }
uint8_t max()
{
@@ -359,7 +359,7 @@
int64_t getTimeoutInSeconds() const
{
return std::chrono::seconds(timeoutInMinutes).count();
- };
+ }
static SessionStore& getInstance()
{
diff --git a/include/vm_websocket.hpp b/include/vm_websocket.hpp
index 33fadd0..d07469e 100644
--- a/include/vm_websocket.hpp
+++ b/include/vm_websocket.hpp
@@ -154,10 +154,10 @@
static std::shared_ptr<Handler> handler;
-void requestRoutes(App& app)
+inline void requestRoutes(App& app)
{
BMCWEB_ROUTE(app, "/vm/0/0")
- .requires({"ConfigureComponents", "ConfigureManager"})
+ .privileges({"ConfigureComponents", "ConfigureManager"})
.websocket()
.onopen([](crow::websocket::Connection& conn,
std::shared_ptr<bmcweb::AsyncResp> asyncResp) {
diff --git a/include/webassets.hpp b/include/webassets.hpp
index 54d3c98..7e382d8 100644
--- a/include/webassets.hpp
+++ b/include/webassets.hpp
@@ -27,7 +27,7 @@
}
};
-void requestRoutes(App& app)
+inline void requestRoutes(App& app)
{
const static boost::container::flat_map<const char*, const char*, CmpStr>
contentTypes{
diff --git a/redfish-core/include/event_service_manager.hpp b/redfish-core/include/event_service_manager.hpp
index 9c42e06..64c3b7f 100644
--- a/redfish-core/include/event_service_manager.hpp
+++ b/redfish-core/include/event_service_manager.hpp
@@ -48,7 +48,7 @@
"/var/lib/bmcweb/eventservice_config.json";
#ifndef BMCWEB_ENABLE_REDFISH_DBUS_LOG_ENTRIES
-std::shared_ptr<boost::asio::posix::stream_descriptor> inotifyConn = nullptr;
+static std::optional<boost::asio::posix::stream_descriptor> inotifyConn;
static constexpr const char* redfishEventLogDir = "/var/log";
static constexpr const char* redfishEventLogFile = "/var/log/redfish";
static constexpr const size_t iEventSize = sizeof(inotify_event);
@@ -113,8 +113,8 @@
namespace event_log
{
-bool getUniqueEntryID(const std::string& logEntry, std::string& entryID,
- const bool firstEntry = true)
+inline bool getUniqueEntryID(const std::string& logEntry, std::string& entryID,
+ const bool firstEntry = true)
{
static time_t prevTs = 0;
static int index = 0;
@@ -149,9 +149,9 @@
return true;
}
-int getEventLogParams(const std::string& logEntry, std::string& timestamp,
- std::string& messageID,
- std::vector<std::string>& messageArgs)
+inline int getEventLogParams(const std::string& logEntry,
+ std::string& timestamp, std::string& messageID,
+ std::vector<std::string>& messageArgs)
{
// The redfish log format is "<Timestamp> <MessageId>,<MessageArgs>"
// First get the Timestamp
@@ -195,9 +195,9 @@
return 0;
}
-void getRegistryAndMessageKey(const std::string& messageID,
- std::string& registryName,
- std::string& messageKey)
+inline void getRegistryAndMessageKey(const std::string& messageID,
+ std::string& registryName,
+ std::string& messageKey)
{
// Redfish MessageIds are in the form
// RegistryName.MajorVersion.MinorVersion.MessageKey, so parse it to find
@@ -212,11 +212,12 @@
}
}
-int formatEventLogEntry(const std::string& logEntryID,
- const std::string& messageID,
- const std::vector<std::string>& messageArgs,
- std::string timestamp, const std::string customText,
- nlohmann::json& logEntryJson)
+inline int formatEventLogEntry(const std::string& logEntryID,
+ const std::string& messageID,
+ const std::vector<std::string>& messageArgs,
+ std::string timestamp,
+ const std::string customText,
+ nlohmann::json& logEntryJson)
{
// Get the Message from the MessageRegistry
const message_registries::Message* message =
@@ -267,7 +268,7 @@
} // namespace event_log
#endif
-bool isFilterQuerySpecialChar(char c)
+inline bool isFilterQuerySpecialChar(char c)
{
switch (c)
{
@@ -280,10 +281,11 @@
}
}
-bool readSSEQueryParams(std::string sseFilter, std::string& formatType,
- std::vector<std::string>& messageIds,
- std::vector<std::string>& registryPrefixes,
- std::vector<std::string>& metricReportDefinitions)
+inline bool
+ readSSEQueryParams(std::string sseFilter, std::string& formatType,
+ std::vector<std::string>& messageIds,
+ std::vector<std::string>& registryPrefixes,
+ std::vector<std::string>& metricReportDefinitions)
{
sseFilter.erase(std::remove_if(sseFilter.begin(), sseFilter.end(),
isFilterQuerySpecialChar),
@@ -508,12 +510,12 @@
}
#endif
- void filterAndSendReports(const std::string& id,
+ void filterAndSendReports(const std::string& id2,
const std::string& readingsTs,
const ReadingsObjType& readings)
{
std::string metricReportDef =
- "/redfish/v1/TelemetryService/MetricReportDefinitions/" + id;
+ "/redfish/v1/TelemetryService/MetricReportDefinitions/" + id2;
// Empty list means no filter. Send everything.
if (metricReportDefinitions.size())
@@ -541,8 +543,8 @@
nlohmann::json msg = {
{"@odata.id", "/redfish/v1/TelemetryService/MetricReports/" + id},
{"@odata.type", "#MetricReport.v1_3_0.MetricReport"},
- {"Id", id},
- {"Name", id},
+ {"Id", id2},
+ {"Name", id2},
{"Timestamp", readingsTs},
{"MetricReportDefinition", {{"@odata.id", metricReportDef}}},
{"MetricValues", metricValuesArray}};
@@ -924,7 +926,7 @@
std::string addSubscription(const std::shared_ptr<Subscription> subValue,
const bool updateFile = true)
{
- std::srand(static_cast<uint32_t>(std::time(0)));
+ std::srand(static_cast<uint32_t>(std::time(nullptr)));
std::string id;
int retry = 3;
@@ -937,7 +939,7 @@
break;
}
--retry;
- };
+ }
if (retry <= 0)
{
@@ -1199,7 +1201,7 @@
static void watchRedfishEventLogFile()
{
- if (inotifyConn == nullptr)
+ if (inotifyConn)
{
return;
}
@@ -1295,8 +1297,7 @@
static int startEventLogMonitor(boost::asio::io_context& ioc)
{
- inotifyConn =
- std::make_shared<boost::asio::posix::stream_descriptor>(ioc);
+ inotifyConn.emplace(ioc);
inotifyFd = inotify_init1(IN_NONBLOCK);
if (inotifyFd == -1)
{
@@ -1486,6 +1487,6 @@
}
return true;
}
-}; // namespace redfish
+};
} // namespace redfish
diff --git a/redfish-core/include/node.hpp b/redfish-core/include/node.hpp
index be098ca..b21fba5 100644
--- a/redfish-core/include/node.hpp
+++ b/redfish-core/include/node.hpp
@@ -108,7 +108,7 @@
{
if (getRule != nullptr)
{
- getRule->requires(it->second);
+ getRule->privileges(it->second);
}
}
it = entityPrivileges.find(boost::beast::http::verb::post);
@@ -116,7 +116,7 @@
{
if (postRule != nullptr)
{
- postRule->requires(it->second);
+ postRule->privileges(it->second);
}
}
it = entityPrivileges.find(boost::beast::http::verb::patch);
@@ -124,7 +124,7 @@
{
if (patchRule != nullptr)
{
- patchRule->requires(it->second);
+ patchRule->privileges(it->second);
}
}
it = entityPrivileges.find(boost::beast::http::verb::put);
@@ -132,7 +132,7 @@
{
if (putRule != nullptr)
{
- putRule->requires(it->second);
+ putRule->privileges(it->second);
}
}
it = entityPrivileges.find(boost::beast::http::verb::delete_);
@@ -140,7 +140,7 @@
{
if (deleteRule != nullptr)
{
- deleteRule->requires(it->second);
+ deleteRule->privileges(it->second);
}
}
}
diff --git a/redfish-core/include/privileges.hpp b/redfish-core/include/privileges.hpp
index 0282f35..d9bf1fc 100644
--- a/redfish-core/include/privileges.hpp
+++ b/redfish-core/include/privileges.hpp
@@ -45,8 +45,9 @@
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(),
- basePrivileges.end()};
+static const std::array<std::string, maxPrivilegeCount> privilegeNames{
+ "Login", "ConfigureManager", "ConfigureComponents", "ConfigureSelf",
+ "ConfigureUsers"};
/**
* @brief Redfish privileges
@@ -100,7 +101,7 @@
* @return None
*
*/
- bool setSinglePrivilege(const char* privilege)
+ bool setSinglePrivilege(const std::string_view privilege)
{
for (size_t searchIndex = 0; searchIndex < privilegeNames.size();
searchIndex++)
@@ -116,19 +117,6 @@
}
/**
- * @brief Sets given privilege in the bitset
- *
- * @param[in] privilege Privilege to be set
- *
- * @return None
- *
- */
- bool setSinglePrivilege(const std::string& privilege)
- {
- return setSinglePrivilege(privilege.c_str());
- }
-
- /**
* @brief Resets the given privilege in the bitset
*
* @param[in] privilege Privilege to be reset
@@ -159,10 +147,10 @@
* the setSinglePrivilege is called, or the Privilege structure is destroyed
*
*/
- std::vector<const std::string*>
+ std::vector<std::string>
getActivePrivilegeNames(const PrivilegeType type) const
{
- std::vector<const std::string*> activePrivileges;
+ std::vector<std::string> activePrivileges;
size_t searchIndex = 0;
size_t endIndex = basePrivilegeCount;
@@ -176,7 +164,7 @@
{
if (privilegeBitset.test(searchIndex))
{
- activePrivileges.emplace_back(&privilegeNames[searchIndex]);
+ activePrivileges.emplace_back(privilegeNames[searchIndex]);
}
}
diff --git a/redfish-core/include/server_sent_events.hpp b/redfish-core/include/server_sent_events.hpp
index 1c4d2a5..9f0da8f 100644
--- a/redfish-core/include/server_sent_events.hpp
+++ b/redfish-core/include/server_sent_events.hpp
@@ -229,6 +229,8 @@
case SseConnState::initInProgress:
case SseConnState::sendInProgress:
case SseConnState::suspended:
+ case SseConnState::startInit:
+ case SseConnState::closed:
// do nothing
break;
case SseConnState::initFailed:
@@ -245,8 +247,6 @@
sendEvent(std::to_string(reqData.first), reqData.second);
break;
}
- default:
- break;
}
return;
diff --git a/redfish-core/include/task_messages.hpp b/redfish-core/include/task_messages.hpp
index 050cc63..33c2db5 100644
--- a/redfish-core/include/task_messages.hpp
+++ b/redfish-core/include/task_messages.hpp
@@ -20,7 +20,7 @@
namespace messages
{
-nlohmann::json taskAborted(const std::string& arg1)
+inline nlohmann::json taskAborted(const std::string& arg1)
{
return nlohmann::json{
{"@odata.type", "#Message.v1_0_0.Message"},
@@ -31,7 +31,7 @@
{"Resolution", "None."}};
}
-nlohmann::json taskCancelled(const std::string& arg1)
+inline nlohmann::json taskCancelled(const std::string& arg1)
{
return nlohmann::json{
{"@odata.type", "#Message.v1_0_0.Message"},
@@ -42,7 +42,7 @@
{"Resolution", "None."}};
}
-nlohmann::json taskCompletedOK(const std::string& arg1)
+inline nlohmann::json taskCompletedOK(const std::string& arg1)
{
return nlohmann::json{
{"@odata.type", "#Message.v1_0_0.Message"},
@@ -53,7 +53,7 @@
{"Resolution", "None."}};
}
-nlohmann::json taskCompletedWarning(const std::string& arg1)
+inline nlohmann::json taskCompletedWarning(const std::string& arg1)
{
return nlohmann::json{{"@odata.type", "#Message.v1_0_0.Message"},
{"MessageId", "TaskEvent.1.0.1.TaskCompletedWarning"},
@@ -64,7 +64,7 @@
{"Resolution", "None."}};
}
-nlohmann::json taskPaused(const std::string& arg1)
+inline nlohmann::json taskPaused(const std::string& arg1)
{
return nlohmann::json{
{"@odata.type", "#Message.v1_0_0.Message"},
@@ -75,7 +75,8 @@
{"Resolution", "None."}};
}
-nlohmann::json taskProgressChanged(const std::string& arg1, const size_t arg2)
+inline nlohmann::json taskProgressChanged(const std::string& arg1,
+ const size_t arg2)
{
return nlohmann::json{
{"@odata.type", "#Message.v1_0_0.Message"},
@@ -87,7 +88,7 @@
{"Resolution", "None."}};
}
-nlohmann::json taskRemoved(const std::string& arg1)
+inline nlohmann::json taskRemoved(const std::string& arg1)
{
return nlohmann::json{
{"@odata.type", "#Message.v1_0_0.Message"},
@@ -98,7 +99,7 @@
{"Resolution", "None."}};
}
-nlohmann::json taskResumed(const std::string& arg1)
+inline nlohmann::json taskResumed(const std::string& arg1)
{
return nlohmann::json{
{"@odata.type", "#Message.v1_0_0.Message"},
@@ -109,7 +110,7 @@
{"Resolution", "None."}};
}
-nlohmann::json taskStarted(const std::string& arg1)
+inline nlohmann::json taskStarted(const std::string& arg1)
{
return nlohmann::json{
{"@odata.type", "#Message.v1_0_0.Message"},
diff --git a/redfish-core/include/utils/fw_utils.hpp b/redfish-core/include/utils/fw_utils.hpp
index 95d684f..65f19ca 100644
--- a/redfish-core/include/utils/fw_utils.hpp
+++ b/redfish-core/include/utils/fw_utils.hpp
@@ -28,10 +28,10 @@
*
* @return void
*/
-void getActiveFwVersion(std::shared_ptr<AsyncResp> aResp,
- const std::string& fwVersionPurpose,
- const std::string& activeVersionPropName,
- const bool populateLinkToActiveImage)
+inline void getActiveFwVersion(std::shared_ptr<AsyncResp> aResp,
+ const std::string& fwVersionPurpose,
+ const std::string& activeVersionPropName,
+ const bool populateLinkToActiveImage)
{
// Get active FW images
crow::connections::systemBus->async_method_call(
@@ -80,13 +80,13 @@
crow::connections::systemBus->async_method_call(
[aResp, fw, swId, fwVersionPurpose, activeVersionPropName,
populateLinkToActiveImage](
- const boost::system::error_code ec,
+ const boost::system::error_code ec2,
const std::vector<std::pair<
std::string, std::vector<std::string>>>& objInfo) {
- if (ec)
+ if (ec2)
{
- BMCWEB_LOG_DEBUG << "error_code = " << ec;
- BMCWEB_LOG_DEBUG << "error msg = " << ec.message();
+ BMCWEB_LOG_DEBUG << "error_code = " << ec2;
+ BMCWEB_LOG_DEBUG << "error msg = " << ec2.message();
messages::internalError(aResp->res);
return;
}
@@ -116,16 +116,16 @@
crow::connections::systemBus->async_method_call(
[aResp, swId, fwVersionPurpose,
activeVersionPropName, populateLinkToActiveImage](
- const boost::system::error_code ec,
+ const boost::system::error_code ec3,
const boost::container::flat_map<
std::string,
std::variant<bool, std::string, uint64_t,
uint32_t>>& propertiesList) {
- if (ec)
+ if (ec3)
{
- BMCWEB_LOG_ERROR << "error_code = " << ec;
+ BMCWEB_LOG_ERROR << "error_code = " << ec3;
BMCWEB_LOG_ERROR << "error msg = "
- << ec.message();
+ << ec3.message();
messages::internalError(aResp->res);
return;
}
@@ -230,7 +230,7 @@
*
* @return The corresponding Redfish state
*/
-std::string getRedfishFWState(const std::string& fwState)
+inline std::string getRedfishFWState(const std::string& fwState)
{
if (fwState == "xyz.openbmc_project.Software.Activation.Activations.Active")
{
@@ -262,7 +262,7 @@
*
* @return The corresponding Redfish health state
*/
-std::string getRedfishFWHealth(const std::string& fwState)
+inline std::string getRedfishFWHealth(const std::string& fwState)
{
if ((fwState ==
"xyz.openbmc_project.Software.Activation.Activations.Active") ||
@@ -292,9 +292,9 @@
*
* @return void
*/
-void getFwStatus(std::shared_ptr<AsyncResp> asyncResp,
- const std::shared_ptr<std::string> swId,
- const std::string& dbusSvc)
+inline void getFwStatus(std::shared_ptr<AsyncResp> asyncResp,
+ const std::shared_ptr<std::string> swId,
+ const std::string& dbusSvc)
{
BMCWEB_LOG_DEBUG << "getFwStatus: swId " << *swId << " svc " << dbusSvc;
@@ -350,8 +350,8 @@
* @param[i,o] asyncResp Async response object
* @param[i] fwId The firmware ID
*/
-void getFwUpdateableStatus(std::shared_ptr<AsyncResp> asyncResp,
- const std::shared_ptr<std::string> fwId)
+inline void getFwUpdateableStatus(std::shared_ptr<AsyncResp> asyncResp,
+ const std::shared_ptr<std::string> fwId)
{
crow::connections::systemBus->async_method_call(
[asyncResp, fwId](const boost::system::error_code ec,
diff --git a/redfish-core/include/utils/systemd_utils.hpp b/redfish-core/include/utils/systemd_utils.hpp
index da1b4e2..0db1d94 100644
--- a/redfish-core/include/utils/systemd_utils.hpp
+++ b/redfish-core/include/utils/systemd_utils.hpp
@@ -29,7 +29,7 @@
* @return Service root UUID
*/
-const std::string getUuid()
+inline const std::string getUuid()
{
std::string ret;
// This ID needs to match the one in ipmid
diff --git a/redfish-core/lib/account_service.hpp b/redfish-core/lib/account_service.hpp
index 0522149..b8517b4 100644
--- a/redfish-core/lib/account_service.hpp
+++ b/redfish-core/lib/account_service.hpp
@@ -27,7 +27,7 @@
namespace redfish
{
-constexpr const char* ldapConfigObject =
+constexpr const char* ldapConfigObjectName =
"/xyz/openbmc_project/user/ldap/openldap";
constexpr const char* ADConfigObject =
"/xyz/openbmc_project/user/ldap/active_directory";
@@ -118,10 +118,10 @@
return "";
}
-void userErrorMessageHandler(const sd_bus_error* e,
- std::shared_ptr<AsyncResp> asyncResp,
- const std::string& newUser,
- const std::string& username)
+inline void userErrorMessageHandler(const sd_bus_error* e,
+ std::shared_ptr<AsyncResp> asyncResp,
+ const std::string& newUser,
+ const std::string& username)
{
const char* errorMessage = e->name;
if (e == nullptr)
@@ -166,9 +166,9 @@
return;
}
-void parseLDAPConfigData(nlohmann::json& json_response,
- const LDAPConfigData& confData,
- const std::string& ldapType)
+inline void parseLDAPConfigData(nlohmann::json& json_response,
+ const LDAPConfigData& confData,
+ const std::string& ldapType)
{
std::string service =
(ldapType == "LDAP") ? "LDAPService" : "ActiveDirectoryService";
@@ -207,7 +207,7 @@
* create, to delete or to set Rolemapping object based on the given input.
*
*/
-static void handleRoleMapPatch(
+inline void handleRoleMapPatch(
const std::shared_ptr<AsyncResp>& asyncResp,
const std::vector<std::pair<std::string, LDAPRoleMapData>>& roleMapObjData,
const std::string& serverType, std::vector<nlohmann::json>& input)
@@ -344,7 +344,7 @@
}
else if (serverType == "LDAP")
{
- dbusObjectPath = ldapConfigObject;
+ dbusObjectPath = ldapConfigObjectName;
}
BMCWEB_LOG_DEBUG << "Remote Group=" << *remoteGroup
@@ -389,13 +389,13 @@
crow::connections::systemBus->async_method_call(
[callback, ldapType](const boost::system::error_code ec,
const GetObjectType& resp) {
- LDAPConfigData confData{};
if (ec || resp.empty())
{
BMCWEB_LOG_ERROR << "DBUS response error during getting of "
"service name: "
<< ec;
- callback(false, confData, ldapType);
+ LDAPConfigData empty{};
+ callback(false, empty, ldapType);
return;
}
std::string service = resp.begin()->first;
@@ -551,14 +551,13 @@
"GetManagedObjects");
},
mapperBusName, mapperObjectPath, mapperIntf, "GetObject",
- ldapConfigObject, interfaces);
+ ldapConfigObjectName, interfaces);
}
class AccountService : public Node
{
public:
- AccountService(App& app) :
- Node(app, "/redfish/v1/AccountService/"), app(app)
+ AccountService(App& app) : Node(app, "/redfish/v1/AccountService/")
{
entityPrivileges = {
{boost::beast::http::verb::get, {{"Login"}}},
@@ -977,7 +976,7 @@
}
else if (serverType == "LDAP")
{
- dbusObjectPath = ldapConfigObject;
+ dbusObjectPath = ldapConfigObjectName;
}
std::optional<nlohmann::json> authentication;
@@ -1045,51 +1044,51 @@
serviceEnabled, dbusObjectPath,
remoteRoleMapData](
bool success, LDAPConfigData confData,
- const std::string& serverType) {
+ const std::string& serverT) {
if (!success)
{
messages::internalError(asyncResp->res);
return;
}
- parseLDAPConfigData(asyncResp->res.jsonValue, confData, serverType);
+ parseLDAPConfigData(asyncResp->res.jsonValue, confData, serverT);
if (confData.serviceEnabled)
{
// Disable the service first and update the rest of
// the properties.
- handleServiceEnablePatch(false, asyncResp, serverType,
+ handleServiceEnablePatch(false, asyncResp, serverT,
dbusObjectPath);
}
if (serviceAddressList)
{
handleServiceAddressPatch(*serviceAddressList, asyncResp,
- serverType, dbusObjectPath);
+ serverT, dbusObjectPath);
}
if (userName)
{
- handleUserNamePatch(*userName, asyncResp, serverType,
+ handleUserNamePatch(*userName, asyncResp, serverT,
dbusObjectPath);
}
if (password)
{
- handlePasswordPatch(*password, asyncResp, serverType,
+ handlePasswordPatch(*password, asyncResp, serverT,
dbusObjectPath);
}
if (baseDNList)
{
- handleBaseDNPatch(*baseDNList, asyncResp, serverType,
+ handleBaseDNPatch(*baseDNList, asyncResp, serverT,
dbusObjectPath);
}
if (userNameAttribute)
{
- handleUserNameAttrPatch(*userNameAttribute, asyncResp,
- serverType, dbusObjectPath);
+ handleUserNameAttrPatch(*userNameAttribute, asyncResp, serverT,
+ dbusObjectPath);
}
if (groupsAttribute)
{
- handleGroupNameAttrPatch(*groupsAttribute, asyncResp,
- serverType, dbusObjectPath);
+ handleGroupNameAttrPatch(*groupsAttribute, asyncResp, serverT,
+ dbusObjectPath);
}
if (serviceEnabled)
{
@@ -1099,7 +1098,7 @@
if (*serviceEnabled)
{
handleServiceEnablePatch(*serviceEnabled, asyncResp,
- serverType, dbusObjectPath);
+ serverT, dbusObjectPath);
}
}
else
@@ -1108,7 +1107,7 @@
// then revert it to the same state as it was
// before.
handleServiceEnablePatch(confData.serviceEnabled, asyncResp,
- serverType, dbusObjectPath);
+ serverT, dbusObjectPath);
}
if (remoteRoleMapData)
@@ -1116,8 +1115,8 @@
std::vector<nlohmann::json> remoteRoleMap =
std::move(*remoteRoleMapData);
- handleRoleMapPatch(asyncResp, confData.groupRoleList,
- serverType, remoteRoleMap);
+ handleRoleMapPatch(asyncResp, confData.groupRoleList, serverT,
+ remoteRoleMap);
}
});
}
@@ -1312,8 +1311,6 @@
std::variant<uint16_t>(*lockoutThreshold));
}
}
-
- App& app;
};
class AccountsCollection : public Node
@@ -1453,9 +1450,9 @@
crow::connections::systemBus->async_method_call(
[asyncResp, username, password{std::move(password)}](
- const boost::system::error_code ec,
+ const boost::system::error_code ec2,
sdbusplus::message::message& m) {
- if (ec)
+ if (ec2)
{
userErrorMessageHandler(m.get_error(), asyncResp,
username, "");
@@ -1469,9 +1466,9 @@
// but the password set failed.Something is wrong,
// so delete the user that we've already created
crow::connections::systemBus->async_method_call(
- [asyncResp,
- password](const boost::system::error_code ec) {
- if (ec)
+ [asyncResp, password](
+ const boost::system::error_code ec3) {
+ if (ec3)
{
messages::internalError(asyncResp->res);
return;
diff --git a/redfish-core/lib/certificate_service.hpp b/redfish-core/lib/certificate_service.hpp
index 6ade4e5..e237fd3 100644
--- a/redfish-core/lib/certificate_service.hpp
+++ b/redfish-core/lib/certificate_service.hpp
@@ -97,7 +97,7 @@
* @param[in] path URL
* @return -1 on failure and number on success
*/
-long getIDFromURL(const std::string_view url)
+inline long getIDFromURL(const std::string_view url)
{
std::size_t found = url.rfind("/");
if (found == std::string::npos)
@@ -115,7 +115,7 @@
return -1;
}
-std::string
+inline std::string
getCertificateFromReqBody(const std::shared_ptr<AsyncResp>& asyncResp,
const crow::Request& req)
{
@@ -180,11 +180,9 @@
if (std::filesystem::exists(certDirectory))
{
BMCWEB_LOG_DEBUG << "Removing certificate file" << certificateFile;
- try
- {
- std::filesystem::remove_all(certDirectory);
- }
- catch (const std::filesystem::filesystem_error& e)
+ std::error_code ec;
+ std::filesystem::remove_all(certDirectory, ec);
+ if (ec)
{
BMCWEB_LOG_ERROR << "Failed to remove temp directory"
<< certDirectory;
diff --git a/redfish-core/lib/chassis.hpp b/redfish-core/lib/chassis.hpp
index ce0a8c1..10b0798 100644
--- a/redfish-core/lib/chassis.hpp
+++ b/redfish-core/lib/chassis.hpp
@@ -33,7 +33,7 @@
*
* @return None.
*/
-void getChassisState(std::shared_ptr<AsyncResp> aResp)
+inline void getChassisState(std::shared_ptr<AsyncResp> aResp)
{
crow::connections::systemBus->async_method_call(
[aResp{std::move(aResp)}](
@@ -85,9 +85,9 @@
using PropertiesType = boost::container::flat_map<std::string, VariantType>;
-void getIntrusionByService(std::shared_ptr<AsyncResp> aResp,
- const std::string& service,
- const std::string& objPath)
+inline void getIntrusionByService(std::shared_ptr<AsyncResp> aResp,
+ const std::string& service,
+ const std::string& objPath)
{
BMCWEB_LOG_DEBUG << "Get intrusion status by service \n";
@@ -120,7 +120,7 @@
/**
* Retrieves physical security properties over dbus
*/
-void getPhysicalSecurityData(std::shared_ptr<AsyncResp> aResp)
+inline void getPhysicalSecurityData(std::shared_ptr<AsyncResp> aResp)
{
crow::connections::systemBus->async_method_call(
[aResp{std::move(aResp)}](
@@ -289,9 +289,9 @@
auto health = std::make_shared<HealthPopulate>(asyncResp);
crow::connections::systemBus->async_method_call(
- [health](const boost::system::error_code ec,
+ [health](const boost::system::error_code ec2,
std::variant<std::vector<std::string>>& resp) {
- if (ec)
+ if (ec2)
{
return; // no sensors = no failures
}
@@ -335,7 +335,7 @@
const std::string& connectionName =
connectionNames[0].first;
- const std::vector<std::string>& interfaces =
+ const std::vector<std::string>& interfaces2 =
connectionNames[0].second;
const std::array<const char*, 2> hasIndicatorLed = {
"xyz.openbmc_project.Inventory.Item.Panel",
@@ -343,8 +343,8 @@
for (const char* interface : hasIndicatorLed)
{
- if (std::find(interfaces.begin(), interfaces.end(),
- interface) != interfaces.end())
+ if (std::find(interfaces2.begin(), interfaces2.end(),
+ interface) != interfaces2.end())
{
getIndicatorLedState(asyncResp);
break;
@@ -353,7 +353,7 @@
crow::connections::systemBus->async_method_call(
[asyncResp, chassisId(std::string(chassisId))](
- const boost::system::error_code ec,
+ const boost::system::error_code ec2,
const std::vector<std::pair<
std::string, VariantType>>& propertiesList) {
for (const std::pair<std::string, VariantType>&
@@ -480,7 +480,7 @@
continue;
}
- const std::vector<std::string>& interfaces =
+ const std::vector<std::string>& interfaces3 =
connectionNames[0].second;
if (indicatorLed)
@@ -492,8 +492,9 @@
bool indicatorChassis = false;
for (const char* interface : hasIndicatorLed)
{
- if (std::find(interfaces.begin(), interfaces.end(),
- interface) != interfaces.end())
+ if (std::find(interfaces3.begin(),
+ interfaces3.end(),
+ interface) != interfaces3.end())
{
indicatorChassis = true;
break;
@@ -523,7 +524,7 @@
}
};
-void doChassisPowerCycle(std::shared_ptr<AsyncResp> asyncResp)
+inline void doChassisPowerCycle(std::shared_ptr<AsyncResp> asyncResp)
{
const char* processName = "xyz.openbmc_project.State.Chassis";
const char* objectPath = "/xyz/openbmc_project/state/chassis0";
diff --git a/redfish-core/lib/cpudimm.hpp b/redfish-core/lib/cpudimm.hpp
index 0510f2b..b4178b4 100644
--- a/redfish-core/lib/cpudimm.hpp
+++ b/redfish-core/lib/cpudimm.hpp
@@ -29,9 +29,9 @@
std::string,
boost::container::flat_map<std::string, dbus::utility::DbusVariantType>>;
-void getResourceList(std::shared_ptr<AsyncResp> aResp,
- const std::string& subclass,
- const std::vector<const char*>& collectionName)
+inline void getResourceList(std::shared_ptr<AsyncResp> aResp,
+ const std::string& subclass,
+ const std::vector<const char*>& collectionName)
{
BMCWEB_LOG_DEBUG << "Get available system cpu/mem resources.";
crow::connections::systemBus->async_method_call(
@@ -69,8 +69,9 @@
"/xyz/openbmc_project/inventory", 0, collectionName);
}
-void getCpuDataByInterface(std::shared_ptr<AsyncResp> aResp,
- const InterfacesProperties& cpuInterfacesProperties)
+inline void
+ getCpuDataByInterface(std::shared_ptr<AsyncResp> aResp,
+ const InterfacesProperties& cpuInterfacesProperties)
{
BMCWEB_LOG_DEBUG << "Get CPU resources by interface.";
@@ -193,9 +194,10 @@
return;
}
-void getCpuDataByService(std::shared_ptr<AsyncResp> aResp,
- const std::string& cpuId, const std::string& service,
- const std::string& objPath)
+inline void getCpuDataByService(std::shared_ptr<AsyncResp> aResp,
+ const std::string& cpuId,
+ const std::string& service,
+ const std::string& objPath)
{
BMCWEB_LOG_DEBUG << "Get available system cpu resources by service.";
@@ -263,8 +265,9 @@
"org.freedesktop.DBus.ObjectManager", "GetManagedObjects");
}
-void getCpuAssetData(std::shared_ptr<AsyncResp> aResp,
- const std::string& service, const std::string& objPath)
+inline void getCpuAssetData(std::shared_ptr<AsyncResp> aResp,
+ const std::string& service,
+ const std::string& objPath)
{
BMCWEB_LOG_DEBUG << "Get Cpu Asset Data";
crow::connections::systemBus->async_method_call(
@@ -306,10 +309,10 @@
"xyz.openbmc_project.Inventory.Decorator.Asset");
}
-void getAcceleratorDataByService(std::shared_ptr<AsyncResp> aResp,
- const std::string& acclrtrId,
- const std::string& service,
- const std::string& objPath)
+inline void getAcceleratorDataByService(std::shared_ptr<AsyncResp> aResp,
+ const std::string& acclrtrId,
+ const std::string& service,
+ const std::string& objPath)
{
BMCWEB_LOG_DEBUG
<< "Get available system Accelerator resources by service.";
@@ -365,8 +368,9 @@
service, objPath, "org.freedesktop.DBus.Properties", "GetAll", "");
}
-void getCpuData(std::shared_ptr<AsyncResp> aResp, const std::string& cpuId,
- const std::vector<const char*> inventoryItems)
+inline void getCpuData(std::shared_ptr<AsyncResp> aResp,
+ const std::string& cpuId,
+ const std::vector<const char*> inventoryItems)
{
BMCWEB_LOG_DEBUG << "Get available system cpu resources.";
@@ -891,8 +895,9 @@
service, objPath, "org.freedesktop.DBus.Properties", "GetAll", "");
}
-void getDimmPartitionData(std::shared_ptr<AsyncResp> aResp,
- const std::string& service, const std::string& path)
+inline void getDimmPartitionData(std::shared_ptr<AsyncResp> aResp,
+ const std::string& service,
+ const std::string& path)
{
crow::connections::systemBus->async_method_call(
[aResp{std::move(aResp)}](
@@ -958,7 +963,8 @@
"xyz.openbmc_project.Inventory.Item.PersistentMemory.Partition");
}
-void getDimmData(std::shared_ptr<AsyncResp> aResp, const std::string& dimmId)
+inline void getDimmData(std::shared_ptr<AsyncResp> aResp,
+ const std::string& dimmId)
{
BMCWEB_LOG_DEBUG << "Get available system dimm resources.";
crow::connections::systemBus->async_method_call(
diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp
index a47d4b1..852b3b7 100644
--- a/redfish-core/lib/ethernet.hpp
+++ b/redfish-core/lib/ethernet.hpp
@@ -669,9 +669,9 @@
firstZeroInByteHit = false;
// Count bits
- for (int bitIdx = 7; bitIdx >= 0; bitIdx--)
+ for (long bitIdx = 7; bitIdx >= 0; bitIdx--)
{
- if (value & (1 << bitIdx))
+ if (value & (1L << bitIdx))
{
if (firstZeroInByteHit)
{
@@ -777,8 +777,8 @@
messages::internalError(asyncResp->res);
}
crow::connections::systemBus->async_method_call(
- [asyncResp](const boost::system::error_code ec) {
- if (ec)
+ [asyncResp](const boost::system::error_code ec2) {
+ if (ec2)
{
messages::internalError(asyncResp->res);
}
@@ -843,8 +843,8 @@
messages::internalError(asyncResp->res);
}
crow::connections::systemBus->async_method_call(
- [asyncResp](const boost::system::error_code ec) {
- if (ec)
+ [asyncResp](const boost::system::error_code ec2) {
+ if (ec2)
{
messages::internalError(asyncResp->res);
}
diff --git a/redfish-core/lib/event_service.hpp b/redfish-core/lib/event_service.hpp
index 26cd80a..fa06fcf 100644
--- a/redfish-core/lib/event_service.hpp
+++ b/redfish-core/lib/event_service.hpp
@@ -233,7 +233,7 @@
std::string protocol;
std::optional<std::string> context;
std::optional<std::string> subscriptionType;
- std::optional<std::string> eventFormatType;
+ std::optional<std::string> eventFormatType2;
std::optional<std::string> retryPolicy;
std::optional<std::vector<std::string>> msgIds;
std::optional<std::vector<std::string>> regPrefixes;
@@ -244,7 +244,7 @@
if (!json_util::readJson(
req, res, "Destination", destUrl, "Context", context,
"Protocol", protocol, "SubscriptionType", subscriptionType,
- "EventFormatType", eventFormatType, "HttpHeaders", headers,
+ "EventFormatType", eventFormatType2, "HttpHeaders", headers,
"RegistryPrefixes", regPrefixes, "MessageIds", msgIds,
"DeliveryRetryPolicy", retryPolicy, "MetricReportDefinitions",
mrdJsonArray, "ResourceTypes", resTypes))
@@ -328,22 +328,22 @@
}
subValue->protocol = protocol;
- if (eventFormatType)
+ if (eventFormatType2)
{
if (std::find(supportedEvtFormatTypes.begin(),
supportedEvtFormatTypes.end(),
- *eventFormatType) == supportedEvtFormatTypes.end())
+ *eventFormatType2) == supportedEvtFormatTypes.end())
{
messages::propertyValueNotInList(
- asyncResp->res, *eventFormatType, "EventFormatType");
+ asyncResp->res, *eventFormatType2, "EventFormatType");
return;
}
- subValue->eventFormatType = *eventFormatType;
+ subValue->eventFormatType = *eventFormatType2;
}
else
{
// If not specified, use default "Event"
- subValue->eventFormatType.assign({"Event"});
+ subValue->eventFormatType = "Event";
}
if (context)
@@ -522,7 +522,7 @@
else
{
// If nothing specified, using default "Event"
- subValue->eventFormatType.assign({"Event"});
+ subValue->eventFormatType = "Event";
}
if (!subValue->registryPrefixes.empty())
diff --git a/redfish-core/lib/health.hpp b/redfish-core/lib/health.hpp
index 59c8a27..4f21b3e 100644
--- a/redfish-core/lib/health.hpp
+++ b/redfish-core/lib/health.hpp
@@ -28,13 +28,13 @@
struct HealthPopulate : std::enable_shared_from_this<HealthPopulate>
{
- HealthPopulate(const std::shared_ptr<AsyncResp>& asyncResp) :
- asyncResp(asyncResp), jsonStatus(asyncResp->res.jsonValue["Status"])
+ HealthPopulate(const std::shared_ptr<AsyncResp>& asyncRespIn) :
+ asyncResp(asyncRespIn), jsonStatus(asyncResp->res.jsonValue["Status"])
{}
- HealthPopulate(const std::shared_ptr<AsyncResp>& asyncResp,
+ HealthPopulate(const std::shared_ptr<AsyncResp>& asyncRespIn,
nlohmann::json& status) :
- asyncResp(asyncResp),
+ asyncResp(asyncRespIn),
jsonStatus(status)
{}
@@ -46,10 +46,10 @@
health = "OK";
rollup = "OK";
- for (const std::shared_ptr<HealthPopulate>& health : children)
+ for (const std::shared_ptr<HealthPopulate>& healthChild : children)
{
- health->globalInventoryPath = globalInventoryPath;
- health->statuses = statuses;
+ healthChild->globalInventoryPath = globalInventoryPath;
+ healthChild->statuses = statuses;
}
for (const auto& [path, interfaces] : statuses)
@@ -232,4 +232,4 @@
std::string globalInventoryPath = "-"; // default to illegal dbus path
bool populated = false;
};
-} // namespace redfish
\ No newline at end of file
+} // namespace redfish
diff --git a/redfish-core/lib/led.hpp b/redfish-core/lib/led.hpp
index 25248f8..a2a5bc9 100644
--- a/redfish-core/lib/led.hpp
+++ b/redfish-core/lib/led.hpp
@@ -30,7 +30,7 @@
*
* @return None.
*/
-void getIndicatorLedState(std::shared_ptr<AsyncResp> aResp)
+inline void getIndicatorLedState(std::shared_ptr<AsyncResp> aResp)
{
BMCWEB_LOG_DEBUG << "Get led groups";
crow::connections::systemBus->async_method_call(
@@ -55,11 +55,11 @@
}
}
crow::connections::systemBus->async_method_call(
- [aResp](const boost::system::error_code ec,
- const std::variant<bool> asserted) {
- if (!ec)
+ [aResp](const boost::system::error_code ec2,
+ const std::variant<bool> asserted2) {
+ if (!ec2)
{
- const bool* ledOn = std::get_if<bool>(&asserted);
+ const bool* ledOn = std::get_if<bool>(&asserted2);
if (!ledOn)
{
BMCWEB_LOG_DEBUG
@@ -98,8 +98,8 @@
*
* @return None.
*/
-void setIndicatorLedState(std::shared_ptr<AsyncResp> aResp,
- const std::string& ledState)
+inline void setIndicatorLedState(std::shared_ptr<AsyncResp> aResp,
+ const std::string& ledState)
{
BMCWEB_LOG_DEBUG << "Set led groups";
bool ledOn = false;
@@ -133,11 +133,11 @@
}
}
crow::connections::systemBus->async_method_call(
- [aResp](const boost::system::error_code ec,
- const std::variant<bool> asserted) {
- if (ec)
+ [aResp](const boost::system::error_code ec2,
+ const std::variant<bool> asserted2) {
+ if (ec2)
{
- BMCWEB_LOG_DEBUG << "DBUS response error " << ec;
+ BMCWEB_LOG_DEBUG << "DBUS response error " << ec2;
messages::internalError(aResp->res);
return;
}
@@ -154,4 +154,4 @@
"xyz.openbmc_project.Led.Group", "Asserted",
std::variant<bool>(ledBlinkng));
}
-} // namespace redfish
\ No newline at end of file
+} // namespace redfish
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp
index a884290..a4a873a 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -989,13 +989,13 @@
{
if (pathStr.find("PostCode") != std::string::npos)
{
- nlohmann::json& logServiceArray =
+ nlohmann::json& logServiceArrayLocal =
asyncResp->res.jsonValue["Members"];
- logServiceArray.push_back(
+ logServiceArrayLocal.push_back(
{{"@odata.id", "/redfish/v1/Systems/system/"
"LogServices/PostCodes"}});
asyncResp->res.jsonValue["Members@odata.count"] =
- logServiceArray.size();
+ logServiceArrayLocal.size();
return;
}
}
@@ -1152,7 +1152,7 @@
messageArgsSize = logEntryFields.size() - 1;
}
- messageArgs = boost::beast::span(&messageArgsStart, messageArgsSize);
+ messageArgs = {&messageArgsStart, messageArgsSize};
// Fill the MessageArgs into the Message
int i = 0;
@@ -3476,8 +3476,8 @@
codeIndexStr.remove_prefix(dashPos + 1);
bootIndex = static_cast<uint16_t>(
- strtoul(std::string(bootIndexStr).c_str(), NULL, 0));
- codeIndex = strtoul(std::string(codeIndexStr).c_str(), NULL, 0);
+ strtoul(std::string(bootIndexStr).c_str(), nullptr, 0));
+ codeIndex = strtoul(std::string(codeIndexStr).c_str(), nullptr, 0);
if (bootIndex == 0 || codeIndex == 0)
{
BMCWEB_LOG_DEBUG << "Get Post Code invalid entry string "
diff --git a/redfish-core/lib/managers.hpp b/redfish-core/lib/managers.hpp
index 552c264..a113ba1 100644
--- a/redfish-core/lib/managers.hpp
+++ b/redfish-core/lib/managers.hpp
@@ -38,7 +38,7 @@
*
* @param[in] asyncResp - Shared pointer for completing asynchronous calls
*/
-void doBMCGracefulRestart(std::shared_ptr<AsyncResp> asyncResp)
+inline void doBMCGracefulRestart(std::shared_ptr<AsyncResp> asyncResp)
{
const char* processName = "xyz.openbmc_project.State.BMC";
const char* objectPath = "/xyz/openbmc_project/state/bmc0";
@@ -238,7 +238,7 @@
static constexpr const char* thermalModeIface =
"xyz.openbmc_project.Control.ThermalMode";
-static void asyncPopulatePid(const std::string& connection,
+inline void asyncPopulatePid(const std::string& connection,
const std::string& path,
const std::string& currentProfile,
const std::vector<std::string>& supportedProfiles,
@@ -655,7 +655,7 @@
patch
};
-static bool getZonesFromJsonReq(const std::shared_ptr<AsyncResp>& response,
+inline bool getZonesFromJsonReq(const std::shared_ptr<AsyncResp>& response,
std::vector<nlohmann::json>& config,
std::vector<std::string>& zones)
{
@@ -693,7 +693,7 @@
return true;
}
-static const dbus::utility::ManagedItem*
+inline const dbus::utility::ManagedItem*
findChassis(const dbus::utility::ManagedObjectType& managedObj,
const std::string& value, std::string& chassis)
{
@@ -725,7 +725,7 @@
return nullptr;
}
-static CreatePIDRet createPidInterface(
+inline CreatePIDRet createPidInterface(
const std::shared_ptr<AsyncResp>& response, const std::string& type,
nlohmann::json::iterator it, const std::string& path,
const dbus::utility::ManagedObjectType& managedObj, bool createNewObject,
@@ -1052,10 +1052,10 @@
for (auto& step : *steps)
{
double target;
- double output;
+ double out;
if (!redfish::json_util::readJson(step, response->res, "Target",
- target, "Output", output))
+ target, "Output", out))
{
BMCWEB_LOG_ERROR << "Line:" << __LINE__
<< ", Illegal Property "
@@ -1063,7 +1063,7 @@
return CreatePIDRet::fail;
}
readings.emplace_back(target);
- outputs.emplace_back(output);
+ outputs.emplace_back(out);
}
output["Reading"] = std::move(readings);
output["Output"] = std::move(outputs);
@@ -1109,8 +1109,8 @@
struct GetPIDValues : std::enable_shared_from_this<GetPIDValues>
{
- GetPIDValues(const std::shared_ptr<AsyncResp>& asyncResp) :
- asyncResp(asyncResp)
+ GetPIDValues(const std::shared_ptr<AsyncResp>& asyncRespIn) :
+ asyncResp(asyncRespIn)
{}
@@ -1121,14 +1121,14 @@
// get all configurations
crow::connections::systemBus->async_method_call(
[self](const boost::system::error_code ec,
- const crow::openbmc_mapper::GetSubTreeType& subtree) {
+ const crow::openbmc_mapper::GetSubTreeType& subtreeLocal) {
if (ec)
{
BMCWEB_LOG_ERROR << ec;
messages::internalError(self->asyncResp->res);
return;
}
- self->subtree = subtree;
+ self->subtree = subtreeLocal;
},
"xyz.openbmc_project.ObjectMapper",
"/xyz/openbmc_project/object_mapper",
@@ -1140,12 +1140,12 @@
// at the same time get the selected profile
crow::connections::systemBus->async_method_call(
[self](const boost::system::error_code ec,
- const crow::openbmc_mapper::GetSubTreeType& subtree) {
- if (ec || subtree.empty())
+ const crow::openbmc_mapper::GetSubTreeType& subtreeLocal) {
+ if (ec || subtreeLocal.empty())
{
return;
}
- if (subtree[0].second.size() != 1)
+ if (subtreeLocal[0].second.size() != 1)
{
// invalid mapper response, should never happen
BMCWEB_LOG_ERROR << "GetPIDValues: Mapper Error";
@@ -1153,15 +1153,15 @@
return;
}
- const std::string& path = subtree[0].first;
- const std::string& owner = subtree[0].second[0].first;
+ const std::string& path = subtreeLocal[0].first;
+ const std::string& owner = subtreeLocal[0].second[0].first;
crow::connections::systemBus->async_method_call(
[path, owner, self](
- const boost::system::error_code ec,
+ const boost::system::error_code ec2,
const boost::container::flat_map<
std::string, std::variant<std::vector<std::string>,
std::string>>& resp) {
- if (ec)
+ if (ec2)
{
BMCWEB_LOG_ERROR << "GetPIDValues: Can't get "
"thermalModeIface "
diff --git a/redfish-core/lib/network_protocol.hpp b/redfish-core/lib/network_protocol.hpp
index 3e48efb..4d612fc 100644
--- a/redfish-core/lib/network_protocol.hpp
+++ b/redfish-core/lib/network_protocol.hpp
@@ -452,9 +452,8 @@
netipmidBasePath))
{
crow::connections::systemBus->async_method_call(
- [ipmiProtocolEnabled,
- asyncResp](const boost::system::error_code ec) {
- if (ec)
+ [asyncResp](const boost::system::error_code ec2) {
+ if (ec2)
{
messages::internalError(asyncResp->res);
return;
@@ -466,9 +465,8 @@
"Running", std::variant<bool>{ipmiProtocolEnabled});
crow::connections::systemBus->async_method_call(
- [ipmiProtocolEnabled,
- asyncResp](const boost::system::error_code ec) {
- if (ec)
+ [asyncResp](const boost::system::error_code ec2) {
+ if (ec2)
{
messages::internalError(asyncResp->res);
return;
diff --git a/redfish-core/lib/power.hpp b/redfish-core/lib/power.hpp
index 544c42b..031657a 100644
--- a/redfish-core/lib/power.hpp
+++ b/redfish-core/lib/power.hpp
@@ -114,11 +114,11 @@
}
crow::connections::systemBus->async_method_call(
- [asyncResp](const boost::system::error_code ec) {
- if (ec)
+ [asyncResp](const boost::system::error_code ec2) {
+ if (ec2)
{
BMCWEB_LOG_DEBUG
- << "Power Limit Set: Dbus error: " << ec;
+ << "Power Limit Set: Dbus error: " << ec2;
messages::internalError(asyncResp->res);
return;
}
diff --git a/redfish-core/lib/sensors.hpp b/redfish-core/lib/sensors.hpp
index 99a03c9..d1895c4 100644
--- a/redfish-core/lib/sensors.hpp
+++ b/redfish-core/lib/sensors.hpp
@@ -320,7 +320,7 @@
* allSensors list. Eliminate Thermal sensors when a Power request is
* made, and eliminate Power sensors when a Thermal request is made.
*/
-void reduceSensorList(
+inline void reduceSensorList(
std::shared_ptr<SensorsAsyncResp> SensorsAsyncResp,
const std::vector<std::string>* allSensors,
std::shared_ptr<boost::container::flat_set<std::string>> activeSensors)
@@ -623,7 +623,7 @@
* @param inventoryItem D-Bus inventory item associated with a sensor.
* @return State value for inventory item.
*/
-static std::string getState(const InventoryItem* inventoryItem)
+inline std::string getState(const InventoryItem* inventoryItem)
{
if ((inventoryItem != nullptr) && !(inventoryItem->isPresent))
{
@@ -641,7 +641,7 @@
* be nullptr if no associated inventory item was found.
* @return Health value for sensor.
*/
-static std::string getHealth(
+inline std::string getHealth(
nlohmann::json& sensorJson,
const boost::container::flat_map<
std::string, boost::container::flat_map<std::string, SensorVariant>>&
@@ -759,7 +759,7 @@
return "OK";
}
-static void setLedState(nlohmann::json& sensorJson,
+inline void setLedState(nlohmann::json& sensorJson,
const InventoryItem* inventoryItem)
{
if (inventoryItem != nullptr && !inventoryItem->ledObjectPath.empty())
@@ -775,7 +775,7 @@
case LedState::BLINK:
sensorJson["IndicatorLED"] = "Blinking";
break;
- default:
+ case LedState::UNKNOWN:
break;
}
}
@@ -793,7 +793,7 @@
* @param inventoryItem D-Bus inventory item associated with the sensor. Will
* be nullptr if no associated inventory item was found.
*/
-void objectInterfacesToJson(
+inline void objectInterfacesToJson(
const std::string& sensorName, const std::string& sensorType,
std::shared_ptr<SensorsAsyncResp> sensorsAsyncResp,
const boost::container::flat_map<
@@ -1043,7 +1043,7 @@
BMCWEB_LOG_DEBUG << "Added sensor " << sensorName;
}
-static void
+inline void
populateFanRedundancy(std::shared_ptr<SensorsAsyncResp> sensorsAsyncResp)
{
crow::connections::systemBus->async_method_call(
@@ -1250,7 +1250,7 @@
"xyz.openbmc_project.Control.FanRedundancy"});
}
-void sortJSONResponse(std::shared_ptr<SensorsAsyncResp> SensorsAsyncResp)
+inline void sortJSONResponse(std::shared_ptr<SensorsAsyncResp> SensorsAsyncResp)
{
nlohmann::json& response = SensorsAsyncResp->res.jsonValue;
std::array<std::string, 2> sensorHeaders{"Temperatures", "Fans"};
@@ -1295,7 +1295,7 @@
* @param invItemObjPath D-Bus object path of inventory item.
* @return Inventory item within vector, or nullptr if no match found.
*/
-static InventoryItem* findInventoryItem(
+inline InventoryItem* findInventoryItem(
std::shared_ptr<std::vector<InventoryItem>> inventoryItems,
const std::string& invItemObjPath)
{
@@ -1315,7 +1315,7 @@
* @param sensorObjPath D-Bus object path of sensor.
* @return Inventory item within vector, or nullptr if no match found.
*/
-static InventoryItem* findInventoryItemForSensor(
+inline InventoryItem* findInventoryItemForSensor(
std::shared_ptr<std::vector<InventoryItem>> inventoryItems,
const std::string& sensorObjPath)
{
@@ -1363,7 +1363,7 @@
* @param invItemObjPath D-Bus object path of inventory item.
* @param sensorObjPath D-Bus object path of sensor
*/
-static void
+inline void
addInventoryItem(std::shared_ptr<std::vector<InventoryItem>> inventoryItems,
const std::string& invItemObjPath,
const std::string& sensorObjPath)
@@ -1396,7 +1396,7 @@
* @param interfacesDict Map containing D-Bus interfaces and their properties
* for the specified inventory item.
*/
-static void storeInventoryItemData(
+inline void storeInventoryItemData(
InventoryItem& inventoryItem,
const boost::container::flat_map<
std::string, boost::container::flat_map<std::string, SensorVariant>>&
@@ -2348,7 +2348,7 @@
* @param chassisId Chassis that contains the power supply.
* @return JSON PowerSupply object for the specified inventory item.
*/
-static nlohmann::json& getPowerSupply(nlohmann::json& powerSupplyArray,
+inline nlohmann::json& getPowerSupply(nlohmann::json& powerSupplyArray,
const InventoryItem& inventoryItem,
const std::string& chassisId)
{
@@ -2416,7 +2416,7 @@
* implements ObjectManager.
* @param inventoryItems Inventory items associated with the sensors.
*/
-void getSensorData(
+inline void getSensorData(
std::shared_ptr<SensorsAsyncResp> SensorsAsyncResp,
const std::shared_ptr<boost::container::flat_set<std::string>> sensorNames,
const boost::container::flat_set<std::string>& connections,
@@ -2596,11 +2596,11 @@
crow::connections::systemBus->async_method_call(
getManagedObjectsCb, connection, objectMgrPath,
"org.freedesktop.DBus.ObjectManager", "GetManagedObjects");
- };
+ }
BMCWEB_LOG_DEBUG << "getSensorData exit";
}
-void processSensorList(
+inline void processSensorList(
std::shared_ptr<SensorsAsyncResp> SensorsAsyncResp,
std::shared_ptr<boost::container::flat_set<std::string>> sensorNames)
{
@@ -2651,7 +2651,7 @@
* chassis.
* @param SensorsAsyncResp Pointer to object holding response data
*/
-void getChassisData(std::shared_ptr<SensorsAsyncResp> SensorsAsyncResp)
+inline void getChassisData(std::shared_ptr<SensorsAsyncResp> SensorsAsyncResp)
{
BMCWEB_LOG_DEBUG << "getChassisData enter";
auto getChassisCb =
@@ -2678,7 +2678,7 @@
* @param sensorsModified The list of sensors that were found as a result of
* repeated calls to this function
*/
-bool findSensorNameUsingSensorPath(
+inline bool findSensorNameUsingSensorPath(
std::string_view sensorName,
boost::container::flat_set<std::string>& sensorsList,
boost::container::flat_set<std::string>& sensorsModified)
@@ -2707,7 +2707,7 @@
* @param allCollections Collections extract from sensors' request patch info
* @param chassisSubNode Chassis Node for which the query has to happen
*/
-void setSensorsOverride(
+inline void setSensorsOverride(
std::shared_ptr<SensorsAsyncResp> sensorAsyncResp,
std::unordered_map<std::string, std::vector<nlohmann::json>>&
allCollections)
@@ -2832,7 +2832,7 @@
getChassis(sensorAsyncResp, std::move(getChassisSensorListCb));
}
-bool isOverridingAllowed(const std::string& manufacturingModeStatus)
+inline bool isOverridingAllowed(const std::string& manufacturingModeStatus)
{
if (manufacturingModeStatus ==
"xyz.openbmc_project.Control.Security.SpecialMode.Modes.Manufacturing")
@@ -2860,7 +2860,7 @@
* @param allCollections Collections extract from sensors' request patch info
* @param chassisSubNode Chassis Node for which the query has to happen
*/
-void checkAndDoSensorsOverride(
+inline void checkAndDoSensorsOverride(
std::shared_ptr<SensorsAsyncResp> sensorAsyncResp,
std::unordered_map<std::string, std::vector<nlohmann::json>>&
allCollections)
@@ -2872,13 +2872,13 @@
"xyz.openbmc_project.Security.SpecialMode"};
crow::connections::systemBus->async_method_call(
- [sensorAsyncResp, allCollections](const boost::system::error_code ec,
+ [sensorAsyncResp, allCollections](const boost::system::error_code ec2,
const GetSubTreeType& resp) mutable {
- if (ec)
+ if (ec2)
{
BMCWEB_LOG_DEBUG
<< "Error in querying GetSubTree with Object Mapper. "
- << ec;
+ << ec2;
messages::internalError(sensorAsyncResp->res);
return;
}
@@ -2972,8 +2972,9 @@
* @param node Node (group) of sensors. See sensors::node for supported values
* @param mapComplete Callback to be called with retrieval result
*/
-void retrieveUriToDbusMap(const std::string& chassis, const std::string& node,
- SensorsAsyncResp::DataCompleteCb&& mapComplete)
+inline void retrieveUriToDbusMap(const std::string& chassis,
+ const std::string& node,
+ SensorsAsyncResp::DataCompleteCb&& mapComplete)
{
auto typesIt = sensors::dbus::types.find(node);
if (typesIt == sensors::dbus::types.end())
diff --git a/redfish-core/lib/storage.hpp b/redfish-core/lib/storage.hpp
index 0114c4e..9b1e2d7 100644
--- a/redfish-core/lib/storage.hpp
+++ b/redfish-core/lib/storage.hpp
@@ -176,11 +176,11 @@
storageController["Status"]["State"] = "Enabled";
crow::connections::systemBus->async_method_call(
- [asyncResp, index](const boost::system::error_code ec,
+ [asyncResp, index](const boost::system::error_code ec2,
const std::variant<bool> present) {
// this interface isn't necessary, only check it if
// we get a good return
- if (ec)
+ if (ec2)
{
return;
}
@@ -203,12 +203,12 @@
crow::connections::systemBus->async_method_call(
[asyncResp,
- index](const boost::system::error_code ec,
+ index](const boost::system::error_code ec2,
const std::vector<std::pair<
std::string,
std::variant<bool, std::string, uint64_t>>>&
propertiesList) {
- if (ec)
+ if (ec2)
{
// this interface isn't necessary
return;
@@ -311,23 +311,23 @@
return;
}
- auto object = std::find_if(
+ auto object2 = std::find_if(
subtree.begin(), subtree.end(), [&driveId](auto& object) {
const std::string& path = object.first;
return boost::ends_with(path, "/" + driveId);
});
- if (object == subtree.end())
+ if (object2 == subtree.end())
{
messages::resourceNotFound(asyncResp->res, "Drive",
driveId);
return;
}
- const std::string& path = object->first;
+ const std::string& path = object2->first;
const std::vector<
std::pair<std::string, std::vector<std::string>>>&
- connectionNames = object->second;
+ connectionNames = object2->second;
asyncResp->res.jsonValue["@odata.type"] = "#Drive.v1_7_0.Drive";
asyncResp->res.jsonValue["@odata.id"] =
diff --git a/redfish-core/lib/systems.hpp b/redfish-core/lib/systems.hpp
index 9ca95d5..c4bc3d4 100644
--- a/redfish-core/lib/systems.hpp
+++ b/redfish-core/lib/systems.hpp
@@ -38,8 +38,8 @@
*
* @return None.
*/
-void updateDimmProperties(std::shared_ptr<AsyncResp> aResp,
- const std::variant<bool>& dimmState)
+inline void updateDimmProperties(std::shared_ptr<AsyncResp> aResp,
+ const std::variant<bool>& dimmState)
{
const bool* isDimmFunctional = std::get_if<bool>(&dimmState);
if (isDimmFunctional == nullptr)
@@ -72,8 +72,8 @@
*
* @return None.
*/
-void modifyCpuPresenceState(std::shared_ptr<AsyncResp> aResp,
- const std::variant<bool>& cpuPresenceState)
+inline void modifyCpuPresenceState(std::shared_ptr<AsyncResp> aResp,
+ const std::variant<bool>& cpuPresenceState)
{
const bool* isCpuPresent = std::get_if<bool>(&cpuPresenceState);
@@ -107,8 +107,9 @@
*
* @return None.
*/
-void modifyCpuFunctionalState(std::shared_ptr<AsyncResp> aResp,
- const std::variant<bool>& cpuFunctionalState)
+inline void
+ modifyCpuFunctionalState(std::shared_ptr<AsyncResp> aResp,
+ const std::variant<bool>& cpuFunctionalState)
{
const bool* isCpuFunctional = std::get_if<bool>(&cpuFunctionalState);
@@ -143,8 +144,8 @@
*
* @return None.
*/
-void getComputerSystem(std::shared_ptr<AsyncResp> aResp,
- std::shared_ptr<HealthPopulate> systemHealth)
+inline void getComputerSystem(std::shared_ptr<AsyncResp> aResp,
+ std::shared_ptr<HealthPopulate> systemHealth)
{
BMCWEB_LOG_DEBUG << "Get available system components.";
@@ -590,7 +591,7 @@
*
* @return None.
*/
-void getHostState(std::shared_ptr<AsyncResp> aResp)
+inline void getHostState(std::shared_ptr<AsyncResp> aResp)
{
BMCWEB_LOG_DEBUG << "Get host information.";
crow::connections::systemBus->async_method_call(
@@ -645,7 +646,7 @@
* @return Returns as a string, the boot source in Redfish terms. If translation
* cannot be done, returns an empty string.
*/
-static std::string dbusToRfBootSource(const std::string& dbusSource)
+inline std::string dbusToRfBootSource(const std::string& dbusSource)
{
if (dbusSource == "xyz.openbmc_project.Control.Boot.Source.Sources.Default")
{
@@ -685,7 +686,7 @@
* @return Returns as a string, the boot mode in Redfish terms. If translation
* cannot be done, returns an empty string.
*/
-static std::string dbusToRfBootMode(const std::string& dbusMode)
+inline std::string dbusToRfBootMode(const std::string& dbusMode)
{
if (dbusMode == "xyz.openbmc_project.Control.Boot.Mode.Modes.Regular")
{
@@ -714,7 +715,7 @@
*
* @return Integer error code.
*/
-static int assignBootParameters(std::shared_ptr<AsyncResp> aResp,
+inline int assignBootParameters(std::shared_ptr<AsyncResp> aResp,
const std::string& rfSource,
std::string& bootSource, std::string& bootMode)
{
@@ -774,7 +775,7 @@
*
* @return None.
*/
-static void getBootMode(std::shared_ptr<AsyncResp> aResp,
+inline void getBootMode(std::shared_ptr<AsyncResp> aResp,
std::string bootDbusObj)
{
crow::connections::systemBus->async_method_call(
@@ -838,7 +839,7 @@
*
* @return None.
*/
-static void getBootSource(std::shared_ptr<AsyncResp> aResp, bool oneTimeEnabled)
+inline void getBootSource(std::shared_ptr<AsyncResp> aResp, bool oneTimeEnabled)
{
std::string bootDbusObj =
oneTimeEnabled ? "/xyz/openbmc_project/control/host0/boot/one_time"
@@ -889,7 +890,7 @@
*
* @return None.
*/
-static void getBootProperties(std::shared_ptr<AsyncResp> aResp)
+inline void getBootProperties(std::shared_ptr<AsyncResp> aResp)
{
BMCWEB_LOG_DEBUG << "Get boot information.";
@@ -930,7 +931,7 @@
*
* @return None.
*/
-void getLastResetTime(std::shared_ptr<AsyncResp> aResp)
+inline void getLastResetTime(std::shared_ptr<AsyncResp> aResp)
{
BMCWEB_LOG_DEBUG << "Getting System Last Reset Time";
@@ -973,7 +974,7 @@
*
* @return None.
*/
-void getAutomaticRetry(std::shared_ptr<AsyncResp> aResp)
+inline void getAutomaticRetry(std::shared_ptr<AsyncResp> aResp)
{
BMCWEB_LOG_DEBUG << "Get Automatic Retry policy";
@@ -1064,7 +1065,7 @@
*
* @return None.
*/
-void getPowerRestorePolicy(std::shared_ptr<AsyncResp> aResp)
+inline void getPowerRestorePolicy(std::shared_ptr<AsyncResp> aResp)
{
BMCWEB_LOG_DEBUG << "Get power restore policy";
@@ -1123,7 +1124,7 @@
*
* @return Integer error code.
*/
-static void setBootModeOrSource(std::shared_ptr<AsyncResp> aResp,
+inline void setBootModeOrSource(std::shared_ptr<AsyncResp> aResp,
bool oneTimeEnabled,
std::optional<std::string> bootSource,
std::optional<std::string> bootEnable)
@@ -1244,7 +1245,7 @@
*
* @return Integer error code.
*/
-static void setBootSourceProperties(std::shared_ptr<AsyncResp> aResp,
+inline void setBootSourceProperties(std::shared_ptr<AsyncResp> aResp,
std::optional<std::string> bootSource,
std::optional<std::string> bootEnable)
{
@@ -1288,7 +1289,7 @@
*
* @return None.
*/
-static void setAutomaticRetry(std::shared_ptr<AsyncResp> aResp,
+inline void setAutomaticRetry(std::shared_ptr<AsyncResp> aResp,
const std::string&& automaticRetryConfig)
{
BMCWEB_LOG_DEBUG << "Set Automatic Retry.";
@@ -1337,7 +1338,7 @@
*
* @return None.
*/
-static void setPowerRestorePolicy(std::shared_ptr<AsyncResp> aResp,
+inline void setPowerRestorePolicy(std::shared_ptr<AsyncResp> aResp,
std::optional<std::string> policy)
{
BMCWEB_LOG_DEBUG << "Set power restore policy.";
@@ -1384,7 +1385,7 @@
*
* @return None.
*/
-void getProvisioningStatus(std::shared_ptr<AsyncResp> aResp)
+inline void getProvisioningStatus(std::shared_ptr<AsyncResp> aResp)
{
BMCWEB_LOG_DEBUG << "Get OEM information.";
crow::connections::systemBus->async_method_call(
@@ -1453,7 +1454,7 @@
* @return Returns as a string, the timeout action in Redfish terms. If
* translation cannot be done, returns an empty string.
*/
-static std::string dbusToRfWatchdogAction(const std::string& dbusAction)
+inline std::string dbusToRfWatchdogAction(const std::string& dbusAction)
{
if (dbusAction == "xyz.openbmc_project.State.Watchdog.Action.None")
{
@@ -1486,7 +1487,7 @@
*If translation cannot be done, returns an empty string.
*/
-static std::string rfToDbusWDTTimeOutAct(const std::string& rfAction)
+inline std::string rfToDbusWDTTimeOutAct(const std::string& rfAction)
{
if (rfAction == "None")
{
@@ -1515,7 +1516,7 @@
*
* @return None.
*/
-void getHostWatchdogTimer(std::shared_ptr<AsyncResp> aResp)
+inline void getHostWatchdogTimer(std::shared_ptr<AsyncResp> aResp)
{
BMCWEB_LOG_DEBUG << "Get host watchodg";
crow::connections::systemBus->async_method_call(
@@ -1586,7 +1587,7 @@
*
* @return None.
*/
-static void setWDTProperties(std::shared_ptr<AsyncResp> aResp,
+inline void setWDTProperties(std::shared_ptr<AsyncResp> aResp,
const std::optional<bool> wdtEnable,
const std::optional<std::string>& wdtTimeOutAction)
{
diff --git a/redfish-core/lib/task.hpp b/redfish-core/lib/task.hpp
index 1b9077d..d6c479f 100644
--- a/redfish-core/lib/task.hpp
+++ b/redfish-core/lib/task.hpp
@@ -93,9 +93,9 @@
TaskData(std::function<bool(boost::system::error_code,
sdbusplus::message::message&,
const std::shared_ptr<TaskData>&)>&& handler,
- const std::string& match, size_t idx) :
+ const std::string& matchIn, size_t idx) :
callback(std::move(handler)),
- matchStr(match), index(idx),
+ matchStr(matchIn), index(idx),
startTime(std::chrono::system_clock::to_time_t(
std::chrono::system_clock::now())),
status("OK"), state("Running"), messages(nlohmann::json::array()),
@@ -118,8 +118,8 @@
std::function<bool(boost::system::error_code,
sdbusplus::message::message&,
const std::shared_ptr<TaskData>&)>&& handler,
- const std::string& match, size_t idx) :
- TaskData(std::move(handler), match, idx)
+ const std::string& match2, size_t idx) :
+ TaskData(std::move(handler), match2, idx)
{}
};
diff --git a/redfish-core/ut/privileges_test.cpp b/redfish-core/ut/privileges_test.cpp
index d857290..1613fbb 100644
--- a/redfish-core/ut/privileges_test.cpp
+++ b/redfish-core/ut/privileges_test.cpp
@@ -13,9 +13,7 @@
Privileges privileges{"Login", "ConfigureManager"};
EXPECT_THAT(privileges.getActivePrivilegeNames(PrivilegeType::BASE),
- ::testing::UnorderedElementsAre(
- ::testing::Pointee(&"Login"[0]),
- ::testing::Pointee(&"ConfigureManager"[0])));
+ ::testing::UnorderedElementsAre("Login", "ConfigureManager"));
}
TEST(PrivilegeTest, PrivilegeCheckForNoPrivilegesRequired)
@@ -119,9 +117,7 @@
EXPECT_THAT(privileges.getActivePrivilegeNames(PrivilegeType::BASE),
::testing::UnorderedElementsAre(
- ::testing::Pointee(expectedPrivileges[0]),
- ::testing::Pointee(expectedPrivileges[1]),
- ::testing::Pointee(expectedPrivileges[2]),
- ::testing::Pointee(expectedPrivileges[3]),
- ::testing::Pointee(expectedPrivileges[4])));
+ expectedPrivileges[0], expectedPrivileges[1],
+ expectedPrivileges[2], expectedPrivileges[3],
+ expectedPrivileges[4]));
}
diff --git a/src/webserver_main.cpp b/src/webserver_main.cpp
index 2e043d7..b626f5b 100644
--- a/src/webserver_main.cpp
+++ b/src/webserver_main.cpp
@@ -32,7 +32,7 @@
constexpr int defaultPort = 18080;
-void setupSocket(crow::App& app)
+inline void setupSocket(crow::App& app)
{
int listenFd = sd_listen_fds(0);
if (1 == listenFd)
@@ -107,7 +107,6 @@
crow::login_routes::requestRoutes(app);
- BMCWEB_LOG_INFO << "bmcweb (" << __DATE__ << ": " << __TIME__ << ')';
setupSocket(app);
crow::connections::systemBus =