treewide: use unsigned variable to compare with unsigned
some times we initialize a loop variable like auto i = 0; or int i = 0; but since the type of `0` is `int`, what we get is a variable of `int` type, but later we compare it with an unsigned number, if we compile the source code with `-Werror=sign-compare` option, the compiler would warn at seeing this. in general, this is a false alarm, as we are not likely to have a wrong comparison result here. but in order to prevent issues due to the integer promotion for comparison in other places. and to prepare for enabling `-Werror=sign-compare`. let's use unsigned to silence this warning. Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
This commit is contained in:
@@ -802,7 +802,7 @@ class clients_table : public streaming_virtual_table {
|
||||
decorated_ip::compare cmp(*_s);
|
||||
std::set<decorated_ip, decorated_ip::compare> ips(cmp);
|
||||
std::unordered_map<net::inet_address, client_data_vec> cd_map;
|
||||
for (int i = 0; i < smp::count; i++) {
|
||||
for (unsigned i = 0; i < smp::count; i++) {
|
||||
for (auto&& ps_cdc : *cd_vec[i]) {
|
||||
for (auto&& cd : ps_cdc) {
|
||||
if (cd_map.contains(cd.ip)) {
|
||||
|
||||
@@ -274,7 +274,7 @@ SEASTAR_TEST_CASE(test_correctness_when_crossing_chunk_boundary) {
|
||||
as(region, [&] {
|
||||
size_t max_chunk_size = lsa::chunked_managed_vector<int>::max_chunk_capacity();
|
||||
|
||||
lsa::chunked_managed_vector<int> v;
|
||||
lsa::chunked_managed_vector<size_t> v;
|
||||
for (size_t i = 0; i < (max_chunk_size + 1); i++) {
|
||||
v.push_back(i);
|
||||
}
|
||||
|
||||
@@ -1237,7 +1237,7 @@ SEASTAR_TEST_CASE(populate_from_quarantine_works) {
|
||||
});
|
||||
auto shard = tests::random::get_int<unsigned>(0, smp::count);
|
||||
auto found = false;
|
||||
for (auto i = 0; i < smp::count && !found; i++) {
|
||||
for (unsigned i = 0; i < smp::count && !found; i++) {
|
||||
found = co_await db.invoke_on((shard + i) % smp::count, [] (replica::database& db) -> future<bool> {
|
||||
auto& cf = db.find_column_family("ks", "cf");
|
||||
bool found = false;
|
||||
@@ -1286,7 +1286,7 @@ SEASTAR_TEST_CASE(snapshot_with_quarantine_works) {
|
||||
// move a random sstable to quarantine
|
||||
auto shard = tests::random::get_int<unsigned>(0, smp::count);
|
||||
auto found = false;
|
||||
for (auto i = 0; i < smp::count; i++) {
|
||||
for (unsigned i = 0; i < smp::count; i++) {
|
||||
co_await db.invoke_on((shard + i) % smp::count, [&] (replica::database& db) -> future<> {
|
||||
auto& cf = db.find_column_family("ks", "cf");
|
||||
co_await cf.parallel_foreach_table_state([&] (compaction::table_state& ts) -> future<> {
|
||||
|
||||
@@ -259,23 +259,23 @@ SEASTAR_THREAD_TEST_CASE(test_load_sketch) {
|
||||
std::vector<unsigned> node2_shards(node2_shard_count, 0);
|
||||
std::vector<unsigned> node3_shards(node3_shard_count, 0);
|
||||
|
||||
for (int i = 0; i < node1_shard_count * 3; ++i) {
|
||||
for (unsigned i = 0; i < node1_shard_count * 3; ++i) {
|
||||
node1_shards[load.next_shard(host1)] += 1;
|
||||
}
|
||||
for (int i = 0; i < node2_shard_count * 3; ++i) {
|
||||
for (unsigned i = 0; i < node2_shard_count * 3; ++i) {
|
||||
node2_shards[load.next_shard(host2)] += 1;
|
||||
}
|
||||
for (int i = 0; i < node3_shard_count * 3; ++i) {
|
||||
for (unsigned i = 0; i < node3_shard_count * 3; ++i) {
|
||||
node3_shards[load.next_shard(host3)] += 1;
|
||||
}
|
||||
|
||||
for (int i = 1; i < node1_shard_count; ++i) {
|
||||
for (unsigned i = 1; i < node1_shard_count; ++i) {
|
||||
BOOST_REQUIRE_EQUAL(node1_shards[i], node1_shards[0]);
|
||||
}
|
||||
for (int i = 1; i < node2_shard_count; ++i) {
|
||||
for (unsigned i = 1; i < node2_shard_count; ++i) {
|
||||
BOOST_REQUIRE_EQUAL(node2_shards[i], node2_shards[0]);
|
||||
}
|
||||
for (int i = 1; i < node3_shard_count; ++i) {
|
||||
for (unsigned i = 1; i < node3_shard_count; ++i) {
|
||||
BOOST_REQUIRE_EQUAL(node3_shards[i], node3_shards[0]);
|
||||
}
|
||||
}
|
||||
@@ -330,7 +330,7 @@ SEASTAR_THREAD_TEST_CASE(test_load_sketch) {
|
||||
node3_shards[s] += 1;
|
||||
}
|
||||
|
||||
for (int i = 1; i < node3_shard_count; ++i) {
|
||||
for (unsigned i = 1; i < node3_shard_count; ++i) {
|
||||
BOOST_REQUIRE_EQUAL(node3_shards[i], node3_shards[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3078,7 +3078,7 @@ SEASTAR_THREAD_TEST_CASE(test_mutation_rebuilder_v2_flush) {
|
||||
frags.emplace_back(*s, p, partition_end());
|
||||
|
||||
mutation_rebuilder_v2 rebuilder_without_flush(s);
|
||||
for (int i = 0; i < frags.size(); ++i) {
|
||||
for (unsigned i = 0; i < frags.size(); ++i) {
|
||||
rebuilder_without_flush.consume(mutation_fragment_v2(*s, p, frags[i]));
|
||||
}
|
||||
auto m_expected = std::move(*rebuilder_without_flush.consume_end_of_stream());
|
||||
@@ -3087,13 +3087,13 @@ SEASTAR_THREAD_TEST_CASE(test_mutation_rebuilder_v2_flush) {
|
||||
// including no flush).
|
||||
// This is to test that the first flush doesn't break the rebuilder in
|
||||
// a way that prevents another flush.
|
||||
for (int first_flush = 0; first_flush < frags.size(); ++first_flush) {
|
||||
for (int second_flush = first_flush; second_flush < frags.size(); ++second_flush) {
|
||||
for (unsigned first_flush = 0; first_flush < frags.size(); ++first_flush) {
|
||||
for (unsigned second_flush = first_flush; second_flush < frags.size(); ++second_flush) {
|
||||
mutation_rebuilder_v2 rebuilder(s);
|
||||
auto m1 = mutation(s, pk); // Contents of flush 1.
|
||||
auto m2 = mutation(s, pk); // Contents of flush 2.
|
||||
auto m3 = mutation(s, pk); // Contents of final flush.
|
||||
for (int i = 0; i < frags.size(); ++i) {
|
||||
for (unsigned i = 0; i < frags.size(); ++i) {
|
||||
rebuilder.consume(mutation_fragment_v2(*s, p, frags[i]));
|
||||
if (i == first_flush) {
|
||||
m1 = rebuilder.flush();
|
||||
|
||||
@@ -703,7 +703,7 @@ SEASTAR_THREAD_TEST_CASE(test_split_token_range_msb) {
|
||||
BOOST_REQUIRE_EQUAL(ranges.size(), 1 << msb);
|
||||
|
||||
std::optional<dht::token> prev_last_token;
|
||||
for (int i = 0; i < ranges.size(); i++) {
|
||||
for (unsigned i = 0; i < ranges.size(); i++) {
|
||||
auto t = dht::last_token_of_compaction_group(msb, i);
|
||||
testlog.debug("msb: {}, t: {}, range: {}", msb, t, ranges[i]);
|
||||
BOOST_REQUIRE(ranges[i].contains(t, cmp));
|
||||
|
||||
@@ -207,7 +207,7 @@ SEASTAR_TEST_CASE(test_reader_with_different_strategies) {
|
||||
if (data1.size() != data2.size()) {
|
||||
mismatch = ::format("size1 {} != size2 {}", data1.size(), data2.size());
|
||||
} else {
|
||||
for (int i = 0; i < data1.size(); ++i) {
|
||||
for (unsigned i = 0; i < data1.size(); ++i) {
|
||||
const auto& mf1 = data1[i];
|
||||
const auto& mf2 = data2[i];
|
||||
if (!mf1.equal(s, mf2)) {
|
||||
|
||||
@@ -321,7 +321,7 @@ static future<compact_sstables_result> compact_sstables(test_env& env, std::vect
|
||||
std::vector<sstables::shared_sstable> created;
|
||||
|
||||
if (create_sstables) {
|
||||
for (auto i = 0; i < create_sstables; i++) {
|
||||
for (unsigned i = 0; i < create_sstables; i++) {
|
||||
const column_definition& r1_col = *s->get_column_definition("r1");
|
||||
|
||||
auto sst = sst_gen();
|
||||
@@ -459,7 +459,7 @@ SEASTAR_TEST_CASE(compact_02) {
|
||||
|
||||
static constexpr size_t num_rounds = 4;
|
||||
static constexpr size_t sstables_in_round = 4;
|
||||
for (auto i = 0; i < num_rounds; ++i) {
|
||||
for (unsigned i = 0; i < num_rounds; ++i) {
|
||||
compact_and_verify(sstables_in_round);
|
||||
}
|
||||
|
||||
@@ -3843,7 +3843,7 @@ SEASTAR_TEST_CASE(twcs_reshape_with_disjoint_set_test) {
|
||||
|
||||
std::vector<sstables::shared_sstable> sstables;
|
||||
sstables.reserve(disjoint_sstable_count);
|
||||
for (auto i = 0; i < disjoint_sstable_count; i++) {
|
||||
for (unsigned i = 0; i < disjoint_sstable_count; i++) {
|
||||
auto sst = make_sstable_containing(sst_gen, {make_row(i, std::chrono::hours(i))});
|
||||
sstables.push_back(std::move(sst));
|
||||
}
|
||||
@@ -3858,7 +3858,7 @@ SEASTAR_TEST_CASE(twcs_reshape_with_disjoint_set_test) {
|
||||
|
||||
std::vector<sstables::shared_sstable> sstables;
|
||||
sstables.reserve(disjoint_sstable_count);
|
||||
for (auto i = 0; i < disjoint_sstable_count; i++) {
|
||||
for (unsigned i = 0; i < disjoint_sstable_count; i++) {
|
||||
auto sst = make_sstable_containing(sst_gen, {make_row(i, std::chrono::hours(24*i))});
|
||||
sstables.push_back(std::move(sst));
|
||||
i++;
|
||||
@@ -3890,7 +3890,7 @@ SEASTAR_TEST_CASE(twcs_reshape_with_disjoint_set_test) {
|
||||
mutations_for_small_files.push_back(make_row(0, std::chrono::hours(1)));
|
||||
|
||||
std::vector<mutation> mutations_for_big_files;
|
||||
for (auto i = 0; i < keys.size(); i++) {
|
||||
for (unsigned i = 0; i < keys.size(); i++) {
|
||||
mutations_for_big_files.push_back(make_row(i, std::chrono::hours(1)));
|
||||
}
|
||||
|
||||
@@ -4100,7 +4100,7 @@ SEASTAR_TEST_CASE(max_ongoing_compaction_test) {
|
||||
});
|
||||
|
||||
// Make tables
|
||||
for (auto idx = 0; idx < num_tables; idx++) {
|
||||
for (unsigned idx = 0; idx < num_tables; idx++) {
|
||||
auto s = make_schema(idx);
|
||||
schemas.push_back(s);
|
||||
|
||||
@@ -4130,7 +4130,7 @@ SEASTAR_TEST_CASE(max_ongoing_compaction_test) {
|
||||
column_family_test(cf).add_sstable(sst).get();
|
||||
};
|
||||
|
||||
for (auto i = 0; i < num_tables; i++) {
|
||||
for (unsigned i = 0; i < num_tables; i++) {
|
||||
add_single_fully_expired_sstable_to_table(i);
|
||||
}
|
||||
|
||||
@@ -4809,7 +4809,7 @@ SEASTAR_TEST_CASE(test_print_shared_sstables_vector) {
|
||||
mut1.partition().apply_insert(*s, ss.make_ckey(1), ss.new_timestamp());
|
||||
ssts[1] = make_sstable_containing(sst_gen, {std::move(mut1)});
|
||||
|
||||
std::string msg = format("{}", ssts);
|
||||
std::string msg = seastar::format("{}", ssts);
|
||||
for (const auto& sst : ssts) {
|
||||
auto gen_str = format("{}", sst->generation());
|
||||
BOOST_REQUIRE(msg.find(gen_str) != std::string::npos);
|
||||
@@ -4988,14 +4988,14 @@ SEASTAR_TEST_CASE(cleanup_incremental_compaction_test) {
|
||||
dht::token_range_vector owned_token_ranges;
|
||||
|
||||
std::set<mutation, mutation_decorated_key_less_comparator> merged;
|
||||
for (auto i = 0; i < sstables_nr * 2; i++) {
|
||||
for (unsigned i = 0; i < sstables_nr * 2; i++) {
|
||||
merged.insert(make_insert(partition_key::from_exploded(*s, {to_bytes(to_sstring(i))})));
|
||||
}
|
||||
|
||||
std::unordered_set<sstables::generation_type> gens; // input sstable generations
|
||||
run_id run_identifier = run_id::create_random_id();
|
||||
auto merged_it = merged.begin();
|
||||
for (auto i = 0; i < sstables_nr; i++) {
|
||||
for (unsigned i = 0; i < sstables_nr; i++) {
|
||||
auto mut1 = std::move(*merged_it);
|
||||
merged_it++;
|
||||
auto mut2 = std::move(*merged_it);
|
||||
|
||||
@@ -751,7 +751,7 @@ void handle_proposal(unsigned nodes, std::vector<int> accepting_int) {
|
||||
output1 = fsm1.get_output();
|
||||
BOOST_CHECK(output1.messages.size() >= nodes - 1);
|
||||
BOOST_CHECK(output1.term_and_vote);
|
||||
for (int i = 2; i < nodes + 1; ++i) {
|
||||
for (unsigned i = 2; i < nodes + 1; ++i) {
|
||||
fsm1.step(raft::server_id{utils::UUID(0, i)}, raft::vote_reply{output1.term_and_vote->first, true, false});
|
||||
}
|
||||
BOOST_CHECK(fsm1.is_leader());
|
||||
|
||||
Reference in New Issue
Block a user