diff options
| author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2018-04-03 11:16:12 +0100 |
|---|---|---|
| committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2018-04-03 11:16:38 +0100 |
| commit | 6fc97c97ebfe2a82b90f1b69dbe1ed84bf51f1ac (patch) | |
| tree | a12dc40fcbdb41714aa8861f8b530a26046439bd /src/blockchain_utilities/blockchain_usage.cpp | |
| parent | 8361d60aef6e17908658128284899e3a11d808d4 (diff) | |
| download | monzero-core-6fc97c97ebfe2a82b90f1b69dbe1ed84bf51f1ac.tar.gz monzero-core-6fc97c97ebfe2a82b90f1b69dbe1ed84bf51f1ac.tar.xz monzero-core-6fc97c97ebfe2a82b90f1b69dbe1ed84bf51f1ac.zip | |
blockchain_usage: don't divide by 0 when there is nothing to process
Coverity 184942
Diffstat (limited to 'src/blockchain_utilities/blockchain_usage.cpp')
| -rw-r--r-- | src/blockchain_utilities/blockchain_usage.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/blockchain_utilities/blockchain_usage.cpp b/src/blockchain_utilities/blockchain_usage.cpp index 7c3c83167..c8afe0c7b 100644 --- a/src/blockchain_utilities/blockchain_usage.cpp +++ b/src/blockchain_utilities/blockchain_usage.cpp @@ -243,10 +243,17 @@ int main(int argc, char* argv[]) counts[out.second.size()]++; total++; } - for (const auto &c: counts) + if (total > 0) { - float percent = 100.f * c.second / total; - MINFO(std::to_string(c.second) << " outputs used " << c.first << " times (" << percent << "%)"); + for (const auto &c: counts) + { + float percent = 100.f * c.second / total; + MINFO(std::to_string(c.second) << " outputs used " << c.first << " times (" << percent << "%)"); + } + } + else + { + MINFO("No outputs to process"); } LOG_PRINT_L0("Blockchain usage exported OK"); |
