Skip to content

Commit

Permalink
Standardize on clang-format version 18 (#13233)
Browse files Browse the repository at this point in the history
Summary:
... which is the default for CentOS 9 and Ubuntu 24, the latter of which is now available in GitHub Actions. Relevant CI job updated.

Re-formatted all cc|c|h files except in third-party/, using

```
clang-format -i `git ls-files | grep -E '[.](cc|c|h)$' | grep -v third-party/`
```

Pull Request resolved: #13233

Test Plan: CI

Reviewed By: jaykorean, archang19

Differential Revision: D67461638

Pulled By: pdillinger

fbshipit-source-id: 0c9ac21a3f5eea6f5ade68bb6af7b6ba16c8b301
  • Loading branch information
pdillinger authored and facebook-github-bot committed Dec 19, 2024
1 parent 1d919ac commit c72e79a
Show file tree
Hide file tree
Showing 236 changed files with 581 additions and 860 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr-jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
# ======================== Fast Initial Checks ====================== #
check-format-and-targets:
if: ${{ github.repository_owner == 'facebook' }}
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
steps:
- uses: actions/[email protected]
with:
Expand Down
1 change: 0 additions & 1 deletion cache/cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ Status SecondaryCache::CreateFromString(
sec_cache = NewCompressedSecondaryCache(sec_cache_opts);
}


if (status.ok()) {
result->swap(sec_cache);
}
Expand Down
3 changes: 1 addition & 2 deletions cache/cache_bench_tool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,7 @@ namespace {
class SharedState {
public:
explicit SharedState(CacheBench* cache_bench)
: cv_(&mu_),
cache_bench_(cache_bench) {}
: cv_(&mu_), cache_bench_(cache_bench) {}

~SharedState() = default;

Expand Down
1 change: 0 additions & 1 deletion cache/compressed_secondary_cache_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,6 @@ TEST_P(CompressedSecondaryCacheTestWithCompressionParam,
BasicTestHelper(sec_cache, sec_cache_is_compressed_);
}


TEST_P(CompressedSecondaryCacheTestWithCompressionParam, FailsTest) {
FailsTest(sec_cache_is_compressed_);
}
Expand Down
5 changes: 2 additions & 3 deletions cache/lru_cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,8 @@ void LRUHandleTable::Resize() {

uint32_t old_length = uint32_t{1} << length_bits_;
int new_length_bits = length_bits_ + 1;
std::unique_ptr<LRUHandle* []> new_list {
new LRUHandle* [size_t{1} << new_length_bits] {}
};
std::unique_ptr<LRUHandle*[]> new_list{
new LRUHandle* [size_t{1} << new_length_bits] {}};
[[maybe_unused]] uint32_t count = 0;
for (uint32_t i = 0; i < old_length; i++) {
LRUHandle* h = list_[i];
Expand Down
4 changes: 2 additions & 2 deletions cache/lru_cache_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ TYPED_TEST(ClockCacheTest, Limits) {
// verify usage tracking on detached entries.)
{
size_t n = kCapacity * 5 + 1;
std::unique_ptr<HandleImpl* []> ha { new HandleImpl* [n] {} };
std::unique_ptr<HandleImpl*[]> ha{new HandleImpl* [n] {}};
Status s;
for (size_t i = 0; i < n && s.ok(); ++i) {
hkey[1] = i;
Expand Down Expand Up @@ -713,7 +713,7 @@ TYPED_TEST(ClockCacheTest, ClockEvictionEffortCapTest) {
// evictable entries are present beyond the cache capacity, despite
// being evictable.
constexpr size_t kCount = kCapacity - 1;
std::unique_ptr<HandleImpl* []> ha { new HandleImpl* [kCount] {} };
std::unique_ptr<HandleImpl*[]> ha{new HandleImpl* [kCount] {}};
for (size_t i = 0; i < 2 * kCount; ++i) {
UniqueId64x2 hkey = this->CheapHash(i);
ASSERT_OK(shard.Insert(
Expand Down
4 changes: 1 addition & 3 deletions cache/secondary_cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,4 @@

#include "cache/cache_entry_roles.h"

namespace ROCKSDB_NAMESPACE {

} // namespace ROCKSDB_NAMESPACE
namespace ROCKSDB_NAMESPACE {} // namespace ROCKSDB_NAMESPACE
4 changes: 2 additions & 2 deletions db/blob/blob_source.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ Status BlobSource::PutBlobIntoCache(
assert(cached_blob->IsEmpty());

TypedHandle* cache_handle = nullptr;
const Status s = InsertEntryIntoCache(cache_key, blob->get(),
&cache_handle, Cache::Priority::BOTTOM);
const Status s = InsertEntryIntoCache(cache_key, blob->get(), &cache_handle,
Cache::Priority::BOTTOM);
if (s.ok()) {
blob->release();

Expand Down
2 changes: 1 addition & 1 deletion db/c.cc
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ struct rocksdb_livefiles_t {
};
struct rocksdb_column_family_handle_t {
ColumnFamilyHandle* rep;
bool immortal; /* only true for default cf */
bool immortal; /* only true for default cf */
};
struct rocksdb_column_family_metadata_t {
ColumnFamilyMetaData rep;
Expand Down
1 change: 0 additions & 1 deletion db/compact_files_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// COPYING file in the root directory) and Apache 2.0 License
// (found in the LICENSE.Apache file in the root directory).


#include <mutex>
#include <string>
#include <thread>
Expand Down
1 change: 0 additions & 1 deletion db/compaction/compaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,6 @@ class Compaction {
void MarkFilesBeingCompacted(bool being_compacted) const;

private:

Status InitInputTableProperties();

// get the smallest and largest key present in files to be compacted
Expand Down
8 changes: 2 additions & 6 deletions db/compaction/compaction_job.cc
Original file line number Diff line number Diff line change
Expand Up @@ -959,8 +959,7 @@ Status CompactionJob::Install(const MutableCFOptions& mutable_cf_options,
UpdateCompactionJobStats(stats);

auto stream = event_logger_->LogToBuffer(log_buffer_, 8192);
stream << "job" << job_id_ << "event"
<< "compaction_finished"
stream << "job" << job_id_ << "event" << "compaction_finished"
<< "compaction_time_micros" << stats.micros
<< "compaction_time_cpu_micros" << stats.cpu_micros << "output_level"
<< compact_->compaction->output_level() << "num_output_files"
Expand Down Expand Up @@ -1050,12 +1049,10 @@ void CompactionJob::NotifyOnSubcompactionBegin(
listener->OnSubcompactionBegin(info);
}
info.status.PermitUncheckedError();

}

void CompactionJob::NotifyOnSubcompactionCompleted(
SubcompactionState* sub_compact) {

if (db_options_.listeners.empty()) {
return;
}
Expand Down Expand Up @@ -2135,8 +2132,7 @@ void CompactionJob::LogCompaction() {
cfd->GetName().c_str(), scratch);
// build event logger report
auto stream = event_logger_->Log();
stream << "job" << job_id_ << "event"
<< "compaction_started"
stream << "job" << job_id_ << "event" << "compaction_started"
<< "compaction_reason"
<< GetCompactionReasonString(compaction->compaction_reason());
for (size_t i = 0; i < compaction->num_input_levels(); ++i) {
Expand Down
1 change: 0 additions & 1 deletion db/compaction/compaction_job_stats_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,6 @@ int main(int argc, char** argv) {
return RUN_ALL_TESTS();
}


#else

int main(int /*argc*/, char** /*argv*/) { return 0; }
Expand Down
13 changes: 6 additions & 7 deletions db/compaction/compaction_job_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// COPYING file in the root directory) and Apache 2.0 License
// (found in the LICENSE.Apache file in the root directory).


#include "db/compaction/compaction_job.h"

#include <algorithm>
Expand Down Expand Up @@ -1900,8 +1899,8 @@ TEST_F(CompactionJobTest, CutToSkipGrandparentFile) {
const std::vector<int> input_levels = {0, 1};
auto lvl0_files = cfd_->current()->storage_info()->LevelFiles(0);
auto lvl1_files = cfd_->current()->storage_info()->LevelFiles(1);
RunCompaction({lvl0_files, lvl1_files}, input_levels,
{expected_file1, expected_file2});
RunCompaction({lvl0_files, lvl1_files}, input_levels,
{expected_file1, expected_file2});
}

TEST_F(CompactionJobTest, CutToAlignGrandparentBoundary) {
Expand Down Expand Up @@ -1975,8 +1974,8 @@ TEST_F(CompactionJobTest, CutToAlignGrandparentBoundary) {
const std::vector<int> input_levels = {0, 1};
auto lvl0_files = cfd_->current()->storage_info()->LevelFiles(0);
auto lvl1_files = cfd_->current()->storage_info()->LevelFiles(1);
RunCompaction({lvl0_files, lvl1_files}, input_levels,
{expected_file1, expected_file2});
RunCompaction({lvl0_files, lvl1_files}, input_levels,
{expected_file1, expected_file2});
}

TEST_F(CompactionJobTest, CutToAlignGrandparentBoundarySameKey) {
Expand Down Expand Up @@ -2037,8 +2036,8 @@ TEST_F(CompactionJobTest, CutToAlignGrandparentBoundarySameKey) {
for (int i = 80; i <= 100; i++) {
snapshots.emplace_back(i);
}
RunCompaction({lvl0_files, lvl1_files}, input_levels,
{expected_file1, expected_file2}, snapshots);
RunCompaction({lvl0_files, lvl1_files}, input_levels,
{expected_file1, expected_file2}, snapshots);
}

TEST_F(CompactionJobTest, CutForMaxCompactionBytesSameKey) {
Expand Down
1 change: 0 additions & 1 deletion db/convenience.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// (found in the LICENSE.Apache file in the root directory).
//


#include "rocksdb/convenience.h"

#include "db/convenience_impl.h"
Expand Down
3 changes: 1 addition & 2 deletions db/corruption_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. See the AUTHORS file for names of contributors.

#include "rocksdb/options.h"

#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
Expand All @@ -25,6 +23,7 @@
#include "rocksdb/convenience.h"
#include "rocksdb/db.h"
#include "rocksdb/env.h"
#include "rocksdb/options.h"
#include "rocksdb/table.h"
#include "rocksdb/utilities/transaction_db.h"
#include "rocksdb/write_batch.h"
Expand Down
2 changes: 0 additions & 2 deletions db/cuckoo_table_db_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// COPYING file in the root directory) and Apache 2.0 License
// (found in the LICENSE.Apache file in the root directory).


#include "db/db_impl/db_impl.h"
#include "db/db_test_util.h"
#include "rocksdb/db.h"
Expand Down Expand Up @@ -349,4 +348,3 @@ int main(int argc, char** argv) {
return 0;
}
}

4 changes: 1 addition & 3 deletions db/db_basic_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,6 @@ TEST_F(DBBasicTest, Snapshot) {
} while (ChangeOptions());
}


class DBBasicMultiConfigs : public DBBasicTest,
public ::testing::WithParamInterface<int> {
public:
Expand Down Expand Up @@ -2604,8 +2603,7 @@ class DBMultiGetAsyncIOTest : public DBBasicTest,
// Warm up the block cache so we don't need to use the IO uring
Iterator* iter = dbfull()->NewIterator(ReadOptions());
for (iter->SeekToFirst(); iter->Valid() && iter->status().ok();
iter->Next())
;
iter->Next());
EXPECT_OK(iter->status());
delete iter;
#endif // ROCKSDB_IOURING_PRESENT
Expand Down
5 changes: 2 additions & 3 deletions db/db_block_cache_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,6 @@ class ReadOnlyCacheWrapper : public CacheWrapper {
} // anonymous namespace
#endif // SNAPPY


// Make sure that when options.block_cache is set, after a new table is
// created its index/filter blocks are added to block cache.
TEST_F(DBBlockCacheTest, IndexAndFilterBlocksOfNewTableAddedToCache) {
Expand Down Expand Up @@ -1758,8 +1757,8 @@ class CacheKeyTest : public testing::Test {
tp_.db_id = std::to_string(db_id_);
tp_.orig_file_number = file_number;
bool is_stable;
std::string cur_session_id; // ignored
uint64_t cur_file_number = 42; // ignored
std::string cur_session_id; // ignored
uint64_t cur_file_number = 42; // ignored
OffsetableCacheKey rv;
BlockBasedTable::SetupBaseCacheKey(&tp_, cur_session_id, cur_file_number,
&rv, &is_stable);
Expand Down
1 change: 0 additions & 1 deletion db/db_dynamic_level_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,6 @@ TEST_F(DBTestDynamicLevel, DISABLED_MigrateToDynamicLevelMaxBytesBase) {
}
} // namespace ROCKSDB_NAMESPACE


int main(int argc, char** argv) {
ROCKSDB_NAMESPACE::port::InstallStackTraceHandler();
::testing::InitGoogleTest(&argc, argv);
Expand Down
7 changes: 3 additions & 4 deletions db/db_encryption_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
// COPYING file in the root directory) and Apache 2.0 License
// (found in the LICENSE.Apache file in the root directory).
//
#include <iostream>
#include <string>

#include "db/db_test_util.h"
#include "port/stack_trace.h"
#include "rocksdb/perf_context.h"
#include "test_util/sync_point.h"
#include <iostream>
#include <string>

namespace ROCKSDB_NAMESPACE {

Expand All @@ -25,7 +26,6 @@ class DBEncryptionTest : public DBTestBase {
}
};


TEST_F(DBEncryptionTest, CheckEncrypted) {
ASSERT_OK(Put("foo567", "v1.fetdq"));
ASSERT_OK(Put("bar123", "v2.dfgkjdfghsd"));
Expand Down Expand Up @@ -116,7 +116,6 @@ TEST_F(DBEncryptionTest, ReadEmptyFile) {
ASSERT_TRUE(data.empty());
}


} // namespace ROCKSDB_NAMESPACE

int main(int argc, char** argv) {
Expand Down
1 change: 0 additions & 1 deletion db/db_filesnapshot.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// (found in the LICENSE.Apache file in the root directory).
//


#include <algorithm>
#include <cstdint>
#include <memory>
Expand Down
4 changes: 2 additions & 2 deletions db/db_impl/db_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1921,8 +1921,8 @@ class DBImpl : public DB {
const InternalKey* begin = nullptr; // nullptr means beginning of key range
const InternalKey* end = nullptr; // nullptr means end of key range
InternalKey* manual_end = nullptr; // how far we are compacting
InternalKey tmp_storage; // Used to keep track of compaction progress
InternalKey tmp_storage1; // Used to keep track of compaction progress
InternalKey tmp_storage; // Used to keep track of compaction progress
InternalKey tmp_storage1; // Used to keep track of compaction progress

// When the user provides a canceled pointer in CompactRangeOptions, the
// above varaibe is the reference of the user-provided
Expand Down
3 changes: 1 addition & 2 deletions db/db_impl/db_impl_compaction_flush.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3866,8 +3866,7 @@ Status DBImpl::BackgroundCompaction(bool* made_progress,
moved_bytes);
{
event_logger_.LogToBuffer(log_buffer)
<< "job" << job_context->job_id << "event"
<< "trivial_move"
<< "job" << job_context->job_id << "event" << "trivial_move"
<< "destination_level" << c->output_level() << "files" << moved_files
<< "total_files_size" << moved_bytes;
}
Expand Down
3 changes: 1 addition & 2 deletions db/db_impl/db_impl_open.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1158,8 +1158,7 @@ void DBImpl::SetupLogFilesRecovery(
{
auto stream = event_logger_.Log();
stream << "job" << *job_id;
stream << "event"
<< "recovery_started";
stream << "event" << "recovery_started";
stream << "wal_files";
stream.StartArray();
for (auto wal_number : wal_numbers) {
Expand Down
2 changes: 0 additions & 2 deletions db/db_impl/db_impl_readonly.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

namespace ROCKSDB_NAMESPACE {


DBImplReadOnly::DBImplReadOnly(const DBOptions& db_options,
const std::string& dbname)
: DBImpl(db_options, dbname, /*seq_per_batch*/ false,
Expand Down Expand Up @@ -372,5 +371,4 @@ Status DBImplReadOnly::OpenForReadOnlyWithoutCheck(
return s;
}


} // namespace ROCKSDB_NAMESPACE
1 change: 0 additions & 1 deletion db/db_impl/db_impl_readonly.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

#pragma once


#include <string>
#include <vector>

Expand Down
1 change: 0 additions & 1 deletion db/db_impl/db_impl_secondary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1057,5 +1057,4 @@ Status DB::OpenAndCompact(
output, override_options);
}


} // namespace ROCKSDB_NAMESPACE
1 change: 0 additions & 1 deletion db/db_impl/db_impl_secondary.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

#pragma once


#include <string>
#include <vector>

Expand Down
1 change: 0 additions & 1 deletion db/db_log_iter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,6 @@ TEST_F(DBTestXactLogIterator, TransactionLogIteratorBlobs) {
}
} // namespace ROCKSDB_NAMESPACE


int main(int argc, char** argv) {
ROCKSDB_NAMESPACE::port::InstallStackTraceHandler();
::testing::InitGoogleTest(&argc, argv);
Expand Down
Loading

0 comments on commit c72e79a

Please sign in to comment.