Commit ac3e9189 authored by 's avatar

Suppress warnings around return value of write and symlink.


git-svn-id: https://google-glog.googlecode.com/svn/trunk@97 eb4d4688-79bd-11dd-afb4-1d65580434c0
parent c2cbc763
...@@ -505,7 +505,7 @@ inline void LogDestination::SetEmailLogging(LogSeverity min_severity, ...@@ -505,7 +505,7 @@ inline void LogDestination::SetEmailLogging(LogSeverity min_severity,
static void WriteToStderr(const char* message, size_t len) { static void WriteToStderr(const char* message, size_t len) {
// Avoid using cerr from this module since we may get called during // Avoid using cerr from this module since we may get called during
// exit code, and cerr may be partially or fully destroyed by then. // exit code, and cerr may be partially or fully destroyed by then.
write(STDERR_FILENO, message, len); fwrite(message, len, 1, stderr);
} }
inline void LogDestination::MaybeLogToStderr(LogSeverity severity, inline void LogDestination::MaybeLogToStderr(LogSeverity severity,
...@@ -728,14 +728,18 @@ bool LogFileObject::CreateLogfile(const char* time_pid_string) { ...@@ -728,14 +728,18 @@ bool LogFileObject::CreateLogfile(const char* time_pid_string) {
// Make the symlink be relative (in the same dir) so that if the // Make the symlink be relative (in the same dir) so that if the
// entire log directory gets relocated the link is still valid. // entire log directory gets relocated the link is still valid.
const char *linkdest = slash ? (slash + 1) : filename; const char *linkdest = slash ? (slash + 1) : filename;
symlink(linkdest, linkpath.c_str()); // silently ignore failures if (symlink(linkdest, linkpath.c_str()) != 0) {
// silently ignore failures
}
// Make an additional link to the log file in a place specified by // Make an additional link to the log file in a place specified by
// FLAGS_log_link, if indicated // FLAGS_log_link, if indicated
if (!FLAGS_log_link.empty()) { if (!FLAGS_log_link.empty()) {
linkpath = FLAGS_log_link + "/" + linkname; linkpath = FLAGS_log_link + "/" + linkname;
unlink(linkpath.c_str()); // delete old one if it exists unlink(linkpath.c_str()); // delete old one if it exists
symlink(filename, linkpath.c_str()); // silently ignore failures if (symlink(filename, linkpath.c_str()) != 0) {
// silently ignore failures
}
} }
#endif #endif
} }
...@@ -1222,7 +1226,9 @@ void LogMessage::SendToLog() EXCLUSIVE_LOCKS_REQUIRED(log_mutex) { ...@@ -1222,7 +1226,9 @@ void LogMessage::SendToLog() EXCLUSIVE_LOCKS_REQUIRED(log_mutex) {
LogDestination::WaitForSinks(data_); LogDestination::WaitForSinks(data_);
const char* message = "*** Check failure stack trace: ***\n"; const char* message = "*** Check failure stack trace: ***\n";
write(STDERR_FILENO, message, strlen(message)); if (write(STDERR_FILENO, message, strlen(message)) < 0) {
// Ignore errors.
}
Fail(); Fail();
} }
} }
......
...@@ -142,7 +142,9 @@ class MinimalFormatter { ...@@ -142,7 +142,9 @@ class MinimalFormatter {
// Writes the given data with the size to the standard error. // Writes the given data with the size to the standard error.
void WriteToStderr(const char* data, int size) { void WriteToStderr(const char* data, int size) {
write(STDERR_FILENO, data, size); if (write(STDERR_FILENO, data, size) < 0) {
// Ignore errors.
}
} }
// The writer function can be changed by InstallFailureWriter(). // The writer function can be changed by InstallFailureWriter().
......
...@@ -58,7 +58,9 @@ void* DieInThread(void*) { ...@@ -58,7 +58,9 @@ void* DieInThread(void*) {
} }
void WriteToStdout(const char* data, int size) { void WriteToStdout(const char* data, int size) {
write(STDOUT_FILENO, data, size); if (write(STDOUT_FILENO, data, size) < 0) {
// Ignore errors.
}
} }
int main(int argc, char **argv) { int main(int argc, char **argv) {
......
...@@ -79,7 +79,9 @@ static const int kPrintfPointerFieldWidth = 2 + 2 * sizeof(void*); ...@@ -79,7 +79,9 @@ static const int kPrintfPointerFieldWidth = 2 + 2 * sizeof(void*);
static void DebugWriteToStderr(const char* data, void *unused) { static void DebugWriteToStderr(const char* data, void *unused) {
// This one is signal-safe. // This one is signal-safe.
write(STDERR_FILENO, data, strlen(data)); if (write(STDERR_FILENO, data, strlen(data)) < 0) {
// Ignore errors.
}
} }
void DebugWriteToString(const char* data, void *arg) { void DebugWriteToString(const char* data, void *arg) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment