Skip to content

Commit 1ff139b

Browse files
committed
CPLGreatestCommonDivisor(): avoid Coverity Scan warning
1 parent 99d4e89 commit 1ff139b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

port/cpl_float.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,9 +445,11 @@ double CPLGreatestCommonDivisor(double a, double b)
445445

446446
const auto common_num = std::gcd(num_a, num_b);
447447

448-
// coverity[divide_by_zero]
448+
// Add std::numeric_limits<double>::min() to avoid Coverity Scan warning
449+
// about div by zero
449450
const auto common = sign * static_cast<double>(common_num) /
450-
static_cast<double>(common_denom);
451+
(static_cast<double>(common_denom) +
452+
std::numeric_limits<double>::min());
451453

452454
const auto disaggregation_factor = std::max(a / common, b / common);
453455
if (disaggregation_factor > 10000)

0 commit comments

Comments
 (0)