clang-format: re-format for clang-18
clang-format-18 isn't compatible with the clang-format-17 output, so we
need to reformat the code with the latest version. The way clang-18
handles lambda formatting also changed, so we have made changes to the
organization default style format to better handle lambda formatting.
See I5e08687e696dd240402a2780158664b7113def0e for updated style.
See Iea0776aaa7edd483fa395e23de25ebf5a6288f71 for clang-18 enablement.
Change-Id: Iceec1dc95b6c908ec6c21fb40093de9dd18bf11a
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/redfish-core/lib/task.hpp b/redfish-core/lib/task.hpp
index 084e561..78193bc 100644
--- a/redfish-core/lib/task.hpp
+++ b/redfish-core/lib/task.hpp
@@ -74,8 +74,8 @@
continue;
}
std::string header;
- header.reserve(field.name_string().size() + 2 +
- field.value().size());
+ header.reserve(
+ field.name_string().size() + 2 + field.value().size());
header += field.name_string();
header += ": ";
header += field.value();
@@ -97,8 +97,7 @@
std::function<bool(boost::system::error_code, sdbusplus::message_t&,
const std::shared_ptr<TaskData>&)>&& handler,
const std::string& matchIn, size_t idx) :
- callback(std::move(handler)),
- matchStr(matchIn), index(idx),
+ callback(std::move(handler)), matchStr(matchIn), index(idx),
startTime(std::chrono::system_clock::to_time_t(
std::chrono::system_clock::now())),
status("OK"), state("Running"), messages(nlohmann::json::array()),
@@ -181,26 +180,26 @@
timer.expires_after(timeout);
timer.async_wait(
[self = shared_from_this()](boost::system::error_code ec) {
- if (ec == boost::asio::error::operation_aborted)
- {
- return; // completed successfully
- }
- if (!ec)
- {
- // change ec to error as timer expired
- ec = boost::asio::error::operation_aborted;
- }
- self->match.reset();
- sdbusplus::message_t msg;
- self->finishTask();
- self->state = "Cancelled";
- self->status = "Warning";
- self->messages.emplace_back(
- messages::taskAborted(std::to_string(self->index)));
- // Send event :TaskAborted
- self->sendTaskEvent(self->state, self->index);
- self->callback(ec, msg, self);
- });
+ if (ec == boost::asio::error::operation_aborted)
+ {
+ return; // completed successfully
+ }
+ if (!ec)
+ {
+ // change ec to error as timer expired
+ ec = boost::asio::error::operation_aborted;
+ }
+ self->match.reset();
+ sdbusplus::message_t msg;
+ self->finishTask();
+ self->state = "Cancelled";
+ self->status = "Warning";
+ self->messages.emplace_back(
+ messages::taskAborted(std::to_string(self->index)));
+ // Send event :TaskAborted
+ self->sendTaskEvent(self->state, self->index);
+ self->callback(ec, msg, self);
+ });
}
static void sendTaskEvent(std::string_view state, size_t index)
@@ -272,25 +271,25 @@
static_cast<sdbusplus::bus_t&>(*crow::connections::systemBus),
matchStr,
[self = shared_from_this()](sdbusplus::message_t& message) {
- boost::system::error_code ec;
+ boost::system::error_code ec;
- // callback to return True if callback is done, callback needs
- // to update status itself if needed
- if (self->callback(ec, message, self) == task::completed)
- {
- self->timer.cancel();
- self->finishTask();
+ // callback to return True if callback is done, callback needs
+ // to update status itself if needed
+ if (self->callback(ec, message, self) == task::completed)
+ {
+ self->timer.cancel();
+ self->finishTask();
- // Send event
- self->sendTaskEvent(self->state, self->index);
+ // Send event
+ self->sendTaskEvent(self->state, self->index);
- // reset the match after the callback was successful
- boost::asio::post(
- crow::connections::systemBus->get_io_context(),
- [self] { self->match.reset(); });
- return;
- }
- });
+ // reset the match after the callback was successful
+ boost::asio::post(
+ crow::connections::systemBus->get_io_context(),
+ [self] { self->match.reset(); });
+ return;
+ }
+ });
extendTimer(timeout);
messages.emplace_back(messages::taskStarted(std::to_string(index)));
@@ -325,37 +324,39 @@
[&app](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& strParam) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
- auto find = std::ranges::find_if(
- task::tasks,
- [&strParam](const std::shared_ptr<task::TaskData>& task) {
- if (!task)
- {
- return false;
- }
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
+ auto find = std::ranges::find_if(
+ task::tasks,
+ [&strParam](const std::shared_ptr<task::TaskData>& task) {
+ if (!task)
+ {
+ return false;
+ }
- // we compare against the string version as on failure
- // strtoul returns 0
- return std::to_string(task->index) == strParam;
- });
+ // we compare against the string version as on failure
+ // strtoul returns 0
+ return std::to_string(task->index) == strParam;
+ });
- if (find == task::tasks.end())
- {
- messages::resourceNotFound(asyncResp->res, "Task", strParam);
- return;
- }
- std::shared_ptr<task::TaskData>& ptr = *find;
- // monitor expires after 204
- if (ptr->gave204)
- {
- messages::resourceNotFound(asyncResp->res, "Task", strParam);
- return;
- }
- ptr->populateResp(asyncResp->res);
- });
+ if (find == task::tasks.end())
+ {
+ messages::resourceNotFound(asyncResp->res, "Task",
+ strParam);
+ return;
+ }
+ std::shared_ptr<task::TaskData>& ptr = *find;
+ // monitor expires after 204
+ if (ptr->gave204)
+ {
+ messages::resourceNotFound(asyncResp->res, "Task",
+ strParam);
+ return;
+ }
+ ptr->populateResp(asyncResp->res);
+ });
}
inline void requestRoutesTask(App& app)
@@ -366,66 +367,75 @@
[&app](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& strParam) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
- auto find = std::ranges::find_if(
- task::tasks,
- [&strParam](const std::shared_ptr<task::TaskData>& task) {
- if (!task)
- {
- return false;
- }
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
+ auto find = std::ranges::find_if(
+ task::tasks,
+ [&strParam](const std::shared_ptr<task::TaskData>& task) {
+ if (!task)
+ {
+ return false;
+ }
- // we compare against the string version as on failure
- // strtoul returns 0
- return std::to_string(task->index) == strParam;
- });
+ // we compare against the string version as on failure
+ // strtoul returns 0
+ return std::to_string(task->index) == strParam;
+ });
- if (find == task::tasks.end())
- {
- messages::resourceNotFound(asyncResp->res, "Task", strParam);
- return;
- }
+ if (find == task::tasks.end())
+ {
+ messages::resourceNotFound(asyncResp->res, "Task",
+ strParam);
+ return;
+ }
- const std::shared_ptr<task::TaskData>& ptr = *find;
+ const std::shared_ptr<task::TaskData>& ptr = *find;
- asyncResp->res.jsonValue["@odata.type"] = "#Task.v1_4_3.Task";
- asyncResp->res.jsonValue["Id"] = strParam;
- asyncResp->res.jsonValue["Name"] = "Task " + strParam;
- asyncResp->res.jsonValue["TaskState"] = ptr->state;
- asyncResp->res.jsonValue["StartTime"] =
- redfish::time_utils::getDateTimeStdtime(ptr->startTime);
- if (ptr->endTime)
- {
- asyncResp->res.jsonValue["EndTime"] =
- redfish::time_utils::getDateTimeStdtime(*(ptr->endTime));
- }
- asyncResp->res.jsonValue["TaskStatus"] = ptr->status;
- asyncResp->res.jsonValue["Messages"] = ptr->messages;
- asyncResp->res.jsonValue["@odata.id"] =
- boost::urls::format("/redfish/v1/TaskService/Tasks/{}", strParam);
- if (!ptr->gave204)
- {
- asyncResp->res.jsonValue["TaskMonitor"] = boost::urls::format(
- "/redfish/v1/TaskService/TaskMonitors/{}", strParam);
- }
+ asyncResp->res.jsonValue["@odata.type"] = "#Task.v1_4_3.Task";
+ asyncResp->res.jsonValue["Id"] = strParam;
+ asyncResp->res.jsonValue["Name"] = "Task " + strParam;
+ asyncResp->res.jsonValue["TaskState"] = ptr->state;
+ asyncResp->res.jsonValue["StartTime"] =
+ redfish::time_utils::getDateTimeStdtime(ptr->startTime);
+ if (ptr->endTime)
+ {
+ asyncResp->res.jsonValue["EndTime"] =
+ redfish::time_utils::getDateTimeStdtime(
+ *(ptr->endTime));
+ }
+ asyncResp->res.jsonValue["TaskStatus"] = ptr->status;
+ asyncResp->res.jsonValue["Messages"] = ptr->messages;
+ asyncResp->res.jsonValue["@odata.id"] = boost::urls::format(
+ "/redfish/v1/TaskService/Tasks/{}", strParam);
+ if (!ptr->gave204)
+ {
+ asyncResp->res.jsonValue["TaskMonitor"] =
+ boost::urls::format(
+ "/redfish/v1/TaskService/TaskMonitors/{}",
+ strParam);
+ }
- asyncResp->res.jsonValue["HidePayload"] = !ptr->payload;
+ asyncResp->res.jsonValue["HidePayload"] = !ptr->payload;
- if (ptr->payload)
- {
- const task::Payload& p = *(ptr->payload);
- asyncResp->res.jsonValue["Payload"]["TargetUri"] = p.targetUri;
- asyncResp->res.jsonValue["Payload"]["HttpOperation"] =
- p.httpOperation;
- asyncResp->res.jsonValue["Payload"]["HttpHeaders"] = p.httpHeaders;
- asyncResp->res.jsonValue["Payload"]["JsonBody"] = p.jsonBody.dump(
- -1, ' ', true, nlohmann::json::error_handler_t::replace);
- }
- asyncResp->res.jsonValue["PercentComplete"] = ptr->percentComplete;
- });
+ if (ptr->payload)
+ {
+ const task::Payload& p = *(ptr->payload);
+ asyncResp->res.jsonValue["Payload"]["TargetUri"] =
+ p.targetUri;
+ asyncResp->res.jsonValue["Payload"]["HttpOperation"] =
+ p.httpOperation;
+ asyncResp->res.jsonValue["Payload"]["HttpHeaders"] =
+ p.httpHeaders;
+ asyncResp->res.jsonValue["Payload"]["JsonBody"] =
+ p.jsonBody.dump(
+ -1, ' ', true,
+ nlohmann::json::error_handler_t::replace);
+ }
+ asyncResp->res.jsonValue["PercentComplete"] =
+ ptr->percentComplete;
+ });
}
inline void requestRoutesTaskCollection(App& app)
@@ -435,31 +445,33 @@
.methods(boost::beast::http::verb::get)(
[&app](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
- asyncResp->res.jsonValue["@odata.type"] =
- "#TaskCollection.TaskCollection";
- asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/TaskService/Tasks";
- asyncResp->res.jsonValue["Name"] = "Task Collection";
- asyncResp->res.jsonValue["Members@odata.count"] = task::tasks.size();
- nlohmann::json& members = asyncResp->res.jsonValue["Members"];
- members = nlohmann::json::array();
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#TaskCollection.TaskCollection";
+ asyncResp->res.jsonValue["@odata.id"] =
+ "/redfish/v1/TaskService/Tasks";
+ asyncResp->res.jsonValue["Name"] = "Task Collection";
+ asyncResp->res.jsonValue["Members@odata.count"] =
+ task::tasks.size();
+ nlohmann::json& members = asyncResp->res.jsonValue["Members"];
+ members = nlohmann::json::array();
- for (const std::shared_ptr<task::TaskData>& task : task::tasks)
- {
- if (task == nullptr)
- {
- continue; // shouldn't be possible
- }
- nlohmann::json::object_t member;
- member["@odata.id"] =
- boost::urls::format("/redfish/v1/TaskService/Tasks/{}",
- std::to_string(task->index));
- members.emplace_back(std::move(member));
- }
- });
+ for (const std::shared_ptr<task::TaskData>& task : task::tasks)
+ {
+ if (task == nullptr)
+ {
+ continue; // shouldn't be possible
+ }
+ nlohmann::json::object_t member;
+ member["@odata.id"] =
+ boost::urls::format("/redfish/v1/TaskService/Tasks/{}",
+ std::to_string(task->index));
+ members.emplace_back(std::move(member));
+ }
+ });
}
inline void requestRoutesTaskService(App& app)
@@ -469,27 +481,30 @@
.methods(boost::beast::http::verb::get)(
[&app](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
- asyncResp->res.jsonValue["@odata.type"] =
- "#TaskService.v1_1_4.TaskService";
- asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/TaskService";
- asyncResp->res.jsonValue["Name"] = "Task Service";
- asyncResp->res.jsonValue["Id"] = "TaskService";
- asyncResp->res.jsonValue["DateTime"] =
- redfish::time_utils::getDateTimeOffsetNow().first;
- asyncResp->res.jsonValue["CompletedTaskOverWritePolicy"] =
- task_service::OverWritePolicy::Oldest;
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#TaskService.v1_1_4.TaskService";
+ asyncResp->res.jsonValue["@odata.id"] =
+ "/redfish/v1/TaskService";
+ asyncResp->res.jsonValue["Name"] = "Task Service";
+ asyncResp->res.jsonValue["Id"] = "TaskService";
+ asyncResp->res.jsonValue["DateTime"] =
+ redfish::time_utils::getDateTimeOffsetNow().first;
+ asyncResp->res.jsonValue["CompletedTaskOverWritePolicy"] =
+ task_service::OverWritePolicy::Oldest;
- asyncResp->res.jsonValue["LifeCycleEventOnTaskStateChange"] = true;
+ asyncResp->res.jsonValue["LifeCycleEventOnTaskStateChange"] =
+ true;
- asyncResp->res.jsonValue["Status"]["State"] = resource::State::Enabled;
- asyncResp->res.jsonValue["ServiceEnabled"] = true;
- asyncResp->res.jsonValue["Tasks"]["@odata.id"] =
- "/redfish/v1/TaskService/Tasks";
- });
+ asyncResp->res.jsonValue["Status"]["State"] =
+ resource::State::Enabled;
+ asyncResp->res.jsonValue["ServiceEnabled"] = true;
+ asyncResp->res.jsonValue["Tasks"]["@odata.id"] =
+ "/redfish/v1/TaskService/Tasks";
+ });
}
} // namespace redfish