refactor: [gui] Use SettingTo<int64_t> over deprecated SettingToInt
What changed, and why it matters
This is a routine code cleanup in Bitcoin Core's graphical user interface. It replaces a few internal helper function calls with their newer equivalents and removes the old, now-unused helper aliases. The commit message explicitly states this does not change behavior, and the diff shows identical logic with only renamed function calls.
No security action needed. This is a non-functional refactor.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit refactors src/qt/optionsmodel.cpp to call the template function SettingTo<int64_t> directly instead of the deprecated inline wrappers SettingToInt. It then removes those two unused SettingToInt aliases from src/common/args.h. The call sites, default values, and return-value handling remain unchanged.
Changed components
src/common/args.hsrc/qt/optionsmodel.cppInspect captured patch +4 / −7
diff --git a/src/common/args.h b/src/common/args.h
index 477f2cbf..ea4e173b 100644
--- a/src/common/args.h
+++ b/src/common/args.h
@@ -96,9 +96,6 @@ Int SettingTo(const common::SettingsValue&, Int);
template <std::integral Int>
std::optional<Int> SettingTo(const common::SettingsValue&);
-inline int64_t SettingToInt(const common::SettingsValue& value, int64_t nDefault) { return SettingTo<int64_t>(value, nDefault); }
-inline std::optional<int64_t> SettingToInt(const common::SettingsValue& value) { return SettingTo<int64_t>(value); }
-
bool SettingToBool(const common::SettingsValue&, bool);
std::optional<bool> SettingToBool(const common::SettingsValue&);
diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp
index 3d876a8f..cfbc350f 100644
--- a/src/qt/optionsmodel.cpp
+++ b/src/qt/optionsmodel.cpp
@@ -88,14 +88,14 @@ static common::SettingsValue PruneSetting(bool prune_enabled, int prune_size_gb)
static bool PruneEnabled(const common::SettingsValue& prune_setting)
{
// -prune=1 setting is manual pruning mode, so disabled for purposes of the gui
- return SettingToInt(prune_setting, 0) > 1;
+ return SettingTo<int64_t>(prune_setting, 0) > 1;
}
//! Get pruning size value to show in GUI from bitcoin -prune setting. If
//! pruning is not enabled, just show default recommended pruning size (2GB).
static int PruneSizeGB(const common::SettingsValue& prune_setting)
{
- int value = SettingToInt(prune_setting, 0);
+ int value = SettingTo<int64_t>(prune_setting, 0);
return value > 1 ? PruneMiBtoGB(value) : DEFAULT_PRUNE_TARGET_GB;
}
@@ -469,9 +469,9 @@ QVariant OptionsModel::getOption(OptionID option, const std::string& suffix) con
suffix.empty() ? getOption(option, "-prev") :
DEFAULT_PRUNE_TARGET_GB;
case DatabaseCache:
- return qlonglong(SettingToInt(setting(), DEFAULT_DB_CACHE >> 20));
+ return qlonglong(SettingTo<int64_t>(setting(), DEFAULT_DB_CACHE >> 20));
case ThreadsScriptVerif:
- return qlonglong(SettingToInt(setting(), DEFAULT_SCRIPTCHECK_THREADS));
+ return qlonglong(SettingTo<int64_t>(setting(), DEFAULT_SCRIPTCHECK_THREADS));
case Listen:
return SettingToBool(setting(), DEFAULT_LISTEN);
case Server:
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.