]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Fix Coverity's false positives
authorRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 20 May 2025 08:08:49 +0000 (10:08 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 20 May 2025 08:08:49 +0000 (10:08 +0200)
pdns/dnsdistdist/dnsdist-lua-bindings-dnsquestion.cc
pdns/dnsdistdist/dnsdist-metrics.cc
pdns/dnsdistdist/dnsdist.hh

index 4136d9c2d3337725f1b0b15226c95e67ad6c9286..049b88a5c18c84c61a5a22f3145c1e5c60fe9750 100644 (file)
@@ -168,7 +168,8 @@ void setupLuaBindingsDNSQuestion([[maybe_unused]] LuaContext& luaCtx)
     return {};
   });
 
-  luaCtx.registerFunction<std::string (DNSQuestion::*)() const>("getProtocol", [](const DNSQuestion& dnsQuestion) {
+  luaCtx.registerFunction<std::string (DNSQuestion::*)() const>("getProtocol", [](const DNSQuestion& dnsQuestion) -> std::string {
+    // coverity[auto_causes_copy]
     return dnsQuestion.getProtocol().toPrettyString();
   });
 
@@ -208,7 +209,7 @@ void setupLuaBindingsDNSQuestion([[maybe_unused]] LuaContext& luaCtx)
     }
     return tagIt->second;
   });
-  luaCtx.registerFunction<QTag (DNSQuestion::*)(void) const>("getTagArray", [](const DNSQuestion& dnsQuestion) {
+  luaCtx.registerFunction<QTag (DNSQuestion::*)(void) const>("getTagArray", [](const DNSQuestion& dnsQuestion) -> QTag {
     if (!dnsQuestion.ids.qTag) {
       QTag empty;
       return empty;
@@ -581,7 +582,7 @@ void setupLuaBindingsDNSQuestion([[maybe_unused]] LuaContext& luaCtx)
     return std::string();
   });
 
-  luaCtx.registerFunction<LuaAssociativeTable<std::string> (DNSQuestion::*)(void) const>("getHTTPHeaders", [](const DNSQuestion& dnsQuestion) {
+  luaCtx.registerFunction<LuaAssociativeTable<std::string> (DNSQuestion::*)(void) const>("getHTTPHeaders", [](const DNSQuestion& dnsQuestion) -> LuaAssociativeTable<std::string> {
 #if defined(HAVE_DNS_OVER_HTTPS)
     if (dnsQuestion.ids.du) {
       // coverity[auto_causes_copy]
index 4ec0fed4968d4cd939951cc6d5d5ef11e5627510..cbb237ed0b845e92482e9d26b4c535616c8c9150 100644 (file)
@@ -269,6 +269,8 @@ static std::variant<MetricValueType, Error> updateMetric(const std::string_view&
 
   /* OK, so we the metric exists (otherwise we would have returned an Error) but the label doesn't yet */
   {
+    // too bad Coverity claims to understand C++ yet does not understand RAII
+    // coverity[double_lock]
     auto writeLockedMap = metricMap.write_lock();
     auto labelsMapIt = writeLockedMap->find(name);
     if (labelsMapIt == writeLockedMap->end()) {
index b2826ccf9da3f049e5b59a0236d20ffe750c4575..6624e86a45214cde2e122bd68ed820fa46b78e60 100644 (file)
@@ -967,6 +967,7 @@ struct ServerPool
   void removeServer(shared_ptr<DownstreamState>& server);
   bool isTCPOnly() const
   {
+    // coverity[missing_lock]
     return d_tcpOnly;
   }