Skip to content

Commit daadfb2

Browse files
committed
Fix clang-tidy
Change-Id: Iefe1b695b86a640d8dfaafd1f77f374fa34246de Signed-off-by: Ed Tanous <[email protected]>
1 parent 60b8de3 commit daadfb2

File tree

8 files changed

+34
-41
lines changed

8 files changed

+34
-41
lines changed

.clang-tidy

+1-1
Original file line numberDiff line numberDiff line change
@@ -385,4 +385,4 @@ CheckOptions:
385385
- { key: readability-identifier-naming.StructIgnoredRegexp, value: (BMCWEB_LOG_DEBUG|BMCWEB_LOG_INFO|BMCWEB_LOG_WARNING|BMCWEB_LOG_ERROR|BMCWEB_LOG_CRITICAL) }
386386
- { key: cppcoreguidelines-macro-usage.AllowedRegexp, value: DEBUG*|NLOHMANN_JSON_SERIALIZE_ENUM }
387387
- { key: cppcoreguidelines-rvalue-reference-param-not-moved.IgnoreUnnamedParams, value: true }
388-
- { 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/.*)) }
388+
- { 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/.*)) }

http/http2_connection.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ class HTTP2Connection :
234234
if (reqReader)
235235
{
236236
boost::beast::error_code ec;
237-
reqReader->finish(ec);
237+
bmcweb::HttpBody::reader::finish(ec);
238238
if (ec)
239239
{
240240
BMCWEB_LOG_CRITICAL("Failed to finalize payload");

http/utility.hpp

+7-16
Original file line numberDiff line numberDiff line change
@@ -314,27 +314,18 @@ inline bool base64Decode(std::string_view input, std::string& output)
314314
return true;
315315
}
316316

317-
namespace details
318-
{
319-
inline boost::urls::url appendUrlPieces(
320-
boost::urls::url& url, const std::initializer_list<std::string_view> args)
321-
{
322-
for (std::string_view arg : args)
323-
{
324-
url.segments().push_back(arg);
325-
}
326-
return url;
327-
}
328-
329-
} // namespace details
330-
331317
class OrMorePaths
332318
{};
333319

334320
template <typename... AV>
335-
inline void appendUrlPieces(boost::urls::url& url, const AV... args)
321+
inline void appendUrlPieces(boost::urls::url& url, AV&&... args)
336322
{
337-
details::appendUrlPieces(url, {args...});
323+
// Unclear the correct fix here.
324+
// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-array-to-pointer-decay)
325+
for (const std::string_view arg : {args...})
326+
{
327+
url.segments().push_back(arg);
328+
}
338329
}
339330

340331
namespace details

redfish-core/include/redfish_aggregator.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ inline void addPrefixToStringItem(std::string& strValue,
177177
return;
178178
}
179179

180-
boost::urls::url_view thisUrl = *parsed;
180+
const boost::urls::url_view& thisUrl = *parsed;
181181

182182
// We don't need to aggregate JsonSchemas due to potential issues such as
183183
// version mismatches between aggregator and satellite BMCs. For now

redfish-core/lib/redfish_util.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ using UnitStruct =
5959
std::string, sdbusplus::message::object_path>;
6060

6161
template <typename CallbackFunc>
62-
void getMainChassisId(std::shared_ptr<bmcweb::AsyncResp> asyncResp,
62+
void getMainChassisId(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
6363
CallbackFunc&& callback)
6464
{
6565
// Find managed chassis

redfish-core/lib/sensors.hpp

+18-18
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,8 @@ void getObjectsWithConnection(
303303
* @param callback Callback for processing gathered connections
304304
*/
305305
template <typename Callback>
306-
void getConnections(std::shared_ptr<SensorsAsyncResp> sensorsAsyncResp,
307-
const std::shared_ptr<std::set<std::string>> sensorNames,
306+
void getConnections(const std::shared_ptr<SensorsAsyncResp>& sensorsAsyncResp,
307+
const std::shared_ptr<std::set<std::string>>& sensorNames,
308308
Callback&& callback)
309309
{
310310
auto objectsWithConnectionCb =
@@ -970,10 +970,10 @@ inline void storeInventoryItemData(
970970
*/
971971
template <typename Callback>
972972
void getInventoryItemsData(
973-
std::shared_ptr<SensorsAsyncResp> sensorsAsyncResp,
974-
std::shared_ptr<std::vector<InventoryItem>> inventoryItems,
975-
std::shared_ptr<std::set<std::string>> invConnections, Callback&& callback,
976-
size_t invConnectionsIndex = 0)
973+
const std::shared_ptr<SensorsAsyncResp>& sensorsAsyncResp,
974+
const std::shared_ptr<std::vector<InventoryItem>>& inventoryItems,
975+
const std::shared_ptr<std::set<std::string>>& invConnections,
976+
Callback&& callback, size_t invConnectionsIndex = 0)
977977
{
978978
BMCWEB_LOG_DEBUG("getInventoryItemsData enter");
979979

@@ -1303,9 +1303,9 @@ void getInventoryItemAssociations(
13031303
*/
13041304
template <typename Callback>
13051305
void getInventoryLedData(
1306-
std::shared_ptr<SensorsAsyncResp> sensorsAsyncResp,
1307-
std::shared_ptr<std::vector<InventoryItem>> inventoryItems,
1308-
std::shared_ptr<std::map<std::string, std::string>> ledConnections,
1306+
const std::shared_ptr<SensorsAsyncResp>& sensorsAsyncResp,
1307+
const std::shared_ptr<std::vector<InventoryItem>>& inventoryItems,
1308+
const std::shared_ptr<std::map<std::string, std::string>>& ledConnections,
13091309
Callback&& callback, size_t ledConnectionsIndex = 0)
13101310
{
13111311
BMCWEB_LOG_DEBUG("getInventoryLedData enter");
@@ -1407,8 +1407,8 @@ void getInventoryLedData(
14071407
*/
14081408
template <typename Callback>
14091409
void getInventoryLeds(
1410-
std::shared_ptr<SensorsAsyncResp> sensorsAsyncResp,
1411-
std::shared_ptr<std::vector<InventoryItem>> inventoryItems,
1410+
const std::shared_ptr<SensorsAsyncResp>& sensorsAsyncResp,
1411+
const std::shared_ptr<std::vector<InventoryItem>>& inventoryItems,
14121412
Callback&& callback)
14131413
{
14141414
BMCWEB_LOG_DEBUG("getInventoryLeds enter");
@@ -1493,7 +1493,7 @@ void getInventoryLeds(
14931493
template <typename Callback>
14941494
void getPowerSupplyAttributesData(
14951495
const std::shared_ptr<SensorsAsyncResp>& sensorsAsyncResp,
1496-
std::shared_ptr<std::vector<InventoryItem>> inventoryItems,
1496+
const std::shared_ptr<std::vector<InventoryItem>>& inventoryItems,
14971497
const std::map<std::string, std::string>& psAttributesConnections,
14981498
Callback&& callback)
14991499
{
@@ -1576,8 +1576,8 @@ void getPowerSupplyAttributesData(
15761576
*/
15771577
template <typename Callback>
15781578
void getPowerSupplyAttributes(
1579-
std::shared_ptr<SensorsAsyncResp> sensorsAsyncResp,
1580-
std::shared_ptr<std::vector<InventoryItem>> inventoryItems,
1579+
const std::shared_ptr<SensorsAsyncResp>& sensorsAsyncResp,
1580+
const std::shared_ptr<std::vector<InventoryItem>>& inventoryItems,
15811581
Callback&& callback)
15821582
{
15831583
BMCWEB_LOG_DEBUG("getPowerSupplyAttributes enter");
@@ -1674,20 +1674,20 @@ void getPowerSupplyAttributes(
16741674
*/
16751675
template <typename Callback>
16761676
inline void
1677-
getInventoryItems(std::shared_ptr<SensorsAsyncResp> sensorsAsyncResp,
1678-
const std::shared_ptr<std::set<std::string>> sensorNames,
1677+
getInventoryItems(const std::shared_ptr<SensorsAsyncResp>& sensorsAsyncResp,
1678+
const std::shared_ptr<std::set<std::string>>& sensorNames,
16791679
Callback&& callback)
16801680
{
16811681
BMCWEB_LOG_DEBUG("getInventoryItems enter");
16821682
auto getInventoryItemAssociationsCb =
16831683
[sensorsAsyncResp, callback = std::forward<Callback>(callback)](
1684-
std::shared_ptr<std::vector<InventoryItem>>
1684+
const std::shared_ptr<std::vector<InventoryItem>>&
16851685
inventoryItems) mutable {
16861686
BMCWEB_LOG_DEBUG("getInventoryItemAssociationsCb enter");
16871687
auto getInventoryItemsConnectionsCb =
16881688
[sensorsAsyncResp, inventoryItems,
16891689
callback = std::forward<Callback>(callback)](
1690-
std::shared_ptr<std::set<std::string>>
1690+
const std::shared_ptr<std::set<std::string>>&
16911691
invConnections) mutable {
16921692
BMCWEB_LOG_DEBUG("getInventoryItemsConnectionsCb enter");
16931693
auto getInventoryItemsDataCb =

redfish-core/lib/task.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ struct TaskData : std::enable_shared_from_this<TaskData>
197197
self->messages.emplace_back(
198198
messages::taskAborted(std::to_string(self->index)));
199199
// Send event :TaskAborted
200-
self->sendTaskEvent(self->state, self->index);
200+
sendTaskEvent(self->state, self->index);
201201
self->callback(ec, msg, self);
202202
});
203203
}
@@ -281,7 +281,7 @@ struct TaskData : std::enable_shared_from_this<TaskData>
281281
self->finishTask();
282282

283283
// Send event
284-
self->sendTaskEvent(self->state, self->index);
284+
sendTaskEvent(self->state, self->index);
285285

286286
// reset the match after the callback was successful
287287
boost::asio::post(

test/http/http_body_test.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,9 @@ TEST(HttpFileBodyValueType, SetFd)
116116
HttpBody::value_type value(EncodingType::Base64);
117117
TemporaryFileHandle temporaryFile("teststring");
118118
boost::system::error_code ec;
119-
value.setFd(fileno(fopen(temporaryFile.stringPath.c_str(), "r")), ec);
119+
FILE* r = fopen(temporaryFile.stringPath.c_str(), "r");
120+
ASSERT_NE(r, nullptr);
121+
value.setFd(fileno(r), ec);
120122
ASSERT_FALSE(ec);
121123

122124
std::array<char, 4096> buffer{};

0 commit comments

Comments
 (0)