diff options
author | mark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-03 14:10:59 +0000 |
---|---|---|
committer | mark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-03 14:10:59 +0000 |
commit | d89eec809e2d25aee8d386186653699f5017b15b (patch) | |
tree | b8b0433f5766958907ea4cebb7b954e82fc1148a /chrome | |
parent | 34b5946e889071a9c838a4b87d32437415148fed (diff) | |
download | chromium_src-d89eec809e2d25aee8d386186653699f5017b15b.zip chromium_src-d89eec809e2d25aee8d386186653699f5017b15b.tar.gz chromium_src-d89eec809e2d25aee8d386186653699f5017b15b.tar.bz2 |
Don't HANDLE_EINTR(close). Either IGNORE_EINTR(close) or just close.
It is incorrect to wrap close in HANDLE_EINTR on Linux. Correctness is
generally undefined on Mac, but as of r223369, it is incorrect in Chrome on
Mac.
To avoid new offenders, a PRESUBMIT check ensures that HANDLE_EINTR is not
used with close, and that IGNORE_EINTR is only used with close. Unnecessary
#includes of eintr_wrapper.h are also removed.
base/posix/einter_wrapper.h, PRESUBMIT.py, and ppapi/tests/test_broker.cc
contain non-mechanical changes. Variable naming within the latter is updated
per r178174. Missing #includes for <errno.h> in
content/zygote/zygote_main_linux.cc and tools/android/common/daemon.cc were
manually added. Mechanical changes were generated by running:
sed -E -i '' \
-e 's/((=|if|return|CHECK|EXPECT|ASSERT).*)HANDLE(_EINTR\(.*close)/\1IGNORE\3/' \
-e 's/(ignore_result|void ?)\(HANDLE_EINTR\((.*close\(.*)\)\)/\2/' \
-e 's/(\(void\) ?)?HANDLE_EINTR\((.*close\(.*)\)/\2/' \
$(git grep -El 'HANDLE_EINTR.*close')
sed -E -i '' -e '/#include.*eintr_wrapper\.h"/d' \
$(grep -EL '(HANDLE|IGNORE)_EINTR' \
$(git grep -El '#include.*eintr_wrapper\.h"'))
BUG=269623
R=agl@chromium.org, jln@chromium.org
TBR=OWNERS
Review URL: https://codereview.chromium.org/100253002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@238390 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/extensions/api/serial/serial_connection_posix.cc | 1 | ||||
-rw-r--r-- | chrome/browser/process_info_snapshot_mac_unittest.cc | 4 | ||||
-rw-r--r-- | chrome/browser/process_singleton_linux.cc | 2 | ||||
-rw-r--r-- | chrome/browser/process_singleton_mac.cc | 2 | ||||
-rw-r--r-- | chrome/browser/shell_integration_linux.cc | 6 | ||||
-rw-r--r-- | chrome/common/multi_process_lock_linux.cc | 4 | ||||
-rw-r--r-- | chrome/common/service_process_util_posix.cc | 4 |
7 files changed, 11 insertions, 12 deletions
diff --git a/chrome/browser/extensions/api/serial/serial_connection_posix.cc b/chrome/browser/extensions/api/serial/serial_connection_posix.cc index ee07701..b1ad1dc 100644 --- a/chrome/browser/extensions/api/serial/serial_connection_posix.cc +++ b/chrome/browser/extensions/api/serial/serial_connection_posix.cc @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/posix/eintr_wrapper.h" #include "chrome/browser/extensions/api/serial/serial_connection.h" #include <sys/ioctl.h> diff --git a/chrome/browser/process_info_snapshot_mac_unittest.cc b/chrome/browser/process_info_snapshot_mac_unittest.cc index c30a883..e968048 100644 --- a/chrome/browser/process_info_snapshot_mac_unittest.cc +++ b/chrome/browser/process_info_snapshot_mac_unittest.cc @@ -116,7 +116,7 @@ TEST_F(ProcessInfoSnapshotMacTest, EffectiveVsRealUserIDTest) { base::LaunchOptions options; options.fds_to_remap = &fds_to_remap; ASSERT_TRUE(base::LaunchProcess(argv, options, &process_handle)); - PCHECK(HANDLE_EINTR(close(fds[1])) == 0); + PCHECK(IGNORE_EINTR(close(fds[1])) == 0); // Wait until there's some output form top. This is an easy way to tell that // the exec() call is done and top is actually running. @@ -136,5 +136,5 @@ TEST_F(ProcessInfoSnapshotMacTest, EffectiveVsRealUserIDTest) { EXPECT_EQ(proc_info.uid, geteuid()); ASSERT_TRUE(base::KillProcess(process_handle, 0, true)); - PCHECK(HANDLE_EINTR(close(fds[0])) == 0); + PCHECK(IGNORE_EINTR(close(fds[0])) == 0); } diff --git a/chrome/browser/process_singleton_linux.cc b/chrome/browser/process_singleton_linux.cc index cf84c5b..5887bf5 100644 --- a/chrome/browser/process_singleton_linux.cc +++ b/chrome/browser/process_singleton_linux.cc @@ -125,7 +125,7 @@ int SetCloseOnExec(int fd) { // Close a socket and check return value. void CloseSocket(int fd) { - int rv = HANDLE_EINTR(close(fd)); + int rv = IGNORE_EINTR(close(fd)); DCHECK_EQ(0, rv) << "Error closing socket: " << safe_strerror(errno); } diff --git a/chrome/browser/process_singleton_mac.cc b/chrome/browser/process_singleton_mac.cc index 8ff4cae..bf326ea 100644 --- a/chrome/browser/process_singleton_mac.cc +++ b/chrome/browser/process_singleton_mac.cc @@ -110,7 +110,7 @@ bool ProcessSingleton::Create() { void ProcessSingleton::Cleanup() { // Closing the file also releases the lock. if (lock_fd_ != -1) { - int rc = HANDLE_EINTR(close(lock_fd_)); + int rc = IGNORE_EINTR(close(lock_fd_)); DPCHECK(!rc) << "Closing lock_fd_:"; } lock_fd_ = -1; diff --git a/chrome/browser/shell_integration_linux.cc b/chrome/browser/shell_integration_linux.cc index a2186ba..61a0092 100644 --- a/chrome/browser/shell_integration_linux.cc +++ b/chrome/browser/shell_integration_linux.cc @@ -147,14 +147,14 @@ bool CreateShortcutOnDesktop(const base::FilePath& shortcut_filename, O_CREAT | O_EXCL | O_WRONLY, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH); if (fd < 0) { - if (HANDLE_EINTR(close(desktop_fd)) < 0) + if (IGNORE_EINTR(close(desktop_fd)) < 0) PLOG(ERROR) << "close"; return false; } ssize_t bytes_written = file_util::WriteFileDescriptor(fd, contents.data(), contents.length()); - if (HANDLE_EINTR(close(fd)) < 0) + if (IGNORE_EINTR(close(fd)) < 0) PLOG(ERROR) << "close"; if (bytes_written != static_cast<ssize_t>(contents.length())) { @@ -165,7 +165,7 @@ bool CreateShortcutOnDesktop(const base::FilePath& shortcut_filename, unlinkat(desktop_fd, shortcut_filename.value().c_str(), 0); } - if (HANDLE_EINTR(close(desktop_fd)) < 0) + if (IGNORE_EINTR(close(desktop_fd)) < 0) PLOG(ERROR) << "close"; return true; diff --git a/chrome/common/multi_process_lock_linux.cc b/chrome/common/multi_process_lock_linux.cc index c3494aa..07d6635 100644 --- a/chrome/common/multi_process_lock_linux.cc +++ b/chrome/common/multi_process_lock_linux.cc @@ -78,7 +78,7 @@ class MultiProcessLockLinux : public MultiProcessLock { DVLOG(1) << "Couldn't bind socket - " << &(address.sun_path[1]) << " Length: " << length; - if (HANDLE_EINTR(close(socket_fd)) < 0) { + if (IGNORE_EINTR(close(socket_fd)) < 0) { PLOG(ERROR) << "close"; } return false; @@ -90,7 +90,7 @@ class MultiProcessLockLinux : public MultiProcessLock { DLOG(ERROR) << "Over-unlocked MultiProcessLock - " << name_; return; } - if (HANDLE_EINTR(close(fd_)) < 0) { + if (IGNORE_EINTR(close(fd_)) < 0) { DPLOG(ERROR) << "close"; } fd_ = -1; diff --git a/chrome/common/service_process_util_posix.cc b/chrome/common/service_process_util_posix.cc index df57c91..92b79b5 100644 --- a/chrome/common/service_process_util_posix.cc +++ b/chrome/common/service_process_util_posix.cc @@ -133,12 +133,12 @@ void ServiceProcessState::StateData::SignalReady(base::WaitableEvent* signal, ServiceProcessState::StateData::~StateData() { if (sockets_[0] != -1) { - if (HANDLE_EINTR(close(sockets_[0]))) { + if (IGNORE_EINTR(close(sockets_[0]))) { DPLOG(ERROR) << "close"; } } if (sockets_[1] != -1) { - if (HANDLE_EINTR(close(sockets_[1]))) { + if (IGNORE_EINTR(close(sockets_[1]))) { DPLOG(ERROR) << "close"; } } |