Skip to content

Commit

Permalink
Fix Clang static analyzer warning in db_bench (#4910)
Browse files Browse the repository at this point in the history
Summary:
Fixed clang static analyzer warning about division by 0.
```
ar: creating librocksdb_debug.a
tools/db_bench_tool.cc:4650:43: warning: Division by zero
      int pos = static_cast<int>(rand_num % range_);
                                 ~~~~~~~~~^~~~~~~~
1 warning generated.
make: *** [analyze] Error 1
```

This is from the new code I recently merged in ce8e88d.
Pull Request resolved: #4910

Differential Revision: D13788037

Pulled By: sagar0

fbshipit-source-id: f48851dca85047c19fbb1a361e25ce643aa4c7ea
  • Loading branch information
sagar0 authored and facebook-github-bot committed Jan 23, 2019
1 parent 5bf9419 commit 0cead31
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions tools/db_bench_tool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4647,6 +4647,7 @@ void VerifyDBFromDB(std::string& truth_db_name) {
if (rand_num < 0) {
rand_num = rand_num * (-1);
}
assert(range_ != 0);
int pos = static_cast<int>(rand_num % range_);
for (int i = 0; i < static_cast<int>(type_.size()); i++) {
if (pos < type_[i]) {
Expand Down

0 comments on commit 0cead31

Please sign in to comment.