[PATCH v2 1/2] ReportsBase.cc: Remove possible division by zero
Ryan Long
ryan.long at oarcorp.com
Tue Jun 29 17:44:24 UTC 2021
CID 1503709: Division or modulo by float zero
Closes #4415
---
tester/covoar/ReportsBase.cc | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/tester/covoar/ReportsBase.cc b/tester/covoar/ReportsBase.cc
index b4a755c..328980d 100644
--- a/tester/covoar/ReportsBase.cc
+++ b/tester/covoar/ReportsBase.cc
@@ -482,9 +482,11 @@ void ReportsBase::WriteSummaryReport(
}
}
- percentage = (double) notExecuted;
- percentage /= (double) totalBytes;
- percentage *= 100.0;
+ if ( totalBytes == 0 ) {
+ percentage = 0;
+ } else {
+ percentage = 100.0 * (double) notExecuted / totalBytes;
+ }
percentageBranches = (double) (
SymbolsToAnalyze->getNumberBranchesAlwaysTaken(symbolSetName) +
--
1.8.3.1
More information about the devel
mailing list