summaryrefslogtreecommitdiff
path: root/include/async_resolve.hpp
diff options
context:
space:
mode:
authorEd Tanous <edtanous@google.com>2022-05-31 18:59:27 +0300
committerEd Tanous <ed@tanous.net>2022-06-01 19:10:35 +0300
commit002d39b4a7a5ed7166e2acad84e0943c3def9492 (patch)
tree4307dd5161ec9779d59308a9b933e408cc2c6ca7 /include/async_resolve.hpp
parent62c416fb0d2f62e09d7f60754ff359ac2389e749 (diff)
downloadbmcweb-002d39b4a7a5ed7166e2acad84e0943c3def9492.tar.xz
Try to fix the lambda formatting issue
clang-tidy has a setting, LambdaBodyIndentation, which it says: "For callback-heavy code, it may improve readability to have the signature indented two levels and to use OuterScope." bmcweb is very callback heavy code. Try to enable it and see if that improves things. There are many cases where the length of a lambda call will change, and reindent the entire lambda function. This is really bad for code reviews, as it's difficult to see the lines changed. This commit should resolve it. This does have the downside of reindenting a lot of functions, which is unfortunate, but probably worth it in the long run. All changes except for the .clang-format file were made by the robot. Tested: Code compiles, whitespace changes only. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ib4aa2f1391fada981febd25b67dcdb9143827f43
Diffstat (limited to 'include/async_resolve.hpp')
-rw-r--r--include/async_resolve.hpp85
1 files changed, 42 insertions, 43 deletions
diff --git a/include/async_resolve.hpp b/include/async_resolve.hpp
index 87f53a082a..8a5cc4e7fe 100644
--- a/include/async_resolve.hpp
+++ b/include/async_resolve.hpp
@@ -37,53 +37,52 @@ class Resolver
const std::vector<
std::tuple<int32_t, int32_t, std::vector<uint8_t>>>& resp,
const std::string& hostName, const uint64_t flagNum) {
- std::vector<boost::asio::ip::tcp::endpoint> endpointList;
- if (ec)
+ std::vector<boost::asio::ip::tcp::endpoint> endpointList;
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR << "Resolve failed: " << ec.message();
+ handler(ec, endpointList);
+ return;
+ }
+ BMCWEB_LOG_DEBUG << "ResolveHostname returned: " << hostName << ":"
+ << flagNum;
+ // Extract the IP address from the response
+ for (auto resolveList : resp)
+ {
+ std::vector<uint8_t> ipAddress = std::get<2>(resolveList);
+ boost::asio::ip::tcp::endpoint endpoint;
+ if (ipAddress.size() == 4) // ipv4 address
{
- BMCWEB_LOG_ERROR << "Resolve failed: " << ec.message();
- handler(ec, endpointList);
- return;
+ BMCWEB_LOG_DEBUG << "ipv4 address";
+ boost::asio::ip::address_v4 ipv4Addr(
+ {ipAddress[0], ipAddress[1], ipAddress[2],
+ ipAddress[3]});
+ endpoint.address(ipv4Addr);
}
- BMCWEB_LOG_DEBUG << "ResolveHostname returned: " << hostName
- << ":" << flagNum;
- // Extract the IP address from the response
- for (auto resolveList : resp)
+ else if (ipAddress.size() == 16) // ipv6 address
{
- std::vector<uint8_t> ipAddress = std::get<2>(resolveList);
- boost::asio::ip::tcp::endpoint endpoint;
- if (ipAddress.size() == 4) // ipv4 address
- {
- BMCWEB_LOG_DEBUG << "ipv4 address";
- boost::asio::ip::address_v4 ipv4Addr(
- {ipAddress[0], ipAddress[1], ipAddress[2],
- ipAddress[3]});
- endpoint.address(ipv4Addr);
- }
- else if (ipAddress.size() == 16) // ipv6 address
- {
- BMCWEB_LOG_DEBUG << "ipv6 address";
- boost::asio::ip::address_v6 ipv6Addr(
- {ipAddress[0], ipAddress[1], ipAddress[2],
- ipAddress[3], ipAddress[4], ipAddress[5],
- ipAddress[6], ipAddress[7], ipAddress[8],
- ipAddress[9], ipAddress[10], ipAddress[11],
- ipAddress[12], ipAddress[13], ipAddress[14],
- ipAddress[15]});
- endpoint.address(ipv6Addr);
- }
- else
- {
- BMCWEB_LOG_ERROR
- << "Resolve failed to fetch the IP address";
- handler(ec, endpointList);
- return;
- }
- endpoint.port(port);
- BMCWEB_LOG_DEBUG << "resolved endpoint is : " << endpoint;
- endpointList.push_back(endpoint);
+ BMCWEB_LOG_DEBUG << "ipv6 address";
+ boost::asio::ip::address_v6 ipv6Addr(
+ {ipAddress[0], ipAddress[1], ipAddress[2], ipAddress[3],
+ ipAddress[4], ipAddress[5], ipAddress[6], ipAddress[7],
+ ipAddress[8], ipAddress[9], ipAddress[10],
+ ipAddress[11], ipAddress[12], ipAddress[13],
+ ipAddress[14], ipAddress[15]});
+ endpoint.address(ipv6Addr);
}
- // All the resolved data is filled in the endpointList
- handler(ec, endpointList);
+ else
+ {
+ BMCWEB_LOG_ERROR
+ << "Resolve failed to fetch the IP address";
+ handler(ec, endpointList);
+ return;
+ }
+ endpoint.port(port);
+ BMCWEB_LOG_DEBUG << "resolved endpoint is : " << endpoint;
+ endpointList.push_back(endpoint);
+ }
+ // All the resolved data is filled in the endpointList
+ handler(ec, endpointList);
},
"org.freedesktop.resolve1", "/org/freedesktop/resolve1",
"org.freedesktop.resolve1.Manager", "ResolveHostname", 0, host,