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/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{