Skip to content

Commit b281c99

Browse files
committed
Fix warning: possibly dangling reference to a temporary
1 parent 705e94e commit b281c99

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/handler/settings.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -573,14 +573,14 @@ void operate_toml_kv_table(const std::vector<toml::table> &arr, const toml::key
573573
{
574574
for(const toml::table &table : arr)
575575
{
576-
const auto &key = table.at(key_name), value = table.at(value_name);
576+
const auto &key = table.at(key_name), &value = table.at(value_name);
577577
binary_op(key, value);
578578
}
579579
}
580580

581581
void readTOMLConf(toml::value &root)
582582
{
583-
const auto &section_common = toml::find(root, "common");
583+
auto section_common = toml::find(root, "common");
584584
string_array default_url, insert_url;
585585

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

622-
const auto &section_node_pref = toml::find(root, "node_pref");
622+
auto section_node_pref = toml::find(root, "node_pref");
623623

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

641-
const auto &section_managed = toml::find(root, "managed_config");
641+
auto section_managed = toml::find(root, "managed_config");
642642

643643
find_if_exist(section_managed,
644644
"write_managed_config", global.writeManagedConfig,
@@ -648,13 +648,13 @@ void readTOMLConf(toml::value &root)
648648
"quanx_device_id", global.quanXDevID
649649
);
650650

651-
const auto &section_surge_external = toml::find(root, "surge_external_proxy");
651+
auto section_surge_external = toml::find(root, "surge_external_proxy");
652652
find_if_exist(section_surge_external,
653653
"surge_ssr_path", global.surgeSSRPath,
654654
"resolve_hostname", global.surgeResolveHostname
655655
);
656656

657-
const auto &section_emojis = toml::find(root, "emojis");
657+
auto section_emojis = toml::find(root, "emojis");
658658

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

672-
const auto &section_ruleset = toml::find(root, "ruleset");
672+
auto section_ruleset = toml::find(root, "ruleset");
673673

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

684-
const auto &section_template = toml::find(root, "template");
684+
auto section_template = toml::find(root, "template");
685685

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

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

705-
const auto &section_server = toml::find(root, "server");
705+
auto section_server = toml::find(root, "server");
706706

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

714-
const auto &section_advanced = toml::find(root, "advanced");
714+
auto section_advanced = toml::find(root, "advanced");
715715

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

11361136
int loadExternalTOML(toml::value &root, ExternalConfig &ext)
11371137
{
1138-
const auto &section = toml::find(root, "custom");
1138+
auto section = toml::find(root, "custom");
11391139

11401140
find_if_exist(section,
11411141
"enable_rule_generator", ext.enable_rule_generator,

0 commit comments

Comments
 (0)