Skip to content

Commit

Permalink
Merge pull request #15070 from rgacogne/ddist-coverity-20250121
Browse files Browse the repository at this point in the history
dnsdist: Fix possible low impact performance issues reported by Coverity
  • Loading branch information
rgacogne authored Jan 23, 2025
2 parents 9a9bed3 + c95c94f commit 010b23d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions pdns/dnsdistdist/dnsdist-configuration-yaml.cc
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ static void loadBinds(const ::rust::Vec<dnsdist::rust::settings::BindConfigurati
/* also create the UDP listener */
state = std::make_shared<ClientState>(ComboAddress(std::string(bind.listen_address), defaultPort), false, bind.reuseport, bind.tcp.fast_open_queue_size, std::string(bind.interface), cpus, false);
#if defined(HAVE_DNSCRYPT)
state->dnscryptCtx = dnsCryptContext;
state->dnscryptCtx = std::move(dnsCryptContext);
#endif /* defined(HAVE_DNSCRYPT) */
#if defined(HAVE_XSK)
if (xskMap) {
Expand Down Expand Up @@ -739,7 +739,7 @@ static void loadWebServer(const dnsdist::rust::settings::WebserverConfiguration&
catch (const PDNSException& e) {
throw std::runtime_error(std::string("Error parsing the bind address for the webserver: ") + e.reason);
}
dnsdist::configuration::updateRuntimeConfiguration([local, webConfig](dnsdist::configuration::RuntimeConfiguration& config) {
dnsdist::configuration::updateRuntimeConfiguration([local, &webConfig](dnsdist::configuration::RuntimeConfiguration& config) {
config.d_webServerAddress = local;
if (!webConfig.password.empty()) {
auto holder = std::make_shared<CredentialsHolder>(std::string(webConfig.password), webConfig.hash_plaintext_credentials);
Expand Down Expand Up @@ -872,7 +872,7 @@ static void handleLoggingConfiguration(const dnsdist::rust::settings::LoggingCon
}
}

dnsdist::logging::LoggingConfiguration::setStructuredLogging(true, levelPrefix);
dnsdist::logging::LoggingConfiguration::setStructuredLogging(true, std::move(levelPrefix));
}
}

Expand Down Expand Up @@ -1310,7 +1310,7 @@ std::shared_ptr<DNSResponseActionWrapper> getLimitTTLResponseAction(const LimitT
capTypes.insert(QType(type));
}

auto action = dnsdist::actions::getLimitTTLResponseAction(config.min, config.max, capTypes);
auto action = dnsdist::actions::getLimitTTLResponseAction(config.min, config.max, std::move(capTypes));
return newDNSResponseActionWrapper(std::move(action), config.name);
}

Expand Down Expand Up @@ -1432,7 +1432,7 @@ std::shared_ptr<DNSActionWrapper> getDnstapLogAction(const DnstapLogActionConfig
}
dnsdist::actions::DnstapAlterFunction alterFunc;
dnsdist::configuration::yaml::getLuaFunctionFromConfiguration(alterFunc, config.alter_function_name, config.alter_function_code, config.alter_function_file, "dnstap log action");
auto action = dnsdist::actions::getDnstapLogAction(std::string(config.identity), logger, alterFunc);
auto action = dnsdist::actions::getDnstapLogAction(std::string(config.identity), std::move(logger), std::move(alterFunc));
return newDNSActionWrapper(std::move(action), config.name);
#endif
}
Expand All @@ -1448,7 +1448,7 @@ std::shared_ptr<DNSResponseActionWrapper> getDnstapLogResponseAction(const Dnsta
}
dnsdist::actions::DnstapAlterResponseFunction alterFunc;
dnsdist::configuration::yaml::getLuaFunctionFromConfiguration(alterFunc, config.alter_function_name, config.alter_function_code, config.alter_function_file, "dnstap log response action");
auto action = dnsdist::actions::getDnstapLogResponseAction(std::string(config.identity), logger, alterFunc);
auto action = dnsdist::actions::getDnstapLogResponseAction(std::string(config.identity), std::move(logger), std::move(alterFunc));
return newDNSResponseActionWrapper(std::move(action), config.name);
#endif
}
Expand Down
2 changes: 1 addition & 1 deletion pdns/dnsdistdist/dnsdist-lua-actions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ void setupLuaActions(LuaContext& luaCtx)
capTypes.insert(QType(type));
}
}
return dnsdist::actions::getLimitTTLResponseAction(min, max, capTypes);
return dnsdist::actions::getLimitTTLResponseAction(min, max, std::move(capTypes));
});

luaCtx.writeFunction("SetMinTTLResponseAction", [](uint32_t min) {
Expand Down
2 changes: 1 addition & 1 deletion pdns/dnsdistdist/dnsdist-lua.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2104,7 +2104,7 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck)
}
setLuaSideEffect();
if (facility.type() == typeid(std::string)) {
auto facilityStr = boost::get<std::string>(facility);
const auto& facilityStr = boost::get<std::string>(facility);
auto facilityLevel = logFacilityFromString(facilityStr);
if (!facilityLevel) {
g_outputBuffer = "Unknown facility '" + facilityStr + "' passed to setSyslogFacility()!\n";
Expand Down

0 comments on commit 010b23d

Please sign in to comment.