]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Fix 'comparison of integer expressions of different signedness' warning
authorRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 21 Oct 2022 09:30:30 +0000 (11:30 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 21 Oct 2022 09:30:30 +0000 (11:30 +0200)
We are making sure that our computation will not overflow the maximum
value of a `time_t`, and we know that this maximum value is positive,
so we can use a `size_t` to do the comparison.

pdns/dnsdistdist/dnsdist-backend.cc

index c99d72101ddfd6e5acb6e6399b6afd375f168cd9..a8a065fc15ed117c65f0f9db089f62aaafb70cf0 100644 (file)
@@ -588,7 +588,7 @@ void DownstreamState::updateNextLazyHealthCheck(LazyHealthCheckStats& stats)
       const uint16_t failedTests = currentCheckFailures;
       size_t backOffCoeff = std::pow(2U, failedTests);
       time_t backOff = d_config.d_lazyHealthCheckMaxBackOff;
-      if ((std::numeric_limits<time_t>::max() / d_config.d_lazyHealthCheckFailedInterval) >= backOffCoeff) {
+      if ((static_cast<size_t>(std::numeric_limits<time_t>::max()) / d_config.d_lazyHealthCheckFailedInterval) >= backOffCoeff) {
         backOff = d_config.d_lazyHealthCheckFailedInterval * backOffCoeff;
         if (backOff > d_config.d_lazyHealthCheckMaxBackOff || (std::numeric_limits<time_t>::max() - now) <= backOff) {
           backOff = d_config.d_lazyHealthCheckMaxBackOff;