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>
diff --git a/redfish-core/include/error_messages.hpp b/redfish-core/include/error_messages.hpp
index 91edc3c..b692eda 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 @@
* @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 @@
* @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 @@
* @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 @@
* @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 @@
* @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 @@
* @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 @@
* @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 @@
* @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 @@
* @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 @@
* @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 @@
*
* @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 679c4f6..9872bf8 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 @@
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 f255b9f..bc0300a 100644
--- a/redfish-core/include/redfish_aggregator.hpp
+++ b/redfish-core/include/redfish_aggregator.hpp
@@ -202,7 +202,7 @@
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 @@
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 @@
{
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 @@
// /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 43ec77d..9ea886e 100644
--- a/redfish-core/lib/trigger.hpp
+++ b/redfish-core/lib/trigger.hpp
@@ -546,7 +546,7 @@
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 b03f323..529b9dc 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 @@
*
*/
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 7b02515..8729383 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 @@
* 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 @@
* 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 @@
* 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 @@
}
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 @@
* 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 @@
* 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 @@
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 @@
* 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 @@
* 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 @@
* 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 @@
}
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 @@
* 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 @@
* 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 @@
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 @@
* 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));
}