Browse Source

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
baseline
Chris Mumford 5 years ago
parent
commit
9521545b06
2 changed files with 13 additions and 13 deletions
  1. +11
    -11
      util/env_posix.cc
  2. +2
    -2
      util/env_posix_test.cc

+ 11
- 11
util/env_posix.cc 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);
}

+ 2
- 2
util/env_posix_test.cc 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,

Loading…
Cancel
Save