raft: don't compare signed and unsigned types

gcc warns it can lead to undefined behavior, though 2G entries
in a list of mutations are unlikely. Use the correct type for iteration.
This commit is contained in:
Avi Kivity
2022-11-28 21:47:48 +02:00
parent f565db75ce
commit fb6804e7a4

View File

@@ -244,7 +244,7 @@ size_t log::apply_snapshot(snapshot_descriptor&& snp, size_t max_trailing_entrie
} else {
auto entries_to_remove = _log.size() - (last_idx() - idx);
size_t trailing_bytes = 0;
for (int i = 0; i < max_trailing_entries && entries_to_remove > 0; ++i) {
for (size_t i = 0; i < max_trailing_entries && entries_to_remove > 0; ++i) {
trailing_bytes += memory_usage_of(*_log[entries_to_remove - 1], _max_command_size);
if (trailing_bytes > max_trailing_bytes) {
break;