From 89a09828c9b297b4fd4294d9d99260a15e422b92 Mon Sep 17 00:00:00 2001 From: Otto Moerbeek Date: Mon, 17 Feb 2025 09:05:16 +0100 Subject: [PATCH 1/2] Coverity 1591604 Use of auto that causes a copy --- pdns/recursordist/ws-recursor.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pdns/recursordist/ws-recursor.cc b/pdns/recursordist/ws-recursor.cc index 52cdf5c1bda3..c48bf852b49d 100644 --- a/pdns/recursordist/ws-recursor.cc +++ b/pdns/recursordist/ws-recursor.cc @@ -1020,7 +1020,7 @@ void serveRustWeb() auto logPtr = g_slog->withName("webserver"); pdns::rust::misc::LogLevel loglevel = pdns::rust::misc::LogLevel::Normal; - auto configLevel = ::arg()["webserver-loglevel"]; + const auto& configLevel = ::arg()["webserver-loglevel"]; if (configLevel == "none") { loglevel = pdns::rust::misc::LogLevel::Normal; } From 776c2fe86aa1371f94f19f696813531f33a7d24d Mon Sep 17 00:00:00 2001 From: Otto Moerbeek Date: Mon, 17 Feb 2025 09:15:34 +0100 Subject: [PATCH 2/2] This should eliminate a dozen or so Coverity warnigs For example: 1591605 Data race condition 5. missing_lock: Accessing g_lowercaseOutgoing without holding lock LockGuarded, std::equal_to, std::allocator > > > >.d_mutex. Elsewhere, g_lowercaseOutgoing is written to with LockGuarded.d_mutex held 1 out of 1 times. --- pdns/recursordist/rec-main.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pdns/recursordist/rec-main.cc b/pdns/recursordist/rec-main.cc index 0666317678b3..0e2a66a55f71 100644 --- a/pdns/recursordist/rec-main.cc +++ b/pdns/recursordist/rec-main.cc @@ -2233,7 +2233,10 @@ static int serviceMain(Logr::log_t log) } g_networkTimeoutMsec = ::arg().asNum("network-timeout"); - std::tie(*g_initialDomainMap.lock(), *g_initialAllowNotifyFor.lock()) = parseZoneConfiguration(g_yamlSettings); + { // Reduce scope of locks (otherwise Coverity induces from this line the global vars below should be + // protected by a mutex) + std::tie(*g_initialDomainMap.lock(), *g_initialAllowNotifyFor.lock()) = parseZoneConfiguration(g_yamlSettings); + } g_latencyStatSize = ::arg().asNum("latency-statistic-size");