Skip to content

Commit fd447a6

Browse files
Fix dead stores. Values were stored but never read. Limit scope.
1 parent 39439e5 commit fd447a6

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

src/test/util_tests.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -950,6 +950,7 @@ static void TestOtherProcess(fs::path dirname, std::string lockname, int fd)
950950
ReleaseDirectoryLocks();
951951
ch = true; // Always succeeds
952952
rv = write(fd, &ch, 1);
953+
assert(rv == 1);
953954
break;
954955
case ExitCommand:
955956
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)