Skip to content

Commit

Permalink
Run clang-format on env/ folder (facebook#10859)
Browse files Browse the repository at this point in the history
Summary: Pull Request resolved: facebook#10859

Test Plan: CircleCI jobs

Reviewed By: anand1976

Differential Revision: D40653839

Pulled By: akankshamahajan15

fbshipit-source-id: ce75205ee34ee3896a77a807d5c556886de78b01
  • Loading branch information
akankshamahajan15 authored and facebook-github-bot committed Oct 25, 2022
1 parent 0ed1a80 commit ee3dbdc
Show file tree
Hide file tree
Showing 11 changed files with 291 additions and 289 deletions.
35 changes: 16 additions & 19 deletions env/env.cc
Original file line number Diff line number Diff line change
Expand Up @@ -633,8 +633,7 @@ Env::Env(const std::shared_ptr<FileSystem>& fs,
const std::shared_ptr<SystemClock>& clock)
: thread_status_updater_(nullptr), file_system_(fs), system_clock_(clock) {}

Env::~Env() {
}
Env::~Env() {}

Status Env::NewLogger(const std::string& fname,
std::shared_ptr<Logger>* result) {
Expand Down Expand Up @@ -841,14 +840,11 @@ std::string Env::GenerateUniqueId() {
return result;
}

SequentialFile::~SequentialFile() {
}
SequentialFile::~SequentialFile() {}

RandomAccessFile::~RandomAccessFile() {
}
RandomAccessFile::~RandomAccessFile() {}

WritableFile::~WritableFile() {
}
WritableFile::~WritableFile() {}

MemoryMappedFileBuffer::~MemoryMappedFileBuffer() {}

Expand All @@ -865,16 +861,15 @@ Status Logger::Close() {

Status Logger::CloseImpl() { return Status::NotSupported(); }

FileLock::~FileLock() {
}
FileLock::~FileLock() {}

void LogFlush(Logger *info_log) {
void LogFlush(Logger* info_log) {
if (info_log) {
info_log->Flush();
}
}

static void Logv(Logger *info_log, const char* format, va_list ap) {
static void Logv(Logger* info_log, const char* format, va_list ap) {
if (info_log && info_log->GetInfoLogLevel() <= InfoLogLevel::INFO_LEVEL) {
info_log->Logv(InfoLogLevel::INFO_LEVEL, format, ap);
}
Expand All @@ -887,9 +882,10 @@ void Log(Logger* info_log, const char* format, ...) {
va_end(ap);
}

void Logger::Logv(const InfoLogLevel log_level, const char* format, va_list ap) {
static const char* kInfoLogLevelNames[5] = { "DEBUG", "INFO", "WARN",
"ERROR", "FATAL" };
void Logger::Logv(const InfoLogLevel log_level, const char* format,
va_list ap) {
static const char* kInfoLogLevelNames[5] = {"DEBUG", "INFO", "WARN", "ERROR",
"FATAL"};
if (log_level < log_level_) {
return;
}
Expand All @@ -906,7 +902,7 @@ void Logger::Logv(const InfoLogLevel log_level, const char* format, va_list ap)
} else {
char new_format[500];
snprintf(new_format, sizeof(new_format) - 1, "[%s] %s",
kInfoLogLevelNames[log_level], format);
kInfoLogLevelNames[log_level], format);
Logv(new_format, ap);
}

Expand All @@ -919,7 +915,8 @@ void Logger::Logv(const InfoLogLevel log_level, const char* format, va_list ap)
}
}

static void Logv(const InfoLogLevel log_level, Logger *info_log, const char *format, va_list ap) {
static void Logv(const InfoLogLevel log_level, Logger* info_log,
const char* format, va_list ap) {
if (info_log && info_log->GetInfoLogLevel() <= log_level) {
if (log_level == InfoLogLevel::HEADER_LEVEL) {
info_log->LogHeader(format, ap);
Expand All @@ -937,7 +934,7 @@ void Log(const InfoLogLevel log_level, Logger* info_log, const char* format,
va_end(ap);
}

static void Headerv(Logger *info_log, const char *format, va_list ap) {
static void Headerv(Logger* info_log, const char* format, va_list ap) {
if (info_log) {
info_log->LogHeader(format, ap);
}
Expand Down Expand Up @@ -1106,7 +1103,7 @@ void AssignEnvOptions(EnvOptions* env_options, const DBOptions& options) {
options.env->SanitizeEnvOptions(env_options);
}

}
} // namespace

EnvOptions Env::OptimizeForLogWrite(const EnvOptions& env_options,
const DBOptions& db_options) const {
Expand Down
2 changes: 1 addition & 1 deletion env/env_basic_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ TEST_P(EnvBasicTestWithParam, LargeWrite) {
read += result.size();
}
ASSERT_TRUE(write_data == read_data);
delete [] scratch;
delete[] scratch;
}

TEST_P(EnvMoreTestWithParam, GetModTime) {
Expand Down
40 changes: 20 additions & 20 deletions env/env_chroot.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ IOStatus ChrootFileSystem::GetTestDirectory(const IOOptions& options,
return CreateDirIfMissing(*path, options, dbg);
}

// Returns status and expanded absolute path including the chroot directory.
// Checks whether the provided path breaks out of the chroot. If it returns
// non-OK status, the returned path should not be used.
// Returns status and expanded absolute path including the chroot directory.
// Checks whether the provided path breaks out of the chroot. If it returns
// non-OK status, the returned path should not be used.
std::pair<IOStatus, std::string> ChrootFileSystem::EncodePath(
const std::string& path) {
if (path.empty() || path[0] != '/') {
Expand All @@ -77,29 +77,29 @@ std::pair<IOStatus, std::string> ChrootFileSystem::EncodePath(
std::pair<IOStatus, std::string> res;
res.second = chroot_dir_ + path;
#if defined(OS_AIX)
char resolvedName[PATH_MAX];
char* normalized_path = realpath(res.second.c_str(), resolvedName);
char resolvedName[PATH_MAX];
char* normalized_path = realpath(res.second.c_str(), resolvedName);
#else
char* normalized_path = realpath(res.second.c_str(), nullptr);
char* normalized_path = realpath(res.second.c_str(), nullptr);
#endif
if (normalized_path == nullptr) {
res.first = IOStatus::NotFound(res.second, errnoStr(errno).c_str());
} else if (strlen(normalized_path) < chroot_dir_.size() ||
strncmp(normalized_path, chroot_dir_.c_str(),
chroot_dir_.size()) != 0) {
res.first = IOStatus::IOError(res.second,
"Attempted to access path outside chroot");
} else {
res.first = IOStatus::OK();
}
if (normalized_path == nullptr) {
res.first = IOStatus::NotFound(res.second, errnoStr(errno).c_str());
} else if (strlen(normalized_path) < chroot_dir_.size() ||
strncmp(normalized_path, chroot_dir_.c_str(),
chroot_dir_.size()) != 0) {
res.first = IOStatus::IOError(res.second,
"Attempted to access path outside chroot");
} else {
res.first = IOStatus::OK();
}
#if !defined(OS_AIX)
free(normalized_path);
free(normalized_path);
#endif
return res;
return res;
}

// Similar to EncodePath() except assumes the basename in the path hasn't been
// created yet.
// Similar to EncodePath() except assumes the basename in the path hasn't been
// created yet.
std::pair<IOStatus, std::string> ChrootFileSystem::EncodePathWithNewBasename(
const std::string& path) {
if (path.empty() || path[0] != '/') {
Expand Down
Loading

0 comments on commit ee3dbdc

Please sign in to comment.