Skip to content

Commit 8732599

Browse files
Ben HillisCopilot
andcommitted
Fix clang-format formatting issues
Apply clang-format to 6 files that were failing the formatting CI check. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 498588b commit 8732599

File tree

6 files changed

+73
-52
lines changed

6 files changed

+73
-52
lines changed

src/windows/common/wslutil.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -406,8 +406,9 @@ std::wstring wsl::windows::common::wslutil::DownloadFileImpl(
406406
[[nodiscard]] HANDLE wsl::windows::common::wslutil::DuplicateHandle(_In_ HANDLE Handle, _In_ std::optional<DWORD> DesiredAccess, _In_ BOOL InheritHandle)
407407
{
408408
HANDLE newHandle;
409-
THROW_IF_WIN32_BOOL_FALSE(::DuplicateHandle(
410-
GetCurrentProcess(), Handle, GetCurrentProcess(), &newHandle, DesiredAccess.value_or(0), InheritHandle, DesiredAccess.has_value() ? 0 : DUPLICATE_SAME_ACCESS));
409+
THROW_IF_WIN32_BOOL_FALSE(
410+
::DuplicateHandle(
411+
GetCurrentProcess(), Handle, GetCurrentProcess(), &newHandle, DesiredAccess.value_or(0), InheritHandle, DesiredAccess.has_value() ? 0 : DUPLICATE_SAME_ACCESS));
411412

412413
return newHandle;
413414
}
@@ -418,8 +419,9 @@ std::wstring wsl::windows::common::wslutil::DownloadFileImpl(
418419
THROW_LAST_ERROR_IF(!caller);
419420

420421
HANDLE newHandle;
421-
THROW_IF_WIN32_BOOL_FALSE(::DuplicateHandle(
422-
caller.get(), Handle, GetCurrentProcess(), &newHandle, DesiredAccess.value_or(0), FALSE, DesiredAccess.has_value() ? 0 : DUPLICATE_SAME_ACCESS));
422+
THROW_IF_WIN32_BOOL_FALSE(
423+
::DuplicateHandle(
424+
caller.get(), Handle, GetCurrentProcess(), &newHandle, DesiredAccess.value_or(0), FALSE, DesiredAccess.has_value() ? 0 : DUPLICATE_SAME_ACCESS));
423425

424426
return newHandle;
425427
}
@@ -430,8 +432,9 @@ std::wstring wsl::windows::common::wslutil::DownloadFileImpl(
430432
THROW_LAST_ERROR_IF(!caller);
431433

432434
HANDLE newHandle;
433-
THROW_IF_WIN32_BOOL_FALSE(::DuplicateHandle(
434-
GetCurrentProcess(), Handle, caller.get(), &newHandle, DesiredAccess.value_or(0), FALSE, DesiredAccess.has_value() ? 0 : DUPLICATE_SAME_ACCESS));
435+
THROW_IF_WIN32_BOOL_FALSE(
436+
::DuplicateHandle(
437+
GetCurrentProcess(), Handle, caller.get(), &newHandle, DesiredAccess.value_or(0), FALSE, DesiredAccess.has_value() ? 0 : DUPLICATE_SAME_ACCESS));
435438

436439
return newHandle;
437440
}

src/windows/wslcsession/DockerHTTPClient.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,14 @@ class DockerHTTPException : public std::runtime_error
4949
std::string&& Url,
5050
std::string&& RequestContent,
5151
std::string&& ResponseContent) :
52-
std::runtime_error(std::format(
53-
"HTTP request failed: {} {} -> {} (Request: {}, Response: {})", boost::beast::http::to_string(Method), Url, Response.result_int(), RequestContent, ResponseContent)),
52+
std::runtime_error(
53+
std::format(
54+
"HTTP request failed: {} {} -> {} (Request: {}, Response: {})",
55+
boost::beast::http::to_string(Method),
56+
Url,
57+
Response.result_int(),
58+
RequestContent,
59+
ResponseContent)),
5460
m_response(std::move(Response)),
5561
m_url(std::move(Url)),
5662
m_request(std::move(RequestContent)),

src/windows/wslcsession/WSLCSession.cpp

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -422,15 +422,17 @@ void WSLCSession::StartDockerd()
422422
m_dockerdProcess = launcher.Launch(*m_virtualMachine);
423423

424424
// Read stdout & stderr.
425-
m_ioRelay.AddHandle(std::make_unique<windows::common::relay::LineBasedReadHandle>(
426-
m_dockerdProcess->GetStdHandle(1), [&](const auto& data) { OnDockerdLog(data); }, false));
425+
m_ioRelay.AddHandle(
426+
std::make_unique<windows::common::relay::LineBasedReadHandle>(
427+
m_dockerdProcess->GetStdHandle(1), [&](const auto& data) { OnDockerdLog(data); }, false));
427428

428-
m_ioRelay.AddHandle(std::make_unique<windows::common::relay::LineBasedReadHandle>(
429-
m_dockerdProcess->GetStdHandle(2), [&](const auto& data) { OnDockerdLog(data); }, false));
429+
m_ioRelay.AddHandle(
430+
std::make_unique<windows::common::relay::LineBasedReadHandle>(
431+
m_dockerdProcess->GetStdHandle(2), [&](const auto& data) { OnDockerdLog(data); }, false));
430432

431433
// Monitor dockerd's exist so we can detect abnormal exits.
432-
m_ioRelay.AddHandle(std::make_unique<windows::common::relay::EventHandle>(
433-
m_dockerdProcess->GetExitEvent(), std::bind(&WSLCSession::OnDockerdExited, this)));
434+
m_ioRelay.AddHandle(
435+
std::make_unique<windows::common::relay::EventHandle>(m_dockerdProcess->GetExitEvent(), std::bind(&WSLCSession::OnDockerdExited, this)));
434436
}
435437

436438
void WSLCSession::StreamImageOperation(DockerHTTPClient::HTTPRequestContext& requestContext, LPCSTR Image, LPCSTR OperationName, IProgressCallback* ProgressCallback)
@@ -499,8 +501,9 @@ void WSLCSession::StreamImageOperation(DockerHTTPClient::HTTPRequestContext& req
499501

500502
auto onCompleted = [&]() { io.Cancel(); };
501503

502-
io.AddHandle(std::make_unique<DockerHTTPClient::DockerHttpResponseHandle>(
503-
requestContext, std::move(onHttpResponse), std::move(onChunk), std::move(onCompleted)));
504+
io.AddHandle(
505+
std::make_unique<DockerHTTPClient::DockerHttpResponseHandle>(
506+
requestContext, std::move(onHttpResponse), std::move(onChunk), std::move(onCompleted)));
504507

505508
io.Run({});
506509

@@ -622,8 +625,9 @@ try
622625

623626
auto io = CreateIOContext();
624627

625-
io.AddHandle(std::make_unique<relay::RelayHandle<relay::ReadHandle>>(
626-
buildFileHandle.Get(), common::relay::HandleWrapper{buildProcess.GetStdHandle(WSLCFDStdin)}));
628+
io.AddHandle(
629+
std::make_unique<relay::RelayHandle<relay::ReadHandle>>(
630+
buildFileHandle.Get(), common::relay::HandleWrapper{buildProcess.GetStdHandle(WSLCFDStdin)}));
627631

628632
bool verbose = Options->Verbose;
629633
std::string allOutput;
@@ -912,8 +916,8 @@ void WSLCSession::ImportImageImpl(DockerHTTPClient::HTTPRequestContext& Request,
912916
}
913917
};
914918

915-
io.AddHandle(std::make_unique<relay::RelayHandle<relay::ReadHandle>>(
916-
userHandle.Get(), common::relay::HandleWrapper{Request.stream.native_handle()}));
919+
io.AddHandle(
920+
std::make_unique<relay::RelayHandle<relay::ReadHandle>>(userHandle.Get(), common::relay::HandleWrapper{Request.stream.native_handle()}));
917921

918922
io.AddHandle(
919923
std::make_unique<DockerHTTPClient::DockerHttpResponseHandle>(Request, std::move(onHttpResponse), std::move(onProgress)),
@@ -1385,15 +1389,16 @@ try
13851389
{
13861390
std::scoped_lock lock(m_containersLock, m_volumesLock);
13871391

1388-
auto& it = m_containers.emplace_back(WSLCContainerImpl::Create(
1389-
*containerOptions,
1390-
*this,
1391-
m_virtualMachine.value(),
1392-
m_volumes,
1393-
std::bind(&WSLCSession::OnContainerDeleted, this, std::placeholders::_1),
1394-
m_eventTracker.value(),
1395-
m_dockerClient.value(),
1396-
m_ioRelay));
1392+
auto& it = m_containers.emplace_back(
1393+
WSLCContainerImpl::Create(
1394+
*containerOptions,
1395+
*this,
1396+
m_virtualMachine.value(),
1397+
m_volumes,
1398+
std::bind(&WSLCSession::OnContainerDeleted, this, std::placeholders::_1),
1399+
m_eventTracker.value(),
1400+
m_dockerClient.value(),
1401+
m_ioRelay));
13971402

13981403
it->CopyTo(Container);
13991404

@@ -1985,12 +1990,14 @@ MultiHandleWait WSLCSession::CreateIOContext(HANDLE CancelHandle)
19851990
relay::MultiHandleWait io;
19861991

19871992
// Cancel with E_ABORT if the session is terminating.
1988-
io.AddHandle(std::make_unique<relay::EventHandle>(
1989-
m_sessionTerminatingEvent.get(), [this]() { THROW_HR_MSG(E_ABORT, "Session %lu is terminating", m_id); }));
1993+
io.AddHandle(std::make_unique<relay::EventHandle>(m_sessionTerminatingEvent.get(), [this]() {
1994+
THROW_HR_MSG(E_ABORT, "Session %lu is terminating", m_id);
1995+
}));
19901996

19911997
// Cancel with E_ABORT if the client process exits.
1992-
io.AddHandle(std::make_unique<relay::EventHandle>(
1993-
wslutil::OpenCallingProcess(SYNCHRONIZE), [this]() { THROW_HR_MSG(E_ABORT, "Client process has exited"); }));
1998+
io.AddHandle(std::make_unique<relay::EventHandle>(wslutil::OpenCallingProcess(SYNCHRONIZE), [this]() {
1999+
THROW_HR_MSG(E_ABORT, "Client process has exited");
2000+
}));
19942001

19952002
if (CancelHandle != nullptr)
19962003
{

test/windows/Common.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2733,11 +2733,12 @@ void PartialHandleRead::ExpectConsume(const std::string& Expected)
27332733

27342734
if (content != Expected)
27352735
{
2736-
VERIFY_FAIL(std::format(
2737-
L"Expected: '{}' but got: '{}'",
2738-
wsl::shared::string::MultiByteToWide(EscapeString(Expected)),
2739-
wsl::shared::string::MultiByteToWide(EscapeString(content)))
2740-
.c_str());
2736+
VERIFY_FAIL(
2737+
std::format(
2738+
L"Expected: '{}' but got: '{}'",
2739+
wsl::shared::string::MultiByteToWide(EscapeString(Expected)),
2740+
wsl::shared::string::MultiByteToWide(EscapeString(content)))
2741+
.c_str());
27412742
}
27422743
}
27432744

test/windows/WSLCTests.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,8 @@ class WSLCTests
220220
VERIFY_SUCCEEDED(m_defaultSession->TagImage(&tagOptions));
221221

222222
// Ensures the tag is removed to allow tests to try to push or pull the same image again.
223-
auto cleanup = wil::scope_exit_log(WI_DIAGNOSTICS_INFO, [&]() {
224-
LOG_IF_FAILED(DeleteImageNoThrow(registryImage, WSLCDeleteImageFlagsNone).first);
225-
});
223+
auto cleanup = wil::scope_exit_log(
224+
WI_DIAGNOSTICS_INFO, [&]() { LOG_IF_FAILED(DeleteImageNoThrow(registryImage, WSLCDeleteImageFlagsNone).first); });
226225

227226
VERIFY_SUCCEEDED(m_defaultSession->PushImage(registryImage.c_str(), registryAuth.c_str(), nullptr));
228227

@@ -5273,15 +5272,18 @@ class WSLCTests
52735272
std::string readStdout;
52745273
std::string readStderr;
52755274

5276-
io.AddHandle(std::make_unique<DockerIORelayHandle>(
5277-
std::move(readPipe), std::move(stdoutWrite), std::move(stderrWrite), DockerIORelayHandle::Format::Raw));
5275+
io.AddHandle(
5276+
std::make_unique<DockerIORelayHandle>(
5277+
std::move(readPipe), std::move(stdoutWrite), std::move(stderrWrite), DockerIORelayHandle::Format::Raw));
52785278
io.AddHandle(std::make_unique<WriteHandle>(std::move(writePipe), Input));
52795279

5280-
io.AddHandle(std::make_unique<ReadHandle>(
5281-
std::move(stdoutRead), [&](const auto& buffer) { readStdout.append(buffer.data(), buffer.size()); }));
5280+
io.AddHandle(std::make_unique<ReadHandle>(std::move(stdoutRead), [&](const auto& buffer) {
5281+
readStdout.append(buffer.data(), buffer.size());
5282+
}));
52825283

5283-
io.AddHandle(std::make_unique<ReadHandle>(
5284-
std::move(stderrRead), [&](const auto& buffer) { readStderr.append(buffer.data(), buffer.size()); }));
5284+
io.AddHandle(std::make_unique<ReadHandle>(std::move(stderrRead), [&](const auto& buffer) {
5285+
readStderr.append(buffer.data(), buffer.size());
5286+
}));
52855287

52865288
io.Run({});
52875289

test/windows/WslcSdkTests.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,13 @@ ProcessOutput WaitForProcessOutput(WslcProcess process, std::chrono::millisecond
8787
ProcessOutput output;
8888
wsl::windows::common::relay::MultiHandleWait io;
8989

90-
io.AddHandle(std::make_unique<wsl::windows::common::relay::ReadHandle>(
91-
std::move(ownedStdout), [&](const auto& buffer) { output.stdoutOutput.append(buffer.data(), buffer.size()); }));
90+
io.AddHandle(std::make_unique<wsl::windows::common::relay::ReadHandle>(std::move(ownedStdout), [&](const auto& buffer) {
91+
output.stdoutOutput.append(buffer.data(), buffer.size());
92+
}));
9293

93-
io.AddHandle(std::make_unique<wsl::windows::common::relay::ReadHandle>(
94-
std::move(ownedStderr), [&](const auto& buffer) { output.stderrOutput.append(buffer.data(), buffer.size()); }));
94+
io.AddHandle(std::make_unique<wsl::windows::common::relay::ReadHandle>(std::move(ownedStderr), [&](const auto& buffer) {
95+
output.stderrOutput.append(buffer.data(), buffer.size());
96+
}));
9597

9698
auto timeoutTime = std::chrono::steady_clock::now() + timeout;
9799
io.Run(timeout);
@@ -324,7 +326,7 @@ class WslcSdkTests
324326
// -----------------------------------------------------------------------
325327
// Image tests
326328
// -----------------------------------------------------------------------
327-
329+
328330
WSLC_TEST_METHOD(ImageList)
329331
{
330332
// Positive: session has images pre-loaded — list must return at least one entry.

0 commit comments

Comments
 (0)