summaryrefslogtreecommitdiff
path: root/redfish-core
diff options
context:
space:
mode:
authorEd Tanous <ed@tanous.net>2024-04-07 02:03:49 +0300
committerEd Tanous <ed@tanous.net>2024-04-11 19:38:16 +0300
commit4a7fbefdff330f06d5698a1e60ce893225cd389e (patch)
tree036f2c7795de1d48d06834d6b0ccbe1d0d5c9e79 /redfish-core
parentd9e89dfd49538c54d280dce3750f4af264cfd5fc (diff)
downloadbmcweb-4a7fbefdff330f06d5698a1e60ce893225cd389e.tar.xz
Fix large copies with url_view and segments_view
Despite these objects being called "view" they are still relatively large, as clang-tidy correctly flags, and we ignore. Change all function uses to capture by: const boost::urls::url_view_base& Which is the base class of all boost URL types, and any class (url, url_view, etc) is convertible to that base. Change-Id: I8ee2ea3f4cfba38331303a7e4eb520a2b6f8ba92 Signed-off-by: Ed Tanous <ed@tanous.net>
Diffstat (limited to 'redfish-core')
-rw-r--r--redfish-core/include/error_messages.hpp61
-rw-r--r--redfish-core/include/event_service_manager.hpp4
-rw-r--r--redfish-core/include/redfish_aggregator.hpp14
-rw-r--r--redfish-core/lib/trigger.hpp2
-rw-r--r--redfish-core/lib/virtual_media.hpp3
-rw-r--r--redfish-core/src/error_messages.cpp61
6 files changed, 82 insertions, 63 deletions
diff --git a/redfish-core/include/error_messages.hpp b/redfish-core/include/error_messages.hpp
index 91edc3c7cb..b692edaa78 100644
--- a/redfish-core/include/error_messages.hpp
+++ b/redfish-core/include/error_messages.hpp
@@ -17,7 +17,7 @@
#include "http_response.hpp"
-#include <boost/url/url_view.hpp>
+#include <boost/url/url_view_base.hpp>
#include <nlohmann/json.hpp>
#include <cstdint>
@@ -71,9 +71,10 @@ void malformedJSON(crow::Response& res);
* @param[in] arg1 Parameter of message that will replace %1 in its body.
*
* @returns Message ResourceMissingAtURI formatted to JSON */
-nlohmann::json resourceMissingAtURI(boost::urls::url_view arg1);
+nlohmann::json resourceMissingAtURI(const boost::urls::url_view_base& arg1);
-void resourceMissingAtURI(crow::Response& res, boost::urls::url_view arg1);
+void resourceMissingAtURI(crow::Response& res,
+ const boost::urls::url_view_base& arg1);
/**
* @brief Formats ActionParameterValueFormatError message into JSON
@@ -144,10 +145,11 @@ void unrecognizedRequestBody(crow::Response& res);
* @param[in] arg2 Parameter of message that will replace %2 in its body.
*
* @returns Message ResourceAtUriUnauthorized formatted to JSON */
-nlohmann::json resourceAtUriUnauthorized(boost::urls::url_view arg1,
+nlohmann::json resourceAtUriUnauthorized(const boost::urls::url_view_base& arg1,
std::string_view arg2);
-void resourceAtUriUnauthorized(crow::Response& res, boost::urls::url_view arg1,
+void resourceAtUriUnauthorized(crow::Response& res,
+ const boost::urls::url_view_base& arg1,
std::string_view arg2);
/**
@@ -292,10 +294,11 @@ void propertyValueOutOfRange(crow::Response& res, const nlohmann::json& arg1,
* @param[in] arg1 Parameter of message that will replace %1 in its body.
*
* @returns Message ResourceAtUriInUnknownFormat formatted to JSON */
-nlohmann::json resourceAtUriInUnknownFormat(boost::urls::url_view arg1);
+nlohmann::json
+ resourceAtUriInUnknownFormat(const boost::urls::url_view_base& arg1);
void resourceAtUriInUnknownFormat(crow::Response& res,
- boost::urls::url_view arg1);
+ const boost::urls::url_view_base& arg1);
/**
* @brief Formats ServiceDisabled message into JSON
@@ -402,9 +405,10 @@ void resourceTypeIncompatible(crow::Response& res, std::string_view arg1,
* @param[in] arg2 Parameter of message that will replace %2 in its body.
*
* @returns Message ResetRequired formatted to JSON */
-nlohmann::json resetRequired(boost::urls::url_view arg1, std::string_view arg2);
+nlohmann::json resetRequired(const boost::urls::url_view_base& arg1,
+ std::string_view arg2);
-void resetRequired(crow::Response& res, boost::urls::url_view arg1,
+void resetRequired(crow::Response& res, const boost::urls::url_view_base& arg1,
std::string_view arg2);
/**
@@ -457,13 +461,14 @@ void propertyValueConflict(crow::Response& res, std::string_view arg1,
* @param[in] arg3 Parameter of message that will replace %3 in its body.
*
* @returns Message PropertyValueResourceConflict to JSON */
-nlohmann::json propertyValueResourceConflict(std::string_view arg1,
- const nlohmann::json& arg2,
- boost::urls::url_view arg3);
+nlohmann::json
+ propertyValueResourceConflict(std::string_view arg1,
+ const nlohmann::json& arg2,
+ const boost::urls::url_view_base& arg3);
void propertyValueResourceConflict(crow::Response& res, std::string_view arg1,
const nlohmann::json& arg2,
- boost::urls::url_view arg3);
+ const boost::urls::url_view_base& arg3);
/**
* @brief Formats PropertyValueExternalConflict message into JSON
@@ -505,9 +510,10 @@ void propertyValueIncorrect(crow::Response& res, std::string_view arg1,
* @param[in] arg1 Parameter of message that will replace %1 in its body.
*
* @returns Message ResourceCreationConflict formatted to JSON */
-nlohmann::json resourceCreationConflict(boost::urls::url_view arg1);
+nlohmann::json resourceCreationConflict(const boost::urls::url_view_base& arg1);
-void resourceCreationConflict(crow::Response& res, boost::urls::url_view arg1);
+void resourceCreationConflict(crow::Response& res,
+ const boost::urls::url_view_base& arg1);
/**
* @brief Formats MaximumErrorsExceeded message into JSON
@@ -600,10 +606,11 @@ void resourceNotFound(crow::Response& res, std::string_view arg1,
* @param[in] arg1 Parameter of message that will replace %1 in its body.
*
* @returns Message CouldNotEstablishConnection formatted to JSON */
-nlohmann::json couldNotEstablishConnection(boost::urls::url_view arg1);
+nlohmann::json
+ couldNotEstablishConnection(const boost::urls::url_view_base& arg1);
void couldNotEstablishConnection(crow::Response& res,
- boost::urls::url_view arg1);
+ const boost::urls::url_view_base& arg1);
/**
* @brief Formats PropertyNotWritable message into JSON
@@ -683,11 +690,12 @@ void actionParameterNotSupported(crow::Response& res, std::string_view arg1,
* @param[in] arg2 Parameter of message that will replace %2 in its body.
*
* @returns Message SourceDoesNotSupportProtocol formatted to JSON */
-nlohmann::json sourceDoesNotSupportProtocol(boost::urls::url_view arg1,
- std::string_view arg2);
+nlohmann::json
+ sourceDoesNotSupportProtocol(const boost::urls::url_view_base& arg1,
+ std::string_view arg2);
void sourceDoesNotSupportProtocol(crow::Response& res,
- boost::urls::url_view arg1,
+ const boost::urls::url_view_base& arg1,
std::string_view arg2);
/**
@@ -719,9 +727,9 @@ void accountRemoved(crow::Response& res);
* @param[in] arg1 Parameter of message that will replace %1 in its body.
*
* @returns Message AccessDenied formatted to JSON */
-nlohmann::json accessDenied(boost::urls::url_view arg1);
+nlohmann::json accessDenied(const boost::urls::url_view_base& arg1);
-void accessDenied(crow::Response& res, boost::urls::url_view arg1);
+void accessDenied(crow::Response& res, const boost::urls::url_view_base& arg1);
/**
* @brief Formats QueryNotSupported message into JSON
@@ -816,9 +824,9 @@ void noValidSession(crow::Response& res);
* @param[in] arg1 Parameter of message that will replace %1 in its body.
*
* @returns Message InvalidObject formatted to JSON */
-nlohmann::json invalidObject(boost::urls::url_view arg1);
+nlohmann::json invalidObject(const boost::urls::url_view_base& arg1);
-void invalidObject(crow::Response& res, boost::urls::url_view arg1);
+void invalidObject(crow::Response& res, const boost::urls::url_view_base& arg1);
/**
* @brief Formats ResourceInStandby message into JSON
@@ -1055,9 +1063,10 @@ void queryParameterOutOfRange(crow::Response& res, std::string_view arg1,
*
* @returns Message PasswordChangeRequired formatted to JSON */
-nlohmann::json passwordChangeRequired(boost::urls::url_view arg1);
+nlohmann::json passwordChangeRequired(const boost::urls::url_view_base& arg1);
-void passwordChangeRequired(crow::Response& res, boost::urls::url_view arg1);
+void passwordChangeRequired(crow::Response& res,
+ const boost::urls::url_view_base& arg1);
/**
* @brief Formats InvalidUpload message into JSON
diff --git a/redfish-core/include/event_service_manager.hpp b/redfish-core/include/event_service_manager.hpp
index 679c4f6918..9872bf8410 100644
--- a/redfish-core/include/event_service_manager.hpp
+++ b/redfish-core/include/event_service_manager.hpp
@@ -32,6 +32,7 @@
#include <boost/asio/io_context.hpp>
#include <boost/container/flat_map.hpp>
#include <boost/url/format.hpp>
+#include <boost/url/url_view_base.hpp>
#include <sdbusplus/bus/match.hpp>
#include <algorithm>
@@ -355,7 +356,8 @@ class Subscription : public persistent_data::UserSubscription
Subscription(Subscription&&) = delete;
Subscription& operator=(Subscription&&) = delete;
- Subscription(boost::urls::url_view url, boost::asio::io_context& ioc) :
+ Subscription(const boost::urls::url_view_base& url,
+ boost::asio::io_context& ioc) :
policy(std::make_shared<crow::ConnectionPolicy>())
{
destinationUrl = url;
diff --git a/redfish-core/include/redfish_aggregator.hpp b/redfish-core/include/redfish_aggregator.hpp
index f255b9f0a6..bc0300a1a9 100644
--- a/redfish-core/include/redfish_aggregator.hpp
+++ b/redfish-core/include/redfish_aggregator.hpp
@@ -202,7 +202,7 @@ static inline void addPrefixToStringItem(std::string& strValue,
const boost::urls::segments_view urlSegments = thisUrl.segments();
bool addedPrefix = false;
boost::urls::url url("/");
- boost::urls::segments_view::iterator it = urlSegments.begin();
+ boost::urls::segments_view::const_iterator it = urlSegments.begin();
const boost::urls::segments_view::const_iterator end = urlSegments.end();
// Skip past the leading "/redfish/v1"
@@ -671,9 +671,8 @@ class RedfishAggregator
const boost::urls::segments_view urlSegments = thisReq.url().segments();
boost::urls::url currentUrl("/");
- boost::urls::segments_view::iterator it = urlSegments.begin();
- const boost::urls::segments_view::const_iterator end =
- urlSegments.end();
+ boost::urls::segments_view::const_iterator it = urlSegments.begin();
+ boost::urls::segments_view::const_iterator end = urlSegments.end();
// Skip past the leading "/redfish/v1"
it++;
@@ -1188,7 +1187,7 @@ class RedfishAggregator
{
using crow::utility::OrMorePaths;
using crow::utility::readUrlSegments;
- const boost::urls::url_view url = thisReq.url();
+ boost::urls::url_view url = thisReq.url();
// We don't need to aggregate JsonSchemas due to potential issues such
// as version mismatches between aggregator and satellite BMCs. For
@@ -1214,9 +1213,8 @@ class RedfishAggregator
// /redfish/v1/UpdateService/FirmwareInventory
const boost::urls::segments_view urlSegments = url.segments();
boost::urls::url currentUrl("/");
- boost::urls::segments_view::iterator it = urlSegments.begin();
- const boost::urls::segments_view::const_iterator end =
- urlSegments.end();
+ boost::urls::segments_view::const_iterator it = urlSegments.begin();
+ boost::urls::segments_view::const_iterator end = urlSegments.end();
// Skip past the leading "/redfish/v1"
it++;
diff --git a/redfish-core/lib/trigger.hpp b/redfish-core/lib/trigger.hpp
index 43ec77daf8..9ea886e641 100644
--- a/redfish-core/lib/trigger.hpp
+++ b/redfish-core/lib/trigger.hpp
@@ -546,7 +546,7 @@ inline bool parseMetricProperties(crow::Response& res, Context& ctx)
size_t uriIdx = 0;
for (const std::string& uriStr : *ctx.metricProperties)
{
- boost::system::result<boost::urls::url_view> uri =
+ boost::system::result<boost::urls::url> uri =
boost::urls::parse_relative_ref(uriStr);
if (!uri)
{
diff --git a/redfish-core/lib/virtual_media.hpp b/redfish-core/lib/virtual_media.hpp
index b03f323620..529b9dc5d9 100644
--- a/redfish-core/lib/virtual_media.hpp
+++ b/redfish-core/lib/virtual_media.hpp
@@ -28,6 +28,7 @@
#include <boost/process/async_pipe.hpp>
#include <boost/url/format.hpp>
#include <boost/url/url_view.hpp>
+#include <boost/url/url_view_base.hpp>
#include <array>
#include <ranges>
@@ -367,7 +368,7 @@ enum class TransferProtocol
*
*/
inline std::optional<TransferProtocol>
- getTransferProtocolFromUri(boost::urls::url_view imageUri)
+ getTransferProtocolFromUri(const boost::urls::url_view_base& imageUri)
{
std::string_view scheme = imageUri.scheme();
if (scheme == "smb")
diff --git a/redfish-core/src/error_messages.cpp b/redfish-core/src/error_messages.cpp
index 7b0251562d..87293833fc 100644
--- a/redfish-core/src/error_messages.cpp
+++ b/redfish-core/src/error_messages.cpp
@@ -22,7 +22,7 @@
#include <boost/beast/http/field.hpp>
#include <boost/beast/http/status.hpp>
-#include <boost/url/url_view.hpp>
+#include <boost/url/url_view_base.hpp>
#include <nlohmann/json.hpp>
#include <array>
@@ -206,13 +206,14 @@ void malformedJSON(crow::Response& res)
* See header file for more information
* @endinternal
*/
-nlohmann::json resourceMissingAtURI(boost::urls::url_view arg1)
+nlohmann::json resourceMissingAtURI(const boost::urls::url_view_base& arg1)
{
std::array<std::string_view, 1> args{arg1.buffer()};
return getLog(redfish::registries::base::Index::resourceMissingAtURI, args);
}
-void resourceMissingAtURI(crow::Response& res, boost::urls::url_view arg1)
+void resourceMissingAtURI(crow::Response& res,
+ const boost::urls::url_view_base& arg1)
{
res.result(boost::beast::http::status::bad_request);
addMessageToErrorJson(res.jsonValue, resourceMissingAtURI(arg1));
@@ -317,14 +318,15 @@ void unrecognizedRequestBody(crow::Response& res)
* See header file for more information
* @endinternal
*/
-nlohmann::json resourceAtUriUnauthorized(boost::urls::url_view arg1,
+nlohmann::json resourceAtUriUnauthorized(const boost::urls::url_view_base& arg1,
std::string_view arg2)
{
return getLog(redfish::registries::base::Index::resourceAtUriUnauthorized,
std::to_array<std::string_view>({arg1.buffer(), arg2}));
}
-void resourceAtUriUnauthorized(crow::Response& res, boost::urls::url_view arg1,
+void resourceAtUriUnauthorized(crow::Response& res,
+ const boost::urls::url_view_base& arg1,
std::string_view arg2)
{
res.result(boost::beast::http::status::unauthorized);
@@ -554,7 +556,8 @@ void propertyValueOutOfRange(crow::Response& res, const nlohmann::json& arg1,
* See header file for more information
* @endinternal
*/
-nlohmann::json resourceAtUriInUnknownFormat(boost::urls::url_view arg1)
+nlohmann::json
+ resourceAtUriInUnknownFormat(const boost::urls::url_view_base& arg1)
{
return getLog(
redfish::registries::base::Index::resourceAtUriInUnknownFormat,
@@ -562,7 +565,7 @@ nlohmann::json resourceAtUriInUnknownFormat(boost::urls::url_view arg1)
}
void resourceAtUriInUnknownFormat(crow::Response& res,
- boost::urls::url_view arg1)
+ const boost::urls::url_view_base& arg1)
{
res.result(boost::beast::http::status::bad_request);
addMessageToErrorJson(res.jsonValue, resourceAtUriInUnknownFormat(arg1));
@@ -729,13 +732,14 @@ void resourceTypeIncompatible(crow::Response& res, std::string_view arg1,
* See header file for more information
* @endinternal
*/
-nlohmann::json resetRequired(boost::urls::url_view arg1, std::string_view arg2)
+nlohmann::json resetRequired(const boost::urls::url_view_base& arg1,
+ std::string_view arg2)
{
return getLog(redfish::registries::base::Index::resetRequired,
std::to_array<std::string_view>({arg1.buffer(), arg2}));
}
-void resetRequired(crow::Response& res, boost::urls::url_view arg1,
+void resetRequired(crow::Response& res, const boost::urls::url_view_base& arg1,
std::string_view arg2)
{
res.result(boost::beast::http::status::bad_request);
@@ -809,9 +813,10 @@ void propertyValueConflict(crow::Response& res, std::string_view arg1,
* See header file for more information
* @endinternal
*/
-nlohmann::json propertyValueResourceConflict(std::string_view arg1,
- const nlohmann::json& arg2,
- boost::urls::url_view arg3)
+nlohmann::json
+ propertyValueResourceConflict(std::string_view arg1,
+ const nlohmann::json& arg2,
+ const boost::urls::url_view_base& arg3)
{
std::string arg2Str = arg2.dump(2, ' ', true,
nlohmann::json::error_handler_t::replace);
@@ -823,7 +828,7 @@ nlohmann::json propertyValueResourceConflict(std::string_view arg1,
void propertyValueResourceConflict(crow::Response& res, std::string_view arg1,
const nlohmann::json& arg2,
- boost::urls::url_view arg3)
+ const boost::urls::url_view_base& arg3)
{
res.result(boost::beast::http::status::conflict);
addMessageToErrorJson(res.jsonValue,
@@ -886,13 +891,14 @@ void propertyValueIncorrect(crow::Response& res, std::string_view arg1,
* See header file for more information
* @endinternal
*/
-nlohmann::json resourceCreationConflict(boost::urls::url_view arg1)
+nlohmann::json resourceCreationConflict(const boost::urls::url_view_base& arg1)
{
return getLog(redfish::registries::base::Index::resourceCreationConflict,
std::to_array<std::string_view>({arg1.buffer()}));
}
-void resourceCreationConflict(crow::Response& res, boost::urls::url_view arg1)
+void resourceCreationConflict(crow::Response& res,
+ const boost::urls::url_view_base& arg1)
{
res.result(boost::beast::http::status::bad_request);
addMessageToErrorJson(res.jsonValue, resourceCreationConflict(arg1));
@@ -1039,14 +1045,15 @@ void resourceNotFound(crow::Response& res, std::string_view arg1,
* See header file for more information
* @endinternal
*/
-nlohmann::json couldNotEstablishConnection(boost::urls::url_view arg1)
+nlohmann::json
+ couldNotEstablishConnection(const boost::urls::url_view_base& arg1)
{
return getLog(redfish::registries::base::Index::couldNotEstablishConnection,
std::to_array<std::string_view>({arg1.buffer()}));
}
void couldNotEstablishConnection(crow::Response& res,
- boost::urls::url_view arg1)
+ const boost::urls::url_view_base& arg1)
{
res.result(boost::beast::http::status::not_found);
addMessageToErrorJson(res.jsonValue, couldNotEstablishConnection(arg1));
@@ -1166,8 +1173,9 @@ void actionParameterNotSupported(crow::Response& res, std::string_view arg1,
* See header file for more information
* @endinternal
*/
-nlohmann::json sourceDoesNotSupportProtocol(boost::urls::url_view arg1,
- std::string_view arg2)
+nlohmann::json
+ sourceDoesNotSupportProtocol(const boost::urls::url_view_base& arg1,
+ std::string_view arg2)
{
return getLog(
redfish::registries::base::Index::sourceDoesNotSupportProtocol,
@@ -1175,7 +1183,7 @@ nlohmann::json sourceDoesNotSupportProtocol(boost::urls::url_view arg1,
}
void sourceDoesNotSupportProtocol(crow::Response& res,
- boost::urls::url_view arg1,
+ const boost::urls::url_view_base& arg1,
std::string_view arg2)
{
res.result(boost::beast::http::status::bad_request);
@@ -1227,13 +1235,13 @@ void accountRemoved(crow::Response& res)
* See header file for more information
* @endinternal
*/
-nlohmann::json accessDenied(boost::urls::url_view arg1)
+nlohmann::json accessDenied(const boost::urls::url_view_base& arg1)
{
return getLog(redfish::registries::base::Index::accessDenied,
std::to_array<std::string_view>({arg1.buffer()}));
}
-void accessDenied(crow::Response& res, boost::urls::url_view arg1)
+void accessDenied(crow::Response& res, const boost::urls::url_view_base& arg1)
{
res.result(boost::beast::http::status::forbidden);
addMessageToErrorJson(res.jsonValue, accessDenied(arg1));
@@ -1394,13 +1402,13 @@ void noValidSession(crow::Response& res)
* See header file for more information
* @endinternal
*/
-nlohmann::json invalidObject(boost::urls::url_view arg1)
+nlohmann::json invalidObject(const boost::urls::url_view_base& arg1)
{
return getLog(redfish::registries::base::Index::invalidObject,
std::to_array<std::string_view>({arg1.buffer()}));
}
-void invalidObject(crow::Response& res, boost::urls::url_view arg1)
+void invalidObject(crow::Response& res, const boost::urls::url_view_base& arg1)
{
res.result(boost::beast::http::status::bad_request);
addMessageToErrorJson(res.jsonValue, invalidObject(arg1));
@@ -1771,7 +1779,7 @@ void queryParameterOutOfRange(crow::Response& res, std::string_view arg1,
queryParameterOutOfRange(arg1, arg2, arg3));
}
-nlohmann::json passwordChangeRequired(boost::urls::url_view arg1)
+nlohmann::json passwordChangeRequired(const boost::urls::url_view_base& arg1)
{
return getLog(redfish::registries::base::Index::passwordChangeRequired,
std::to_array<std::string_view>({arg1.buffer()}));
@@ -1784,7 +1792,8 @@ nlohmann::json passwordChangeRequired(boost::urls::url_view arg1)
* See header file for more information
* @endinternal
*/
-void passwordChangeRequired(crow::Response& res, boost::urls::url_view arg1)
+void passwordChangeRequired(crow::Response& res,
+ const boost::urls::url_view_base& arg1)
{
messages::addMessageToJsonRoot(res.jsonValue, passwordChangeRequired(arg1));
}