Skip to content

Commit

Permalink
Fix warning: possibly dangling reference to a temporary
Browse files Browse the repository at this point in the history
  • Loading branch information
tindy2013 committed Oct 11, 2023
1 parent 705e94e commit b281c99
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/handler/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -573,14 +573,14 @@ void operate_toml_kv_table(const std::vector<toml::table> &arr, const toml::key
{
for(const toml::table &table : arr)
{
const auto &key = table.at(key_name), value = table.at(value_name);
const auto &key = table.at(key_name), &value = table.at(value_name);
binary_op(key, value);
}
}

void readTOMLConf(toml::value &root)
{
const auto &section_common = toml::find(root, "common");
auto section_common = toml::find(root, "common");
string_array default_url, insert_url;

find_if_exist(section_common, "default_url", default_url, "insert_url", insert_url);
Expand Down Expand Up @@ -619,7 +619,7 @@ void readTOMLConf(toml::value &root)
safe_set_streams(toml::find_or<RegexMatchConfigs>(root, "userinfo", "stream_rule", RegexMatchConfigs{}));
safe_set_times(toml::find_or<RegexMatchConfigs>(root, "userinfo", "time_rule", RegexMatchConfigs{}));

const auto &section_node_pref = toml::find(root, "node_pref");
auto section_node_pref = toml::find(root, "node_pref");

find_if_exist(section_node_pref,
"udp_flag", global.UDPFlag,
Expand All @@ -638,7 +638,7 @@ void readTOMLConf(toml::value &root)
importItems(renameconfs, "rename_node", false);
safe_set_renames(toml::get<RegexMatchConfigs>(toml::value(renameconfs)));

const auto &section_managed = toml::find(root, "managed_config");
auto section_managed = toml::find(root, "managed_config");

find_if_exist(section_managed,
"write_managed_config", global.writeManagedConfig,
Expand All @@ -648,13 +648,13 @@ void readTOMLConf(toml::value &root)
"quanx_device_id", global.quanXDevID
);

const auto &section_surge_external = toml::find(root, "surge_external_proxy");
auto section_surge_external = toml::find(root, "surge_external_proxy");
find_if_exist(section_surge_external,
"surge_ssr_path", global.surgeSSRPath,
"resolve_hostname", global.surgeResolveHostname
);

const auto &section_emojis = toml::find(root, "emojis");
auto section_emojis = toml::find(root, "emojis");

find_if_exist(section_emojis,
"add_emoji", global.addEmoji,
Expand All @@ -669,7 +669,7 @@ void readTOMLConf(toml::value &root)
importItems(groups, "custom_groups", false);
global.customProxyGroups = toml::get<ProxyGroupConfigs>(toml::value(groups));

const auto &section_ruleset = toml::find(root, "ruleset");
auto section_ruleset = toml::find(root, "ruleset");

find_if_exist(section_ruleset,
"enabled", global.enableRuleGen,
Expand All @@ -681,7 +681,7 @@ void readTOMLConf(toml::value &root)
importItems(rulesets, "rulesets", false);
global.customRulesets = toml::get<RulesetConfigs>(toml::value(rulesets));

const auto &section_template = toml::find(root, "template");
auto section_template = toml::find(root, "template");

global.templatePath = toml::find_or(section_template, "template_path", "template");

Expand All @@ -702,7 +702,7 @@ void readTOMLConf(toml::value &root)
global.cronTasks = toml::get<CronTaskConfigs>(toml::value(tasks));
refresh_schedule();

const auto &section_server = toml::find(root, "server");
auto section_server = toml::find(root, "server");

find_if_exist(section_server,
"listen", global.listenAddress,
Expand All @@ -711,7 +711,7 @@ void readTOMLConf(toml::value &root)
);
webServer.serve_file = !webServer.serve_file_root.empty();

const auto &section_advanced = toml::find(root, "advanced");
auto section_advanced = toml::find(root, "advanced");

std::string log_level;
bool enable_cache = true;
Expand Down Expand Up @@ -1135,7 +1135,7 @@ int loadExternalYAML(YAML::Node &node, ExternalConfig &ext)

int loadExternalTOML(toml::value &root, ExternalConfig &ext)
{
const auto &section = toml::find(root, "custom");
auto section = toml::find(root, "custom");

find_if_exist(section,
"enable_rule_generator", ext.enable_rule_generator,
Expand Down

0 comments on commit b281c99

Please sign in to comment.