wallet: fix some "may be used uninitialized" warnings
The compiler can't always work out the _found booleans are set iff the value is initialized.
This commit is contained in:
parent
4a41dd4068
commit
fbd7c359ee
|
@ -28,8 +28,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#define GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, name, type, jtype, mandatory) \
|
||||
type field_##name; \
|
||||
#define GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, name, type, jtype, mandatory, def) \
|
||||
type field_##name = def; \
|
||||
bool field_##name##_found = false; \
|
||||
(void)field_##name##_found; \
|
||||
do if (json.HasMember(#name)) \
|
||||
|
|
|
@ -979,22 +979,22 @@ bool simple_wallet::generate_from_json(const boost::program_options::variables_m
|
|||
return false;
|
||||
}
|
||||
|
||||
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, version, unsigned, Uint, true);
|
||||
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, version, unsigned, Uint, true, 0);
|
||||
const int current_version = 1;
|
||||
if (field_version > current_version) {
|
||||
fail_msg_writer() << boost::format(tr("Version %u too new, we can only grok up to %u")) % field_version % current_version;
|
||||
return false;
|
||||
}
|
||||
|
||||
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, filename, std::string, String, true);
|
||||
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, filename, std::string, String, true, std::string());
|
||||
|
||||
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, scan_from_height, uint64_t, Uint64, false);
|
||||
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, scan_from_height, uint64_t, Uint64, false, 0);
|
||||
bool recover = field_scan_from_height_found;
|
||||
|
||||
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, password, std::string, String, false);
|
||||
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, password, std::string, String, false, std::string());
|
||||
password = field_password;
|
||||
|
||||
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, viewkey, std::string, String, false);
|
||||
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, viewkey, std::string, String, false, std::string());
|
||||
crypto::secret_key viewkey;
|
||||
if (field_viewkey_found)
|
||||
{
|
||||
|
@ -1012,7 +1012,7 @@ bool simple_wallet::generate_from_json(const boost::program_options::variables_m
|
|||
}
|
||||
}
|
||||
|
||||
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, spendkey, std::string, String, false);
|
||||
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, spendkey, std::string, String, false, std::string());
|
||||
crypto::secret_key spendkey;
|
||||
if (field_spendkey_found)
|
||||
{
|
||||
|
@ -1030,7 +1030,7 @@ bool simple_wallet::generate_from_json(const boost::program_options::variables_m
|
|||
}
|
||||
}
|
||||
|
||||
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, seed, std::string, String, false);
|
||||
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, seed, std::string, String, false, std::string());
|
||||
std::string old_language;
|
||||
if (field_seed_found)
|
||||
{
|
||||
|
@ -1043,7 +1043,7 @@ bool simple_wallet::generate_from_json(const boost::program_options::variables_m
|
|||
m_restore_deterministic_wallet = true;
|
||||
}
|
||||
|
||||
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, address, std::string, String, false);
|
||||
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, address, std::string, String, false, std::string());
|
||||
|
||||
// compatibility checks
|
||||
if (!field_seed_found && !field_viewkey_found)
|
||||
|
|
|
@ -1495,26 +1495,25 @@ bool wallet2::load_keys(const std::string& keys_file_name, const std::string& pa
|
|||
const char *field_key_data = json["key_data"].GetString();
|
||||
account_data = std::string(field_key_data, field_key_data + json["key_data"].GetStringLength());
|
||||
|
||||
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, seed_language, std::string, String, false);
|
||||
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, seed_language, std::string, String, false, std::string());
|
||||
if (field_seed_language_found)
|
||||
{
|
||||
set_seed_language(field_seed_language);
|
||||
}
|
||||
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, watch_only, int, Int, false);
|
||||
m_watch_only = field_watch_only_found && field_watch_only;
|
||||
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, always_confirm_transfers, int, Int, false);
|
||||
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, watch_only, int, Int, false, false);
|
||||
m_watch_only = field_watch_only;
|
||||
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, always_confirm_transfers, int, Int, false, false);
|
||||
m_always_confirm_transfers = field_always_confirm_transfers_found && field_always_confirm_transfers;
|
||||
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, store_tx_keys, int, Int, false);
|
||||
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, store_tx_info, int, Int, false);
|
||||
m_store_tx_info = (field_store_tx_keys_found && (field_store_tx_keys != 0))
|
||||
|| (field_store_tx_info_found && (field_store_tx_info != 0));
|
||||
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, default_mixin, unsigned int, Uint, false);
|
||||
m_default_mixin = field_default_mixin_found ? field_default_mixin : 0;
|
||||
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, default_fee_multiplier, unsigned int, Uint, false);
|
||||
m_default_fee_multiplier = field_default_fee_multiplier_found ? field_default_fee_multiplier : 0;
|
||||
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, auto_refresh, int, Int, false);
|
||||
m_auto_refresh = !field_auto_refresh_found || (field_auto_refresh != 0);
|
||||
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, refresh_type, int, Int, false);
|
||||
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, store_tx_keys, int, Int, false, true);
|
||||
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, store_tx_info, int, Int, false, true);
|
||||
m_store_tx_info = ((field_store_tx_keys != 0) || (field_store_tx_info != 0));
|
||||
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, default_mixin, unsigned int, Uint, false, 0);
|
||||
m_default_mixin = field_default_mixin;
|
||||
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, default_fee_multiplier, unsigned int, Uint, false, 0);
|
||||
m_default_fee_multiplier = field_default_fee_multiplier;
|
||||
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, auto_refresh, int, Int, false, true);
|
||||
m_auto_refresh = field_auto_refresh;
|
||||
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, refresh_type, int, Int, false, RefreshType::RefreshDefault);
|
||||
m_refresh_type = RefreshType::RefreshDefault;
|
||||
if (field_refresh_type_found)
|
||||
{
|
||||
|
@ -1523,7 +1522,7 @@ bool wallet2::load_keys(const std::string& keys_file_name, const std::string& pa
|
|||
else
|
||||
LOG_PRINT_L0("Unknown refresh-type value (" << field_refresh_type << "), using default");
|
||||
}
|
||||
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, refresh_height, uint64_t, Uint64, false);
|
||||
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, refresh_height, uint64_t, Uint64, false, 0);
|
||||
if (field_refresh_height_found)
|
||||
m_refresh_from_block_height = field_refresh_height;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue