]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Fix a warning about long to double conversion 12283/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 6 Dec 2022 16:43:12 +0000 (17:43 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 6 Dec 2022 16:43:12 +0000 (17:43 +0100)
```
dnsdist-backend.cc:601:61: warning: implicit conversion from 'long' to 'double' changes value from 9223372036854775807 to 9223372036854775808 [-Wimplicit-const-int-float-conversion]
      if (backOffCoeffTmp != HUGE_VAL && backOffCoeffTmp <= std::numeric_limits<time_t>::max()) {
                                                         ~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

pdns/dnsdistdist/dnsdist-backend.cc

index 562cb8abe84026f7be73a61583b63aaf7e6e7695..701bef77521f8dcf5f50967718b230f759f1859f 100644 (file)
@@ -598,7 +598,7 @@ void DownstreamState::updateNextLazyHealthCheck(LazyHealthCheckStats& stats, boo
 
       time_t backOff = d_config.d_lazyHealthCheckMaxBackOff;
       double backOffCoeffTmp = std::pow(2.0, failedTests);
-      if (backOffCoeffTmp != HUGE_VAL && backOffCoeffTmp <= std::numeric_limits<time_t>::max()) {
+      if (backOffCoeffTmp != HUGE_VAL && static_cast<uint64_t>(backOffCoeffTmp) <= static_cast<uint64_t>(std::numeric_limits<time_t>::max())) {
         time_t backOffCoeff = static_cast<time_t>(backOffCoeffTmp);
         if ((std::numeric_limits<time_t>::max() / d_config.d_lazyHealthCheckFailedInterval) >= backOffCoeff) {
           backOff = d_config.d_lazyHealthCheckFailedInterval * backOffCoeff;