Skip to content

Commit

Permalink
fault_injection_fs: Add back accidental revert in DropRandomUnsyncedD…
Browse files Browse the repository at this point in the history
…ata (#402)

Code was accidentally dropped during recent PR (#380)
  • Loading branch information
mrambacher authored and ayulas committed Feb 26, 2023
1 parent b3fe18a commit 60e2ca9
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions utilities/fault_injection_fs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,11 @@ IOStatus FSFileState::DropUnsyncedData() {
}

IOStatus FSFileState::DropRandomUnsyncedData(Random* rand) {
int range = static_cast<int>(buffer_.size());
size_t truncated_size = static_cast<size_t>(rand->Uniform(range));
buffer_.resize(truncated_size);
const int range = static_cast<int>(buffer_.size());
if (range > 0) {
size_t truncated_size = static_cast<size_t>(rand->Uniform(range));
buffer_.resize(truncated_size);
}
return IOStatus::OK();
}

Expand Down

0 comments on commit 60e2ca9

Please sign in to comment.