clang-format: update to latest from docs repo
This is from openbmc/docs/style/cpp/.clang-format
Other OpenBMC repos are doing the same.
Tested: Built and validator passed.
Change-Id: Ief26c755c9ce012823e16a506342b0547a53517a
Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
diff --git a/include/async_resp.hpp b/include/async_resp.hpp
index 78994cf..f596dcd 100644
--- a/include/async_resp.hpp
+++ b/include/async_resp.hpp
@@ -14,13 +14,11 @@
{
public:
AsyncResp(crow::Response& response) : res(response)
- {
- }
+ {}
AsyncResp(crow::Response& response, std::function<void()>&& function) :
res(response), func(std::move(function))
- {
- }
+ {}
~AsyncResp()
{
diff --git a/include/dbus_monitor.hpp b/include/dbus_monitor.hpp
index 1747810..4cc5b06 100644
--- a/include/dbus_monitor.hpp
+++ b/include/dbus_monitor.hpp
@@ -9,11 +9,13 @@
#include <openbmc_dbus_rest.hpp>
#include <sdbusplus/bus/match.hpp>
#include <sdbusplus/message/types.hpp>
+
#include <variant>
namespace nlohmann
{
-template <typename... Args> struct adl_serializer<std::variant<Args...>>
+template <typename... Args>
+struct adl_serializer<std::variant<Args...>>
{
static void to_json(json& j, const std::variant<Args...>& v)
{
@@ -112,7 +114,8 @@
return 0;
}
-template <typename... Middlewares> void requestRoutes(Crow<Middlewares...>& app)
+template <typename... Middlewares>
+void requestRoutes(Crow<Middlewares...>& app)
{
BMCWEB_ROUTE(app, "/subscribe")
.requires({"Login"})
diff --git a/include/dbus_utility.hpp b/include/dbus_utility.hpp
index ddf1e61..e1360f7 100644
--- a/include/dbus_utility.hpp
+++ b/include/dbus_utility.hpp
@@ -15,9 +15,10 @@
*/
#pragma once
-#include <regex>
#include <sdbusplus/message.hpp>
+#include <regex>
+
namespace dbus
{
diff --git a/include/dump_offload.hpp b/include/dump_offload.hpp
index 0c470b4..1b956e7 100644
--- a/include/dump_offload.hpp
+++ b/include/dump_offload.hpp
@@ -6,6 +6,7 @@
#include <boost/beast/core/flat_static_buffer.hpp>
#include <boost/beast/http.hpp>
#include <boost/process.hpp>
+
#include <cstdio>
#include <cstdlib>
@@ -39,12 +40,10 @@
boost::beast::flat_static_buffer<nbdBufferSize>>()),
inputBuffer(
std::make_unique<boost::beast::flat_static_buffer<nbdBufferSize>>())
- {
- }
+ {}
~Handler()
- {
- }
+ {}
/**
* @brief Invokes InitiateOffload method of dump manager which
diff --git a/include/http_utility.hpp b/include/http_utility.hpp
index 6f55c59..88b0247 100644
--- a/include/http_utility.hpp
+++ b/include/http_utility.hpp
@@ -1,8 +1,8 @@
#pragma once
-#include <boost/algorithm/string.hpp>
-
#include "http_request.h"
+#include <boost/algorithm/string.hpp>
+
namespace http_helpers
{
inline bool requestPrefersHtml(const crow::Request& req)
diff --git a/include/ibm/locks.hpp b/include/ibm/locks.hpp
index 3c4f8ec..6e9421f 100644
--- a/include/ibm/locks.hpp
+++ b/include/ibm/locks.hpp
@@ -5,9 +5,10 @@
#include <boost/algorithm/string.hpp>
#include <boost/container/flat_map.hpp>
#include <boost/endian/conversion.hpp>
+#include <nlohmann/json.hpp>
+
#include <filesystem>
#include <fstream>
-#include <nlohmann/json.hpp>
namespace crow
{
@@ -36,7 +37,7 @@
using RcReleaseLockApi = std::pair<bool, std::variant<bool, RcRelaseLock>>;
using SessionFlags = std::pair<SType, SType>;
using ListOfSessionIds = std::vector<std::string>;
-static constexpr const char *fileName =
+static constexpr const char* fileName =
"/var/lib/obmc/bmc-console-mgmt/locks/ibm_mc_persistent_lock_data.json";
class Lock
@@ -106,22 +107,22 @@
* Returns : False (if the request HMC or Session does not own the lock(s))
*/
- virtual RcRelaseLock isItMyLock(const ListOfTransactionIds &,
- const SessionFlags &);
+ virtual RcRelaseLock isItMyLock(const ListOfTransactionIds&,
+ const SessionFlags&);
/*
* This function validates the the list of transactionID's and returns false
* if the transaction ID is not valid & not present in the lock table
*/
- virtual bool validateRids(const ListOfTransactionIds &);
+ virtual bool validateRids(const ListOfTransactionIds&);
/*
* This function releases the locks that are already obtained by the
* requesting Management console.
*/
- void releaseLock(const ListOfTransactionIds &);
+ void releaseLock(const ListOfTransactionIds&);
Lock()
{
@@ -165,31 +166,30 @@
* Client can choose either of the ways by using `Type` JSON key.
*
*/
- RcReleaseLockApi releaseLock(const ListOfTransactionIds &,
- const SessionFlags &);
+ RcReleaseLockApi releaseLock(const ListOfTransactionIds&,
+ const SessionFlags&);
/*
* This function implements the logic for getting the list of locks obtained
* by a particular management console.
*/
- RcGetLockList getLockList(const ListOfSessionIds &);
+ RcGetLockList getLockList(const ListOfSessionIds&);
/*
* This function is releases all the locks obtained by a particular
* session.
*/
- void releaseLock(const std::string &);
+ void releaseLock(const std::string&);
- static Lock &getInstance()
+ static Lock& getInstance()
{
static Lock lockObject;
return lockObject;
}
virtual ~Lock()
- {
- }
+ {}
};
inline bool Lock::createPersistentLockFilePath()
@@ -235,7 +235,7 @@
return;
}
BMCWEB_LOG_DEBUG << "The persistent lock data is available";
- for (const auto &item : data.items())
+ for (const auto& item : data.items())
{
BMCWEB_LOG_DEBUG << item.key();
BMCWEB_LOG_DEBUG << item.value();
@@ -265,7 +265,7 @@
fs::perms::owner_read | fs::perms::owner_write | fs::perms::group_read;
fs::permissions(fileName, permission);
nlohmann::json data;
- for (const auto &it : lockTable)
+ for (const auto& it : lockTable)
{
data[std::to_string(it.first)] = it.second;
}
@@ -273,14 +273,14 @@
persistentFile << data;
}
-inline RcGetLockList Lock::getLockList(const ListOfSessionIds &listSessionId)
+inline RcGetLockList Lock::getLockList(const ListOfSessionIds& listSessionId)
{
std::vector<std::pair<uint32_t, LockRequests>> lockList;
if (!lockTable.empty())
{
- for (const auto &i : listSessionId)
+ for (const auto& i : listSessionId)
{
auto it = lockTable.begin();
while (it != lockTable.end())
@@ -306,8 +306,8 @@
return lockList;
}
-inline RcReleaseLockApi Lock::releaseLock(const ListOfTransactionIds &p,
- const SessionFlags &ids)
+inline RcReleaseLockApi Lock::releaseLock(const ListOfTransactionIds& p,
+ const SessionFlags& ids)
{
bool status = validateRids(p);
@@ -339,7 +339,7 @@
// validate the lock request
- for (auto &lockRecord : lockRequestStructure)
+ for (auto& lockRecord : lockRequestStructure)
{
bool status = isValidLockRequest(lockRecord);
if (!status)
@@ -351,7 +351,7 @@
}
// check for conflict record
- const LockRequests &multiRequest = lockRequestStructure;
+ const LockRequests& multiRequest = lockRequestStructure;
bool status = isConflictRequest(multiRequest);
if (status)
@@ -374,9 +374,9 @@
return std::make_pair(true, std::make_pair(true, 1));
}
-inline void Lock::releaseLock(const ListOfTransactionIds &refRids)
+inline void Lock::releaseLock(const ListOfTransactionIds& refRids)
{
- for (const auto &id : refRids)
+ for (const auto& id : refRids)
{
if (lockTable.erase(id))
{
@@ -395,7 +395,7 @@
saveLocks();
}
-inline void Lock::releaseLock(const std::string &sessionId)
+inline void Lock::releaseLock(const std::string& sessionId)
{
bool isErased = false;
if (!lockTable.empty())
@@ -429,10 +429,10 @@
}
}
}
-inline RcRelaseLock Lock::isItMyLock(const ListOfTransactionIds &refRids,
- const SessionFlags &ids)
+inline RcRelaseLock Lock::isItMyLock(const ListOfTransactionIds& refRids,
+ const SessionFlags& ids)
{
- for (const auto &id : refRids)
+ for (const auto& id : refRids)
{
// Just need to compare the client id of the first lock records in the
// complete lock row(in the map), because the rest of the lock records
@@ -456,9 +456,9 @@
return std::make_pair(true, std::make_pair(0, LockRequest()));
}
-inline bool Lock::validateRids(const ListOfTransactionIds &refRids)
+inline bool Lock::validateRids(const ListOfTransactionIds& refRids)
{
- for (const auto &id : refRids)
+ for (const auto& id : refRids)
{
auto search = lockTable.find(id);
@@ -505,7 +505,7 @@
int lockFlag = 0;
// validate the lockflags & segment length
- for (const auto &p : std::get<4>(refLockRecord))
+ for (const auto& p : std::get<4>(refLockRecord))
{
// validate the lock flags
@@ -571,11 +571,11 @@
// Lock table is not empty, compare the lockrequest entries with
// the entries in the lock table
- for (const auto &lockRecord1 : refLockRequestStructure)
+ for (const auto& lockRecord1 : refLockRequestStructure)
{
- for (const auto &map : lockTable)
+ for (const auto& map : lockTable)
{
- for (const auto &lockRecord2 : map.second)
+ for (const auto& lockRecord2 : map.second)
{
bool status = isConflictRecord(lockRecord1, lockRecord2);
if (status)
@@ -627,8 +627,8 @@
{
for (uint32_t j = i + 1; j < refLockRequestStructure.size(); j++)
{
- const LockRequest &p = refLockRequestStructure[i];
- const LockRequest &q = refLockRequestStructure[j];
+ const LockRequest& p = refLockRequestStructure[i];
+ const LockRequest& q = refLockRequestStructure[j];
bool status = isConflictRecord(p, q);
if (status)
@@ -652,8 +652,8 @@
inline bool Lock::checkByte(uint64_t resourceId1, uint64_t resourceId2,
uint32_t position)
{
- uint8_t *p = reinterpret_cast<uint8_t *>(&resourceId1);
- uint8_t *q = reinterpret_cast<uint8_t *>(&resourceId2);
+ uint8_t* p = reinterpret_cast<uint8_t*>(&resourceId1);
+ uint8_t* q = reinterpret_cast<uint8_t*>(&resourceId2);
BMCWEB_LOG_DEBUG << "Comparing bytes " << std::to_string(p[position]) << ","
<< std::to_string(q[position]);
@@ -685,7 +685,7 @@
else
{
uint32_t i = 0;
- for (const auto &p : std::get<4>(refLockRecord1))
+ for (const auto& p : std::get<4>(refLockRecord1))
{
// return conflict when any of them is try to lock all resources
diff --git a/include/ibm/management_console_rest.hpp b/include/ibm/management_console_rest.hpp
index 9f8f8d2..e9805d6 100644
--- a/include/ibm/management_console_rest.hpp
+++ b/include/ibm/management_console_rest.hpp
@@ -6,14 +6,15 @@
#include <boost/algorithm/string.hpp>
#include <boost/container/flat_set.hpp>
#include <error_messages.hpp>
-#include <filesystem>
-#include <fstream>
#include <ibm/locks.hpp>
#include <nlohmann/json.hpp>
-#include <regex>
#include <sdbusplus/message/types.hpp>
#include <utils/json_utils.hpp>
+#include <filesystem>
+#include <fstream>
+#include <regex>
+
// Allow save area file size to 500KB
#define MAX_SAVE_AREA_FILESIZE 500000
@@ -29,12 +30,12 @@
{
namespace ibm_mc
{
-constexpr const char *methodNotAllowedMsg = "Method Not Allowed";
-constexpr const char *resourceNotFoundMsg = "Resource Not Found";
-constexpr const char *contentNotAcceptableMsg = "Content Not Acceptable";
-constexpr const char *internalServerError = "Internal Server Error";
+constexpr const char* methodNotAllowedMsg = "Method Not Allowed";
+constexpr const char* resourceNotFoundMsg = "Resource Not Found";
+constexpr const char* contentNotAcceptableMsg = "Content Not Acceptable";
+constexpr const char* internalServerError = "Internal Server Error";
-bool createSaveAreaPath(crow::Response &res)
+bool createSaveAreaPath(crow::Response& res)
{
// The path /var/lib/obmc will be created by initrdscripts
// Create the directories for the save-area files, when we get
@@ -71,8 +72,8 @@
}
return true;
}
-void handleFilePut(const crow::Request &req, crow::Response &res,
- const std::string &fileID)
+void handleFilePut(const crow::Request& req, crow::Response& res,
+ const std::string& fileID)
{
// Check the content-type of the request
std::string_view contentType = req.getHeaderValue("content-type");
@@ -129,13 +130,13 @@
}
}
-void handleConfigFileList(crow::Response &res)
+void handleConfigFileList(crow::Response& res)
{
std::vector<std::string> pathObjList;
std::filesystem::path loc("/var/lib/obmc/bmc-console-mgmt/save-area");
if (std::filesystem::exists(loc) && std::filesystem::is_directory(loc))
{
- for (const auto &file : std::filesystem::directory_iterator(loc))
+ for (const auto& file : std::filesystem::directory_iterator(loc))
{
std::filesystem::path pathObj(file.path());
pathObjList.push_back("/ibm/v1/Host/ConfigFiles/" +
@@ -154,7 +155,7 @@
res.end();
}
-void deleteConfigFiles(crow::Response &res)
+void deleteConfigFiles(crow::Response& res)
{
std::vector<std::string> pathObjList;
std::error_code ec;
@@ -174,7 +175,7 @@
res.end();
}
-void getLockServiceData(crow::Response &res)
+void getLockServiceData(crow::Response& res)
{
res.jsonValue["@odata.type"] = "#LockService.v1_0_0.LockService";
res.jsonValue["@odata.id"] = "/ibm/v1/HMC/LockService/";
@@ -190,7 +191,7 @@
res.end();
}
-void handleFileGet(crow::Response &res, const std::string &fileID)
+void handleFileGet(crow::Response& res, const std::string& fileID)
{
BMCWEB_LOG_DEBUG << "HandleGet on SaveArea files on path: " << fileID;
std::filesystem::path loc("/var/lib/obmc/bmc-console-mgmt/save-area/" +
@@ -222,7 +223,7 @@
return;
}
-void handleFileDelete(crow::Response &res, const std::string &fileID)
+void handleFileDelete(crow::Response& res, const std::string& fileID)
{
std::string filePath("/var/lib/obmc/bmc-console-mgmt/save-area/" + fileID);
BMCWEB_LOG_DEBUG << "Removing the file : " << filePath << "\n";
@@ -249,8 +250,8 @@
return;
}
-inline void handleFileUrl(const crow::Request &req, crow::Response &res,
- const std::string &fileID)
+inline void handleFileUrl(const crow::Request& req, crow::Response& res,
+ const std::string& fileID)
{
if (req.method() == "PUT"_method)
{
@@ -272,11 +273,11 @@
}
}
-void handleAcquireLockAPI(const crow::Request &req, crow::Response &res,
+void handleAcquireLockAPI(const crow::Request& req, crow::Response& res,
std::vector<nlohmann::json> body)
{
LockRequests lockRequestStructure;
- for (auto &element : body)
+ for (auto& element : body)
{
std::string lockType;
uint64_t resourceId;
@@ -298,7 +299,7 @@
BMCWEB_LOG_DEBUG << "Segment Flags are present";
- for (auto &e : segmentFlags)
+ for (auto& e : segmentFlags)
{
std::string lockFlags;
uint32_t segmentLength;
@@ -329,13 +330,13 @@
BMCWEB_LOG_DEBUG << std::get<2>(lockRequestStructure[i]);
BMCWEB_LOG_DEBUG << std::get<3>(lockRequestStructure[i]);
- for (const auto &p : std::get<4>(lockRequestStructure[i]))
+ for (const auto& p : std::get<4>(lockRequestStructure[i]))
{
BMCWEB_LOG_DEBUG << p.first << ", " << p.second;
}
}
- const LockRequests &t = lockRequestStructure;
+ const LockRequests& t = lockRequestStructure;
auto varAcquireLock = crow::ibm_mc_lock::Lock::getInstance().acquireLock(t);
@@ -407,7 +408,7 @@
}
}
}
-void handleRelaseAllAPI(const crow::Request &req, crow::Response &res)
+void handleRelaseAllAPI(const crow::Request& req, crow::Response& res)
{
crow::ibm_mc_lock::Lock::getInstance().releaseLock(req.session->uniqueId);
res.result(boost::beast::http::status::ok);
@@ -415,8 +416,8 @@
return;
}
-void handleReleaseLockAPI(const crow::Request &req, crow::Response &res,
- const std::vector<uint32_t> &listTransactionIds)
+void handleReleaseLockAPI(const crow::Request& req, crow::Response& res,
+ const std::vector<uint32_t>& listTransactionIds)
{
BMCWEB_LOG_DEBUG << listTransactionIds.size();
BMCWEB_LOG_DEBUG << "Data is present";
@@ -483,8 +484,8 @@
}
}
-void handleGetLockListAPI(const crow::Request &req, crow::Response &res,
- const ListOfSessionIds &listSessionIds)
+void handleGetLockListAPI(const crow::Request& req, crow::Response& res,
+ const ListOfSessionIds& listSessionIds)
{
BMCWEB_LOG_DEBUG << listSessionIds.size();
@@ -494,9 +495,9 @@
nlohmann::json lockRecords = nlohmann::json::array();
- for (const auto &transactionId : var)
+ for (const auto& transactionId : var)
{
- for (const auto &lockRecord : transactionId.second)
+ for (const auto& lockRecord : transactionId.second)
{
nlohmann::json returnJson;
@@ -509,7 +510,7 @@
nlohmann::json segments;
nlohmann::json segmentInfoArray = nlohmann::json::array();
- for (const auto &segment : std::get<4>(lockRecord))
+ for (const auto& segment : std::get<4>(lockRecord))
{
segments["LockFlag"] = segment.first;
segments["SegmentLength"] = segment.second;
@@ -525,14 +526,15 @@
res.end();
}
-template <typename... Middlewares> void requestRoutes(Crow<Middlewares...> &app)
+template <typename... Middlewares>
+void requestRoutes(Crow<Middlewares...>& app)
{
// allowed only for admin
BMCWEB_ROUTE(app, "/ibm/v1/")
.requires({"ConfigureComponents", "ConfigureManager"})
.methods("GET"_method)(
- [](const crow::Request &req, crow::Response &res) {
+ [](const crow::Request& req, crow::Response& res) {
res.jsonValue["@odata.type"] =
"#ibmServiceRoot.v1_0_0.ibmServiceRoot";
res.jsonValue["@odata.id"] = "/ibm/v1/";
@@ -548,7 +550,7 @@
BMCWEB_ROUTE(app, "/ibm/v1/Host/ConfigFiles")
.requires({"ConfigureComponents", "ConfigureManager"})
.methods("GET"_method)(
- [](const crow::Request &req, crow::Response &res) {
+ [](const crow::Request& req, crow::Response& res) {
handleConfigFileList(res);
});
@@ -556,27 +558,27 @@
"/ibm/v1/Host/ConfigFiles/Actions/FileCollection.DeleteAll")
.requires({"ConfigureComponents", "ConfigureManager"})
.methods("POST"_method)(
- [](const crow::Request &req, crow::Response &res) {
+ [](const crow::Request& req, crow::Response& res) {
deleteConfigFiles(res);
});
BMCWEB_ROUTE(app, "/ibm/v1/Host/ConfigFiles/<path>")
.requires({"ConfigureComponents", "ConfigureManager"})
.methods("PUT"_method, "GET"_method, "DELETE"_method)(
- [](const crow::Request &req, crow::Response &res,
- const std::string &path) { handleFileUrl(req, res, path); });
+ [](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"})
.methods("GET"_method)(
- [](const crow::Request &req, crow::Response &res) {
+ [](const crow::Request& req, crow::Response& res) {
getLockServiceData(res);
});
BMCWEB_ROUTE(app, "/ibm/v1/HMC/LockService/Actions/LockService.AcquireLock")
.requires({"ConfigureComponents", "ConfigureManager"})
.methods("POST"_method)(
- [](const crow::Request &req, crow::Response &res) {
+ [](const crow::Request& req, crow::Response& res) {
std::vector<nlohmann::json> body;
if (!redfish::json_util::readJson(req, res, "Request", body))
{
@@ -590,7 +592,7 @@
BMCWEB_ROUTE(app, "/ibm/v1/HMC/LockService/Actions/LockService.ReleaseLock")
.requires({"ConfigureComponents", "ConfigureManager"})
.methods(
- "POST"_method)([](const crow::Request &req, crow::Response &res) {
+ "POST"_method)([](const crow::Request& req, crow::Response& res) {
std::string type;
std::vector<uint32_t> listTransactionIds;
@@ -620,7 +622,7 @@
BMCWEB_ROUTE(app, "/ibm/v1/HMC/LockService/Actions/LockService.GetLockList")
.requires({"ConfigureComponents", "ConfigureManager"})
.methods("POST"_method)(
- [](const crow::Request &req, crow::Response &res) {
+ [](const crow::Request& req, crow::Response& res) {
ListOfSessionIds listSessionIds;
if (!redfish::json_util::readJson(req, res, "SessionIDs",
diff --git a/include/image_upload.hpp b/include/image_upload.hpp
index 69e5637..64adccd 100644
--- a/include/image_upload.hpp
+++ b/include/image_upload.hpp
@@ -5,8 +5,9 @@
#include <boost/uuid/uuid.hpp>
#include <boost/uuid/uuid_generators.hpp>
#include <boost/uuid/uuid_io.hpp>
-#include <cstdio>
#include <dbus_singleton.hpp>
+
+#include <cstdio>
#include <fstream>
#include <memory>
@@ -108,7 +109,8 @@
timeout.async_wait(timeoutHandler);
}
-template <typename... Middlewares> void requestRoutes(Crow<Middlewares...>& app)
+template <typename... Middlewares>
+void requestRoutes(Crow<Middlewares...>& app)
{
BMCWEB_ROUTE(app, "/upload/image/<str>")
.requires({"ConfigureComponents", "ConfigureManager"})
diff --git a/include/nbd_proxy.hpp b/include/nbd_proxy.hpp
index 12fbb8e..4a9cfb8 100644
--- a/include/nbd_proxy.hpp
+++ b/include/nbd_proxy.hpp
@@ -22,11 +22,12 @@
#include <boost/beast/core/multi_buffer.hpp>
#include <boost/container/flat_map.hpp>
#include <dbus_utility.hpp>
-#include <experimental/filesystem>
#include <privileges.hpp>
-#include <variant>
#include <webserver_common.hpp>
+#include <experimental/filesystem>
+#include <variant>
+
namespace crow
{
@@ -47,8 +48,7 @@
endpointId(endpointIdIn), path(pathIn),
acceptor(connIn.get_io_context(), stream_protocol::endpoint(socketId)),
connection(connIn)
- {
- }
+ {}
~NbdProxyServer()
{
diff --git a/include/openbmc_dbus_rest.hpp b/include/openbmc_dbus_rest.hpp
index 4de6ea0..456c768 100644
--- a/include/openbmc_dbus_rest.hpp
+++ b/include/openbmc_dbus_rest.hpp
@@ -21,10 +21,11 @@
#include <boost/container/flat_set.hpp>
#include <dbus_singleton.hpp>
#include <dbus_utility.hpp>
+#include <sdbusplus/message/types.hpp>
+
#include <filesystem>
#include <fstream>
#include <regex>
-#include <sdbusplus/message/types.hpp>
namespace crow
{
@@ -35,23 +36,23 @@
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 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 =
"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 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";
-void setErrorResponse(crow::Response &res, boost::beast::http::status result,
- const std::string &desc, const std::string_view msg)
+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}}},
@@ -59,8 +60,8 @@
{"status", "error"}};
}
-void introspectObjects(const std::string &processName,
- const std::string &objectPath,
+void introspectObjects(const std::string& processName,
+ const std::string& objectPath,
std::shared_ptr<bmcweb::AsyncResp> transaction)
{
if (transaction->res.jsonValue.is_null())
@@ -74,7 +75,7 @@
[transaction, processName{std::string(processName)},
objectPath{std::string(objectPath)}](
const boost::system::error_code ec,
- const std::string &introspect_xml) {
+ const std::string& introspect_xml) {
if (ec)
{
BMCWEB_LOG_ERROR
@@ -89,7 +90,7 @@
tinyxml2::XMLDocument doc;
doc.Parse(introspect_xml.c_str());
- tinyxml2::XMLNode *pRoot = doc.FirstChildElement("node");
+ tinyxml2::XMLNode* pRoot = doc.FirstChildElement("node");
if (pRoot == nullptr)
{
BMCWEB_LOG_ERROR << "XML document failed to parse "
@@ -97,10 +98,10 @@
}
else
{
- tinyxml2::XMLElement *node = pRoot->FirstChildElement("node");
+ tinyxml2::XMLElement* node = pRoot->FirstChildElement("node");
while (node != nullptr)
{
- const char *childPath = node->Attribute("name");
+ const char* childPath = node->Attribute("name");
if (childPath != nullptr)
{
std::string newpath;
@@ -121,20 +122,19 @@
"Introspect");
}
-void getPropertiesForEnumerate(const std::string &objectPath,
- const std::string &service,
- const std::string &interface,
+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;
crow::connections::systemBus->async_method_call(
- [asyncResp, objectPath, service,
- interface](const boost::system::error_code ec,
- const std::vector<
- std::pair<std::string, dbus::utility::DbusVariantType>>
- &propertiesList) {
+ [asyncResp, objectPath, service, interface](
+ const boost::system::error_code ec,
+ const std::vector<std::pair<
+ std::string, dbus::utility::DbusVariantType>>& propertiesList) {
if (ec)
{
BMCWEB_LOG_ERROR << "GetAll on path " << objectPath << " iface "
@@ -143,17 +143,17 @@
return;
}
- nlohmann::json &dataJson = asyncResp->res.jsonValue["data"];
- nlohmann::json &objectJson = dataJson[objectPath];
+ nlohmann::json& dataJson = asyncResp->res.jsonValue["data"];
+ nlohmann::json& objectJson = dataJson[objectPath];
if (objectJson.is_null())
{
objectJson = nlohmann::json::object();
}
- for (const auto &[name, value] : propertiesList)
+ for (const auto& [name, value] : propertiesList)
{
- nlohmann::json &propertyJson = objectJson[name];
- std::visit([&propertyJson](auto &&val) { propertyJson = val; },
+ nlohmann::json& propertyJson = objectJson[name];
+ std::visit([&propertyJson](auto&& val) { propertyJson = val; },
value);
}
},
@@ -164,13 +164,13 @@
// Find any results that weren't picked up by ObjectManagers, to be
// called after all ObjectManagers are searched for and called.
void findRemainingObjectsForEnumerate(
- const std::string &objectPath, std::shared_ptr<GetSubTreeType> subtree,
+ const std::string& objectPath, std::shared_ptr<GetSubTreeType> subtree,
std::shared_ptr<bmcweb::AsyncResp> asyncResp)
{
BMCWEB_LOG_DEBUG << "findRemainingObjectsForEnumerate";
- const nlohmann::json &dataJson = asyncResp->res.jsonValue["data"];
+ const nlohmann::json& dataJson = asyncResp->res.jsonValue["data"];
- for (const auto &[path, interface_map] : *subtree)
+ for (const auto& [path, interface_map] : *subtree)
{
if (path == objectPath)
{
@@ -179,9 +179,9 @@
}
if (dataJson.find(path) == dataJson.end())
{
- for (const auto &[service, interfaces] : interface_map)
+ for (const auto& [service, interfaces] : interface_map)
{
- for (const auto &interface : interfaces)
+ for (const auto& interface : interfaces)
{
if (!boost::starts_with(interface, "org.freedesktop.DBus"))
{
@@ -196,12 +196,11 @@
struct InProgressEnumerateData
{
- InProgressEnumerateData(const std::string &objectPath,
+ InProgressEnumerateData(const std::string& objectPath,
std::shared_ptr<bmcweb::AsyncResp> asyncResp) :
objectPath(objectPath),
asyncResp(asyncResp)
- {
- }
+ {}
~InProgressEnumerateData()
{
@@ -214,8 +213,8 @@
};
void getManagedObjectsForEnumerate(
- const std::string &object_name, const std::string &object_manager_path,
- const std::string &connection_name,
+ const std::string& object_name, const std::string& object_manager_path,
+ const std::string& connection_name,
std::shared_ptr<InProgressEnumerateData> transaction)
{
BMCWEB_LOG_DEBUG << "getManagedObjectsForEnumerate " << object_name
@@ -224,7 +223,7 @@
crow::connections::systemBus->async_method_call(
[transaction, object_name,
connection_name](const boost::system::error_code ec,
- const dbus::utility::ManagedObjectType &objects) {
+ const dbus::utility::ManagedObjectType& objects) {
if (ec)
{
BMCWEB_LOG_ERROR << "GetManagedObjects on path " << object_name
@@ -233,33 +232,33 @@
return;
}
- nlohmann::json &dataJson =
+ nlohmann::json& dataJson =
transaction->asyncResp->res.jsonValue["data"];
- for (const auto &objectPath : objects)
+ for (const auto& objectPath : objects)
{
if (boost::starts_with(objectPath.first.str, object_name))
{
BMCWEB_LOG_DEBUG << "Reading object "
<< objectPath.first.str;
- nlohmann::json &objectJson = dataJson[objectPath.first.str];
+ nlohmann::json& objectJson = dataJson[objectPath.first.str];
if (objectJson.is_null())
{
objectJson = nlohmann::json::object();
}
- for (const auto &interface : objectPath.second)
+ for (const auto& interface : objectPath.second)
{
- for (const auto &property : interface.second)
+ for (const auto& property : interface.second)
{
- nlohmann::json &propertyJson =
+ nlohmann::json& propertyJson =
objectJson[property.first];
std::visit([&propertyJson](
- auto &&val) { propertyJson = val; },
+ auto&& val) { propertyJson = val; },
property.second);
}
}
}
- for (const auto &interface : objectPath.second)
+ for (const auto& interface : objectPath.second)
{
if (interface.first == "org.freedesktop.DBus.ObjectManager")
{
@@ -275,7 +274,7 @@
}
void findObjectManagerPathForEnumerate(
- const std::string &object_name, const std::string &connection_name,
+ const std::string& object_name, const std::string& connection_name,
std::shared_ptr<InProgressEnumerateData> transaction)
{
BMCWEB_LOG_DEBUG << "Finding objectmanager for path " << object_name
@@ -285,8 +284,8 @@
const boost::system::error_code ec,
const boost::container::flat_map<
std::string, boost::container::flat_map<
- std::string, std::vector<std::string>>>
- &objects) {
+ std::string, std::vector<std::string>>>&
+ objects) {
if (ec)
{
BMCWEB_LOG_ERROR << "GetAncestors on path " << object_name
@@ -294,9 +293,9 @@
return;
}
- for (const auto &pathGroup : objects)
+ for (const auto& pathGroup : objects)
{
- for (const auto &connectionGroup : pathGroup.second)
+ for (const auto& connectionGroup : pathGroup.second)
{
if (connectionGroup.first == connection_name)
{
@@ -312,7 +311,7 @@
"xyz.openbmc_project.ObjectMapper",
"/xyz/openbmc_project/object_mapper",
"xyz.openbmc_project.ObjectMapper", "GetAncestors", object_name,
- std::array<const char *, 1>{"org.freedesktop.DBus.ObjectManager"});
+ std::array<const char*, 1>{"org.freedesktop.DBus.ObjectManager"});
}
// Uses GetObject to add the object info about the target /enumerate path to
@@ -325,7 +324,7 @@
crow::connections::systemBus->async_method_call(
[transaction](const boost::system::error_code ec,
- const GetObjectType &objects) {
+ const GetObjectType& objects) {
if (ec)
{
BMCWEB_LOG_ERROR << "GetObject for path "
@@ -346,13 +345,13 @@
// manager exists
boost::container::flat_map<std::string, std::string> connections;
- for (const auto &object : *(transaction->subtree))
+ for (const auto& object : *(transaction->subtree))
{
- for (const auto &connection : object.second)
+ for (const auto& connection : object.second)
{
- std::string &objectManagerPath =
+ std::string& objectManagerPath =
connections[connection.first];
- for (const auto &interface : connection.second)
+ for (const auto& interface : connection.second)
{
BMCWEB_LOG_DEBUG << connection.first
<< " has interface " << interface;
@@ -367,7 +366,7 @@
}
BMCWEB_LOG_DEBUG << "Got " << connections.size() << " connections";
- for (const auto &connection : connections)
+ for (const auto& connection : connections)
{
// If we already know where the object manager is, we don't
// need to search for it, we can call directly in to
@@ -390,13 +389,13 @@
"xyz.openbmc_project.ObjectMapper",
"/xyz/openbmc_project/object_mapper",
"xyz.openbmc_project.ObjectMapper", "GetObject",
- transaction->objectPath, std::array<const char *, 0>());
+ transaction->objectPath, std::array<const char*, 0>());
}
// Structure for storing data on an in progress action
struct InProgressActionData
{
- InProgressActionData(crow::Response &res) : res(res){};
+ InProgressActionData(crow::Response& res) : res(res){};
~InProgressActionData()
{
// Methods could have been called across different owners
@@ -440,12 +439,12 @@
res.end();
}
- void setErrorStatus(const std::string &desc)
+ void setErrorStatus(const std::string& desc)
{
setErrorResponse(res, boost::beast::http::status::bad_request, desc,
badReqMsg);
}
- crow::Response &res;
+ crow::Response& res;
std::string path;
std::string methodName;
std::string interfaceName;
@@ -457,7 +456,7 @@
nlohmann::json arguments;
};
-std::vector<std::string> dbusArgSplit(const std::string &string)
+std::vector<std::string> dbusArgSplit(const std::string& string)
{
std::vector<std::string> ret;
if (string.empty())
@@ -505,8 +504,8 @@
return ret;
}
-int convertJsonToDbus(sd_bus_message *m, const std::string &arg_type,
- const nlohmann::json &input_json)
+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()
@@ -514,10 +513,10 @@
const std::vector<std::string> argTypes = dbusArgSplit(arg_type);
// Assume a single object for now.
- const nlohmann::json *j = &input_json;
+ const nlohmann::json* j = &input_json;
nlohmann::json::const_iterator jIt = input_json.begin();
- for (const std::string &argCode : argTypes)
+ for (const std::string& argCode : argTypes)
{
// If we are decoding multiple objects, grab the pointer to the
// iterator, and increment it for the next loop
@@ -530,10 +529,10 @@
j = &*jIt;
jIt++;
}
- const int64_t *intValue = j->get_ptr<const int64_t *>();
- const std::string *stringValue = j->get_ptr<const std::string *>();
- const double *doubleValue = j->get_ptr<const double *>();
- const bool *b = j->get_ptr<const bool *>();
+ const int64_t* intValue = j->get_ptr<const int64_t*>();
+ const std::string* stringValue = j->get_ptr<const std::string*>();
+ const double* doubleValue = j->get_ptr<const double*>();
+ const bool* b = j->get_ptr<const bool*>();
int64_t v = 0;
double d = 0.0;
@@ -541,7 +540,7 @@
// converted to int. int and uint can be converted to double
if (intValue == nullptr)
{
- const uint64_t *uintValue = j->get_ptr<const uint64_t *>();
+ const uint64_t* uintValue = j->get_ptr<const uint64_t*>();
if (uintValue != nullptr)
{
v = static_cast<int64_t>(*uintValue);
@@ -550,7 +549,7 @@
}
if (doubleValue == nullptr)
{
- const uint64_t *uintValue = j->get_ptr<const uint64_t *>();
+ const uint64_t* uintValue = j->get_ptr<const uint64_t*>();
if (uintValue != nullptr)
{
d = static_cast<double>(*uintValue);
@@ -573,7 +572,7 @@
return -1;
}
r = sd_bus_message_append_basic(
- m, argCode[0], static_cast<const void *>(stringValue->data()));
+ m, argCode[0], static_cast<const void*>(stringValue->data()));
if (r < 0)
{
return r;
@@ -671,7 +670,7 @@
}
else if (argCode == "y")
{
- const uint64_t *uintValue = j->get_ptr<const uint64_t *>();
+ const uint64_t* uintValue = j->get_ptr<const uint64_t*>();
if (uintValue == nullptr)
{
return -1;
@@ -686,7 +685,7 @@
}
else if (argCode == "q")
{
- const uint64_t *uintValue = j->get_ptr<const uint64_t *>();
+ const uint64_t* uintValue = j->get_ptr<const uint64_t*>();
if (uintValue == nullptr)
{
return -1;
@@ -701,7 +700,7 @@
}
else if (argCode == "u")
{
- const uint64_t *uintValue = j->get_ptr<const uint64_t *>();
+ const uint64_t* uintValue = j->get_ptr<const uint64_t*>();
if (uintValue == nullptr)
{
return -1;
@@ -716,7 +715,7 @@
}
else if (argCode == "t")
{
- const uint64_t *uintValue = j->get_ptr<const uint64_t *>();
+ const uint64_t* uintValue = j->get_ptr<const uint64_t*>();
if (uintValue == nullptr)
{
return -1;
@@ -798,7 +797,7 @@
}
nlohmann::json::const_iterator it = j->begin();
- for (const std::string &argCode : dbusArgSplit(arg_type))
+ for (const std::string& argCode : dbusArgSplit(arg_type))
{
if (it == j->end())
{
@@ -829,8 +828,8 @@
{
return -1;
}
- const std::string &key_type = codes[0];
- const std::string &value_type = codes[1];
+ const std::string& key_type = codes[0];
+ const std::string& value_type = codes[1];
for (auto it : j->items())
{
r = convertJsonToDbus(m, key_type, it.key());
@@ -866,8 +865,8 @@
}
template <typename T>
-int readMessageItem(const std::string &typeCode, sdbusplus::message::message &m,
- nlohmann::json &data)
+int readMessageItem(const std::string& typeCode, sdbusplus::message::message& m,
+ nlohmann::json& data)
{
T value;
@@ -883,12 +882,12 @@
return 0;
}
-int convertDBusToJSON(const std::string &returnType,
- sdbusplus::message::message &m, nlohmann::json &response);
+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)
+int readDictEntryFromMessage(const std::string& typeCode,
+ sdbusplus::message::message& m,
+ nlohmann::json& object)
{
std::vector<std::string> types = dbusArgSplit(typeCode);
if (types.size() != 2)
@@ -913,13 +912,13 @@
return r;
}
- const std::string *keyPtr = key.get_ptr<const std::string *>();
+ const std::string* keyPtr = key.get_ptr<const std::string*>();
if (keyPtr == nullptr)
{
// json doesn't support non-string keys. If we hit this condition,
// convert the result to a string so we can proceed
key = key.dump();
- keyPtr = key.get_ptr<const std::string *>();
+ keyPtr = key.get_ptr<const std::string*>();
// in theory this can't fail now, but lets be paranoid about it
// anyway
if (keyPtr == nullptr)
@@ -927,7 +926,7 @@
return -1;
}
}
- nlohmann::json &value = object[*keyPtr];
+ nlohmann::json& value = object[*keyPtr];
r = convertDBusToJSON(types[1], m, value);
if (r < 0)
@@ -945,8 +944,8 @@
return 0;
}
-int readArrayFromMessage(const std::string &typeCode,
- sdbusplus::message::message &m, nlohmann::json &data)
+int readArrayFromMessage(const std::string& typeCode,
+ sdbusplus::message::message& m, nlohmann::json& data)
{
if (typeCode.size() < 2)
{
@@ -1025,8 +1024,8 @@
return 0;
}
-int readStructFromMessage(const std::string &typeCode,
- sdbusplus::message::message &m, nlohmann::json &data)
+int readStructFromMessage(const std::string& typeCode,
+ sdbusplus::message::message& m, nlohmann::json& data)
{
if (typeCode.size() < 3)
{
@@ -1047,7 +1046,7 @@
return r;
}
- for (const std::string &type : types)
+ for (const std::string& type : types)
{
data.push_back(nlohmann::json());
r = convertDBusToJSON(type, m, data.back());
@@ -1066,9 +1065,9 @@
return 0;
}
-int readVariantFromMessage(sdbusplus::message::message &m, nlohmann::json &data)
+int readVariantFromMessage(sdbusplus::message::message& m, nlohmann::json& data)
{
- const char *containerType;
+ const char* containerType;
int r = sd_bus_message_peek_type(m.get(), nullptr, &containerType);
if (r < 0)
{
@@ -1101,15 +1100,15 @@
return 0;
}
-int convertDBusToJSON(const std::string &returnType,
- sdbusplus::message::message &m, nlohmann::json &response)
+int convertDBusToJSON(const std::string& returnType,
+ sdbusplus::message::message& m, nlohmann::json& response)
{
int r = 0;
const std::vector<std::string> returnTypes = dbusArgSplit(returnType);
- for (const std::string &typeCode : returnTypes)
+ for (const std::string& typeCode : returnTypes)
{
- nlohmann::json *thisElement = &response;
+ nlohmann::json* thisElement = &response;
if (returnTypes.size() > 1)
{
response.push_back(nlohmann::json{});
@@ -1118,7 +1117,7 @@
if (typeCode == "s")
{
- r = readMessageItem<char *>(typeCode, m, *thisElement);
+ r = readMessageItem<char*>(typeCode, m, *thisElement);
if (r < 0)
{
return r;
@@ -1126,7 +1125,7 @@
}
else if (typeCode == "g")
{
- r = readMessageItem<char *>(typeCode, m, *thisElement);
+ r = readMessageItem<char*>(typeCode, m, *thisElement);
if (r < 0)
{
return r;
@@ -1134,7 +1133,7 @@
}
else if (typeCode == "o")
{
- r = readMessageItem<char *>(typeCode, m, *thisElement);
+ r = readMessageItem<char*>(typeCode, m, *thisElement);
if (r < 0)
{
return r;
@@ -1258,8 +1257,8 @@
}
void handleMethodResponse(std::shared_ptr<InProgressActionData> transaction,
- sdbusplus::message::message &m,
- const std::string &returnType)
+ sdbusplus::message::message& m,
+ const std::string& returnType)
{
nlohmann::json data;
@@ -1288,7 +1287,7 @@
if (transaction->methodResponse.is_object() && data.is_object())
{
- for (const auto &obj : data.items())
+ for (const auto& obj : data.items())
{
// Note: Will overwrite the data for a duplicate key
transaction->methodResponse.emplace(obj.key(),
@@ -1299,7 +1298,7 @@
if (transaction->methodResponse.is_array() && data.is_array())
{
- for (auto &obj : data)
+ for (auto& obj : data)
{
transaction->methodResponse.push_back(std::move(obj));
}
@@ -1322,14 +1321,14 @@
}
void findActionOnInterface(std::shared_ptr<InProgressActionData> transaction,
- const std::string &connectionName)
+ const std::string& connectionName)
{
BMCWEB_LOG_DEBUG << "findActionOnInterface for connection "
<< connectionName;
crow::connections::systemBus->async_method_call(
[transaction, connectionName{std::string(connectionName)}](
const boost::system::error_code ec,
- const std::string &introspect_xml) {
+ const std::string& introspect_xml) {
BMCWEB_LOG_DEBUG << "got xml:\n " << introspect_xml;
if (ec)
{
@@ -1341,18 +1340,18 @@
tinyxml2::XMLDocument doc;
doc.Parse(introspect_xml.data(), introspect_xml.size());
- tinyxml2::XMLNode *pRoot = doc.FirstChildElement("node");
+ tinyxml2::XMLNode* pRoot = doc.FirstChildElement("node");
if (pRoot == nullptr)
{
BMCWEB_LOG_ERROR << "XML document failed to parse "
<< connectionName << "\n";
return;
}
- tinyxml2::XMLElement *interfaceNode =
+ tinyxml2::XMLElement* interfaceNode =
pRoot->FirstChildElement("interface");
while (interfaceNode != nullptr)
{
- const char *thisInterfaceName =
+ const char* thisInterfaceName =
interfaceNode->Attribute("name");
if (thisInterfaceName != nullptr)
{
@@ -1364,11 +1363,11 @@
continue;
}
- tinyxml2::XMLElement *methodNode =
+ tinyxml2::XMLElement* methodNode =
interfaceNode->FirstChildElement("method");
while (methodNode != nullptr)
{
- const char *thisMethodName =
+ const char* thisMethodName =
methodNode->Attribute("name");
BMCWEB_LOG_DEBUG << "Found method: " << thisMethodName;
if (thisMethodName != nullptr &&
@@ -1384,7 +1383,7 @@
thisInterfaceName,
transaction->methodName.c_str());
- tinyxml2::XMLElement *argumentNode =
+ tinyxml2::XMLElement* argumentNode =
methodNode->FirstChildElement("arg");
std::string returnType;
@@ -1392,9 +1391,9 @@
// Find the output type
while (argumentNode != nullptr)
{
- const char *argDirection =
+ const char* argDirection =
argumentNode->Attribute("direction");
- const char *argType =
+ const char* argType =
argumentNode->Attribute("type");
if (argDirection != nullptr &&
argType != nullptr &&
@@ -1414,9 +1413,9 @@
while (argumentNode != nullptr)
{
- const char *argDirection =
+ const char* argDirection =
argumentNode->Attribute("direction");
- const char *argType =
+ const char* argType =
argumentNode->Attribute("type");
if (argDirection != nullptr &&
argType != nullptr &&
@@ -1446,11 +1445,11 @@
crow::connections::systemBus->async_send(
m, [transaction, returnType](
boost::system::error_code ec,
- sdbusplus::message::message &m) {
+ sdbusplus::message::message& m) {
if (ec)
{
transaction->methodFailed = true;
- const sd_bus_error *e = m.get_error();
+ const sd_bus_error* e = m.get_error();
if (e)
{
@@ -1491,8 +1490,8 @@
"org.freedesktop.DBus.Introspectable", "Introspect");
}
-void handleAction(const crow::Request &req, crow::Response &res,
- const std::string &objectPath, const std::string &methodName)
+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;
@@ -1530,8 +1529,8 @@
crow::connections::systemBus->async_method_call(
[transaction](
const boost::system::error_code ec,
- const std::vector<std::pair<std::string, std::vector<std::string>>>
- &interfaceNames) {
+ const std::vector<std::pair<std::string, std::vector<std::string>>>&
+ interfaceNames) {
if (ec || interfaceNames.size() <= 0)
{
BMCWEB_LOG_ERROR << "Can't find object";
@@ -1544,8 +1543,8 @@
BMCWEB_LOG_DEBUG << "GetObject returned " << interfaceNames.size()
<< " object(s)";
- for (const std::pair<std::string, std::vector<std::string>>
- &object : interfaceNames)
+ for (const std::pair<std::string, std::vector<std::string>>&
+ object : interfaceNames)
{
findActionOnInterface(transaction, object.first);
}
@@ -1556,16 +1555,16 @@
std::array<std::string, 0>());
}
-void handleDelete(const crow::Request &req, crow::Response &res,
- const std::string &objectPath)
+void handleDelete(const crow::Request& req, crow::Response& res,
+ const std::string& objectPath)
{
BMCWEB_LOG_DEBUG << "handleDelete on path: " << objectPath;
crow::connections::systemBus->async_method_call(
[&res, objectPath](
const boost::system::error_code ec,
- const std::vector<std::pair<std::string, std::vector<std::string>>>
- &interfaceNames) {
+ const std::vector<std::pair<std::string, std::vector<std::string>>>&
+ interfaceNames) {
if (ec || interfaceNames.size() <= 0)
{
BMCWEB_LOG_ERROR << "Can't find object";
@@ -1581,8 +1580,8 @@
transaction->methodName = "Delete";
transaction->interfaceName = "xyz.openbmc_project.Object.Delete";
- for (const std::pair<std::string, std::vector<std::string>>
- &object : interfaceNames)
+ for (const std::pair<std::string, std::vector<std::string>>&
+ object : interfaceNames)
{
findActionOnInterface(transaction, object.first);
}
@@ -1590,15 +1589,15 @@
"xyz.openbmc_project.ObjectMapper",
"/xyz/openbmc_project/object_mapper",
"xyz.openbmc_project.ObjectMapper", "GetObject", objectPath,
- std::array<const char *, 0>());
+ std::array<const char*, 0>());
}
-void handleList(crow::Response &res, const std::string &objectPath,
+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,
- std::vector<std::string> &objectPaths) {
+ std::vector<std::string>& objectPaths) {
if (ec)
{
setErrorResponse(res, boost::beast::http::status::not_found,
@@ -1618,7 +1617,7 @@
depth, std::array<std::string, 0>());
}
-void handleEnumerate(crow::Response &res, const std::string &objectPath)
+void handleEnumerate(crow::Response& res, const std::string& objectPath)
{
BMCWEB_LOG_DEBUG << "Doing enumerate on " << objectPath;
auto asyncResp = std::make_shared<bmcweb::AsyncResp>(res);
@@ -1629,7 +1628,7 @@
crow::connections::systemBus->async_method_call(
[objectPath, asyncResp](const boost::system::error_code ec,
- GetSubTreeType &object_names) {
+ GetSubTreeType& object_names) {
auto transaction = std::make_shared<InProgressEnumerateData>(
objectPath, asyncResp);
@@ -1653,11 +1652,11 @@
"xyz.openbmc_project.ObjectMapper",
"/xyz/openbmc_project/object_mapper",
"xyz.openbmc_project.ObjectMapper", "GetSubTree", objectPath, 0,
- std::array<const char *, 0>());
+ std::array<const char*, 0>());
}
-void handleGet(crow::Response &res, std::string &objectPath,
- std::string &destProperty)
+void handleGet(crow::Response& res, std::string& objectPath,
+ std::string& destProperty)
{
BMCWEB_LOG_DEBUG << "handleGet: " << objectPath << " prop:" << destProperty;
std::shared_ptr<std::string> propertyName =
@@ -1670,7 +1669,7 @@
std::vector<std::pair<std::string, std::vector<std::string>>>;
crow::connections::systemBus->async_method_call(
[&res, path, propertyName](const boost::system::error_code ec,
- const GetObjectType &object_names) {
+ const GetObjectType& object_names) {
if (ec || object_names.size() <= 0)
{
setErrorResponse(res, boost::beast::http::status::not_found,
@@ -1685,7 +1684,7 @@
for (const std::pair<std::string, std::vector<std::string>>
connection : object_names)
{
- const std::vector<std::string> &interfaceNames =
+ const std::vector<std::string>& interfaceNames =
connection.second;
if (interfaceNames.size() <= 0)
@@ -1696,7 +1695,7 @@
return;
}
- for (const std::string &interface : interfaceNames)
+ for (const std::string& interface : interfaceNames)
{
sdbusplus::message::message m =
crow::connections::systemBus->new_method_call(
@@ -1706,7 +1705,7 @@
crow::connections::systemBus->async_send(
m, [&res, response,
propertyName](const boost::system::error_code ec,
- sdbusplus::message::message &msg) {
+ sdbusplus::message::message& msg) {
if (ec)
{
BMCWEB_LOG_ERROR << "Bad dbus request error: "
@@ -1724,7 +1723,7 @@
}
else
{
- for (auto &prop : properties.items())
+ for (auto& prop : properties.items())
{
// if property name is empty, or
// matches our search query, add it
@@ -1771,9 +1770,8 @@
struct AsyncPutRequest
{
- AsyncPutRequest(crow::Response &res) : res(res)
- {
- }
+ AsyncPutRequest(crow::Response& res) : res(res)
+ {}
~AsyncPutRequest()
{
if (res.jsonValue.empty())
@@ -1785,20 +1783,20 @@
res.end();
}
- void setErrorStatus(const std::string &desc)
+ void setErrorStatus(const std::string& desc)
{
setErrorResponse(res, boost::beast::http::status::internal_server_error,
desc, badReqMsg);
}
- crow::Response &res;
+ crow::Response& res;
std::string objectPath;
std::string propertyName;
nlohmann::json propertyValue;
};
-void handlePut(const crow::Request &req, crow::Response &res,
- const std::string &objectPath, const std::string &destProperty)
+void handlePut(const crow::Request& req, crow::Response& res,
+ const std::string& objectPath, const std::string& destProperty)
{
if (destProperty.empty())
{
@@ -1827,7 +1825,7 @@
res.end();
return;
}
- const nlohmann::json &propertySetValue = *propertyIt;
+ const nlohmann::json& propertySetValue = *propertyIt;
auto transaction = std::make_shared<AsyncPutRequest>(res);
transaction->objectPath = objectPath;
transaction->propertyName = destProperty;
@@ -1838,7 +1836,7 @@
crow::connections::systemBus->async_method_call(
[transaction](const boost::system::error_code ec,
- const GetObjectType &object_names) {
+ const GetObjectType& object_names) {
if (!ec && object_names.size() <= 0)
{
setErrorResponse(transaction->res,
@@ -1850,12 +1848,12 @@
for (const std::pair<std::string, std::vector<std::string>>
connection : object_names)
{
- const std::string &connectionName = connection.first;
+ const std::string& connectionName = connection.first;
crow::connections::systemBus->async_method_call(
[connectionName{std::string(connectionName)},
transaction](const boost::system::error_code ec,
- const std::string &introspectXml) {
+ const std::string& introspectXml) {
if (ec)
{
BMCWEB_LOG_ERROR
@@ -1868,7 +1866,7 @@
tinyxml2::XMLDocument doc;
doc.Parse(introspectXml.c_str());
- tinyxml2::XMLNode *pRoot =
+ tinyxml2::XMLNode* pRoot =
doc.FirstChildElement("node");
if (pRoot == nullptr)
{
@@ -1877,25 +1875,25 @@
transaction->setErrorStatus("Unexpected Error");
return;
}
- tinyxml2::XMLElement *ifaceNode =
+ tinyxml2::XMLElement* ifaceNode =
pRoot->FirstChildElement("interface");
while (ifaceNode != nullptr)
{
- const char *interfaceName =
+ const char* interfaceName =
ifaceNode->Attribute("name");
BMCWEB_LOG_DEBUG << "found interface "
<< interfaceName;
- tinyxml2::XMLElement *propNode =
+ tinyxml2::XMLElement* propNode =
ifaceNode->FirstChildElement("property");
while (propNode != nullptr)
{
- const char *propertyName =
+ const char* propertyName =
propNode->Attribute("name");
BMCWEB_LOG_DEBUG << "Found property "
<< propertyName;
if (propertyName == transaction->propertyName)
{
- const char *argType =
+ const char* argType =
propNode->Attribute("type");
if (argType != nullptr)
{
@@ -1952,12 +1950,12 @@
[transaction](
boost::system::error_code
ec,
- sdbusplus::message::message
- &m) {
+ sdbusplus::message::message&
+ m) {
BMCWEB_LOG_DEBUG << "sent";
if (ec)
{
- const sd_bus_error *e =
+ const sd_bus_error* e =
m.get_error();
setErrorResponse(
transaction->res,
@@ -1999,14 +1997,14 @@
transaction->objectPath, std::array<std::string, 0>());
}
-inline void handleDBusUrl(const crow::Request &req, crow::Response &res,
- std::string &objectPath)
+inline void handleDBusUrl(const crow::Request& req, crow::Response& res,
+ std::string& objectPath)
{
// If accessing a single attribute, fill in and update objectPath,
// otherwise leave destProperty blank
std::string destProperty = "";
- const char *attrSeperator = "/attr/";
+ const char* attrSeperator = "/attr/";
size_t attrPosition = objectPath.find(attrSeperator);
if (attrPosition != objectPath.npos)
{
@@ -2017,7 +2015,7 @@
if (req.method() == "POST"_method)
{
- constexpr const char *actionSeperator = "/action/";
+ constexpr const char* actionSeperator = "/action/";
size_t actionPosition = objectPath.find(actionSeperator);
if (actionPosition != objectPath.npos)
{
@@ -2074,12 +2072,13 @@
res.end();
}
-template <typename... Middlewares> void requestRoutes(Crow<Middlewares...> &app)
+template <typename... Middlewares>
+void requestRoutes(Crow<Middlewares...>& app)
{
BMCWEB_ROUTE(app, "/bus/")
.requires({"Login"})
.methods("GET"_method)(
- [](const crow::Request &req, crow::Response &res) {
+ [](const crow::Request& req, crow::Response& res) {
res.jsonValue = {{"busses", {{{"name", "system"}}}},
{"status", "ok"}};
res.end();
@@ -2088,9 +2087,9 @@
BMCWEB_ROUTE(app, "/bus/system/")
.requires({"Login"})
.methods("GET"_method)(
- [](const crow::Request &req, crow::Response &res) {
+ [](const crow::Request& req, crow::Response& res) {
auto myCallback = [&res](const boost::system::error_code ec,
- std::vector<std::string> &names) {
+ std::vector<std::string>& names) {
if (ec)
{
BMCWEB_LOG_ERROR << "Dbus call failed with code " << ec;
@@ -2101,8 +2100,8 @@
{
std::sort(names.begin(), names.end());
res.jsonValue = {{"status", "ok"}};
- auto &objectsSub = res.jsonValue["objects"];
- for (auto &name : names)
+ auto& objectsSub = res.jsonValue["objects"];
+ for (auto& name : names)
{
objectsSub.push_back({{"name", name}});
}
@@ -2117,14 +2116,14 @@
BMCWEB_ROUTE(app, "/list/")
.requires({"Login"})
.methods("GET"_method)(
- [](const crow::Request &req, crow::Response &res) {
+ [](const crow::Request& req, crow::Response& res) {
handleList(res, "/");
});
BMCWEB_ROUTE(app, "/xyz/<path>")
.requires({"Login"})
- .methods("GET"_method)([](const crow::Request &req, crow::Response &res,
- const std::string &path) {
+ .methods("GET"_method)([](const crow::Request& req, crow::Response& res,
+ const std::string& path) {
std::string objectPath = "/xyz/" + path;
handleDBusUrl(req, res, objectPath);
});
@@ -2132,16 +2131,16 @@
BMCWEB_ROUTE(app, "/xyz/<path>")
.requires({"ConfigureComponents", "ConfigureManager"})
.methods("PUT"_method, "POST"_method, "DELETE"_method)(
- [](const crow::Request &req, crow::Response &res,
- const std::string &path) {
+ [](const crow::Request& req, crow::Response& res,
+ const std::string& path) {
std::string objectPath = "/xyz/" + path;
handleDBusUrl(req, res, objectPath);
});
BMCWEB_ROUTE(app, "/org/<path>")
.requires({"Login"})
- .methods("GET"_method)([](const crow::Request &req, crow::Response &res,
- const std::string &path) {
+ .methods("GET"_method)([](const crow::Request& req, crow::Response& res,
+ const std::string& path) {
std::string objectPath = "/org/" + path;
handleDBusUrl(req, res, objectPath);
});
@@ -2149,16 +2148,16 @@
BMCWEB_ROUTE(app, "/org/<path>")
.requires({"ConfigureComponents", "ConfigureManager"})
.methods("PUT"_method, "POST"_method, "DELETE"_method)(
- [](const crow::Request &req, crow::Response &res,
- const std::string &path) {
+ [](const crow::Request& req, crow::Response& res,
+ const std::string& path) {
std::string objectPath = "/org/" + path;
handleDBusUrl(req, res, objectPath);
});
BMCWEB_ROUTE(app, "/download/dump/<str>/")
.requires({"ConfigureManager"})
- .methods("GET"_method)([](const crow::Request &req, crow::Response &res,
- const std::string &dumpId) {
+ .methods("GET"_method)([](const crow::Request& req, crow::Response& res,
+ const std::string& dumpId) {
std::regex validFilename("^[\\w\\- ]+(\\.?[\\w\\- ]*)$");
if (!std::regex_match(dumpId, validFilename))
{
@@ -2181,7 +2180,7 @@
}
std::filesystem::directory_iterator files(loc);
- for (auto &file : files)
+ for (auto& file : files)
{
std::ifstream readFile(file.path());
if (!readFile.good())
@@ -2224,8 +2223,8 @@
BMCWEB_ROUTE(app, "/bus/system/<str>/")
.requires({"Login"})
- .methods("GET"_method)([](const crow::Request &req, crow::Response &res,
- const std::string &Connection) {
+ .methods("GET"_method)([](const crow::Request& req, crow::Response& res,
+ const std::string& Connection) {
introspectObjects(Connection, "/",
std::make_shared<bmcweb::AsyncResp>(res));
});
@@ -2233,10 +2232,10 @@
BMCWEB_ROUTE(app, "/bus/system/<str>/<path>")
.requires({"ConfigureComponents", "ConfigureManager"})
.methods("GET"_method,
- "POST"_method)([](const crow::Request &req,
- crow::Response &res,
- const std::string &processName,
- const std::string &requestedPath) {
+ "POST"_method)([](const crow::Request& req,
+ crow::Response& res,
+ const std::string& processName,
+ const std::string& requestedPath) {
std::vector<std::string> strs;
boost::split(strs, requestedPath, boost::is_any_of("/"));
std::string objectPath;
@@ -2293,7 +2292,7 @@
crow::connections::systemBus->async_method_call(
[asyncResp, processName,
objectPath](const boost::system::error_code ec,
- const std::string &introspect_xml) {
+ const std::string& introspect_xml) {
if (ec)
{
BMCWEB_LOG_ERROR
@@ -2306,7 +2305,7 @@
tinyxml2::XMLDocument doc;
doc.Parse(introspect_xml.c_str());
- tinyxml2::XMLNode *pRoot =
+ tinyxml2::XMLNode* pRoot =
doc.FirstChildElement("node");
if (pRoot == nullptr)
{
@@ -2325,15 +2324,15 @@
{"status", "ok"},
{"bus_name", processName},
{"object_path", objectPath}};
- nlohmann::json &interfacesArray =
+ nlohmann::json& interfacesArray =
asyncResp->res.jsonValue["interfaces"];
interfacesArray = nlohmann::json::array();
- tinyxml2::XMLElement *interface =
+ tinyxml2::XMLElement* interface =
pRoot->FirstChildElement("interface");
while (interface != nullptr)
{
- const char *ifaceName =
+ const char* ifaceName =
interface->Attribute("name");
if (ifaceName != nullptr)
{
@@ -2356,7 +2355,7 @@
crow::connections::systemBus->async_method_call(
[asyncResp, processName, objectPath,
interfaceName](const boost::system::error_code ec,
- const std::string &introspect_xml) {
+ const std::string& introspect_xml) {
if (ec)
{
BMCWEB_LOG_ERROR
@@ -2369,7 +2368,7 @@
tinyxml2::XMLDocument doc;
doc.Parse(introspect_xml.data(), introspect_xml.size());
- tinyxml2::XMLNode *pRoot =
+ tinyxml2::XMLNode* pRoot =
doc.FirstChildElement("node");
if (pRoot == nullptr)
{
@@ -2386,25 +2385,25 @@
{"interface", interfaceName},
{"object_path", objectPath}};
- nlohmann::json &methodsArray =
+ nlohmann::json& methodsArray =
asyncResp->res.jsonValue["methods"];
methodsArray = nlohmann::json::array();
- nlohmann::json &signalsArray =
+ nlohmann::json& signalsArray =
asyncResp->res.jsonValue["signals"];
signalsArray = nlohmann::json::array();
- nlohmann::json &propertiesObj =
+ nlohmann::json& propertiesObj =
asyncResp->res.jsonValue["properties"];
propertiesObj = nlohmann::json::object();
// if we know we're the only call, build the
// json directly
- tinyxml2::XMLElement *interface =
+ tinyxml2::XMLElement* interface =
pRoot->FirstChildElement("interface");
while (interface != nullptr)
{
- const char *ifaceName =
+ const char* ifaceName =
interface->Attribute("name");
if (ifaceName != nullptr &&
@@ -2425,21 +2424,21 @@
return;
}
- tinyxml2::XMLElement *methods =
+ tinyxml2::XMLElement* methods =
interface->FirstChildElement("method");
while (methods != nullptr)
{
nlohmann::json argsArray = nlohmann::json::array();
- tinyxml2::XMLElement *arg =
+ tinyxml2::XMLElement* arg =
methods->FirstChildElement("arg");
while (arg != nullptr)
{
nlohmann::json thisArg;
- for (const char *fieldName :
- std::array<const char *, 3>{
+ for (const char* fieldName :
+ std::array<const char*, 3>{
"name", "direction", "type"})
{
- const char *fieldValue =
+ const char* fieldValue =
arg->Attribute(fieldName);
if (fieldValue != nullptr)
{
@@ -2450,7 +2449,7 @@
arg = arg->NextSiblingElement("arg");
}
- const char *name = methods->Attribute("name");
+ const char* name = methods->Attribute("name");
if (name != nullptr)
{
methodsArray.push_back(
@@ -2462,18 +2461,18 @@
}
methods = methods->NextSiblingElement("method");
}
- tinyxml2::XMLElement *signals =
+ tinyxml2::XMLElement* signals =
interface->FirstChildElement("signal");
while (signals != nullptr)
{
nlohmann::json argsArray = nlohmann::json::array();
- tinyxml2::XMLElement *arg =
+ tinyxml2::XMLElement* arg =
signals->FirstChildElement("arg");
while (arg != nullptr)
{
- const char *name = arg->Attribute("name");
- const char *type = arg->Attribute("type");
+ const char* name = arg->Attribute("name");
+ const char* type = arg->Attribute("type");
if (name != nullptr && type != nullptr)
{
argsArray.push_back({
@@ -2483,7 +2482,7 @@
}
arg = arg->NextSiblingElement("arg");
}
- const char *name = signals->Attribute("name");
+ const char* name = signals->Attribute("name");
if (name != nullptr)
{
signalsArray.push_back(
@@ -2493,12 +2492,12 @@
signals = signals->NextSiblingElement("signal");
}
- tinyxml2::XMLElement *property =
+ tinyxml2::XMLElement* property =
interface->FirstChildElement("property");
while (property != nullptr)
{
- const char *name = property->Attribute("name");
- const char *type = property->Attribute("type");
+ const char* name = property->Attribute("name");
+ const char* type = property->Attribute("type");
if (type != nullptr && name != nullptr)
{
sdbusplus::message::message m =
@@ -2510,12 +2509,12 @@
"Properties",
"Get");
m.append(interfaceName, name);
- nlohmann::json &propertyItem =
+ nlohmann::json& propertyItem =
propertiesObj[name];
crow::connections::systemBus->async_send(
m, [&propertyItem, asyncResp](
- boost::system::error_code &e,
- sdbusplus::message::message &msg) {
+ boost::system::error_code& e,
+ sdbusplus::message::message& msg) {
if (e)
{
return;
diff --git a/include/pam_authenticate.hpp b/include/pam_authenticate.hpp
index f8afbb1..59c8cd6 100644
--- a/include/pam_authenticate.hpp
+++ b/include/pam_authenticate.hpp
@@ -3,6 +3,7 @@
#include <security/pam_appl.h>
#include <boost/utility/string_view.hpp>
+
#include <cstring>
#include <memory>
diff --git a/include/persistent_data_middleware.hpp b/include/persistent_data_middleware.hpp
index 348079b..de3a6ba 100644
--- a/include/persistent_data_middleware.hpp
+++ b/include/persistent_data_middleware.hpp
@@ -8,13 +8,14 @@
#include <boost/uuid/uuid.hpp>
#include <boost/uuid/uuid_generators.hpp>
#include <boost/uuid/uuid_io.hpp>
-#include <filesystem>
#include <nlohmann/json.hpp>
#include <pam_authenticate.hpp>
-#include <random>
#include <sessions.hpp>
#include <webassets.hpp>
+#include <filesystem>
+#include <random>
+
namespace crow
{
@@ -32,8 +33,7 @@
static constexpr const char* filename = "bmcweb_persistent_data.json";
struct Context
- {
- };
+ {};
Middleware()
{
@@ -49,12 +49,10 @@
}
void beforeHandle(crow::Request& req, Response& res, Context& ctx)
- {
- }
+ {}
void afterHandle(Request& req, Response& res, Context& ctx)
- {
- }
+ {}
// TODO(ed) this should really use protobuf, or some other serialization
// library, but adding another dependency is somewhat outside the scope of
diff --git a/include/redfish_v1.hpp b/include/redfish_v1.hpp
index 3e97ad1..d77d893 100644
--- a/include/redfish_v1.hpp
+++ b/include/redfish_v1.hpp
@@ -4,16 +4,18 @@
#include <boost/algorithm/string.hpp>
#include <dbus_singleton.hpp>
-#include <fstream>
#include <persistent_data_middleware.hpp>
+#include <token_authorization_middleware.hpp>
+
+#include <fstream>
#include <streambuf>
#include <string>
-#include <token_authorization_middleware.hpp>
namespace crow
{
namespace redfish
{
-template <typename... Middlewares> void requestRoutes(Crow<Middlewares...>& app)
+template <typename... Middlewares>
+void requestRoutes(Crow<Middlewares...>& app)
{
BMCWEB_ROUTE(app, "/redfish/")
.methods("GET"_method)(
diff --git a/include/security_headers_middleware.hpp b/include/security_headers_middleware.hpp
index f60ce76..ec72cbb 100644
--- a/include/security_headers_middleware.hpp
+++ b/include/security_headers_middleware.hpp
@@ -8,8 +8,7 @@
struct SecurityHeadersMiddleware
{
struct Context
- {
- };
+ {};
void beforeHandle(crow::Request& req, Response& res, Context& ctx)
{
diff --git a/include/sessions.hpp b/include/sessions.hpp
index a7ffe28..1176cfc 100644
--- a/include/sessions.hpp
+++ b/include/sessions.hpp
@@ -1,20 +1,21 @@
#pragma once
+#include "logging.h"
+#include "utility.h"
+
#include <openssl/rand.h>
#include <boost/container/flat_map.hpp>
#include <boost/uuid/uuid.hpp>
#include <boost/uuid/uuid_generators.hpp>
#include <boost/uuid/uuid_io.hpp>
-#include <csignal>
#include <dbus_singleton.hpp>
#include <nlohmann/json.hpp>
#include <pam_authenticate.hpp>
-#include <random>
#include <sdbusplus/bus/match.hpp>
-#include "logging.h"
-#include "utility.h"
+#include <csignal>
+#include <random>
#ifdef BMCWEB_ENABLE_IBM_MANAGEMENT_CONSOLE
#include <ibm/locks.hpp>
#endif
@@ -366,8 +367,7 @@
private:
SessionStore() : timeoutInMinutes(60)
- {
- }
+ {}
void applySessionTimeouts()
{
@@ -431,7 +431,8 @@
}
};
-template <> struct adl_serializer<crow::persistent_data::AuthConfigMethods>
+template <>
+struct adl_serializer<crow::persistent_data::AuthConfigMethods>
{
static void to_json(nlohmann::json& j,
const crow::persistent_data::AuthConfigMethods& c)
diff --git a/include/ssl_key_handler.hpp b/include/ssl_key_handler.hpp
index 57c96a5..7178195 100644
--- a/include/ssl_key_handler.hpp
+++ b/include/ssl_key_handler.hpp
@@ -12,13 +12,14 @@
#include <openssl/ssl.h>
#include <boost/asio/ssl/context.hpp>
+
#include <random>
namespace ensuressl
{
-constexpr char const *trustStorePath = "/etc/ssl/certs/authority";
+constexpr char const* trustStorePath = "/etc/ssl/certs/authority";
static void initOpenssl();
-static EVP_PKEY *createEcKey();
+static EVP_PKEY* createEcKey();
// Trust chain related errors.`
inline bool isTrustChainError(int errnum)
@@ -37,10 +38,10 @@
}
}
-inline bool validateCertificate(X509 *const cert)
+inline bool validateCertificate(X509* const cert)
{
// Create an empty X509_STORE structure for certificate validation.
- X509_STORE *x509Store = X509_STORE_new();
+ X509_STORE* x509Store = X509_STORE_new();
if (!x509Store)
{
BMCWEB_LOG_ERROR << "Error occured during X509_STORE_new call";
@@ -48,7 +49,7 @@
}
// Load Certificate file into the X509 structure.
- X509_STORE_CTX *storeCtx = X509_STORE_CTX_new();
+ X509_STORE_CTX* storeCtx = X509_STORE_CTX_new();
if (!storeCtx)
{
BMCWEB_LOG_ERROR << "Error occured during X509_STORE_CTX_new call";
@@ -99,20 +100,20 @@
return false;
}
-inline bool verifyOpensslKeyCert(const std::string &filepath)
+inline bool verifyOpensslKeyCert(const std::string& filepath)
{
bool privateKeyValid = false;
bool certValid = false;
std::cout << "Checking certs in file " << filepath << "\n";
- FILE *file = fopen(filepath.c_str(), "r");
+ FILE* file = fopen(filepath.c_str(), "r");
if (file != nullptr)
{
- EVP_PKEY *pkey = PEM_read_PrivateKey(file, nullptr, nullptr, nullptr);
+ EVP_PKEY* pkey = PEM_read_PrivateKey(file, nullptr, nullptr, nullptr);
if (pkey != nullptr)
{
- RSA *rsa = EVP_PKEY_get1_RSA(pkey);
+ RSA* rsa = EVP_PKEY_get1_RSA(pkey);
if (rsa != nullptr)
{
std::cout << "Found an RSA key\n";
@@ -129,7 +130,7 @@
}
else
{
- EC_KEY *ec = EVP_PKEY_get1_EC_KEY(pkey);
+ EC_KEY* ec = EVP_PKEY_get1_EC_KEY(pkey);
if (ec != nullptr)
{
std::cout << "Found an EC key\n";
@@ -154,7 +155,7 @@
// key order issue.
fseek(file, 0, SEEK_SET);
- X509 *x509 = PEM_read_X509(file, nullptr, nullptr, nullptr);
+ X509* x509 = PEM_read_X509(file, nullptr, nullptr, nullptr);
if (x509 == nullptr)
{
std::cout << "error getting x509 cert " << ERR_get_error()
@@ -174,19 +175,19 @@
return certValid;
}
-inline void generateSslCertificate(const std::string &filepath)
+inline void generateSslCertificate(const std::string& filepath)
{
- FILE *pFile = nullptr;
+ FILE* pFile = nullptr;
std::cout << "Generating new keys\n";
initOpenssl();
std::cerr << "Generating EC key\n";
- EVP_PKEY *pPrivKey = createEcKey();
+ EVP_PKEY* pPrivKey = createEcKey();
if (pPrivKey != nullptr)
{
std::cerr << "Generating x509 Certificate\n";
// Use this code to directly generate a certificate
- X509 *x509;
+ X509* x509;
x509 = X509_new();
if (x509 != nullptr)
{
@@ -208,18 +209,18 @@
X509_set_pubkey(x509, pPrivKey);
// get the subject name
- X509_NAME *name;
+ X509_NAME* name;
name = X509_get_subject_name(x509);
X509_NAME_add_entry_by_txt(
name, "C", MBSTRING_ASC,
- reinterpret_cast<const unsigned char *>("US"), -1, -1, 0);
+ reinterpret_cast<const unsigned char*>("US"), -1, -1, 0);
X509_NAME_add_entry_by_txt(
name, "O", MBSTRING_ASC,
- reinterpret_cast<const unsigned char *>("OpenBMC"), -1, -1, 0);
+ reinterpret_cast<const unsigned char*>("OpenBMC"), -1, -1, 0);
X509_NAME_add_entry_by_txt(
name, "CN", MBSTRING_ASC,
- reinterpret_cast<const unsigned char *>("testhost"), -1, -1, 0);
+ reinterpret_cast<const unsigned char*>("testhost"), -1, -1, 0);
// set the CSR options
X509_set_issuer_name(x509, name);
@@ -248,13 +249,13 @@
// cleanup_openssl();
}
-EVP_PKEY *createEcKey()
+EVP_PKEY* createEcKey()
{
- EVP_PKEY *pKey = nullptr;
+ EVP_PKEY* pKey = nullptr;
int eccgrp = 0;
eccgrp = OBJ_txt2nid("secp384r1");
- EC_KEY *myecc = EC_KEY_new_by_curve_name(eccgrp);
+ EC_KEY* myecc = EC_KEY_new_by_curve_name(eccgrp);
if (myecc != nullptr)
{
EC_KEY_set_asn1_flag(myecc, OPENSSL_EC_NAMED_CURVE);
@@ -284,7 +285,7 @@
#endif
}
-inline void ensureOpensslKeyPresentAndValid(const std::string &filepath)
+inline void ensureOpensslKeyPresentAndValid(const std::string& filepath)
{
bool pemFileValid = false;
@@ -298,7 +299,7 @@
}
inline std::shared_ptr<boost::asio::ssl::context>
- getSslContext(const std::string &ssl_pem_file)
+ getSslContext(const std::string& ssl_pem_file)
{
std::shared_ptr<boost::asio::ssl::context> mSslContext =
std::make_shared<boost::asio::ssl::context>(
diff --git a/include/token_authorization_middleware.hpp b/include/token_authorization_middleware.hpp
index ccea929..a455926 100644
--- a/include/token_authorization_middleware.hpp
+++ b/include/token_authorization_middleware.hpp
@@ -8,9 +8,10 @@
#include <boost/container/flat_set.hpp>
#include <pam_authenticate.hpp>
#include <persistent_data_middleware.hpp>
-#include <random>
#include <webassets.hpp>
+#include <random>
+
namespace crow
{
@@ -21,8 +22,7 @@
{
public:
struct Context
- {
- };
+ {};
void beforeHandle(crow::Request& req, Response& res, Context& ctx)
{
@@ -282,7 +282,8 @@
// TODO(ed) see if there is a better way to allow middlewares to request
// routes.
// Possibly an init function on first construction?
-template <typename... Middlewares> void requestRoutes(Crow<Middlewares...>& app)
+template <typename... Middlewares>
+void requestRoutes(Crow<Middlewares...>& app)
{
static_assert(
black_magic::Contains<persistent_data::Middleware,
diff --git a/include/vm_websocket.hpp b/include/vm_websocket.hpp
index a8380a7..07f72c6 100644
--- a/include/vm_websocket.hpp
+++ b/include/vm_websocket.hpp
@@ -5,9 +5,10 @@
#include <boost/beast/core/flat_static_buffer.hpp>
#include <boost/process.hpp>
-#include <csignal>
#include <webserver_common.hpp>
+#include <csignal>
+
namespace crow
{
namespace obmc_vm
@@ -27,8 +28,7 @@
pipeOut(ios), pipeIn(ios), media(mediaIn), doingWrite(false),
outputBuffer(new boost::beast::flat_static_buffer<nbdBufferSize>),
inputBuffer(new boost::beast::flat_static_buffer<nbdBufferSize>)
- {
- }
+ {}
~Handler() = default;
@@ -155,7 +155,8 @@
static std::shared_ptr<Handler> handler;
-template <typename... Middlewares> void requestRoutes(Crow<Middlewares...>& app)
+template <typename... Middlewares>
+void requestRoutes(Crow<Middlewares...>& app)
{
BMCWEB_ROUTE(app, "/vm/0/0")
.requires({"ConfigureComponents", "ConfigureManager"})
diff --git a/include/webassets.hpp b/include/webassets.hpp
index 847696a..fc58d37 100644
--- a/include/webassets.hpp
+++ b/include/webassets.hpp
@@ -7,6 +7,7 @@
#include <boost/algorithm/string/replace.hpp>
#include <boost/container/flat_set.hpp>
+
#include <filesystem>
#include <fstream>
#include <string>
@@ -28,7 +29,8 @@
static boost::container::flat_set<std::string> routes;
-template <typename... Middlewares> void requestRoutes(Crow<Middlewares...>& app)
+template <typename... Middlewares>
+void requestRoutes(Crow<Middlewares...>& app)
{
const static boost::container::flat_map<const char*, const char*, CmpStr>
contentTypes{