aboutsummaryrefslogtreecommitdiff
path: root/src/blockchain_utilities/blockchain_usage.cpp
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2018-04-03 11:16:12 +0100
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2018-04-03 11:16:38 +0100
commit6fc97c97ebfe2a82b90f1b69dbe1ed84bf51f1ac (patch)
treea12dc40fcbdb41714aa8861f8b530a26046439bd /src/blockchain_utilities/blockchain_usage.cpp
parentMerge pull request #3434 (diff)
downloadmonero-6fc97c97ebfe2a82b90f1b69dbe1ed84bf51f1ac.tar.xz
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.cpp13
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");