Skip to content

Commit

Permalink
fix Clang 12 build errors (#194) (#223)
Browse files Browse the repository at this point in the history
I needed these changes to run `make` successfully.

See this issue which points out the problem and has the same patch solution but at a different point in time: facebook#7352

Signed-off-by: Breezewish <[email protected]>

Co-authored-by: Greg Weber <[email protected]>
  • Loading branch information
breezewish and gregwebs authored Dec 18, 2020
1 parent 448a2c9 commit cf58bfe
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 18 deletions.
17 changes: 9 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
dist: xenial
dist: focal
language: cpp
os:
- linux
- osx
compiler:
- clang
- gcc
osx_image: xcode8.3
jdk:
- openjdk7
osx_image: xcode12
cache:
- ccache
- apt
Expand All @@ -19,7 +17,7 @@ addons:
- ubuntu-toolchain-r-test
packages:
- curl
- g++-8
- g++-9
- libbz2-dev
- libgflags-dev
- libsnappy-dev
Expand Down Expand Up @@ -50,13 +48,16 @@ matrix:
- os: osx
env: TEST_GROUP=4
- os: osx
env: TEST_GROUP=platform_dependent
env: JOB_NAME=lite_build
- os: osx
env: JOB_NAME=examples
- os: osx
env: JOB_NAME=encrypted_env
- os : linux
compiler: clang
- os: osx
compiler: gcc
- os: osx
env: JOB_NAME=encrypted_env


# https://docs.travis-ci.com/user/caching/#ccache-cache
install:
Expand Down
4 changes: 2 additions & 2 deletions db/db_impl/db_impl_compaction_flush.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,7 @@ Status DBImpl::CompactFilesImpl(
}

if (output_file_names != nullptr) {
for (const auto newf : c->edit()->GetNewFiles()) {
for (const auto& newf : c->edit()->GetNewFiles()) {
(*output_file_names)
.push_back(TableFileName(c->immutable_cf_options()->cf_paths,
newf.second.fd.GetNumber(),
Expand Down Expand Up @@ -1147,7 +1147,7 @@ void DBImpl::NotifyOnCompactionBegin(ColumnFamilyData* cfd, Compaction* c,
}
}
}
for (const auto newf : c->edit()->GetNewFiles()) {
for (const auto& newf : c->edit()->GetNewFiles()) {
info.output_files.push_back(TableFileName(
c->immutable_cf_options()->cf_paths, newf.second.fd.GetNumber(),
newf.second.fd.GetPathId()));
Expand Down
4 changes: 2 additions & 2 deletions db/db_options_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class DBOptionsTest : public DBTestBase {
std::unordered_map<std::string, std::string> options_map;
StringToMap(options_str, &options_map);
std::unordered_map<std::string, std::string> mutable_map;
for (const auto opt : db_options_type_info) {
for (const auto& opt : db_options_type_info) {
if (opt.second.is_mutable &&
opt.second.verification != OptionVerificationType::kDeprecated) {
mutable_map[opt.first] = options_map[opt.first];
Expand All @@ -53,7 +53,7 @@ class DBOptionsTest : public DBTestBase {
std::unordered_map<std::string, std::string> options_map;
StringToMap(options_str, &options_map);
std::unordered_map<std::string, std::string> mutable_map;
for (const auto opt : cf_options_type_info) {
for (const auto& opt : cf_options_type_info) {
if (opt.second.is_mutable &&
opt.second.verification != OptionVerificationType::kDeprecated) {
mutable_map[opt.first] = options_map[opt.first];
Expand Down
2 changes: 1 addition & 1 deletion options/options_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ Status RocksDBOptionsParser::EndSection(
return s;
}
} else if (section == kOptionSectionVersion) {
for (const auto pair : opt_map) {
for (const auto& pair : opt_map) {
if (pair.first == "rocksdb_version") {
s = ParseVersionNumber(pair.first, pair.second, 3, db_version);
if (!s.ok()) {
Expand Down
8 changes: 4 additions & 4 deletions table/table_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ class BlockConstructor: public Constructor {
block_ = nullptr;
BlockBuilder builder(table_options.block_restart_interval);

for (const auto kv : kv_map) {
for (const auto& kv : kv_map) {
builder.Add(kv.first, kv.second);
}
// Open the block
Expand Down Expand Up @@ -349,7 +349,7 @@ class TableConstructor: public Constructor {
TablePropertiesCollectorFactory::Context::kUnknownColumnFamily,
file_writer_.get()));

for (const auto kv : kv_map) {
for (const auto& kv : kv_map) {
if (convert_to_internal_key_) {
ParsedInternalKey ikey(kv.first, kMaxSequenceNumber, kTypeValue);
std::string encoded;
Expand Down Expand Up @@ -482,7 +482,7 @@ class MemTableConstructor: public Constructor {
kMaxSequenceNumber, 0 /* column_family_id */);
memtable_->Ref();
int seq = 1;
for (const auto kv : kv_map) {
for (const auto& kv : kv_map) {
memtable_->Add(seq, kTypeValue, kv.first, kv.second);
seq++;
}
Expand Down Expand Up @@ -543,7 +543,7 @@ class DBConstructor: public Constructor {
delete db_;
db_ = nullptr;
NewDB();
for (const auto kv : kv_map) {
for (const auto& kv : kv_map) {
WriteBatch batch;
batch.Put(kv.first, kv.second);
EXPECT_TRUE(db_->Write(WriteOptions(), &batch).ok());
Expand Down
2 changes: 1 addition & 1 deletion tools/ldb_cmd_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ TEST_F(LdbCmdTest, HexToStringBadInputs) {
const vector<string> badInputs = {
"0xZZ", "123", "0xx5", "0x111G", "0x123", "Ox12", "0xT", "0x1Q1",
};
for (const auto badInput : badInputs) {
for (const auto& badInput : badInputs) {
try {
rocksdb::LDBCommand::HexToString(badInput);
std::cerr << "Should fail on bad hex value: " << badInput << "\n";
Expand Down

0 comments on commit cf58bfe

Please sign in to comment.