diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-16 23:00:15 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-16 23:00:15 +0000 |
commit | 19cb929fa737ae5ef3c1425d38a793ef8967ee00 (patch) | |
tree | 84801b2724d970541aa86f8a81d1f4b0c1d89ff6 /chrome | |
parent | b3c064c2338e88a6ecfef7454bc3301d643a91fe (diff) | |
download | chromium_src-19cb929fa737ae5ef3c1425d38a793ef8967ee00.zip chromium_src-19cb929fa737ae5ef3c1425d38a793ef8967ee00.tar.gz chromium_src-19cb929fa737ae5ef3c1425d38a793ef8967ee00.tar.bz2 |
posix: handle the return value of close() in more places.
Generally, we don't expect it to fail and there isn't much we
can do anyway, but it's good to at least consider each case and
do something so we can continue to receive warnings in situations
where we forgot to check the return code.
(Bonus extra bugfix: use int where we previously had bool.
I think it compiles to the same thing but the old code was
definitely wrong.)
Review URL: http://codereview.chromium.org/1564037
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44844 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/memory_details_linux.cc | 3 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_sandbox_host_linux.cc | 11 | ||||
-rw-r--r-- | chrome/browser/shell_integration_linux.cc | 9 | ||||
-rw-r--r-- | chrome/browser/zygote_host_linux.cc | 6 | ||||
-rw-r--r-- | chrome/browser/zygote_main_linux.cc | 6 | ||||
-rw-r--r-- | chrome/plugin/plugin_channel.cc | 3 |
6 files changed, 25 insertions, 13 deletions
diff --git a/chrome/browser/memory_details_linux.cc b/chrome/browser/memory_details_linux.cc index 1909eec..8ba1863 100644 --- a/chrome/browser/memory_details_linux.cc +++ b/chrome/browser/memory_details_linux.cc @@ -103,7 +103,8 @@ static bool GetProcesses(std::vector<Process>* processes) { continue; const ssize_t len = HANDLE_EINTR(read(fd, buf, sizeof(buf) - 1)); - HANDLE_EINTR(close(fd)); + if (HANDLE_EINTR(close(fd)) < 0) + PLOG(ERROR) << "close"; if (len < 1) continue; buf[len] = 0; diff --git a/chrome/browser/renderer_host/render_sandbox_host_linux.cc b/chrome/browser/renderer_host/render_sandbox_host_linux.cc index 53c736c..6b81839 100644 --- a/chrome/browser/renderer_host/render_sandbox_host_linux.cc +++ b/chrome/browser/renderer_host/render_sandbox_host_linux.cc @@ -70,7 +70,7 @@ class SandboxIPCProcess { pfds[1].fd = browser_socket_; pfds[1].events = POLLIN; - bool failed_polls = 0; + int failed_polls = 0; for (;;) { const int r = HANDLE_EINTR(poll(pfds, 2, -1)); if (r < 1) { @@ -368,7 +368,8 @@ class SandboxIPCProcess { msg.msg_controllen = cmsg->cmsg_len; } - HANDLE_EINTR(sendmsg(fds[0], &msg, MSG_DONTWAIT)); + if (HANDLE_EINTR(sendmsg(fds[0], &msg, MSG_DONTWAIT)) < 0) + PLOG(ERROR) << "sendmsg"; } // --------------------------------------------------------------------------- @@ -417,7 +418,9 @@ void RenderSandboxHostLinux::Init(const std::string& sandbox_path) { RenderSandboxHostLinux::~RenderSandboxHostLinux() { if (init_) { - HANDLE_EINTR(close(renderer_socket_)); - HANDLE_EINTR(close(childs_lifeline_fd_)); + if (HANDLE_EINTR(close(renderer_socket_)) < 0) + PLOG(ERROR) << "close"; + if (HANDLE_EINTR(close(childs_lifeline_fd_)) < 0) + PLOG(ERROR) << "close"; } } diff --git a/chrome/browser/shell_integration_linux.cc b/chrome/browser/shell_integration_linux.cc index 19d1730..3c87350 100644 --- a/chrome/browser/shell_integration_linux.cc +++ b/chrome/browser/shell_integration_linux.cc @@ -139,13 +139,15 @@ void CreateShortcutOnDesktop(const FilePath& shortcut_filename, O_CREAT | O_EXCL | O_WRONLY, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH); if (fd < 0) { - HANDLE_EINTR(close(desktop_fd)); + if (HANDLE_EINTR(close(desktop_fd)) < 0) + PLOG(ERROR) << "close"; return; } ssize_t bytes_written = file_util::WriteFileDescriptor(fd, contents.data(), contents.length()); - HANDLE_EINTR(close(fd)); + if (HANDLE_EINTR(close(fd)) < 0) + PLOG(ERROR) << "close"; if (bytes_written != static_cast<ssize_t>(contents.length())) { // Delete the file. No shortuct is better than corrupted one. Use unlinkat @@ -155,7 +157,8 @@ void CreateShortcutOnDesktop(const FilePath& shortcut_filename, unlinkat(desktop_fd, shortcut_filename.value().c_str(), 0); } - HANDLE_EINTR(close(desktop_fd)); + if (HANDLE_EINTR(close(desktop_fd)) < 0) + PLOG(ERROR) << "close"; } void CreateShortcutInApplicationsMenu(const FilePath& shortcut_filename, diff --git a/chrome/browser/zygote_host_linux.cc b/chrome/browser/zygote_host_linux.cc index cdeda42..9885234 100644 --- a/chrome/browser/zygote_host_linux.cc +++ b/chrome/browser/zygote_host_linux.cc @@ -247,7 +247,8 @@ void ZygoteHost::EnsureProcessTerminated(pid_t process) { pickle.WriteInt(kCmdReap); pickle.WriteInt(process); - HANDLE_EINTR(write(control_fd_, pickle.data(), pickle.size())); + if (HANDLE_EINTR(write(control_fd_, pickle.data(), pickle.size())) < 0) + PLOG(ERROR) << "write"; } bool ZygoteHost::DidProcessCrash(base::ProcessHandle handle, @@ -257,7 +258,8 @@ bool ZygoteHost::DidProcessCrash(base::ProcessHandle handle, pickle.WriteInt(kCmdDidProcessCrash); pickle.WriteInt(handle); - HANDLE_EINTR(write(control_fd_, pickle.data(), pickle.size())); + if (HANDLE_EINTR(write(control_fd_, pickle.data(), pickle.size())) < 0) + PLOG(ERROR) << "write"; static const unsigned kMaxMessageLength = 128; char buf[kMaxMessageLength]; diff --git a/chrome/browser/zygote_main_linux.cc b/chrome/browser/zygote_main_linux.cc index 793c855..a7cfb76 100644 --- a/chrome/browser/zygote_main_linux.cc +++ b/chrome/browser/zygote_main_linux.cc @@ -196,7 +196,8 @@ class Zygote { Pickle write_pickle; write_pickle.WriteBool(did_crash); write_pickle.WriteBool(child_exited); - HANDLE_EINTR(write(fd, write_pickle.data(), write_pickle.size())); + if (HANDLE_EINTR(write(fd, write_pickle.data(), write_pickle.size()))) + PLOG(ERROR) << "write"; } // Handle a 'fork' request from the browser: this means that the browser @@ -305,7 +306,8 @@ class Zygote { i = fds.begin(); i != fds.end(); ++i) close(*i); - HANDLE_EINTR(write(fd, &proc_id, sizeof(proc_id))); + if (HANDLE_EINTR(write(fd, &proc_id, sizeof(proc_id))) < 0) + PLOG(ERROR) << "write"; return false; } diff --git a/chrome/plugin/plugin_channel.cc b/chrome/plugin/plugin_channel.cc index c5913c3..b169b9e 100644 --- a/chrome/plugin/plugin_channel.cc +++ b/chrome/plugin/plugin_channel.cc @@ -326,7 +326,8 @@ bool PluginChannel::Init(MessageLoop* ipc_message_loop, bool create_pipe_now) { #if defined(OS_POSIX) void PluginChannel::CloseRendererFD() { if (renderer_fd_ != -1) { - HANDLE_EINTR(close(renderer_fd_)); + if (HANDLE_EINTR(close(renderer_fd_)) < 0) + PLOG(ERROR) << "close"; renderer_fd_ = -1; } } |