diff --git a/.github/workflows/ubuntu-cmake.yml b/.github/workflows/ubuntu-cmake.yml index 009cbae..ce4ad85 100644 --- a/.github/workflows/ubuntu-cmake.yml +++ b/.github/workflows/ubuntu-cmake.yml @@ -20,7 +20,7 @@ jobs: - name: Create Build Environment run: | - pip3 install absl-py + pip3 install absl-py clang cmake -E make_directory ${{runner.workspace}}/build - name: Configure CMake diff --git a/sandboxed_api/sandbox2/examples/network/BUILD.bazel b/sandboxed_api/sandbox2/examples/network/BUILD.bazel index 2610103..bbefe16 100644 --- a/sandboxed_api/sandbox2/examples/network/BUILD.bazel +++ b/sandboxed_api/sandbox2/examples/network/BUILD.bazel @@ -35,6 +35,7 @@ cc_binary( "//sandboxed_api/sandbox2/util:fileops", "//sandboxed_api/sandbox2/util:runfiles", "//sandboxed_api/util:flags", + "@com_google_absl//absl/base:core_headers", ], ) diff --git a/sandboxed_api/sandbox2/examples/network/network_sandbox.cc b/sandboxed_api/sandbox2/examples/network/network_sandbox.cc index 3c99f82..df96192 100644 --- a/sandboxed_api/sandbox2/examples/network/network_sandbox.cc +++ b/sandboxed_api/sandbox2/examples/network/network_sandbox.cc @@ -28,6 +28,7 @@ #include #include +#include "absl/base/macros.h" #include "sandboxed_api/util/flag.h" #include "sandboxed_api/sandbox2/comms.h" #include "sandboxed_api/sandbox2/executor.h" @@ -62,13 +63,10 @@ void Server(int port) { return; } - { - int enable = 1; - if (setsockopt(s.get(), SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(enable)) < - 0) { - PLOG(ERROR) << "setsockopt(SO_REUSEADDR) failed"; - return; - } + if (int enable = 1; setsockopt(s.get(), SOL_SOCKET, SO_REUSEADDR, &enable, + sizeof(enable)) < 0) { + PLOG(ERROR) << "setsockopt(SO_REUSEADDR) failed"; + return; } // Listen to localhost only. @@ -80,12 +78,14 @@ void Server(int port) { if (err == 0) { LOG(ERROR) << "inet_pton() failed"; return; - } else if (err == -1) { + } + if (err == -1) { PLOG(ERROR) << "inet_pton() failed"; return; } - if (bind(s.get(), (struct sockaddr*)&addr, sizeof(addr)) < 0) { + if (bind(s.get(), reinterpret_cast(&addr), sizeof(addr)) < + 0) { PLOG(ERROR) << "bind() failed"; return; } @@ -101,8 +101,10 @@ void Server(int port) { return; } - const char msg[] = "Hello World\n"; - write(client.get(), msg, strlen(msg)); + constexpr char kMsg[] = "Hello World\n"; + if (write(client.get(), kMsg, ABSL_ARRAYSIZE(kMsg) - 1) < 0) { + PLOG(ERROR) << "write() failed"; + } } int ConnectToServer(int port) { @@ -121,7 +123,8 @@ int ConnectToServer(int port) { LOG(ERROR) << "inet_pton() failed"; close(s); return -1; - } else if (err == -1) { + } + if (err == -1) { PLOG(ERROR) << "inet_pton() failed"; close(s); return -1; diff --git a/sandboxed_api/sandbox2/examples/network_proxy/BUILD.bazel b/sandboxed_api/sandbox2/examples/network_proxy/BUILD.bazel index ccbefc5..1e1f15e 100644 --- a/sandboxed_api/sandbox2/examples/network_proxy/BUILD.bazel +++ b/sandboxed_api/sandbox2/examples/network_proxy/BUILD.bazel @@ -31,6 +31,7 @@ cc_binary( "//sandboxed_api/sandbox2/util:fileops", "//sandboxed_api/sandbox2/util:runfiles", "//sandboxed_api/util:flags", + "@com_google_absl//absl/base:core_headers", ], ) diff --git a/sandboxed_api/sandbox2/examples/network_proxy/networkproxy_sandbox.cc b/sandboxed_api/sandbox2/examples/network_proxy/networkproxy_sandbox.cc index cd72c3a..3555e1a 100644 --- a/sandboxed_api/sandbox2/examples/network_proxy/networkproxy_sandbox.cc +++ b/sandboxed_api/sandbox2/examples/network_proxy/networkproxy_sandbox.cc @@ -16,6 +16,7 @@ #include #include +#include "absl/base/macros.h" #include "sandboxed_api/util/flag.h" #include "sandboxed_api/sandbox2/comms.h" #include "sandboxed_api/sandbox2/executor.h" @@ -102,8 +103,10 @@ void Server(int port) { return; } - const char kMsg[] = "Hello World\n"; - write(client.get(), kMsg, ABSL_ARRAYSIZE(kMsg)); + constexpr char kMsg[] = "Hello World\n"; + if (write(client.get(), kMsg, ABSL_ARRAYSIZE(kMsg) - 1) < 0) { + PLOG(ERROR) << "write() failed"; + } } } // namespace diff --git a/sandboxed_api/sandbox2/global_forkclient.cc b/sandboxed_api/sandbox2/global_forkclient.cc index f531334..049b8d4 100644 --- a/sandboxed_api/sandbox2/global_forkclient.cc +++ b/sandboxed_api/sandbox2/global_forkclient.cc @@ -77,7 +77,7 @@ bool ValidateStartMode(const char*, const std::string& flag) { GlobalForkserverStartModeSet unused; std::string error; if (!AbslParseFlag(flag, &unused, &error)) { - SAPI_RAW_LOG(ERROR, "%s", error); + SAPI_RAW_LOG(ERROR, "%s", error.c_str()); return false; } return true;