Fix clang-tidy
Change-Id: Iefe1b695b86a640d8dfaafd1f77f374fa34246de
Signed-off-by: Ed Tanous <etanous@nvidia.com>
diff --git a/.clang-tidy b/.clang-tidy
index b7975da..8092fdc 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -385,4 +385,4 @@
- { key: readability-identifier-naming.StructIgnoredRegexp, value: (BMCWEB_LOG_DEBUG|BMCWEB_LOG_INFO|BMCWEB_LOG_WARNING|BMCWEB_LOG_ERROR|BMCWEB_LOG_CRITICAL) }
- { key: cppcoreguidelines-macro-usage.AllowedRegexp, value: DEBUG*|NLOHMANN_JSON_SERIALIZE_ENUM }
- { key: cppcoreguidelines-rvalue-reference-param-not-moved.IgnoreUnnamedParams, value: true }
- - { key: misc-include-cleaner.IgnoreHeaders, value: ((nlohmann/json_fwd.hpp)|(boost/.*/src.hpp)|(boost/.*/detail/.*)|(nlohmann/detail/.*)|(stdio.h)|(ranges)|(bits/.*)|(boost/system/error_code.hpp)|(boost_formatters.hpp)|(CLI/.*)) }
+ - { key: misc-include-cleaner.IgnoreHeaders, value: ((nlohmann/json_fwd.hpp)|(boost/asio/.*read.hpp)|(boost/.*/src.hpp)|(boost/.*/detail/.*)|(nlohmann/detail/.*)|(stdio.h)|(ranges)|(bits/.*)|(boost/system/error_code.hpp)|(boost_formatters.hpp)|(CLI/.*)) }
diff --git a/http/http2_connection.hpp b/http/http2_connection.hpp
index be73991..35b192d 100644
--- a/http/http2_connection.hpp
+++ b/http/http2_connection.hpp
@@ -234,7 +234,7 @@
if (reqReader)
{
boost::beast::error_code ec;
- reqReader->finish(ec);
+ bmcweb::HttpBody::reader::finish(ec);
if (ec)
{
BMCWEB_LOG_CRITICAL("Failed to finalize payload");
diff --git a/http/utility.hpp b/http/utility.hpp
index 494b734..0cddb1c 100644
--- a/http/utility.hpp
+++ b/http/utility.hpp
@@ -314,27 +314,18 @@
return true;
}
-namespace details
-{
-inline boost::urls::url appendUrlPieces(
- boost::urls::url& url, const std::initializer_list<std::string_view> args)
-{
- for (std::string_view arg : args)
- {
- url.segments().push_back(arg);
- }
- return url;
-}
-
-} // namespace details
-
class OrMorePaths
{};
template <typename... AV>
-inline void appendUrlPieces(boost::urls::url& url, const AV... args)
+inline void appendUrlPieces(boost::urls::url& url, AV&&... args)
{
- details::appendUrlPieces(url, {args...});
+ // Unclear the correct fix here.
+ // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-array-to-pointer-decay)
+ for (const std::string_view arg : {args...})
+ {
+ url.segments().push_back(arg);
+ }
}
namespace details
diff --git a/redfish-core/include/redfish_aggregator.hpp b/redfish-core/include/redfish_aggregator.hpp
index 0a4ea4a..eb21650 100644
--- a/redfish-core/include/redfish_aggregator.hpp
+++ b/redfish-core/include/redfish_aggregator.hpp
@@ -177,7 +177,7 @@
return;
}
- boost::urls::url_view thisUrl = *parsed;
+ const boost::urls::url_view& thisUrl = *parsed;
// We don't need to aggregate JsonSchemas due to potential issues such as
// version mismatches between aggregator and satellite BMCs. For now
diff --git a/redfish-core/lib/redfish_util.hpp b/redfish-core/lib/redfish_util.hpp
index 117f972..966dde2 100644
--- a/redfish-core/lib/redfish_util.hpp
+++ b/redfish-core/lib/redfish_util.hpp
@@ -59,7 +59,7 @@
std::string, sdbusplus::message::object_path>;
template <typename CallbackFunc>
-void getMainChassisId(std::shared_ptr<bmcweb::AsyncResp> asyncResp,
+void getMainChassisId(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
CallbackFunc&& callback)
{
// Find managed chassis
diff --git a/redfish-core/lib/sensors.hpp b/redfish-core/lib/sensors.hpp
index 3ee36af..d8aa559 100644
--- a/redfish-core/lib/sensors.hpp
+++ b/redfish-core/lib/sensors.hpp
@@ -303,8 +303,8 @@
* @param callback Callback for processing gathered connections
*/
template <typename Callback>
-void getConnections(std::shared_ptr<SensorsAsyncResp> sensorsAsyncResp,
- const std::shared_ptr<std::set<std::string>> sensorNames,
+void getConnections(const std::shared_ptr<SensorsAsyncResp>& sensorsAsyncResp,
+ const std::shared_ptr<std::set<std::string>>& sensorNames,
Callback&& callback)
{
auto objectsWithConnectionCb =
@@ -970,10 +970,10 @@
*/
template <typename Callback>
void getInventoryItemsData(
- std::shared_ptr<SensorsAsyncResp> sensorsAsyncResp,
- std::shared_ptr<std::vector<InventoryItem>> inventoryItems,
- std::shared_ptr<std::set<std::string>> invConnections, Callback&& callback,
- size_t invConnectionsIndex = 0)
+ const std::shared_ptr<SensorsAsyncResp>& sensorsAsyncResp,
+ const std::shared_ptr<std::vector<InventoryItem>>& inventoryItems,
+ const std::shared_ptr<std::set<std::string>>& invConnections,
+ Callback&& callback, size_t invConnectionsIndex = 0)
{
BMCWEB_LOG_DEBUG("getInventoryItemsData enter");
@@ -1303,9 +1303,9 @@
*/
template <typename Callback>
void getInventoryLedData(
- std::shared_ptr<SensorsAsyncResp> sensorsAsyncResp,
- std::shared_ptr<std::vector<InventoryItem>> inventoryItems,
- std::shared_ptr<std::map<std::string, std::string>> ledConnections,
+ const std::shared_ptr<SensorsAsyncResp>& sensorsAsyncResp,
+ const std::shared_ptr<std::vector<InventoryItem>>& inventoryItems,
+ const std::shared_ptr<std::map<std::string, std::string>>& ledConnections,
Callback&& callback, size_t ledConnectionsIndex = 0)
{
BMCWEB_LOG_DEBUG("getInventoryLedData enter");
@@ -1407,8 +1407,8 @@
*/
template <typename Callback>
void getInventoryLeds(
- std::shared_ptr<SensorsAsyncResp> sensorsAsyncResp,
- std::shared_ptr<std::vector<InventoryItem>> inventoryItems,
+ const std::shared_ptr<SensorsAsyncResp>& sensorsAsyncResp,
+ const std::shared_ptr<std::vector<InventoryItem>>& inventoryItems,
Callback&& callback)
{
BMCWEB_LOG_DEBUG("getInventoryLeds enter");
@@ -1493,7 +1493,7 @@
template <typename Callback>
void getPowerSupplyAttributesData(
const std::shared_ptr<SensorsAsyncResp>& sensorsAsyncResp,
- std::shared_ptr<std::vector<InventoryItem>> inventoryItems,
+ const std::shared_ptr<std::vector<InventoryItem>>& inventoryItems,
const std::map<std::string, std::string>& psAttributesConnections,
Callback&& callback)
{
@@ -1576,8 +1576,8 @@
*/
template <typename Callback>
void getPowerSupplyAttributes(
- std::shared_ptr<SensorsAsyncResp> sensorsAsyncResp,
- std::shared_ptr<std::vector<InventoryItem>> inventoryItems,
+ const std::shared_ptr<SensorsAsyncResp>& sensorsAsyncResp,
+ const std::shared_ptr<std::vector<InventoryItem>>& inventoryItems,
Callback&& callback)
{
BMCWEB_LOG_DEBUG("getPowerSupplyAttributes enter");
@@ -1674,20 +1674,20 @@
*/
template <typename Callback>
inline void
- getInventoryItems(std::shared_ptr<SensorsAsyncResp> sensorsAsyncResp,
- const std::shared_ptr<std::set<std::string>> sensorNames,
+ getInventoryItems(const std::shared_ptr<SensorsAsyncResp>& sensorsAsyncResp,
+ const std::shared_ptr<std::set<std::string>>& sensorNames,
Callback&& callback)
{
BMCWEB_LOG_DEBUG("getInventoryItems enter");
auto getInventoryItemAssociationsCb =
[sensorsAsyncResp, callback = std::forward<Callback>(callback)](
- std::shared_ptr<std::vector<InventoryItem>>
+ const std::shared_ptr<std::vector<InventoryItem>>&
inventoryItems) mutable {
BMCWEB_LOG_DEBUG("getInventoryItemAssociationsCb enter");
auto getInventoryItemsConnectionsCb =
[sensorsAsyncResp, inventoryItems,
callback = std::forward<Callback>(callback)](
- std::shared_ptr<std::set<std::string>>
+ const std::shared_ptr<std::set<std::string>>&
invConnections) mutable {
BMCWEB_LOG_DEBUG("getInventoryItemsConnectionsCb enter");
auto getInventoryItemsDataCb =
diff --git a/redfish-core/lib/task.hpp b/redfish-core/lib/task.hpp
index 5f67cf0..80db518 100644
--- a/redfish-core/lib/task.hpp
+++ b/redfish-core/lib/task.hpp
@@ -197,7 +197,7 @@
self->messages.emplace_back(
messages::taskAborted(std::to_string(self->index)));
// Send event :TaskAborted
- self->sendTaskEvent(self->state, self->index);
+ sendTaskEvent(self->state, self->index);
self->callback(ec, msg, self);
});
}
@@ -281,7 +281,7 @@
self->finishTask();
// Send event
- self->sendTaskEvent(self->state, self->index);
+ sendTaskEvent(self->state, self->index);
// reset the match after the callback was successful
boost::asio::post(
diff --git a/test/http/http_body_test.cpp b/test/http/http_body_test.cpp
index d8c9dd1..9a1a098 100644
--- a/test/http/http_body_test.cpp
+++ b/test/http/http_body_test.cpp
@@ -116,7 +116,9 @@
HttpBody::value_type value(EncodingType::Base64);
TemporaryFileHandle temporaryFile("teststring");
boost::system::error_code ec;
- value.setFd(fileno(fopen(temporaryFile.stringPath.c_str(), "r")), ec);
+ FILE* r = fopen(temporaryFile.stringPath.c_str(), "r");
+ ASSERT_NE(r, nullptr);
+ value.setFd(fileno(r), ec);
ASSERT_FALSE(ec);
std::array<char, 4096> buffer{};