blockchain_usage: don't divide by 0 when there is nothing to process

Coverity 184942
This commit is contained in:
moneromooo-monero 2018-04-03 11:16:12 +01:00
parent 8361d60aef
commit 6fc97c97eb
No known key found for this signature in database
GPG Key ID: 686F07454D6CEFC3

View File

@ -243,11 +243,18 @@ int main(int argc, char* argv[])
counts[out.second.size()]++; counts[out.second.size()]++;
total++; total++;
} }
if (total > 0)
{
for (const auto &c: counts) for (const auto &c: counts)
{ {
float percent = 100.f * c.second / total; float percent = 100.f * c.second / total;
MINFO(std::to_string(c.second) << " outputs used " << c.first << " times (" << percent << "%)"); 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"); LOG_PRINT_L0("Blockchain usage exported OK");
return 0; return 0;