Skip to content

Commit

Permalink
ErrorCounter: Fix CID 1164538 (Division or modulo by float zero)
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Weil <[email protected]>
  • Loading branch information
stweil committed Oct 22, 2018
1 parent 8f615d4 commit eaabe4a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/classify/errorcounter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ double ErrorCounter::ComputeErrorRate(ShapeClassifier* classifier,
GenericVector<UnicharRating> results;

clock_t start = clock();
int total_samples = 0;
unsigned total_samples = 0;
double unscaled_error = 0.0;
// Set a number of samples on which to run the classify debug mode.
int error_samples = report_level > 3 ? report_level * report_level : 0;
Expand Down Expand Up @@ -89,7 +89,7 @@ double ErrorCounter::ComputeErrorRate(ShapeClassifier* classifier,
fontinfo_table,
*it, unichar_error, fonts_report);
if (scaled_error != nullptr) *scaled_error = counter.scaled_error_;
if (report_level > 1) {
if (report_level > 1 && total_samples > 0) {
// It is useful to know the time in microseconds/char.
tprintf("Errors computed in %.2fs at %.1f μs/char\n",
total_time, 1000000.0 * total_time / total_samples);
Expand Down

0 comments on commit eaabe4a

Please sign in to comment.