aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/main/cpp/blaze.cc25
-rw-r--r--src/main/cpp/blaze_util.cc9
-rw-r--r--src/main/cpp/blaze_util_posix.cc5
-rw-r--r--src/main/cpp/util/md5.cc5
4 files changed, 29 insertions, 15 deletions
diff --git a/src/main/cpp/blaze.cc b/src/main/cpp/blaze.cc
index a17f86d0de..afb701d787 100644
--- a/src/main/cpp/blaze.cc
+++ b/src/main/cpp/blaze.cc
@@ -829,8 +829,9 @@ static int ForwardServerOutput(int socket, int output) {
}
remaining -= bytes;
- // Not much we can do if this doesn't work
- write(output, server_output_buffer, bytes);
+ if (write(output, server_output_buffer, bytes) != bytes) {
+ // Not much we can do if this doesn't work, just placate the compiler.
+ }
}
return 0;
@@ -1454,7 +1455,9 @@ static void sigprintf(const char *format, ...) {
va_start(ap, format);
int r = vsnprintf(buf, sizeof buf, format, ap);
va_end(ap);
- write(STDERR_FILENO, buf, r);
+ if (write(STDERR_FILENO, buf, r) <= 0) {
+ // We don't care, just placate the compiler.
+ }
}
// Signal handler.
@@ -2111,13 +2114,17 @@ unsigned int GrpcBlazeServer::Communicate() {
}
if (response.standard_output().size() > 0) {
- write(1, response.standard_output().c_str(),
- response.standard_output().size());
+ if (write(1, response.standard_output().c_str(),
+ response.standard_output().size()) <= 0) {
+ // Placate the compiler.
+ }
}
if (response.standard_error().size() > 0) {
- write(2, response.standard_error().c_str(),
- response.standard_error().size());
+ if (write(2, response.standard_error().c_str(),
+ response.standard_error().size()) <= 0) {
+ // Placate the compiler.
+ }
}
if (!command_id_set && response.command_id().size() > 0) {
@@ -2150,7 +2157,9 @@ void GrpcBlazeServer::Disconnect() {
void GrpcBlazeServer::SendAction(CancelThreadAction action) {
char msg = action;
- write(send_socket_, &msg, 1); // We assume this always works
+ if (write(send_socket_, &msg, 1) <= 0) {
+ // We assume this always works, just placate the compiler.
+ }
}
void GrpcBlazeServer::Cancel() {
diff --git a/src/main/cpp/blaze_util.cc b/src/main/cpp/blaze_util.cc
index 0c5ced094c..3c5bdabe15 100644
--- a/src/main/cpp/blaze_util.cc
+++ b/src/main/cpp/blaze_util.cc
@@ -411,13 +411,16 @@ uint64_t AcquireLock(const string& output_base, bool batch_mode, bool block,
}
// Identify ourselves in the lockfile.
- ftruncate(lockfd, 0);
+ if (ftruncate(lockfd, 0)) {
+ // Placate the compiler.
+ }
const char *tty = ttyname(STDIN_FILENO); // NOLINT (single-threaded)
string msg = "owner=launcher\npid="
+ ToString(getpid()) + "\ntty=" + (tty ? tty : "") + "\n";
- // Don't bother checking for error, since it's unlikely and unimportant.
// The contents are currently meant only for debugging.
- write(lockfd, msg.data(), msg.size());
+ if (write(lockfd, msg.data(), msg.size()) <= 0) {
+ // Placate the compiler.
+ }
blaze_lock->lockfd = lockfd;
return wait_time;
}
diff --git a/src/main/cpp/blaze_util_posix.cc b/src/main/cpp/blaze_util_posix.cc
index 12498c4f9a..2203cb0b20 100644
--- a/src/main/cpp/blaze_util_posix.cc
+++ b/src/main/cpp/blaze_util_posix.cc
@@ -100,7 +100,9 @@ static void Daemonize(const string& daemon_output) {
// In a daemon, no-one can hear you scream.
open("/dev/null", O_WRONLY);
}
- dup(STDOUT_FILENO); // stderr (2>&1)
+ if (dup(STDOUT_FILENO)) { // stderr (2>&1)
+ // Placate the compiler.
+ }
}
class PipeBlazeServerStartup : public BlazeServerStartup {
@@ -200,6 +202,7 @@ string RunProgram(const string& exe, const std::vector<string>& args_vector) {
ExecuteProgram(exe, args_vector);
pdie(blaze_exit_code::INTERNAL_ERROR, "Failed to run %s", exe.c_str());
}
+ return string(""); // We cannot reach here, just placate the compiler.
}
bool ReadDirectorySymlink(const string &name, string* result) {
diff --git a/src/main/cpp/util/md5.cc b/src/main/cpp/util/md5.cc
index 05d2ba276c..d25c292787 100644
--- a/src/main/cpp/util/md5.cc
+++ b/src/main/cpp/util/md5.cc
@@ -156,9 +156,8 @@ void Md5Digest::Finish(unsigned char digest[16]) {
/* Put the 64-bit file length in *bits* at the end of the buffer. */
unsigned int size = (ctx_buffer_len < 56 ? 64 : 128);
- *(reinterpret_cast<uint32_t*>(ctx_buffer + size - 8)) = count[0] << 3;
- *(reinterpret_cast<uint32_t*>(ctx_buffer + size - 4)) =
- (count[1] << 3) | (count[0] >> 29);
+ uint32_t words[2] = { count[0] << 3, (count[1] << 3) | (count[0] >> 29) };
+ memcpy(ctx_buffer + size - 8, words, 8);
memcpy(ctx_buffer + ctx_buffer_len, kPadding, size - 8 - ctx_buffer_len);