diff options
author | Patrick Williams <patrick@stwcx.xyz> | 2023-10-20 19:20:21 +0300 |
---|---|---|
committer | Ed Tanous <ed@tanous.net> | 2023-10-24 21:17:16 +0300 |
commit | 5a39f77a17fa28911c87caea1e2903c059e7ec41 (patch) | |
tree | a2a2ff266238e7e9322e36eb2d9c92cf18829406 /include/openbmc_dbus_rest.hpp | |
parent | e9cc1bc93c4ad9662c93e2a98d4c787e2dbf9f07 (diff) | |
download | bmcweb-5a39f77a17fa28911c87caea1e2903c059e7ec41.tar.xz |
clang-format: copy latest and re-format
clang-format-17 has some backwards incompatible changes that require
additional settings for best compatibility and re-running the formatter.
Copy the latest .clang-format from the docs repository and reformat the
repository.
Change-Id: I2f9540cf0d545a2da4d6289fc87b754f684bc9a7
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Diffstat (limited to 'include/openbmc_dbus_rest.hpp')
-rw-r--r-- | include/openbmc_dbus_rest.hpp | 158 |
1 files changed, 78 insertions, 80 deletions
diff --git a/include/openbmc_dbus_rest.hpp b/include/openbmc_dbus_rest.hpp index 7c47bcc5fc..bade59e11b 100644 --- a/include/openbmc_dbus_rest.hpp +++ b/include/openbmc_dbus_rest.hpp @@ -176,7 +176,7 @@ inline void node = node->NextSiblingElement("node"); } } - }, + }, processName, objectPath, "org.freedesktop.DBus.Introspectable", "Introspect"); } @@ -223,10 +223,10 @@ inline void getPropertiesForEnumerate( { propertyJson = val; } - }, + }, value); } - }); + }); } // Find any results that weren't picked up by ObjectManagers, to be @@ -347,7 +347,7 @@ inline void getManagedObjectsForEnumerate( { propertyJson = val; } - }, + }, property.second); } } @@ -362,7 +362,7 @@ inline void getManagedObjectsForEnumerate( } } } - }); + }); } inline void findObjectManagerPathForEnumerate( @@ -395,7 +395,7 @@ inline void findObjectManagerPathForEnumerate( } } } - }, + }, "xyz.openbmc_project.ObjectMapper", "/xyz/openbmc_project/object_mapper", "xyz.openbmc_project.ObjectMapper", "GetAncestors", objectName, @@ -469,7 +469,7 @@ inline void getObjectAndEnumerate( transaction->objectPath, connection.first, transaction); } } - }); + }); } // Structure for storing data on an in progress action @@ -1487,10 +1487,9 @@ inline void findActionOnInterface( } crow::connections::systemBus->async_send( - m, - [transaction, - returnType](const boost::system::error_code& ec2, - sdbusplus::message_t& m2) { + m, [transaction, returnType]( + const boost::system::error_code& ec2, + sdbusplus::message_t& m2) { if (ec2) { transaction->methodFailed = true; @@ -1515,7 +1514,7 @@ inline void findActionOnInterface( transaction->methodPassed = true; handleMethodResponse(transaction, m2, returnType); - }); + }); break; } methodNode = methodNode->NextSiblingElement("method"); @@ -1523,7 +1522,7 @@ inline void findActionOnInterface( } interfaceNode = interfaceNode->NextSiblingElement("interface"); } - }, + }, connectionName, transaction->path, "org.freedesktop.DBus.Introspectable", "Introspect"); } @@ -1596,7 +1595,7 @@ inline void handleAction(const crow::Request& req, { findActionOnInterface(transaction, object.first); } - }); + }); } inline void handleDelete(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, @@ -1629,7 +1628,7 @@ inline void handleDelete(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, { findActionOnInterface(transaction, object.first); } - }); + }); } inline void handleList(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, @@ -1652,7 +1651,7 @@ inline void handleList(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, asyncResp->res.jsonValue["message"] = "200 OK"; asyncResp->res.jsonValue["data"] = objectPaths; } - }); + }); } inline void handleEnumerate(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, @@ -1689,7 +1688,7 @@ inline void handleEnumerate(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, // Add the data for the path passed in to the results // as if GetSubTree returned it, and continue on enumerating getObjectAndEnumerate(transaction); - }); + }); } inline void handleGet(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, @@ -1742,58 +1741,58 @@ inline void handleGet(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, m, [asyncResp, response, propertyName](const boost::system::error_code& ec2, sdbusplus::message_t& msg) { - if (ec2) + if (ec2) + { + BMCWEB_LOG_ERROR("Bad dbus request error: {}", ec2); + } + else + { + nlohmann::json properties; + int r = convertDBusToJSON("a{sv}", msg, properties); + if (r < 0) { - BMCWEB_LOG_ERROR("Bad dbus request error: {}", ec2); + BMCWEB_LOG_ERROR("convertDBusToJSON failed"); } else { - nlohmann::json properties; - int r = convertDBusToJSON("a{sv}", msg, properties); - if (r < 0) - { - BMCWEB_LOG_ERROR("convertDBusToJSON failed"); - } - else + for (const auto& prop : properties.items()) { - for (const auto& prop : properties.items()) - { - // if property name is empty, or - // matches our search query, add it - // to the response json + // if property name is empty, or + // matches our search query, add it + // to the response json - if (propertyName->empty()) - { - (*response)[prop.key()] = - std::move(prop.value()); - } - else if (prop.key() == *propertyName) - { - *response = std::move(prop.value()); - } + if (propertyName->empty()) + { + (*response)[prop.key()] = + std::move(prop.value()); + } + else if (prop.key() == *propertyName) + { + *response = std::move(prop.value()); } } } - if (response.use_count() == 1) + } + if (response.use_count() == 1) + { + if (!propertyName->empty() && response->empty()) { - if (!propertyName->empty() && response->empty()) - { - setErrorResponse( - asyncResp->res, - boost::beast::http::status::not_found, - propNotFoundDesc, notFoundMsg); - } - else - { - asyncResp->res.jsonValue["status"] = "ok"; - asyncResp->res.jsonValue["message"] = "200 OK"; - asyncResp->res.jsonValue["data"] = *response; - } + setErrorResponse( + asyncResp->res, + boost::beast::http::status::not_found, + propNotFoundDesc, notFoundMsg); } - }); + else + { + asyncResp->res.jsonValue["status"] = "ok"; + asyncResp->res.jsonValue["message"] = "200 OK"; + asyncResp->res.jsonValue["data"] = *response; + } + } + }); } } - }); + }); } struct AsyncPutRequest @@ -1975,10 +1974,9 @@ inline void handlePut(const crow::Request& req, return; } crow::connections::systemBus->async_send( - m, - [transaction]( - const boost::system::error_code& ec, - sdbusplus::message_t& m2) { + m, [transaction]( + const boost::system::error_code& ec, + sdbusplus::message_t& m2) { BMCWEB_LOG_DEBUG("sent"); if (ec) { @@ -2002,18 +2000,18 @@ inline void handlePut(const crow::Request& req, transaction->asyncResp->res .jsonValue["data"] = nullptr; } - }); + }); } } propNode = propNode->NextSiblingElement("property"); } ifaceNode = ifaceNode->NextSiblingElement("interface"); } - }, + }, connectionName, transaction->objectPath, "org.freedesktop.DBus.Introspectable", "Introspect"); } - }); + }); } inline void handleDBusUrl(const crow::Request& req, @@ -2195,7 +2193,7 @@ inline void interface = interface->NextSiblingElement("interface"); } - }, + }, processName, objectPath, "org.freedesktop.DBus.Introspectable", "Introspect"); } @@ -2361,17 +2359,17 @@ inline void m, [&propertyItem, asyncResp](const boost::system::error_code& ec2, sdbusplus::message_t& msg) { - if (ec2) - { - return; - } + if (ec2) + { + return; + } - convertDBusToJSON("v", msg, propertyItem); - }); + convertDBusToJSON("v", msg, propertyItem); + }); } property = property->NextSiblingElement("property"); } - }, + }, processName, objectPath, "org.freedesktop.DBus.Introspectable", "Introspect"); } @@ -2427,7 +2425,7 @@ inline void requestRoutes(App& app) bus["name"] = "system"; asyncResp->res.jsonValue["busses"] = std::move(buses); asyncResp->res.jsonValue["status"] = "ok"; - }); + }); BMCWEB_ROUTE(app, "/bus/system/") .privileges({{"Login"}}) @@ -2458,7 +2456,7 @@ inline void requestRoutes(App& app) crow::connections::systemBus->async_method_call( std::move(myCallback), "org.freedesktop.DBus", "/", "org.freedesktop.DBus", "ListNames"); - }); + }); BMCWEB_ROUTE(app, "/list/") .privileges({{"Login"}}) @@ -2466,7 +2464,7 @@ inline void requestRoutes(App& app) [](const crow::Request&, const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) { handleList(asyncResp, "/"); - }); + }); BMCWEB_ROUTE(app, "/xyz/<path>") .privileges({{"Login"}}) @@ -2476,7 +2474,7 @@ inline void requestRoutes(App& app) const std::string& path) { std::string objectPath = "/xyz/" + path; handleDBusUrl(req, asyncResp, objectPath); - }); + }); BMCWEB_ROUTE(app, "/xyz/<path>") .privileges({{"ConfigureComponents", "ConfigureManager"}}) @@ -2487,7 +2485,7 @@ inline void requestRoutes(App& app) const std::string& path) { std::string objectPath = "/xyz/" + path; handleDBusUrl(req, asyncResp, objectPath); - }); + }); BMCWEB_ROUTE(app, "/org/<path>") .privileges({{"Login"}}) @@ -2497,7 +2495,7 @@ inline void requestRoutes(App& app) const std::string& path) { std::string objectPath = "/org/" + path; handleDBusUrl(req, asyncResp, objectPath); - }); + }); BMCWEB_ROUTE(app, "/org/<path>") .privileges({{"ConfigureComponents", "ConfigureManager"}}) @@ -2508,7 +2506,7 @@ inline void requestRoutes(App& app) const std::string& path) { std::string objectPath = "/org/" + path; handleDBusUrl(req, asyncResp, objectPath); - }); + }); BMCWEB_ROUTE(app, "/download/dump/<str>/") .privileges({{"ConfigureManager"}}) @@ -2572,7 +2570,7 @@ inline void requestRoutes(App& app) } asyncResp->res.result(boost::beast::http::status::not_found); return; - }); + }); BMCWEB_ROUTE(app, "/bus/system/<str>/") .privileges({{"Login"}}) @@ -2582,7 +2580,7 @@ inline void requestRoutes(App& app) const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, const std::string& connection) { introspectObjects(connection, "/", asyncResp); - }); + }); BMCWEB_ROUTE(app, "/bus/system/<str>/<path>") .privileges({{"ConfigureComponents", "ConfigureManager"}}) |