Formatting changes for prior O_CLOEXEC fix.

Two minor corrections to correct the 900f7d37eb commit
to conform to the Google C++ style guide.

PiperOrigin-RevId: 246907647
This commit is contained in:
Chris Mumford 2019-05-06 15:20:42 -07:00
parent 900f7d37eb
commit 9521545b06
2 changed files with 13 additions and 13 deletions

View File

@ -50,9 +50,9 @@ int g_mmap_limit = kDefaultMmapLimit;
// Common flags defined for all posix open operations
#if defined(HAVE_O_CLOEXEC)
constexpr const int O_FLAGS = O_CLOEXEC;
constexpr const int kOpenBaseFlags = O_CLOEXEC;
#else
constexpr const int O_FLAGS = 0;
constexpr const int kOpenBaseFlags = 0;
#endif // defined(HAVE_O_CLOEXEC)
constexpr const size_t kWritableFileBufferSize = 65536;
@ -172,7 +172,7 @@ class PosixRandomAccessFile final : public RandomAccessFile {
char* scratch) const override {
int fd = fd_;
if (!has_permanent_fd_) {
fd = ::open(filename_.c_str(), O_RDONLY | O_FLAGS);
fd = ::open(filename_.c_str(), O_RDONLY | kOpenBaseFlags);
if (fd < 0) {
return PosixError(filename_, errno);
}
@ -350,7 +350,7 @@ class PosixWritableFile final : public WritableFile {
return status;
}
int fd = ::open(dirname_.c_str(), O_RDONLY | O_FLAGS);
int fd = ::open(dirname_.c_str(), O_RDONLY | kOpenBaseFlags);
if (fd < 0) {
status = PosixError(dirname_, errno);
} else {
@ -498,7 +498,7 @@ class PosixEnv : public Env {
Status NewSequentialFile(const std::string& filename,
SequentialFile** result) override {
int fd = ::open(filename.c_str(), O_RDONLY | O_FLAGS);
int fd = ::open(filename.c_str(), O_RDONLY | kOpenBaseFlags);
if (fd < 0) {
*result = nullptr;
return PosixError(filename, errno);
@ -511,7 +511,7 @@ class PosixEnv : public Env {
Status NewRandomAccessFile(const std::string& filename,
RandomAccessFile** result) override {
*result = nullptr;
int fd = ::open(filename.c_str(), O_RDONLY | O_FLAGS);
int fd = ::open(filename.c_str(), O_RDONLY | kOpenBaseFlags);
if (fd < 0) {
return PosixError(filename, errno);
}
@ -543,8 +543,8 @@ class PosixEnv : public Env {
Status NewWritableFile(const std::string& filename,
WritableFile** result) override {
int fd =
::open(filename.c_str(), O_TRUNC | O_WRONLY | O_CREAT | O_FLAGS, 0644);
int fd = ::open(filename.c_str(),
O_TRUNC | O_WRONLY | O_CREAT | kOpenBaseFlags, 0644);
if (fd < 0) {
*result = nullptr;
return PosixError(filename, errno);
@ -556,8 +556,8 @@ class PosixEnv : public Env {
Status NewAppendableFile(const std::string& filename,
WritableFile** result) override {
int fd =
::open(filename.c_str(), O_APPEND | O_WRONLY | O_CREAT | O_FLAGS, 0644);
int fd = ::open(filename.c_str(),
O_APPEND | O_WRONLY | O_CREAT | kOpenBaseFlags, 0644);
if (fd < 0) {
*result = nullptr;
return PosixError(filename, errno);
@ -627,7 +627,7 @@ class PosixEnv : public Env {
Status LockFile(const std::string& filename, FileLock** lock) override {
*lock = nullptr;
int fd = ::open(filename.c_str(), O_RDWR | O_CREAT | O_FLAGS, 0644);
int fd = ::open(filename.c_str(), O_RDWR | O_CREAT | kOpenBaseFlags, 0644);
if (fd < 0) {
return PosixError(filename, errno);
}

View File

@ -117,7 +117,7 @@ TEST(EnvPosixTest, TestCloseOnExec) {
#endif // defined(HAVE_O_CLOEXEC)
int cloexecChild() {
int CloexecChild() {
// Checks for open file descriptors in the range 3..FD_SETSIZE.
for (int i = 3; i < FD_SETSIZE; i++) {
int dup_result = dup2(i, i);
@ -156,7 +156,7 @@ int cloexecChild() {
int main(int argc, char** argv) {
// Check if this is the child process for TestCloseOnExec
if (argc > 1 && strcmp(argv[1], "-cloexec-child") == 0) {
return leveldb::cloexecChild();
return leveldb::CloexecChild();
}
// All tests currently run with the same read-only file limits.
leveldb::EnvPosixTest::SetFileLimits(leveldb::kReadOnlyFileLimit,