aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main
diff options
context:
space:
mode:
authorGravatar Lukacs Berki <lberki@google.com>2016-09-13 07:52:01 +0000
committerGravatar Dmitry Lomov <dslomov@google.com>2016-09-13 12:31:58 +0000
commitcdd42274f7e6fa862f3bd3ba7115f2c9feac5d50 (patch)
tree2253ad8fcafaa6117659b0395a39847cb973e495 /src/main
parentef54fb52e3b33ccf9713dca49a5bef01fc860174 (diff)
More client fixes:
- Use an explicit cast to void to tell the compiler that we are intentionally ignoring return values. - Delete the unused function GetPeerProcessId() -- MOS_MIGRATED_REVID=132970162
Diffstat (limited to 'src/main')
-rw-r--r--src/main/cpp/blaze.cc22
-rw-r--r--src/main/cpp/blaze_util.cc8
-rw-r--r--src/main/cpp/blaze_util_darwin.cc10
-rw-r--r--src/main/cpp/blaze_util_freebsd.cc2
-rw-r--r--src/main/cpp/blaze_util_linux.cc10
-rw-r--r--src/main/cpp/blaze_util_mingw.cc10
-rw-r--r--src/main/cpp/blaze_util_platform.h3
-rw-r--r--src/main/cpp/blaze_util_posix.cc4
8 files changed, 11 insertions, 58 deletions
diff --git a/src/main/cpp/blaze.cc b/src/main/cpp/blaze.cc
index 9316a7f707..018e64a7af 100644
--- a/src/main/cpp/blaze.cc
+++ b/src/main/cpp/blaze.cc
@@ -830,9 +830,7 @@ static int ForwardServerOutput(int socket, int output) {
}
remaining -= bytes;
- if (write(output, server_output_buffer, bytes) != bytes) {
- // Not much we can do if this doesn't work, just placate the compiler.
- }
+ (void) write(output, server_output_buffer, bytes);
}
return 0;
@@ -1708,9 +1706,9 @@ static void SetupStreams() {
// Ensure we have three open fds. Otherwise we can end up with
// bizarre things like stdout going to the lock file, etc.
- if (fcntl(0, F_GETFL) == -1) open("/dev/null", O_RDONLY);
- if (fcntl(1, F_GETFL) == -1) open("/dev/null", O_WRONLY);
- if (fcntl(2, F_GETFL) == -1) open("/dev/null", O_WRONLY);
+ if (fcntl(STDIN_FILENO, F_GETFL) == -1) open("/dev/null", O_RDONLY);
+ if (fcntl(STDOUT_FILENO, F_GETFL) == -1) open("/dev/null", O_WRONLY);
+ if (fcntl(STDERR_FILENO, F_GETFL) == -1) open("/dev/null", O_WRONLY);
}
static void CheckBinaryPath(const string& argv0) {
@@ -2073,17 +2071,13 @@ unsigned int GrpcBlazeServer::Communicate() {
}
if (response.standard_output().size() > 0) {
- if (write(1, response.standard_output().c_str(),
- response.standard_output().size()) <= 0) {
- // Placate the compiler.
- }
+ (void) write(STDOUT_FILENO, response.standard_output().c_str(),
+ response.standard_output().size());
}
if (response.standard_error().size() > 0) {
- if (write(2, response.standard_error().c_str(),
- response.standard_error().size()) <= 0) {
- // Placate the compiler.
- }
+ (void) write(STDERR_FILENO, response.standard_error().c_str(),
+ response.standard_error().size());
}
if (!command_id_set && response.command_id().size() > 0) {
diff --git a/src/main/cpp/blaze_util.cc b/src/main/cpp/blaze_util.cc
index 6ba27b5165..7bf95cbade 100644
--- a/src/main/cpp/blaze_util.cc
+++ b/src/main/cpp/blaze_util.cc
@@ -426,9 +426,7 @@ uint64_t AcquireLock(const string& output_base, bool batch_mode, bool block,
string msg = "owner=launcher\npid="
+ ToString(getpid()) + "\ntty=" + (tty ? tty : "") + "\n";
// The contents are currently meant only for debugging.
- if (write(lockfd, msg.data(), msg.size()) <= 0) {
- // Placate the compiler.
- }
+ (void) write(lockfd, msg.data(), msg.size());
blaze_lock->lockfd = lockfd;
return wait_time;
}
@@ -451,9 +449,7 @@ void sigprintf(const char *format, ...) {
va_start(ap, format);
int r = vsnprintf(buf, sizeof buf, format, ap);
va_end(ap);
- if (write(STDERR_FILENO, buf, r) <= 0) {
- // We don't care, just placate the compiler.
- }
+ (void) write(STDERR_FILENO, buf, r);
}
} // namespace blaze
diff --git a/src/main/cpp/blaze_util_darwin.cc b/src/main/cpp/blaze_util_darwin.cc
index 0cadc41660..1f0acbd2cf 100644
--- a/src/main/cpp/blaze_util_darwin.cc
+++ b/src/main/cpp/blaze_util_darwin.cc
@@ -114,16 +114,6 @@ void WarnFilesystemType(const string& output_base) {
}
}
-pid_t GetPeerProcessId(int socket) {
- pid_t pid = 0;
- socklen_t len = sizeof(pid_t);
- if (getsockopt(socket, SOL_LOCAL, LOCAL_PEERPID, &pid, &len) < 0) {
- pdie(blaze_exit_code::LOCAL_ENVIRONMENTAL_ERROR,
- "can't get server pid from connection");
- }
- return pid;
-}
-
string GetSelfPath() {
char pathbuf[PROC_PIDPATHINFO_MAXSIZE] = {};
int len = proc_pidpath(getpid(), pathbuf, sizeof(pathbuf));
diff --git a/src/main/cpp/blaze_util_freebsd.cc b/src/main/cpp/blaze_util_freebsd.cc
index 917a5095bd..4429038258 100644
--- a/src/main/cpp/blaze_util_freebsd.cc
+++ b/src/main/cpp/blaze_util_freebsd.cc
@@ -86,8 +86,6 @@ string GetSelfPath() {
return string(buffer);
}
-pid_t GetPeerProcessId(int socket) { return -1; }
-
uint64_t MonotonicClock() {
struct timespec ts = {};
clock_gettime(CLOCK_MONOTONIC, &ts);
diff --git a/src/main/cpp/blaze_util_linux.cc b/src/main/cpp/blaze_util_linux.cc
index 4bc2224dc9..bd5fc852cb 100644
--- a/src/main/cpp/blaze_util_linux.cc
+++ b/src/main/cpp/blaze_util_linux.cc
@@ -95,16 +95,6 @@ string GetSelfPath() {
return string(buffer);
}
-pid_t GetPeerProcessId(int socket) {
- struct ucred creds = {};
- socklen_t len = sizeof creds;
- if (getsockopt(socket, SOL_SOCKET, SO_PEERCRED, &creds, &len) == -1) {
- pdie(blaze_exit_code::LOCAL_ENVIRONMENTAL_ERROR,
- "can't get server pid from connection");
- }
- return creds.pid;
-}
-
uint64_t MonotonicClock() {
struct timespec ts = {};
clock_gettime(CLOCK_MONOTONIC, &ts);
diff --git a/src/main/cpp/blaze_util_mingw.cc b/src/main/cpp/blaze_util_mingw.cc
index 20d1ea6876..069ce8bb5e 100644
--- a/src/main/cpp/blaze_util_mingw.cc
+++ b/src/main/cpp/blaze_util_mingw.cc
@@ -83,16 +83,6 @@ string GetOutputRoot() {
}
}
-pid_t GetPeerProcessId(int socket) {
- struct ucred creds = {};
- socklen_t len = sizeof creds;
- if (getsockopt(socket, SOL_SOCKET, SO_PEERCRED, &creds, &len) == -1) {
- pdie(blaze_exit_code::LOCAL_ENVIRONMENTAL_ERROR,
- "can't get server pid from connection");
- }
- return creds.pid;
-}
-
uint64_t MonotonicClock() {
struct timespec ts = {};
clock_gettime(CLOCK_MONOTONIC, &ts);
diff --git a/src/main/cpp/blaze_util_platform.h b/src/main/cpp/blaze_util_platform.h
index 1497a85824..5f8b3bfa79 100644
--- a/src/main/cpp/blaze_util_platform.h
+++ b/src/main/cpp/blaze_util_platform.h
@@ -27,9 +27,6 @@ std::string GetSelfPath();
// Returns the directory Bazel can use to store output.
std::string GetOutputRoot();
-// Returns the process id of the peer connected to this socket.
-pid_t GetPeerProcessId(int socket);
-
// Warn about dubious filesystem types, such as NFS, case-insensitive (?).
void WarnFilesystemType(const std::string& output_base);
diff --git a/src/main/cpp/blaze_util_posix.cc b/src/main/cpp/blaze_util_posix.cc
index 2203cb0b20..a7ba5d4f4d 100644
--- a/src/main/cpp/blaze_util_posix.cc
+++ b/src/main/cpp/blaze_util_posix.cc
@@ -100,9 +100,7 @@ static void Daemonize(const string& daemon_output) {
// In a daemon, no-one can hear you scream.
open("/dev/null", O_WRONLY);
}
- if (dup(STDOUT_FILENO)) { // stderr (2>&1)
- // Placate the compiler.
- }
+ (void) dup(STDOUT_FILENO); // stderr (2>&1)
}
class PipeBlazeServerStartup : public BlazeServerStartup {