Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dnsdist: Fix possible low impact performance issues reported by Coverity #15070

Merged
merged 1 commit into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading