Skip to content

Commit f07f2ce

Browse files
committed
[lldb/unittest] Adjust CheckIPSupport function to avoid double-consume of llvm::Error
The problem caught by clang-tidy and reported by Tobias Bosch.
1 parent 5cee8dd commit f07f2ce

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

lldb/unittests/Host/SocketTestUtilities.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,16 +101,19 @@ static bool CheckIPSupport(llvm::StringRef Proto, llvm::StringRef Addr) {
101101
"Creating a canary {0} TCP socket failed: {1}.",
102102
Proto, Err)
103103
.str();
104-
if (Err.isA<llvm::ECError>() &&
105-
errorToErrorCode(std::move(Err)) ==
106-
std::make_error_code(std::errc::address_not_available)) {
104+
bool HasAddrNotAvail = false;
105+
handleAllErrors(std::move(Err), [&](std::unique_ptr<llvm::ECError> ECErr) {
106+
if (ECErr->convertToErrorCode() ==
107+
std::make_error_code(std::errc::address_not_available))
108+
HasAddrNotAvail = true;
109+
});
110+
if (HasAddrNotAvail) {
107111
GTEST_LOG_(WARNING)
108112
<< llvm::formatv(
109113
"Assuming the host does not support {0}. Skipping test.", Proto)
110114
.str();
111115
return false;
112116
}
113-
consumeError(std::move(Err));
114117
GTEST_LOG_(WARNING) << "Continuing anyway. The test will probably fail.";
115118
return true;
116119
}

0 commit comments

Comments
 (0)