Skip to content

Commit 4e14c61

Browse files
committed
Enable clang-format enforcement for untouched 2026 targets
Format source files and enable clang-format enforcement across all build targets where none of the files have been modified since the start of 2026. Out of 768 total targets under //cuttlefish/... (243 unformatted), 55 targets were formatted and enabled in this commit, and 188 targets remain unformatted. Bug: b/512215781 Assisted-by: gemini-next:current
1 parent 734c5fb commit 4e14c61

111 files changed

Lines changed: 2065 additions & 2066 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

base/cvd/cuttlefish/common/libs/fs/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ cf_cc_test(
4949
srcs = [
5050
"shared_fd_test.cpp",
5151
],
52-
clang_format_enabled = False,
5352
deps = [
5453
":fs",
5554
"//libbase",

base/cvd/cuttlefish/common/libs/fs/shared_fd_test.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
#include "cuttlefish/common/libs/fs/shared_fd.h"
1818

19-
#include <unistd.h>
2019
#include <gtest/gtest.h>
20+
#include <unistd.h>
2121

2222
namespace cuttlefish {
2323

@@ -28,10 +28,11 @@ TEST(SendFD, Basic) {
2828
SharedFD::Pipe(fds, fds + 1);
2929
EXPECT_TRUE(fds[0]->IsOpen());
3030
EXPECT_TRUE(fds[1]->IsOpen());
31-
EXPECT_EQ(sizeof(pipe_message), fds[1]->Write(pipe_message, sizeof(pipe_message)));
31+
EXPECT_EQ(sizeof(pipe_message),
32+
fds[1]->Write(pipe_message, sizeof(pipe_message)));
3233
char buf[80];
3334
EXPECT_EQ(sizeof(pipe_message), fds[0]->Read(buf, sizeof(buf)));
3435
EXPECT_EQ(0, strcmp(buf, pipe_message));
3536
}
3637

37-
}
38+
} // namespace cuttlefish

base/cvd/cuttlefish/common/libs/utils/BUILD.bazel

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,6 @@ cf_cc_library(
294294
hdrs = [
295295
"random.h",
296296
],
297-
clang_format_enabled = False,
298297
)
299298

300299
cf_cc_library(
@@ -322,7 +321,6 @@ cf_cc_library(
322321
name = "signals",
323322
srcs = ["signals.cpp"],
324323
hdrs = ["signals.h"],
325-
clang_format_enabled = False,
326324
deps = [
327325
"//libbase",
328326
"@abseil-cpp//absl/log:check",
@@ -338,7 +336,6 @@ cf_cc_library(
338336
name = "socket2socket_proxy",
339337
srcs = ["socket2socket_proxy.cpp"],
340338
hdrs = ["socket2socket_proxy.h"],
341-
clang_format_enabled = False,
342339
target_compatible_with = [
343340
"@platforms//os:linux",
344341
],
@@ -462,7 +459,6 @@ cf_cc_library(
462459
name = "vsock_connection",
463460
srcs = ["vsock_connection.cpp"],
464461
hdrs = ["vsock_connection.h"],
465-
clang_format_enabled = False,
466462
clang_tidy_enabled = False, # TODO: b/403278821 - fix warnings and re-enable after migration work
467463
target_compatible_with = [
468464
"@platforms//os:linux",
@@ -492,7 +488,6 @@ cf_cc_library(
492488
name = "wait_for_unix_socket",
493489
srcs = ["wait_for_unix_socket.cpp"],
494490
hdrs = ["wait_for_unix_socket.h"],
495-
clang_format_enabled = False,
496491
deps = [
497492
"//cuttlefish/common/libs/utils:files",
498493
"//cuttlefish/common/libs/utils:subprocess",

base/cvd/cuttlefish/common/libs/utils/random.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ std::string GenerateRandomString(const std::string& alphabet,
2727
const int length) {
2828
std::srand(std::time(0));
2929
std::vector<char> result(length);
30-
for(int i = 0; i < length; i++){
30+
for (int i = 0; i < length; i++) {
3131
result[i] = alphabet[std::rand() % alphabet.size()];
3232
}
3333
return std::string(result.begin(), result.end());
3434
}
35-
}
35+
} // namespace cuttlefish

base/cvd/cuttlefish/common/libs/utils/signals.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ void ChangeSignalHandlers(void (*handler)(int), std::vector<int> signals) {
4444
struct sigaction act;
4545
act.sa_handler = handler;
4646
sigemptyset(&act.sa_mask);
47-
for (auto signal: signals) {
47+
for (auto signal : signals) {
4848
sigaddset(&act.sa_mask, signal);
4949
}
5050
act.sa_flags = 0;
@@ -55,4 +55,3 @@ void ChangeSignalHandlers(void (*handler)(int), std::vector<int> signals) {
5555
}
5656

5757
} // namespace cuttlefish
58-

base/cvd/cuttlefish/common/libs/utils/signals.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@ class SignalMasker {
4343
sigset_t old_mask_;
4444
};
4545

46-
void ChangeSignalHandlers(void(*handler)(int), std::vector<int> signals);
46+
void ChangeSignalHandlers(void (*handler)(int), std::vector<int> signals);
4747

4848
} // namespace cuttlefish

base/cvd/cuttlefish/common/libs/utils/socket2socket_proxy.cpp

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
#include "cuttlefish/common/libs/utils/socket2socket_proxy.h"
1818

1919
#include <poll.h>
20-
#include <sys/types.h>
2120
#include <sys/socket.h>
21+
#include <sys/types.h>
2222

2323
#include <atomic>
2424
#include <cstring>
@@ -37,8 +37,7 @@ namespace {
3737

3838
class ProxyPair {
3939
public:
40-
ProxyPair()
41-
: stop_fd_(SharedFD::Event()) {
40+
ProxyPair() : stop_fd_(SharedFD::Event()) {
4241
if (!stop_fd_->IsOpen()) {
4342
LOG(FATAL) << "Failed to open eventfd: " << stop_fd_->StrError();
4443
return;
@@ -80,9 +79,7 @@ class ProxyPair {
8079
std::ref(t2c_running_));
8180
}
8281

83-
bool Running() {
84-
return c2t_running_ || t2c_running_;
85-
}
82+
bool Running() { return c2t_running_ || t2c_running_; }
8683

8784
private:
8885
void Forward(const std::string& label, SharedFD from, SharedFD to,
@@ -112,22 +109,22 @@ class ProxyPair {
112109

113110
} // namespace
114111

115-
ProxyServer::ProxyServer(SharedFD server, std::function<SharedFD()> clients_factory)
112+
ProxyServer::ProxyServer(SharedFD server,
113+
std::function<SharedFD()> clients_factory)
116114
: stop_fd_(SharedFD::Event()) {
117115
if (!stop_fd_->IsOpen()) {
118116
LOG(FATAL) << "Failed to open eventfd: " << stop_fd_->StrError();
119117
return;
120118
}
121119
server_ = std::thread([&, server_fd = std::move(server),
122-
clients_factory = std::move(clients_factory)]() {
120+
clients_factory = std::move(clients_factory)]() {
123121
constexpr ssize_t SERVER = 0;
124122
constexpr ssize_t STOP = 1;
125123
std::list<ProxyPair> watched;
126124

127125
std::vector<PollSharedFd> server_poll = {
128-
{.fd = server_fd, .events = POLLIN},
129-
{.fd = stop_fd_, .events = POLLIN}
130-
};
126+
{.fd = server_fd, .events = POLLIN},
127+
{.fd = stop_fd_, .events = POLLIN}};
131128

132129
while (server_fd->IsOpen()) {
133130
server_poll[SERVER].revents = 0;
@@ -151,7 +148,8 @@ ProxyServer::ProxyServer(SharedFD server, std::function<SharedFD()> clients_fact
151148
// connection without blocking on that
152149
auto client = SharedFD::Accept(*server_fd);
153150
if (!client->IsOpen()) {
154-
LOG(ERROR) << "Failed to accept incoming connection: " << client->StrError();
151+
LOG(ERROR) << "Failed to accept incoming connection: "
152+
<< client->StrError();
155153
continue;
156154
}
157155
auto target = clients_factory();
@@ -163,13 +161,15 @@ ProxyServer::ProxyServer(SharedFD server, std::function<SharedFD()> clients_fact
163161
<< "Proxy is launched. Amount of currently tracked proxy pairs: "
164162
<< watched.size();
165163
} else {
166-
LOG(ERROR) << "Cannot connect to the target to setup proxying: " << target->StrError();
164+
LOG(ERROR) << "Cannot connect to the target to setup proxying: "
165+
<< target->StrError();
167166
}
168167
// Unwatch completed proxy pairs
169168
watched.remove_if([](ProxyPair& proxy) { return !proxy.Running(); });
170169
}
171170

172-
// Making sure all launched proxy pairs are finished by triggering their destructor
171+
// Making sure all launched proxy pairs are finished by triggering their
172+
// destructor
173173
VLOG(0) << "Waiting for proxy threads to turn down";
174174
watched.clear();
175175
VLOG(0) << "Proxy threads are successfully turned down";
@@ -194,8 +194,10 @@ void Proxy(SharedFD server, std::function<SharedFD()> conn_factory) {
194194
proxy.Join();
195195
}
196196

197-
std::unique_ptr<ProxyServer> ProxyAsync(SharedFD server, std::function<SharedFD()> conn_factory) {
198-
return std::make_unique<ProxyServer>(std::move(server), std::move(conn_factory));
197+
std::unique_ptr<ProxyServer> ProxyAsync(
198+
SharedFD server, std::function<SharedFD()> conn_factory) {
199+
return std::make_unique<ProxyServer>(std::move(server),
200+
std::move(conn_factory));
199201
}
200202

201203
} // namespace cuttlefish

base/cvd/cuttlefish/common/libs/utils/socket2socket_proxy.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class ProxyServer {
4444
// behavior for SIGPIPE before calling this function, otherwise it runs the risk
4545
// or crashing the process when a connection breaks.
4646
void Proxy(SharedFD server, std::function<SharedFD()> conn_factory);
47-
std::unique_ptr<ProxyServer> ProxyAsync(SharedFD server, std::function<SharedFD()> conn_factory);
47+
std::unique_ptr<ProxyServer> ProxyAsync(SharedFD server,
48+
std::function<SharedFD()> conn_factory);
4849

4950
} // namespace cuttlefish

base/cvd/cuttlefish/common/libs/utils/vsock_connection.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616

1717
#include "cuttlefish/common/libs/utils/vsock_connection.h"
1818

19-
#include <sys/types.h>
2019
#include <sys/socket.h>
2120
#include <sys/time.h>
21+
#include <sys/types.h>
2222

2323
#include <functional>
2424
#include <future>

base/cvd/cuttlefish/common/libs/utils/wait_for_unix_socket.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,4 @@ Result<void> WaitForUnixSocketListeningWithoutConnect(const std::string& path,
102102
return CF_ERR("This shouldn't be executed");
103103
}
104104

105-
}
105+
} // namespace cuttlefish

0 commit comments

Comments
 (0)