From: Remi Gacogne Date: Mon, 20 Nov 2023 13:13:20 +0000 (+0100) Subject: auth: Fix unnecessary copies reported by Coverity X-Git-Tag: rec-5.0.0-rc1~28^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3b45a4347c8af1b28e6871597221eb906c143a29;p=thirdparty%2Fpdns.git auth: Fix unnecessary copies reported by Coverity --- diff --git a/modules/remotebackend/remotebackend.cc b/modules/remotebackend/remotebackend.cc index 2cb6d5f930..887d2b8f4a 100644 --- a/modules/remotebackend/remotebackend.cc +++ b/modules/remotebackend/remotebackend.cc @@ -162,7 +162,7 @@ int RemoteBackend::build() key = opt.substr(0, pos); val = opt.substr(pos + 1); } - options[key] = val; + options[key] = std::move(val); } // connectors know what they are doing diff --git a/pdns/arguments.cc b/pdns/arguments.cc index 6406995153..f87fa39b1d 100644 --- a/pdns/arguments.cc +++ b/pdns/arguments.cc @@ -441,7 +441,7 @@ void ArgvMap::parseOne(const string& arg, const string& parseOnly, bool lax) vector parts; stringtok(parts, d_params["ignore-unknown-settings"], " ,\t\n\r"); if (find(parts.begin(), parts.end(), var) != parts.end()) { - d_unknownParams[var] = val; + d_unknownParams[var] = std::move(val); SLOG(g_log << Logger::Warning << "Ignoring unknown setting '" << var << "' as requested" << endl, d_log->info(Logr::Warning, "Ignoring unknown setting as requested", "name", Logging::Loggable(var))); return; diff --git a/pdns/gss_context.cc b/pdns/gss_context.cc index 4d5b7e7412..a59296df6c 100644 --- a/pdns/gss_context.cc +++ b/pdns/gss_context.cc @@ -556,7 +556,7 @@ bool gss_add_signature(const DNSName& context, const std::string& message, std:: } return false; } - mac = tmp_mac; + mac = std::move(tmp_mac); return true; } diff --git a/pdns/rcpgenerator.cc b/pdns/rcpgenerator.cc index 00a53de67a..7ff9a7be76 100644 --- a/pdns/rcpgenerator.cc +++ b/pdns/rcpgenerator.cc @@ -257,19 +257,22 @@ void RecordTextReader::xfrName(DNSName& val, bool, bool) const char* strptr=d_string.c_str(); string::size_type begin_pos = d_pos; - while(d_pos < d_end) { - if(strptr[d_pos]!='\r' && dns_isspace(strptr[d_pos])) + while (d_pos < d_end) { + if (strptr[d_pos]!='\r' && dns_isspace(strptr[d_pos])) { break; + } d_pos++; } sval = DNSName(std::string(strptr+begin_pos, strptr+d_pos)); - if(sval.empty()) - sval=d_zone; - else if(!d_zone.empty()) - sval+=d_zone; - val = sval; + if (sval.empty()) { + sval = d_zone; + } + else if (!d_zone.empty()) { + sval += d_zone; + } + val = std::move(sval); } static bool isbase64(char c, bool acceptspace) diff --git a/pdns/sdig.cc b/pdns/sdig.cc index 05bfc7d6e8..60d14b6bfe 100644 --- a/pdns/sdig.cc +++ b/pdns/sdig.cc @@ -423,7 +423,7 @@ try { Socket sock(dest.sin4.sin_family, SOCK_STREAM); sock.setNonBlocking(); setTCPNoDelay(sock.getHandle()); // disable NAGLE, which does not play nicely with delayed ACKs - TCPIOHandler handler(subjectName, false, sock.releaseHandle(), timeout, tlsCtx); + TCPIOHandler handler(subjectName, false, sock.releaseHandle(), timeout, std::move(tlsCtx)); handler.connect(fastOpen, dest, timeout); // we are writing the proxyheader inside the TLS connection. Is that right? if (proxyheader.size() > 0 && handler.write(proxyheader.data(), proxyheader.size(), timeout) != proxyheader.size()) { diff --git a/pdns/tsigverifier.cc b/pdns/tsigverifier.cc index 05e7b2a3f6..b530017975 100644 --- a/pdns/tsigverifier.cc +++ b/pdns/tsigverifier.cc @@ -62,13 +62,14 @@ bool TSIGTCPVerifier::check(const string& data, const MOADNSParser& mdp) } // Reset and store some values for the next chunks. - d_prevMac = theirMac; + d_prevMac = std::move(theirMac); d_nonSignedMessages = 0; d_signData.clear(); d_tsigPos = 0; } - else + else { d_nonSignedMessages++; + } return true; } diff --git a/pdns/ueberbackend.cc b/pdns/ueberbackend.cc index a5981a7e7b..ebf0129a57 100644 --- a/pdns/ueberbackend.cc +++ b/pdns/ueberbackend.cc @@ -564,7 +564,7 @@ bool UeberBackend::getSOAUncached(const DNSName& domain, SOAData& soaData) zoneRecord.dr.d_ttl = soaData.ttl; zoneRecord.domain_id = soaData.domain_id; - addCache(d_question, {zoneRecord}); + addCache(d_question, {std::move(zoneRecord)}); } return true; } diff --git a/pdns/webserver.cc b/pdns/webserver.cc index aadea06b43..98431a07d8 100644 --- a/pdns/webserver.cc +++ b/pdns/webserver.cc @@ -346,7 +346,7 @@ void WebServer::handleRequest(HttpRequest& req, HttpResponse& resp) const resp.body = "" + what + "

" + what + "

"; } else { resp.headers["Content-Type"] = "text/plain; charset=utf-8"; - resp.body = what; + resp.body = std::move(what); } } @@ -385,7 +385,7 @@ void WebServer::logRequest(const HttpRequest& req, [[maybe_unused]] const ComboA #ifdef RECURSOR if (!g_slogStructured) { #endif - auto logprefix = req.logprefix; + const auto& logprefix = req.logprefix; g_log<setCatalog(zonename, DNSName(defaultCatalog)); } diff --git a/pdns/zoneparser-tng.cc b/pdns/zoneparser-tng.cc index b042ede33a..1ab6c7119a 100644 --- a/pdns/zoneparser-tng.cc +++ b/pdns/zoneparser-tng.cc @@ -271,7 +271,7 @@ bool ZoneParserTNG::getTemplateLine() d_templatecounter += d_templatestep; } - d_line = retline; + d_line = std::move(retline); return true; }