Skip to content

Commit c5870ab

Browse files
author
MarcoFalke
committed
Merge #12963: Fix Clang Static Analyzer warnings
159c32d Add assertion to guide static analyzers. Clang Static Analyzer needs this guidance. (practicalswift) fd447a6 Fix dead stores. Values were stored but never read. Limit scope. (practicalswift) Pull request description: Fix Clang Static Analyzer warnings reported by @kallewoof in #12961: * Fix dead stores. Values were stored but never read. * Add assertion to guide static analyzers. See #12961 for details. Tree-SHA512: 83dbec821f45217637316bee978e7543f2d2caeb7f7b0b3aec107fede0fff8baa756da8f6b761ae0d38537740839ac9752f6689109c38a4b05c0c041aaa3a1fb
2 parents 6826989 + 159c32d commit c5870ab

File tree

3 files changed

+6
-11
lines changed

3 files changed

+6
-11
lines changed

src/rpc/mining.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,7 @@ static UniValue getblocktemplate(const JSONRPCRequest& request)
525525
// Need to update only after we know CreateNewBlock succeeded
526526
pindexPrev = pindexPrevNew;
527527
}
528+
assert(pindexPrev);
528529
CBlock* pblock = &pblocktemplate->block; // pointer for convenience
529530
const Consensus::Params& consensusParams = Params().GetConsensus();
530531

src/test/util_tests.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,6 +1065,7 @@ static void TestOtherProcess(fs::path dirname, std::string lockname, int fd)
10651065
ReleaseDirectoryLocks();
10661066
ch = true; // Always succeeds
10671067
rv = write(fd, &ch, 1);
1068+
assert(rv == 1);
10681069
break;
10691070
case ExitCommand:
10701071
close(fd);

src/wallet/test/coinselector_tests.cpp

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -536,19 +536,9 @@ BOOST_AUTO_TEST_CASE(SelectCoins_test)
536536
std::exponential_distribution<double> distribution (100);
537537
FastRandomContext rand;
538538

539-
// Output stuff
540-
CAmount out_value = 0;
541-
CoinSet out_set;
542-
CAmount target = 0;
543-
bool bnb_used;
544-
545539
// Run this test 100 times
546540
for (int i = 0; i < 100; ++i)
547541
{
548-
// Reset
549-
out_value = 0;
550-
target = 0;
551-
out_set.clear();
552542
empty_wallet();
553543

554544
// Make a wallet with 1000 exponentially distributed random inputs
@@ -561,11 +551,14 @@ BOOST_AUTO_TEST_CASE(SelectCoins_test)
561551
CFeeRate rate(rand.randrange(300) + 100);
562552

563553
// Generate a random target value between 1000 and wallet balance
564-
target = rand.randrange(balance - 1000) + 1000;
554+
CAmount target = rand.randrange(balance - 1000) + 1000;
565555

566556
// Perform selection
567557
CoinSelectionParams coin_selection_params_knapsack(false, 34, 148, CFeeRate(0), 0);
568558
CoinSelectionParams coin_selection_params_bnb(true, 34, 148, CFeeRate(0), 0);
559+
CoinSet out_set;
560+
CAmount out_value = 0;
561+
bool bnb_used = false;
569562
BOOST_CHECK(testWallet.SelectCoinsMinConf(target, filter_standard, vCoins, out_set, out_value, coin_selection_params_bnb, bnb_used) ||
570563
testWallet.SelectCoinsMinConf(target, filter_standard, vCoins, out_set, out_value, coin_selection_params_knapsack, bnb_used));
571564
BOOST_CHECK_GE(out_value, target);

0 commit comments

Comments
 (0)