Skip to content

Commit 986dad0

Browse files
committed
Merge pull request XRPLF#324 from dalgaaf/wip-da-SCA-20140930
Various SCA fixes
2 parents 1f96330 + 8ee75dc commit 986dad0

19 files changed

+28
-33
lines changed

db/compaction_picker.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,7 @@ Compaction* UniversalCompactionPicker::PickCompactionUniversalSizeAmp(
920920
"earliest-file-size %" PRIu64,
921921
version->cfd_->GetName().c_str(), candidate_size, earliest_file_size);
922922
}
923-
assert(start_index >= 0 && start_index < files.size() - 1);
923+
assert(start_index < files.size() - 1);
924924

925925
// Estimate total file size
926926
uint64_t estimated_total_size = 0;

db/corruption_test.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ class CorruptionTest {
131131
ASSERT_GE(max_expected, correct);
132132
}
133133

134-
void CorruptFile(const std::string fname, int offset, int bytes_to_corrupt) {
134+
void CorruptFile(const std::string& fname, int offset, int bytes_to_corrupt) {
135135
struct stat sbuf;
136136
if (stat(fname.c_str(), &sbuf) != 0) {
137137
const char* msg = strerror(errno);

db/cuckoo_table_db_test.cc

+1
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ TEST(CuckooTableDBTest, Uint64Comparator) {
218218

219219
// Add more keys.
220220
ASSERT_OK(Delete(Uint64Key(2))); // Delete.
221+
dbfull()->TEST_FlushMemTable();
221222
ASSERT_OK(Put(Uint64Key(3), "v0")); // Update.
222223
ASSERT_OK(Put(Uint64Key(4), "v4"));
223224
dbfull()->TEST_FlushMemTable();

db/db_impl.cc

+2-3
Original file line numberDiff line numberDiff line change
@@ -3064,7 +3064,6 @@ Status DBImpl::DoCompactionWork(CompactionState* compact,
30643064
assert(compact);
30653065
compact->CleanupBatchBuffer();
30663066
compact->CleanupMergedBuffer();
3067-
bool prefix_initialized = false;
30683067

30693068
// Generate file_levels_ for compaction berfore making Iterator
30703069
compact->compaction->GenerateFileLevels();
@@ -3149,6 +3148,7 @@ Status DBImpl::DoCompactionWork(CompactionState* compact,
31493148
// 2) send value_buffer to compaction filter and alternate the values;
31503149
// 3) merge value_buffer with ineligible_value_buffer;
31513150
// 4) run the modified "compaction" using the old for loop.
3151+
bool prefix_initialized = false;
31523152
shared_ptr<Iterator> backup_input(
31533153
versions_->MakeInputIterator(compact->compaction));
31543154
backup_input->SeekToFirst();
@@ -4037,11 +4037,10 @@ Status DBImpl::Write(const WriteOptions& options, WriteBatch* my_batch) {
40374037
RecordTick(stats_, WAL_FILE_BYTES, log_size);
40384038
if (status.ok() && options.sync) {
40394039
RecordTick(stats_, WAL_FILE_SYNCED);
4040+
StopWatch sw(env_, stats_, WAL_FILE_SYNC_MICROS);
40404041
if (db_options_.use_fsync) {
4041-
StopWatch(env_, stats_, WAL_FILE_SYNC_MICROS);
40424042
status = log_->file()->Fsync();
40434043
} else {
4044-
StopWatch(env_, stats_, WAL_FILE_SYNC_MICROS);
40454044
status = log_->file()->Sync();
40464045
}
40474046
}

db/db_test.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -6138,7 +6138,7 @@ class WrappedBloom : public FilterPolicy {
61386138
const FilterPolicy* filter_;
61396139
mutable uint32_t counter_;
61406140

6141-
rocksdb::Slice convertKey(const rocksdb::Slice key) const {
6141+
rocksdb::Slice convertKey(const rocksdb::Slice& key) const {
61426142
return key;
61436143
}
61446144
};

db/memtable.cc

-1
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,6 @@ static bool SaveValue(void* arg, const char* entry) {
413413
*(s->found_final_value) = true;
414414
return false;
415415
}
416-
std::string merge_result; // temporary area for merge results later
417416
Slice v = GetLengthPrefixedSlice(key_ptr + key_length);
418417
*(s->merge_in_progress) = true;
419418
merge_context->PushOperand(v);

db/version_set.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -2169,7 +2169,7 @@ Status VersionSet::Recover(
21692169

21702170
// there were some column families in the MANIFEST that weren't specified
21712171
// in the argument. This is OK in read_only mode
2172-
if (read_only == false && column_families_not_found.size() > 0) {
2172+
if (read_only == false && !column_families_not_found.empty()) {
21732173
std::string list_of_not_found;
21742174
for (const auto& cf : column_families_not_found) {
21752175
list_of_not_found += ", " + cf.second;

table/bloom_block.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace rocksdb {
1313

14-
void BloomBlockBuilder::AddKeysHashes(const std::vector<uint32_t> keys_hashes) {
14+
void BloomBlockBuilder::AddKeysHashes(const std::vector<uint32_t>& keys_hashes) {
1515
for (auto hash : keys_hashes) {
1616
bloom_.AddHash(hash);
1717
}

table/bloom_block.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class BloomBlockBuilder {
2626

2727
uint32_t GetNumBlocks() const { return bloom_.GetNumBlocks(); }
2828

29-
void AddKeysHashes(const std::vector<uint32_t> keys_hashes);
29+
void AddKeysHashes(const std::vector<uint32_t>& keys_hashes);
3030

3131
Slice Finish();
3232

table/cuckoo_table_reader.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ class CuckooTableIterator : public Iterator {
191191

192192
private:
193193
struct BucketComparator {
194-
BucketComparator(const Slice file_data, const Comparator* ucomp,
194+
BucketComparator(const Slice& file_data, const Comparator* ucomp,
195195
uint32_t bucket_len, uint32_t user_key_len,
196196
const Slice target = Slice())
197197
: file_data_(file_data),

table/plain_table_factory.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ std::string PlainTableFactory::GetPrintableTableOptions() const {
5252
snprintf(buffer, kBufferSize, " hash_table_ratio: %lf\n",
5353
hash_table_ratio_);
5454
ret.append(buffer);
55-
snprintf(buffer, kBufferSize, " index_sparseness: %zd\n",
55+
snprintf(buffer, kBufferSize, " index_sparseness: %zu\n",
5656
index_sparseness_);
5757
ret.append(buffer);
58-
snprintf(buffer, kBufferSize, " huge_page_tlb_size: %zd\n",
58+
snprintf(buffer, kBufferSize, " huge_page_tlb_size: %zu\n",
5959
huge_page_tlb_size_);
6060
ret.append(buffer);
6161
snprintf(buffer, kBufferSize, " encoding_type: %d\n",

table/table_test.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1216,7 +1216,7 @@ static std::string RandomString(Random* rnd, int len) {
12161216
return r;
12171217
}
12181218

1219-
void AddInternalKey(TableConstructor* c, const std::string prefix,
1219+
void AddInternalKey(TableConstructor* c, const std::string& prefix,
12201220
int suffix_len = 800) {
12211221
static Random rnd(1023);
12221222
InternalKey k(prefix + RandomString(&rnd, 800), 0, kTypeValue);

util/ldb_cmd.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ bool LDBCommand::ParseKeyValue(const string& line, string* key, string* value,
325325
bool LDBCommand::ValidateCmdLineOptions() {
326326

327327
for (map<string, string>::const_iterator itr = option_map_.begin();
328-
itr != option_map_.end(); itr++) {
328+
itr != option_map_.end(); ++itr) {
329329
if (find(valid_cmd_line_options_.begin(),
330330
valid_cmd_line_options_.end(), itr->first) ==
331331
valid_cmd_line_options_.end()) {
@@ -335,7 +335,7 @@ bool LDBCommand::ValidateCmdLineOptions() {
335335
}
336336

337337
for (vector<string>::const_iterator itr = flags_.begin();
338-
itr != flags_.end(); itr++) {
338+
itr != flags_.end(); ++itr) {
339339
if (find(valid_cmd_line_options_.begin(),
340340
valid_cmd_line_options_.end(), *itr) ==
341341
valid_cmd_line_options_.end()) {
@@ -1538,7 +1538,7 @@ void BatchPutCommand::DoCommand() {
15381538
WriteBatch batch;
15391539

15401540
for (vector<pair<string, string>>::const_iterator itr
1541-
= key_values_.begin(); itr != key_values_.end(); itr++) {
1541+
= key_values_.begin(); itr != key_values_.end(); ++itr) {
15421542
batch.Put(itr->first, itr->second);
15431543
}
15441544
Status st = db_->Write(WriteOptions(), &batch);

util/ldb_cmd_execute_result.h

+3-8
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,10 @@ class LDBCommandExecuteResult {
1313
EXEC_NOT_STARTED = 0, EXEC_SUCCEED = 1, EXEC_FAILED = 2,
1414
};
1515

16-
LDBCommandExecuteResult() {
17-
state_ = EXEC_NOT_STARTED;
18-
message_ = "";
19-
}
16+
LDBCommandExecuteResult() : state_(EXEC_NOT_STARTED), message_("") {}
2017

21-
LDBCommandExecuteResult(State state, std::string& msg) {
22-
state_ = state;
23-
message_ = msg;
24-
}
18+
LDBCommandExecuteResult(State state, std::string& msg) :
19+
state_(state), message_(msg) {}
2520

2621
std::string ToString() {
2722
std::string ret;

util/signal_test.cc

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
namespace {
1010
void f0() {
1111
char *p = nullptr;
12+
// cppcheck-suppress nullPointer
1213
*p = 10; /* SIGSEGV here!! */
1314
}
1415

utilities/document/document_db.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ namespace {
3333
// > 0 <=> lhs == rhs
3434
// TODO(icanadi) move this to JSONDocument?
3535
int DocumentCompare(const JSONDocument& lhs, const JSONDocument& rhs) {
36-
assert(rhs.IsObject() == false && rhs.IsObject() == false &&
36+
assert(lhs.IsObject() == false && rhs.IsObject() == false &&
3737
lhs.type() == rhs.type());
3838

3939
switch (lhs.type()) {
@@ -376,7 +376,7 @@ class IndexKey {
376376

377377
class SimpleSortedIndex : public Index {
378378
public:
379-
SimpleSortedIndex(const std::string field, const std::string& name)
379+
SimpleSortedIndex(const std::string& field, const std::string& name)
380380
: field_(field), name_(name) {}
381381

382382
virtual const char* Name() const override { return name_.c_str(); }

utilities/spatialdb/spatial_db.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ class SpatialIndexCursor : public Cursor {
369369
}
370370
delete spatial_iterator;
371371

372-
valid_ = valid_ && primary_key_ids_.size() > 0;
372+
valid_ = valid_ && !primary_key_ids_.empty();
373373

374374
if (valid_) {
375375
primary_keys_iterator_ = primary_key_ids_.begin();

utilities/ttl/db_ttl_impl.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ class TtlCompactionFilterFactory : public CompactionFilterFactory {
206206
class TtlMergeOperator : public MergeOperator {
207207

208208
public:
209-
explicit TtlMergeOperator(const std::shared_ptr<MergeOperator> merge_op,
209+
explicit TtlMergeOperator(const std::shared_ptr<MergeOperator>& merge_op,
210210
Env* env)
211211
: user_merge_op_(merge_op), env_(env) {
212212
assert(merge_op);

utilities/ttl/ttl_test.cc

+4-4
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class TtlTest {
120120
static FlushOptions flush_opts;
121121
WriteBatch batch;
122122
kv_it_ = kvmap_.begin();
123-
for (int i = 0; i < num_ops && kv_it_ != kvmap_.end(); i++, kv_it_++) {
123+
for (int i = 0; i < num_ops && kv_it_ != kvmap_.end(); i++, ++kv_it_) {
124124
switch (batch_ops[i]) {
125125
case PUT:
126126
batch.Put(kv_it_->first, kv_it_->second);
@@ -145,7 +145,7 @@ class TtlTest {
145145
static FlushOptions flush_opts;
146146
kv_it_ = kvmap_.begin();
147147
advance(kv_it_, start_pos_map);
148-
for (int i = 0; kv_it_ != kvmap_.end() && i < num_entries; i++, kv_it_++) {
148+
for (int i = 0; kv_it_ != kvmap_.end() && i < num_entries; i++, ++kv_it_) {
149149
ASSERT_OK(cf == nullptr
150150
? db_ttl_->Put(wopts, kv_it_->first, kv_it_->second)
151151
: db_ttl_->Put(wopts, cf, kv_it_->first, kv_it_->second));
@@ -207,7 +207,7 @@ class TtlTest {
207207
kv_it_ = kvmap_.begin();
208208
advance(kv_it_, st_pos);
209209
std::string v;
210-
for (int i = 0; kv_it_ != kvmap_.end() && i < span; i++, kv_it_++) {
210+
for (int i = 0; kv_it_ != kvmap_.end() && i < span; i++, ++kv_it_) {
211211
Status s = (cf == nullptr) ? db_ttl_->Get(ropts, kv_it_->first, &v)
212212
: db_ttl_->Get(ropts, cf, kv_it_->first, &v);
213213
if (s.ok() != check) {
@@ -252,7 +252,7 @@ class TtlTest {
252252
} else { // dbiter should have found out kvmap_[st_pos]
253253
for (int i = st_pos;
254254
kv_it_ != kvmap_.end() && i < st_pos + span;
255-
i++, kv_it_++) {
255+
i++, ++kv_it_) {
256256
ASSERT_TRUE(dbiter->Valid());
257257
ASSERT_EQ(dbiter->value().compare(kv_it_->second), 0);
258258
dbiter->Next();

0 commit comments

Comments
 (0)