Skip to content

Commit 903e0a0

Browse files
committed
Fix uninitialized variable warnings
1 parent eebc8cb commit 903e0a0

25 files changed

+214
-215
lines changed

src/coin_containers.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ namespace lelantus {
6363
// Use this version of code in case you need mobile api
6464
struct MintValueData {
6565
bool isJMint = false;
66-
uint64_t amount;
66+
uint64_t amount = 0;
6767
std::vector<unsigned char> encryptedValue;
6868
uint256 txHash;
6969

src/crypto/Lyra2Z/Lyra2.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ int LYRA2(void *K, uint64_t kLen, const void *pwd, uint64_t pwdlen, const void *
4949
int64_t row = 2; //index of row to be processed
5050
int64_t prev = 1; //index of prev (last row ever computed/modified)
5151
int64_t rowa = 0; //index of row* (a previous row, deterministically picked during Setup and randomly picked while Wandering)
52-
int64_t tau; //Time Loop iterator
5352
int64_t step = 1; //Visitation step (used during Setup and Wandering phases)
5453
int64_t window = 2; //Visitation window (used to define which rows can be revisited during Setup)
5554
int64_t gap = 1; //Modifier to the step, assuming the values 1 or -1
56-
int64_t i; //auxiliary iteration counter
55+
uint64_t tau = 0; //Time Loop iterator
56+
uint64_t i = 0; //auxiliary iteration counter
5757
//==========================================================================/
5858

5959
//========== Initializing the Memory Matrix and pointers to it =============//
@@ -218,11 +218,11 @@ int LYRA2_old(void *K, uint64_t kLen, const void *pwd, uint64_t pwdlen, const vo
218218
int64_t row = 2; //index of row to be processed
219219
int64_t prev = 1; //index of prev (last row ever computed/modified)
220220
int64_t rowa = 0; //index of row* (a previous row, deterministically picked during Setup and randomly picked while Wandering)
221-
int64_t tau; //Time Loop iterator
222221
int64_t step = 1; //Visitation step (used during Setup and Wandering phases)
223222
int64_t window = 2; //Visitation window (used to define which rows can be revisited during Setup)
224223
int64_t gap = 1; //Modifier to the step, assuming the values 1 or -1
225-
int64_t i; //auxiliary iteration counter
224+
uint64_t tau = 0; //Time Loop iterator
225+
uint64_t i = 0; //auxiliary iteration counter
226226
//==========================================================================/
227227

228228
//========== Initializing the Memory Matrix and pointers to it =============//

src/crypto/MerkleTreeProof/merkle-tree.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ MerkleTree::Buffer MerkleTree::merkleRoot(const Elements& elements,
9090
MerkleTree::Elements MerkleTree::getProof(const Buffer& element) const
9191
{
9292
bool found = false;
93-
size_t index;
93+
size_t index = 0;
9494
for (size_t i = 0; (i < elements_.size()) && !found; ++i) {
9595
if (elements_[i] == element) {
9696
found = true;

src/crypto/MerkleTreeProof/mtp.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,7 @@ bool mtp_verify(const char* input, const uint32_t target,
280280
}
281281

282282
// step 7
283-
uint256 y[L + 1];
284-
std::memset(&y[0], 0, sizeof(y));
283+
uint256 y[L + 1] = {};
285284

286285
blake2b_state state_y0;
287286
blake2b_init(&state_y0, 32); // 256 bit
@@ -521,8 +520,8 @@ bool mtp_hash1(const char* input, uint32_t target, uint8_t hash_root_mtp[16],
521520
return false;
522521
}
523522

524-
std::memset(&y[0], 0, sizeof(y));
525-
std::memset(&blocks[0], 0, sizeof(sizeof(block) * L * 2));
523+
std::fill(std::begin(y), std::end(y), uint256());
524+
std::fill(std::begin(blocks), std::end(blocks), block());
526525

527526
blake2b_state state;
528527
blake2b_init(&state, 32); // 256 bit

src/init.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1483,7 +1483,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
14831483
return InitError(_("Unable to start HTTP server. See debug log for details."));
14841484
}
14851485

1486-
int64_t nStart;
1486+
int64_t nStart = 0;
14871487

14881488
// ********************************************************* Step 5: verify wallet database integrity
14891489
#ifdef ENABLE_WALLET

src/llmq/quorums_dkgsessionhandler.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ std::set<NodeId> BatchVerifyMessageSigs(CDKGSession& session, const std::vector<
325325
}
326326

327327
// are all messages from the same node?
328-
NodeId firstNodeId;
328+
NodeId firstNodeId = 0;
329329
first = true;
330330
bool nodeIdsAllSame = true;
331331
for (auto it = messages.begin(); it != messages.end(); ++it) {

src/qt/sendcoinsdialog.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ void SendCoinsDialog::on_sendButton_clicked()
538538
}
539539
}
540540

541-
double txSize;
541+
double txSize = 0.0;
542542
if ((fAnonymousMode == false) && (recipients.size() == sparkAddressCount) && spark::IsSparkAllowed())
543543
{
544544
for (auto &transaction : transactions) {

src/qt/transactionrecord.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
245245
parts.append(TransactionRecord(hash, nTime, TransactionRecord::MintSparkToSelf, "",
246246
-(nDebit - nChange), 0));
247247
} else if (wtx.tx->IsSparkSpend()) {
248-
CAmount fee;
248+
CAmount fee = 0;
249249
try {
250250
spark::SpendTransaction spend = spark::ParseSparkSpend(*wtx.tx);
251251
fee = spend.getFee();

src/rpc/client.cpp

+56-56
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
class CRPCConvertParam
1717
{
1818
public:
19-
std::string methodName; //!< method whose params want conversion
20-
int paramIdx; //!< 0-based idx of param to convert
21-
std::string paramName; //!< parameter name
19+
std::string methodName {}; //!< method whose params want conversion
20+
int paramIdx {}; //!< 0-based idx of param to convert
21+
std::string paramName {}; //!< parameter name
2222
};
2323

2424
/**
@@ -29,7 +29,7 @@ class CRPCConvertParam
2929
*/
3030
static const CRPCConvertParam vRPCConvertParams[] =
3131
{
32-
{ "stop", 0 },
32+
{ "stop", 0, {} },
3333
{ "setmocktime", 0, "timestamp" },
3434
{ "getaddednodeinfo", 0 },
3535
{ "generate", 0, "nblocks" },
@@ -58,8 +58,8 @@ static const CRPCConvertParam vRPCConvertParams[] =
5858
{ "getbalance", 2, "include_watchonly" },
5959
{ "getbalance", 3, "addlockconf" },
6060
{ "getblockhash", 0, "height" },
61-
{ "move", 2 },
62-
{ "move", 3 },
61+
{ "move", 2, {} },
62+
{ "move", 3, {} },
6363
{ "waitforblockheight", 0, "height" },
6464
{ "waitforblockheight", 1, "timeout" },
6565
{ "waitforblock", 1, "timeout" },
@@ -135,15 +135,15 @@ static const CRPCConvertParam vRPCConvertParams[] =
135135
{ "getmempoolancestors", 1, "verbose" },
136136
{ "getmempooldescendants", 1, "verbose" },
137137
{ "bumpfee", 1, "options" },
138-
{ "getblockhashes", 0 },
139-
{ "getblockhashes", 1 },
140-
{ "getspentinfo", 0},
141-
{ "getaddresstxids", 0},
142-
{ "getaddressbalance", 0},
143-
{ "getAddressNumWBalance", 0},
144-
{ "getaddressdeltas", 0},
145-
{ "getaddressutxos", 0},
146-
{ "getaddressmempool", 0},
138+
{ "getblockhashes", 0, {} },
139+
{ "getblockhashes", 1, {} },
140+
{ "getspentinfo", 0, {} },
141+
{ "getaddresstxids", 0, {} },
142+
{ "getaddressbalance", 0, {} },
143+
{ "getAddressNumWBalance", 0, {} },
144+
{ "getaddressdeltas", 0, {} },
145+
{ "getaddressutxos", 0, {} },
146+
{ "getaddressmempool", 0, {} },
147147
{ "getspecialtxes", 1, "type" },
148148
{ "getspecialtxes", 2, "count" },
149149
{ "getspecialtxes", 3, "skip" },
@@ -160,49 +160,49 @@ static const CRPCConvertParam vRPCConvertParams[] =
160160
{ "echojson", 8, "arg8" },
161161
{ "echojson", 9, "arg9" },
162162
//[firo]
163-
{ "setmininput", 0 },
164-
{ "mint", 0 },
165-
{ "mintzerocoin", 0 },
166-
{ "spendzerocoin", 0 },
167-
{ "spendmanyzerocoin", 0 },
168-
{ "spendmany", 1 },
169-
{ "spendmany", 2 },
170-
{ "spendmany", 4 },
171-
{ "setgenerate", 0 },
172-
{ "setgenerate", 1 },
173-
{ "setmintzerocoinstatus", 2 },
174-
{ "setmintzerocoinstatus", 1 },
175-
{ "setsigmamintstatus", 1 },
176-
{ "setlelantusmintstatus", 1 },
177-
{ "listmintzerocoins", 0 },
178-
{ "listsigmamints", 0 },
179-
{ "listlelantusmints", 0 },
180-
{ "listpubcoins", 0 },
181-
{ "listsigmapubcoins", 0 },
182-
{ "listspendzerocoins", 0 },
183-
{ "listspendzerocoins", 1 },
184-
{ "listsigmaspends", 0 },
185-
{ "listsigmaspends", 1 },
186-
{ "listlelantusjoinsplits", 0 },
187-
{ "listlelantusjoinsplits", 1 },
188-
{ "joinsplit", 0 },
189-
{ "joinsplit", 1 },
190-
{ "joinsplit", 2 },
191-
{ "spendallzerocoin", 0 },
192-
{ "remintzerocointosigma", 0 },
193-
{ "getanonymityset", 0},
194-
{ "getmintmetadata", 0 },
195-
{ "getusedcoinserials", 0 },
196-
{ "getlatestcoinids", 0 },
197-
{ "getsparkmintmetadata", 0 },
198-
{ "getmempooltxs", 0 },
163+
{ "setmininput", 0, {} },
164+
{ "mint", 0, {} },
165+
{ "mintzerocoin", 0, {} },
166+
{ "spendzerocoin", 0, {} },
167+
{ "spendmanyzerocoin", 0, {} },
168+
{ "spendmany", 1, {} },
169+
{ "spendmany", 2, {} },
170+
{ "spendmany", 4, {} },
171+
{ "setgenerate", 0, {} },
172+
{ "setgenerate", 1, {} },
173+
{ "setmintzerocoinstatus", 2, {} },
174+
{ "setmintzerocoinstatus", 1, {} },
175+
{ "setsigmamintstatus", 1, {} },
176+
{ "setlelantusmintstatus", 1, {} },
177+
{ "listmintzerocoins", 0, {} },
178+
{ "listsigmamints", 0, {} },
179+
{ "listlelantusmints", 0, {} },
180+
{ "listpubcoins", 0, {} },
181+
{ "listsigmapubcoins", 0, {} },
182+
{ "listspendzerocoins", 0, {} },
183+
{ "listspendzerocoins", 1, {} },
184+
{ "listsigmaspends", 0, {} },
185+
{ "listsigmaspends", 1, {} },
186+
{ "listlelantusjoinsplits", 0, {} },
187+
{ "listlelantusjoinsplits", 1, {} },
188+
{ "joinsplit", 0, {} },
189+
{ "joinsplit", 1, {} },
190+
{ "joinsplit", 2, {} },
191+
{ "spendallzerocoin", 0, {} },
192+
{ "remintzerocointosigma", 0, {} },
193+
{ "getanonymityset", 0, {} },
194+
{ "getmintmetadata", 0, {} },
195+
{ "getusedcoinserials", 0, {} },
196+
{ "getlatestcoinids", 0, {} },
197+
{ "getsparkmintmetadata", 0, {} },
198+
{ "getmempooltxs", 0, {} },
199199

200200
//Lelantus
201-
{ "mintspark", 0 },
202-
{ "mintspark", 1 },
203-
{ "mintspark", 2 },
204-
{ "spendspark", 0 },
205-
{ "spendspark", 1 },
201+
{ "mintspark", 0, {} },
202+
{ "mintspark", 1, {} },
203+
{ "mintspark", 2, {} },
204+
{ "spendspark", 0, {} },
205+
{ "spendspark", 1, {} },
206206

207207
// Spark names
208208
{ "registersparkname", 2 },

src/rpc/mining.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1217,7 +1217,7 @@ static const CRPCCommand commands[] =
12171217
{ "mining", "pprpcsb", &pprpcsb, true, {"header_hash","mix_hash", "nonce"} },
12181218
{ "mining", "submitblock", &submitblock, true, {"hexdata","parameters"} },
12191219

1220-
{ "generating", "setgenerate", &setgenerate, true },
1220+
{ "generating", "setgenerate", &setgenerate, true, {} },
12211221
{ "generating", "generate", &generate, true, {"nblocks","maxtries"} },
12221222
{ "generating", "generatetoaddress", &generatetoaddress, true, {"nblocks","address","maxtries"} },
12231223

src/rpc/misc.cpp

+40-40
Original file line numberDiff line numberDiff line change
@@ -2235,56 +2235,56 @@ UniValue echo(const JSONRPCRequest& request)
22352235
}
22362236

22372237
static const CRPCCommand commands[] =
2238-
{ // category name actor (function) okSafeMode
2239-
// --------------------- ------------------------ ----------------------- ----------
2240-
{ "control", "getinfo", &getinfo, true, {} }, /* uses wallet if enabled */
2241-
{ "control", "getmemoryinfo", &getmemoryinfo, true, {} },
2242-
{ "util", "validateaddress", &validateaddress, true, {"address"} }, /* uses wallet if enabled */
2243-
{ "util", "createmultisig", &createmultisig, true, {"nrequired","keys"} },
2244-
{ "util", "verifymessage", &verifymessage, true, {"address","signature","message"} },
2245-
{ "util", "signmessagewithprivkey", &signmessagewithprivkey, true, {"privkey","message"} },
2238+
{ // category name actor (function) okSafeMode ArgNames
2239+
// --------------------- ------------------------ ----------------------- ---------- ---------
2240+
{ "control", "getinfo", &getinfo, true, {} }, /* uses wallet if enabled */
2241+
{ "control", "getmemoryinfo", &getmemoryinfo, true, {} },
2242+
{ "util", "validateaddress", &validateaddress, true, {"address"} }, /* uses wallet if enabled */
2243+
{ "util", "createmultisig", &createmultisig, true, {"nrequired","keys"} },
2244+
{ "util", "verifymessage", &verifymessage, true, {"address","signature","message"} },
2245+
{ "util", "signmessagewithprivkey", &signmessagewithprivkey, true, {"privkey","message"} },
22462246

22472247
/* Address index */
2248-
{ "addressindex", "getaddressmempool", &getaddressmempool, true },
2249-
{ "addressindex", "getaddressutxos", &getaddressutxos, false },
2250-
{ "addressindex", "getaddressdeltas", &getaddressdeltas, false },
2251-
{ "addressindex", "getaddresstxids", &getaddresstxids, false },
2252-
{ "addressindex", "getaddressbalance", &getaddressbalance, false },
2248+
{ "addressindex", "getaddressmempool", &getaddressmempool, true, {} },
2249+
{ "addressindex", "getaddressutxos", &getaddressutxos, false, {} },
2250+
{ "addressindex", "getaddressdeltas", &getaddressdeltas, false, {} },
2251+
{ "addressindex", "getaddresstxids", &getaddresstxids, false, {} },
2252+
{ "addressindex", "getaddressbalance", &getaddressbalance, false, {} },
22532253

22542254
/* Znode features */
2255-
{ "firo", "znsync", &mnsync, true, {} },
2256-
{ "firo", "evoznsync", &mnsync, true, {} },
2255+
{ "firo", "znsync", &mnsync, true, {} },
2256+
{ "firo", "evoznsync", &mnsync, true, {} },
22572257

2258-
{ "firo", "verifyprivatetxown", &verifyprivatetxown, true, {} },
2258+
{ "firo", "verifyprivatetxown", &verifyprivatetxown, true, {} },
22592259

22602260
/* Not shown in help */
2261-
{ "hidden", "getinfoex", &getinfoex, false },
2262-
{ "addressindex", "gettotalsupply", &gettotalsupply, false },
2263-
{ "addressindex", "getzerocoinpoolbalance", &getzerocoinpoolbalance, false },
2264-
{ "addressindex", "getCVE17144amount", &getCVE17144amount, false },
2261+
{ "hidden", "getinfoex", &getinfoex, false, {} },
2262+
{ "addressindex", "gettotalsupply", &gettotalsupply, false, {} },
2263+
{ "addressindex", "getzerocoinpoolbalance", &getzerocoinpoolbalance, false, {} },
2264+
{ "addressindex", "getCVE17144amount", &getCVE17144amount, false, {} },
22652265
/* Mobile related */
2266-
{ "mobile", "getanonymityset", &getanonymityset, false },
2267-
{ "mobile", "getmintmetadata", &getmintmetadata, true },
2268-
{ "mobile", "getusedcoinserials", &getusedcoinserials, false },
2269-
{ "mobile", "getfeerate", &getfeerate, true },
2270-
{ "mobile", "getlatestcoinid", &getlatestcoinid, true },
2266+
{ "mobile", "getanonymityset", &getanonymityset, false, {} },
2267+
{ "mobile", "getmintmetadata", &getmintmetadata, true, {} },
2268+
{ "mobile", "getusedcoinserials", &getusedcoinserials, false, {} },
2269+
{ "mobile", "getfeerate", &getfeerate, true, {} },
2270+
{ "mobile", "getlatestcoinid", &getlatestcoinid, true, {} },
22712271

22722272
/* Mobile Spark */
2273-
{ "mobile", "getsparkanonymityset", &getsparkanonymityset, false },
2274-
{ "mobile", "getsparkanonymitysetmeta", &getsparkanonymitysetmeta, false },
2275-
{ "mobile", "getsparkanonymitysetsector", &getsparkanonymitysetsector, false },
2276-
{ "mobile", "getsparkmintmetadata", &getsparkmintmetadata, true },
2277-
{ "mobile", "getusedcoinstags", &getusedcoinstags, false },
2278-
{ "mobile", "getusedcoinstagstxhashes", &getusedcoinstagstxhashes, false },
2279-
{ "mobile", "getsparklatestcoinid", &getsparklatestcoinid, true },
2280-
{ "mobile", "getmempoolsparktxids", &getmempoolsparktxids, true },
2281-
{ "mobile", "getmempoolsparktxs", &getmempoolsparktxs, true },
2282-
2283-
{ "mobile", "checkifmncollateral", &checkifmncollateral, false },
2284-
2285-
{ "hidden", "setmocktime", &setmocktime, true, {"timestamp"}},
2286-
{ "hidden", "echo", &echo, true, {"arg0","arg1","arg2","arg3","arg4","arg5","arg6","arg7","arg8","arg9"}},
2287-
{ "hidden", "echojson", &echo, true, {"arg0","arg1","arg2","arg3","arg4","arg5","arg6","arg7","arg8","arg9"}},
2273+
{ "mobile", "getsparkanonymityset", &getsparkanonymityset, false, {} },
2274+
{ "mobile", "getsparkanonymitysetmeta", &getsparkanonymitysetmeta, false, {} },
2275+
{ "mobile", "getsparkanonymitysetsector", &getsparkanonymitysetsector, false,{} },
2276+
{ "mobile", "getsparkmintmetadata", &getsparkmintmetadata, true, {} },
2277+
{ "mobile", "getusedcoinstags", &getusedcoinstags, false, {} },
2278+
{ "mobile", "getusedcoinstagstxhashes", &getusedcoinstagstxhashes, false, {} },
2279+
{ "mobile", "getsparklatestcoinid", &getsparklatestcoinid, true, {} },
2280+
{ "mobile", "getmempoolsparktxids", &getmempoolsparktxids, true, {} },
2281+
{ "mobile", "getmempoolsparktxs", &getmempoolsparktxs, true, {} },
2282+
2283+
{ "mobile", "checkifmncollateral", &checkifmncollateral, false, {} },
2284+
2285+
{ "hidden", "setmocktime", &setmocktime, true, {"timestamp"} },
2286+
{ "hidden", "echo", &echo, true, {"arg0","arg1","arg2","arg3","arg4","arg5","arg6","arg7","arg8","arg9"} },
2287+
{ "hidden", "echojson", &echo, true, {"arg0","arg1","arg2","arg3","arg4","arg5","arg6","arg7","arg8","arg9"} },
22882288
};
22892289

22902290
void RegisterMiscRPCCommands(CRPCTable &t)

0 commit comments

Comments
 (0)