summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/data_pack.cc3
-rw-r--r--base/debug_util_posix.cc3
-rw-r--r--base/directory_watcher_inotify.cc6
-rw-r--r--base/file_util_posix.cc7
-rw-r--r--base/process_util_linux.cc2
-rw-r--r--base/process_util_posix.cc5
-rw-r--r--base/shared_memory_posix.cc6
-rw-r--r--base/stats_table.cc8
-rw-r--r--chrome/app/chrome_dll_main.cc4
-rw-r--r--chrome/browser/browser_main.cc4
-rw-r--r--chrome/browser/chromeos/pipe_reader_unittest.cc7
-rw-r--r--chrome/browser/process_singleton_linux.cc31
-rw-r--r--chrome/test/page_cycler/page_cycler_test.cc6
-rw-r--r--ipc/ipc_channel_posix.cc16
-rw-r--r--net/proxy/proxy_config_service_linux.cc7
15 files changed, 54 insertions, 61 deletions
diff --git a/base/data_pack.cc b/base/data_pack.cc
index 051fb4e..46f3cb4 100644
--- a/base/data_pack.cc
+++ b/base/data_pack.cc
@@ -50,8 +50,7 @@ DataPack::~DataPack() {
bool DataPack::Load(const FilePath& path) {
mmap_.reset(new file_util::MemoryMappedFile);
if (!mmap_->Initialize(path)) {
- CHECK(false) << "Failed to mmap " << path.value() << " errno: " <<
- strerror(errno);
+ PCHECK(false) << "Failed to mmap " << path.value();
}
// Parse the header of the file.
diff --git a/base/debug_util_posix.cc b/base/debug_util_posix.cc
index dc86c8c..4b79d73 100644
--- a/base/debug_util_posix.cc
+++ b/base/debug_util_posix.cc
@@ -21,6 +21,7 @@
#include "base/compat_execinfo.h"
#include "base/eintr_wrapper.h"
#include "base/logging.h"
+#include "base/safe_strerror_posix.h"
#include "base/scoped_ptr.h"
#include "base/string_piece.h"
@@ -150,7 +151,7 @@ void StackTrace::OutputToStream(std::ostream* os) {
// If we can't retrieve the symbols, print an error and just dump the raw
// addresses.
if (trace_symbols.get() == NULL) {
- (*os) << "Unable get symbols for backtrace (" << strerror(errno)
+ (*os) << "Unable get symbols for backtrace (" << safe_strerror(errno)
<< "). Dumping raw addresses in trace:\n";
for (int i = 0; i < count_; ++i) {
(*os) << "\t" << trace_[i] << "\n";
diff --git a/base/directory_watcher_inotify.cc b/base/directory_watcher_inotify.cc
index 44e4dcb..d171a7a 100644
--- a/base/directory_watcher_inotify.cc
+++ b/base/directory_watcher_inotify.cc
@@ -209,7 +209,7 @@ class InotifyReaderTask : public Task {
HANDLE_EINTR(select(std::max(inotify_fd_, shutdown_fd_) + 1,
&rfds, NULL, NULL, NULL));
if (select_result < 0) {
- DLOG(WARNING) << "select failed: " << strerror(errno);
+ DPLOG(WARNING) << "select failed";
return;
}
@@ -222,7 +222,7 @@ class InotifyReaderTask : public Task {
&buffer_size));
if (ioctl_result != 0) {
- DLOG(WARNING) << "ioctl failed: " << strerror(errno);
+ DPLOG(WARNING) << "ioctl failed";
return;
}
@@ -232,7 +232,7 @@ class InotifyReaderTask : public Task {
buffer_size));
if (bytes_read < 0) {
- DLOG(WARNING) << "read from inotify fd failed: " << strerror(errno);
+ DPLOG(WARNING) << "read from inotify fd failed";
return;
}
diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc
index 4d9e797..3ba351e 100644
--- a/base/file_util_posix.cc
+++ b/base/file_util_posix.cc
@@ -99,7 +99,7 @@ int CountFilesCreatedAfter(const FilePath& path,
stat_wrapper_t st;
int test = CallStat(path.Append(ent->d_name).value().c_str(), &st);
if (test != 0) {
- LOG(ERROR) << "stat64 failed: " << strerror(errno);
+ PLOG(ERROR) << "stat64 failed";
continue;
}
// Here, we use Time::TimeT(), which discards microseconds. This
@@ -634,9 +634,8 @@ bool FileEnumerator::ReadDirectory(std::vector<DirectoryEntryInfo>* entries,
// Print the stat() error message unless it was ENOENT and we're
// following symlinks.
if (!(ret == ENOENT && !show_links)) {
- LOG(ERROR) << "Couldn't stat "
- << source.Append(dent->d_name).value() << ": "
- << strerror(errno);
+ PLOG(ERROR) << "Couldn't stat "
+ << source.Append(dent->d_name).value();
}
memset(&info.stat, 0, sizeof(info.stat));
}
diff --git a/base/process_util_linux.cc b/base/process_util_linux.cc
index 390a2b5..1160b48 100644
--- a/base/process_util_linux.cc
+++ b/base/process_util_linux.cc
@@ -367,7 +367,7 @@ static int GetProcessCPU(pid_t pid) {
DIR* dir = opendir(path.value().c_str());
if (!dir) {
- LOG(ERROR) << "opendir(" << path.value() << "): " << strerror(errno);
+ PLOG(ERROR) << "opendir(" << path.value() << ")";
return -1;
}
diff --git a/base/process_util_posix.cc b/base/process_util_posix.cc
index 235456b..61ecb7e 100644
--- a/base/process_util_posix.cc
+++ b/base/process_util_posix.cc
@@ -274,8 +274,7 @@ bool LaunchApp(const std::vector<std::string>& argv,
argv_cstr[i] = const_cast<char*>(argv[i].c_str());
argv_cstr[argv.size()] = NULL;
execvp(argv_cstr[0], argv_cstr.get());
- LOG(ERROR) << "LaunchApp: execvp(" << argv_cstr[0] << ") failed: "
- << strerror(errno);
+ PLOG(ERROR) << "LaunchApp: execvp(" << argv_cstr[0] << ") failed";
_exit(127);
} else {
// Parent process
@@ -333,7 +332,7 @@ bool DidProcessCrash(bool* child_exited, ProcessHandle handle) {
int status;
const int result = HANDLE_EINTR(waitpid(handle, &status, WNOHANG));
if (result == -1) {
- LOG(ERROR) << "waitpid(" << handle << "): " << strerror(errno);
+ PLOG(ERROR) << "waitpid(" << handle << ")";
if (child_exited)
*child_exited = false;
return false;
diff --git a/base/shared_memory_posix.cc b/base/shared_memory_posix.cc
index 8828b10..34e7b72 100644
--- a/base/shared_memory_posix.cc
+++ b/base/shared_memory_posix.cc
@@ -13,6 +13,7 @@
#include "base/file_util.h"
#include "base/logging.h"
#include "base/platform_thread.h"
+#include "base/safe_strerror_posix.h"
#include "base/string_util.h"
namespace base {
@@ -188,8 +189,7 @@ bool SharedMemory::CreateOrOpen(const std::wstring &name,
if (fp == NULL) {
if (posix_flags & O_CREAT)
- LOG(ERROR) << "Creating shared memory in " << path.value() << " failed: "
- << strerror(errno);
+ PLOG(ERROR) << "Creating shared memory in " << path.value() << " failed";
return false;
}
@@ -291,7 +291,7 @@ void SharedMemory::LockOrUnlockCommon(int function) {
<< " function:" << function
<< " fd:" << mapped_file_
<< " errno:" << errno
- << " msg:" << strerror(errno);
+ << " msg:" << safe_strerror(errno);
}
}
}
diff --git a/base/stats_table.cc b/base/stats_table.cc
index 522db5a..2edbb44 100644
--- a/base/stats_table.cc
+++ b/base/stats_table.cc
@@ -257,14 +257,8 @@ StatsTable::StatsTable(const std::string& name, int max_threads,
impl_ = StatsTablePrivate::New(name, table_size, max_threads, max_counters);
- // TODO(port): clean up this error reporting.
-#if defined(OS_WIN)
if (!impl_)
- LOG(ERROR) << "StatsTable did not initialize:" << GetLastError();
-#elif defined(OS_POSIX)
- if (!impl_)
- LOG(ERROR) << "StatsTable did not initialize:" << strerror(errno);
-#endif
+ PLOG(ERROR) << "StatsTable did not initialize";
}
StatsTable::~StatsTable() {
diff --git a/chrome/app/chrome_dll_main.cc b/chrome/app/chrome_dll_main.cc
index 4df3961..27b4e24 100644
--- a/chrome/app/chrome_dll_main.cc
+++ b/chrome/app/chrome_dll_main.cc
@@ -364,8 +364,8 @@ int ChromeMain(int argc, char** argv) {
if (parsed_command_line.HasSwitch("help") ||
parsed_command_line.HasSwitch("h")) {
FilePath binary(parsed_command_line.argv()[0]);
- int ret = execlp("man", "man", binary.BaseName().value().c_str(), NULL);
- LOG(FATAL) << "execlp failed: " << strerror(ret);
+ execlp("man", "man", binary.BaseName().value().c_str(), NULL);
+ PLOG(FATAL) << "execlp failed";
}
#endif
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc
index 9dd411f..f001f0d 100644
--- a/chrome/browser/browser_main.cc
+++ b/chrome/browser/browser_main.cc
@@ -211,10 +211,10 @@ void SetFileDescriptorLimit(unsigned int max_descriptors) {
}
limits.rlim_cur = new_limit;
if (setrlimit(RLIMIT_NOFILE, &limits) != 0) {
- LOG(INFO) << "Failed to set file descriptor limit: " << strerror(errno);
+ PLOG(INFO) << "Failed to set file descriptor limit";
}
} else {
- LOG(INFO) << "Failed to get file descriptor limit: " << strerror(errno);
+ PLOG(INFO) << "Failed to get file descriptor limit";
}
}
#endif
diff --git a/chrome/browser/chromeos/pipe_reader_unittest.cc b/chrome/browser/chromeos/pipe_reader_unittest.cc
index 6d674dd..1915ae7 100644
--- a/chrome/browser/chromeos/pipe_reader_unittest.cc
+++ b/chrome/browser/chromeos/pipe_reader_unittest.cc
@@ -6,6 +6,7 @@
#include <errno.h>
+#include "base/safe_strerror_posix.h"
#include "testing/gtest/include/gtest/gtest.h"
typedef testing::Test PipeReaderTest;
@@ -20,7 +21,7 @@ TEST_F(PipeReaderTest, SuccessfulReadTest) {
pid_t pID = fork();
if (pID == 0) {
int pipe = open(pipe_name.c_str(), O_WRONLY);
- EXPECT_NE(pipe, -1) << strerror(errno);
+ EXPECT_NE(pipe, -1) << safe_strerror(errno);
write(pipe, line, strlen(line));
close(pipe);
exit(1);
@@ -46,7 +47,7 @@ TEST_F(PipeReaderTest, SuccessfulMultiLineReadTest) {
pid_t pID = fork();
if (pID == 0) {
int pipe = open(pipe_name.c_str(), O_WRONLY);
- EXPECT_NE(pipe, -1) << strerror(errno);
+ EXPECT_NE(pipe, -1) << safe_strerror(errno);
write(pipe, line.c_str(), line.length());
close(pipe);
exit(1);
@@ -79,7 +80,7 @@ TEST_F(PipeReaderTest, SuccessfulMultiLineReadNoEndingNewlineTest) {
pid_t pID = fork();
if (pID == 0) {
int pipe = open(pipe_name.c_str(), O_WRONLY);
- EXPECT_NE(pipe, -1) << strerror(errno);
+ EXPECT_NE(pipe, -1) << safe_strerror(errno);
write(pipe, line.c_str(), line.length());
close(pipe);
exit(1);
diff --git a/chrome/browser/process_singleton_linux.cc b/chrome/browser/process_singleton_linux.cc
index bfff289..094c86a 100644
--- a/chrome/browser/process_singleton_linux.cc
+++ b/chrome/browser/process_singleton_linux.cc
@@ -52,6 +52,7 @@
#include "base/message_loop.h"
#include "base/path_service.h"
#include "base/process_util.h"
+#include "base/safe_strerror_posix.h"
#include "base/stl_util-inl.h"
#include "base/string_util.h"
#include "base/sys_string_conversions.h"
@@ -110,7 +111,7 @@ int SetCloseOnExec(int fd) {
// Close a socket and check return value.
void CloseSocket(int fd) {
int rv = HANDLE_EINTR(close(fd));
- DCHECK_EQ(0, rv) << "Error closing socket: " << strerror(errno);
+ DCHECK_EQ(0, rv) << "Error closing socket: " << safe_strerror(errno);
}
// Write a message to a socket fd.
@@ -128,7 +129,7 @@ bool WriteToSocket(int fd, const char *message, size_t length) {
LOG(ERROR) << "ProcessSingleton would block on write(), so it gave up.";
return false;
}
- LOG(ERROR) << "write() failed: " << strerror(errno);
+ PLOG(ERROR) << "write() failed";
return false;
}
bytes_written += rv;
@@ -167,7 +168,7 @@ ssize_t ReadFromSocket(int fd, char *buf, size_t bufsize, int timeout) {
ssize_t rv = HANDLE_EINTR(read(fd, buf + bytes_read, bufsize - bytes_read));
if (rv < 0) {
if (errno != EAGAIN && errno != EWOULDBLOCK) {
- LOG(ERROR) << "read() failed: " << strerror(errno);
+ PLOG(ERROR) << "read() failed";
return rv;
} else {
// It would block, so we just return what has been read.
@@ -187,7 +188,7 @@ ssize_t ReadFromSocket(int fd, char *buf, size_t bufsize, int timeout) {
// Set up a socket and sockaddr appropriate for messaging.
void SetupSocket(const std::string& path, int* sock, struct sockaddr_un* addr) {
*sock = socket(PF_UNIX, SOCK_STREAM, 0);
- CHECK(*sock >= 0) << "socket() failed: " << strerror(errno);
+ PCHECK(*sock >= 0) << "socket() failed";
int rv = SetNonBlocking(*sock);
DCHECK_EQ(0, rv) << "Failed to make non-blocking socket.";
@@ -216,7 +217,7 @@ std::string ReadLink(const std::string& path) {
buf[len] = '\0';
return std::string(buf);
} else {
- LOG(ERROR) << "readlink(" << path << ") failed: " << strerror(errno);
+ PLOG(ERROR) << "readlink(" << path << ") failed";
}
}
@@ -227,7 +228,7 @@ std::string ReadLink(const std::string& path) {
bool UnlinkPath(const std::string& path) {
int rv = unlink(path.c_str());
if (rv < 0 && errno != ENOENT)
- LOG(ERROR) << "Failed to unlink " << path << ": " << strerror(errno);
+ PLOG(ERROR) << "Failed to unlink " << path;
return rv == 0;
}
@@ -304,7 +305,7 @@ bool KillProcessByLockPath(const std::string& path) {
if (pid >= 0) {
// TODO(james.su@gmail.com): Is SIGKILL ok?
int rv = kill(static_cast<base::ProcessHandle>(pid), SIGKILL);
- DCHECK_EQ(0, rv) << "Error killing process:" << strerror(errno);
+ DCHECK_EQ(0, rv) << "Error killing process: " << safe_strerror(errno);
return true;
}
@@ -453,7 +454,7 @@ void ProcessSingleton::LinuxWatcher::OnFileCanReadWithoutBlocking(int fd) {
int connection_socket = HANDLE_EINTR(accept(
fd, reinterpret_cast<sockaddr*>(&from), &from_len));
if (-1 == connection_socket) {
- LOG(ERROR) << "accept() failed: " << strerror(errno);
+ PLOG(ERROR) << "accept() failed";
return;
}
int rv = SetNonBlocking(connection_socket);
@@ -542,7 +543,7 @@ void ProcessSingleton::LinuxWatcher::SocketReader::OnFileCanReadWithoutBlocking(
read(fd, buf_ + bytes_read_, sizeof(buf_) - bytes_read_));
if (rv < 0) {
if (errno != EAGAIN && errno != EWOULDBLOCK) {
- LOG(ERROR) << "read() failed: " << strerror(errno);
+ PLOG(ERROR) << "read() failed";
CloseSocket(fd);
return;
} else {
@@ -606,7 +607,7 @@ void ProcessSingleton::LinuxWatcher::SocketReader::FinishWithACK(
}
if (shutdown(fd_, SHUT_WR) < 0)
- LOG(ERROR) << "shutdown() failed: " << strerror(errno);
+ PLOG(ERROR) << "shutdown() failed";
parent_->RemoveSocketReader(this);
// We are deleted beyond this point.
@@ -684,7 +685,7 @@ ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcessWithTimeout(
}
if (shutdown(socket, SHUT_WR) < 0)
- LOG(ERROR) << "shutdown() failed: " << strerror(errno);
+ PLOG(ERROR) << "shutdown() failed";
// Read ACK message from the other process. It might be blocked for a certain
// timeout, to make sure the other process has enough time to return ACK.
@@ -735,8 +736,8 @@ void ProcessSingleton::Create() {
// startup race.
// TODO(mattm): If the other instance is on the same host, we could try
// to notify it rather than just failing.
- LOG(FATAL) << "Failed to create " << lock_path_.value() << ": "
- << strerror(saved_errno);
+ errno = saved_errno;
+ PLOG(FATAL) << "Failed to create " << lock_path_.value();
}
}
@@ -745,7 +746,7 @@ void ProcessSingleton::Create() {
UnlinkPath(socket_path_.value());
if (bind(sock, reinterpret_cast<sockaddr*>(&addr), sizeof(addr)) < 0) {
- LOG(ERROR) << "bind() failed: " << strerror(errno);
+ PLOG(ERROR) << "bind() failed";
LOG(ERROR) << "SingletonSocket failed to create a socket in your home "
"directory. This means that running multiple instances of "
"the Chrome binary will start multiple browser process "
@@ -755,7 +756,7 @@ void ProcessSingleton::Create() {
}
if (listen(sock, 5) < 0)
- NOTREACHED() << "listen failed: " << strerror(errno);
+ NOTREACHED() << "listen failed: " << safe_strerror(errno);
// Normally we would use ChromeThread, but the IO thread hasn't started yet.
// Using g_browser_process, we start the thread so we can listen on the
diff --git a/chrome/test/page_cycler/page_cycler_test.cc b/chrome/test/page_cycler/page_cycler_test.cc
index 7c611d5..d950f14 100644
--- a/chrome/test/page_cycler/page_cycler_test.cc
+++ b/chrome/test/page_cycler/page_cycler_test.cc
@@ -52,7 +52,7 @@ rlim_t GetFileDescriptorLimit(void) {
if (getrlimit(RLIMIT_NOFILE, &limits) == 0) {
return limits.rlim_cur;
}
- LOG(ERROR) << "Failed to get file descriptor limit: " << strerror(errno);
+ PLOG(ERROR) << "Failed to get file descriptor limit";
return 0;
}
@@ -65,10 +65,10 @@ void SetFileDescriptorLimit(rlim_t max_descriptors) {
limits.rlim_cur = std::min(max_descriptors, limits.rlim_max);
}
if (setrlimit(RLIMIT_NOFILE, &limits) != 0) {
- LOG(ERROR) << "Failed to set file descriptor limit: " << strerror(errno);
+ PLOG(ERROR) << "Failed to set file descriptor limit";
}
} else {
- LOG(ERROR) << "Failed to get file descriptor limit: " << strerror(errno);
+ PLOG(ERROR) << "Failed to get file descriptor limit";
}
}
diff --git a/ipc/ipc_channel_posix.cc b/ipc/ipc_channel_posix.cc
index ac238ba..e8065fe 100644
--- a/ipc/ipc_channel_posix.cc
+++ b/ipc/ipc_channel_posix.cc
@@ -126,7 +126,7 @@ int ChannelNameToFD(const std::string& channel_id) {
if (fd != -1) {
int dup_fd = dup(fd);
if (dup_fd < 0)
- LOG(FATAL) << "dup(" << fd << "): " << strerror(errno);
+ PLOG(FATAL) << "dup(" << fd << ")";
return dup_fd;
}
@@ -264,9 +264,9 @@ Channel::ChannelImpl::ChannelImpl(const std::string& channel_id, Mode mode,
factory_(this) {
if (!CreatePipe(channel_id, mode)) {
// The pipe may have been closed already.
- LOG(WARNING) << "Unable to create pipe named \"" << channel_id <<
- "\" in " << (mode == MODE_SERVER ? "server" : "client") <<
- " mode error(" << strerror(errno) << ").";
+ PLOG(WARNING) << "Unable to create pipe named \"" << channel_id
+ << "\" in " << (mode == MODE_SERVER ? "server" : "client")
+ << " mode";
}
}
@@ -284,14 +284,14 @@ void RemoveAndCloseChannelSocket(const std::string& name) {
bool SocketPair(int* fd1, int* fd2) {
int pipe_fds[2];
if (socketpair(AF_UNIX, SOCK_STREAM, 0, pipe_fds) != 0) {
- LOG(ERROR) << "socketpair(): " << strerror(errno);
+ PLOG(ERROR) << "socketpair()";
return false;
}
// Set both ends to be non-blocking.
if (fcntl(pipe_fds[0], F_SETFL, O_NONBLOCK) == -1 ||
fcntl(pipe_fds[1], F_SETFL, O_NONBLOCK) == -1) {
- LOG(ERROR) << "fcntl(O_NONBLOCK): " << strerror(errno);
+ PLOG(ERROR) << "fcntl(O_NONBLOCK)";
HANDLE_EINTR(close(pipe_fds[0]));
HANDLE_EINTR(close(pipe_fds[1]));
return false;
@@ -448,7 +448,7 @@ bool Channel::ChannelImpl::ProcessIncomingMessages() {
return false;
#endif // defined(OS_MACOSX)
} else {
- LOG(ERROR) << "pipe error (" << pipe_ << "): " << strerror(errno);
+ PLOG(ERROR) << "pipe error (" << pipe_ << ")";
return false;
}
} else if (bytes_read == 0) {
@@ -811,7 +811,7 @@ bool Channel::ChannelImpl::ProcessOutgoingMessages() {
return false;
}
#endif // OS_MACOSX
- LOG(ERROR) << "pipe error on " << fd_written << ": " << strerror(errno);
+ PLOG(ERROR) << "pipe error on " << fd_written;
return false;
}
diff --git a/net/proxy/proxy_config_service_linux.cc b/net/proxy/proxy_config_service_linux.cc
index a507771..3ca35c5 100644
--- a/net/proxy/proxy_config_service_linux.cc
+++ b/net/proxy/proxy_config_service_linux.cc
@@ -439,12 +439,12 @@ class GConfSettingGetterImplKDE
DCHECK(inotify_fd_ < 0);
inotify_fd_ = inotify_init();
if (inotify_fd_ < 0) {
- LOG(ERROR) << "inotify_init failed: " << strerror(errno);
+ PLOG(ERROR) << "inotify_init failed";
return false;
}
int flags = fcntl(inotify_fd_, F_GETFL);
if (fcntl(inotify_fd_, F_SETFL, flags | O_NONBLOCK) < 0) {
- LOG(ERROR) << "fcntl failed: " << strerror(errno);
+ PLOG(ERROR) << "fcntl failed";
close(inotify_fd_);
inotify_fd_ = -1;
return false;
@@ -763,8 +763,7 @@ class GConfSettingGetterImplKDE
// new behavior (EINVAL) so we can reuse the code below.
errno = EINVAL;
if (errno != EAGAIN) {
- LOG(WARNING) << "error reading inotify file descriptor: "
- << strerror(errno);
+ PLOG(WARNING) << "error reading inotify file descriptor";
if (errno == EINVAL) {
// Our buffer is not large enough to read the next event. This should
// not happen (because its size is calculated to always be sufficiently