Follow-up with more build fixes

Because any change that touches continuous integration needs a companion o.O

PiperOrigin-RevId: 347769780
Change-Id: I20525aaac2ce41c48f619b641baa31e880432e50
pull/75/head
Christian Blichmann 2020-12-16 00:08:56 -08:00 committed by Copybara-Service
parent 07d4d02628
commit 507010781a
6 changed files with 24 additions and 16 deletions

View File

@ -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

View File

@ -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",
],
)

View File

@ -28,6 +28,7 @@
#include <string>
#include <glog/logging.h>
#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<struct sockaddr*>(&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;

View File

@ -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",
],
)

View File

@ -16,6 +16,7 @@
#include <vector>
#include <glog/logging.h>
#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

View File

@ -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;