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
CrOS-Libchrome-Original-Commit: d89eec809e2d25aee8d386186653699f5017b15b
diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc
index b6a4945..0557350 100644
--- a/base/file_util_posix.cc
+++ b/base/file_util_posix.cc
@@ -538,7 +538,7 @@
int fd = CreateAndOpenFdForTemporaryFile(directory, path);
if (fd < 0)
return false;
- ignore_result(HANDLE_EINTR(close(fd)));
+ close(fd);
return true;
}
@@ -557,14 +557,14 @@
FILE* file = fdopen(fd, "a+");
if (!file)
- ignore_result(HANDLE_EINTR(close(fd)));
+ close(fd);
return file;
}
bool CreateTemporaryFileInDir(const FilePath& dir, FilePath* temp_file) {
base::ThreadRestrictions::AssertIOAllowed(); // For call to close().
int fd = CreateAndOpenFdForTemporaryFile(dir, temp_file);
- return ((fd >= 0) && !HANDLE_EINTR(close(fd)));
+ return ((fd >= 0) && !IGNORE_EINTR(close(fd)));
}
static bool CreateTemporaryDirInDirImpl(const FilePath& base_dir,
@@ -740,7 +740,7 @@
return -1;
ssize_t bytes_read = HANDLE_EINTR(read(fd, data, size));
- if (int ret = HANDLE_EINTR(close(fd)) < 0)
+ if (int ret = IGNORE_EINTR(close(fd)) < 0)
return ret;
return bytes_read;
}
@@ -752,7 +752,7 @@
return -1;
int bytes_written = WriteFileDescriptor(fd, data, size);
- if (int ret = HANDLE_EINTR(close(fd)) < 0)
+ if (int ret = IGNORE_EINTR(close(fd)) < 0)
return ret;
return bytes_written;
}
@@ -779,7 +779,7 @@
return -1;
int bytes_written = WriteFileDescriptor(fd, data, size);
- if (int ret = HANDLE_EINTR(close(fd)) < 0)
+ if (int ret = IGNORE_EINTR(close(fd)) < 0)
return ret;
return bytes_written;
}
@@ -936,7 +936,7 @@
int outfile = HANDLE_EINTR(creat(to_path.value().c_str(), 0666));
if (outfile < 0) {
- ignore_result(HANDLE_EINTR(close(infile)));
+ close(infile);
return false;
}
@@ -967,9 +967,9 @@
} while (bytes_written_per_read < bytes_read);
}
- if (HANDLE_EINTR(close(infile)) < 0)
+ if (IGNORE_EINTR(close(infile)) < 0)
result = false;
- if (HANDLE_EINTR(close(outfile)) < 0)
+ if (IGNORE_EINTR(close(outfile)) < 0)
result = false;
return result;