commit 0f3ead965ed985e6a64d55d66e6c262351863b63
parent b5371d0e404581b11633ff16bbad1f33c2a28766
Author: Christian Grothoff <christian@grothoff.org>
Date: Fri, 28 Mar 2025 04:41:20 +0100
-fix compiler warnings, use of uninitialized variables
Diffstat:
1 file changed, 38 insertions(+), 41 deletions(-)
diff --git a/src/exchangedb/test_exchangedb.c b/src/exchangedb/test_exchangedb.c
@@ -340,8 +340,8 @@ create_denom_key_pair (unsigned int size,
}
-static struct TALER_Amount amount;
-static struct TALER_Amount value;
+static struct TALER_Amount global_amount;
+static struct TALER_Amount global_value;
static struct TALER_DenomFeeSet global_fees;
static struct TALER_Amount fee_closing;
@@ -771,7 +771,7 @@ test_gc (void)
4)));
dkp = create_denom_key_pair (RSA_KEY_SIZE,
past,
- &value,
+ &global_value,
&global_fees);
GNUNET_assert (NULL != dkp);
if (GNUNET_OK !=
@@ -1279,10 +1279,10 @@ run (void *cls)
RND_BLK (&reserve_pub);
GNUNET_assert (GNUNET_OK ==
TALER_string_to_amount (CURRENCY ":1.000000",
- &amount));
+ &global_amount));
GNUNET_assert (GNUNET_OK ==
TALER_string_to_amount (CURRENCY ":1.000010",
- &value));
+ &global_value));
GNUNET_assert (GNUNET_OK ==
TALER_string_to_amount (CURRENCY ":0.000010",
&global_fees.withdraw));
@@ -1305,7 +1305,7 @@ run (void *cls)
{
struct TALER_EXCHANGEDB_ReserveInInfo reserve = {
.reserve_pub = &reserve_pub,
- .balance = &value,
+ .balance = &global_value,
.execution_time = now,
.sender_account_details = sndr,
.exchange_account_name = "exchange-account-1",
@@ -1323,15 +1323,15 @@ run (void *cls)
}
FAILIF (GNUNET_OK !=
check_reserve (&reserve_pub,
- value.value,
- value.fraction,
- value.currency));
+ global_value.value,
+ global_value.fraction,
+ global_value.currency));
now = GNUNET_TIME_timestamp_get ();
RND_BLK (&reserve_pub2);
{
struct TALER_EXCHANGEDB_ReserveInInfo reserve = {
.reserve_pub = &reserve_pub2,
- .balance = &value,
+ .balance = &global_value,
.execution_time = now,
.sender_account_details = sndr,
.exchange_account_name = "exchange-account-1",
@@ -1352,19 +1352,19 @@ run (void *cls)
"test-2"));
FAILIF (GNUNET_OK !=
check_reserve (&reserve_pub,
- value.value,
- value.fraction,
- value.currency));
+ global_value.value,
+ global_value.fraction,
+ global_value.currency));
FAILIF (GNUNET_OK !=
check_reserve (&reserve_pub2,
- value.value,
- value.fraction,
- value.currency));
+ global_value.value,
+ global_value.fraction,
+ global_value.currency));
result = 5;
now = GNUNET_TIME_timestamp_get ();
dkp = create_denom_key_pair (RSA_KEY_SIZE,
now,
- &value,
+ &global_value,
&global_fees);
GNUNET_assert (NULL != dkp);
TALER_denom_pub_hash (&dkp->pub,
@@ -1411,24 +1411,22 @@ run (void *cls)
}
cbc.reserve_pub = reserve_pub;
- cbc.amount_with_fee = value;
+ cbc.amount_with_fee = global_value;
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (CURRENCY,
&cbc.withdraw_fee));
{
bool found;
- bool nonce_reuse;
bool balance_ok;
bool age_ok;
bool conflict;
- bool denom_unknown;
uint16_t maximum_age;
uint32_t reserve_birthday;
uint64_t denom_serial = 1; /* FIXME: this should be taken from the database */
struct TALER_Amount reserve_balance;
struct TALER_EXCHANGEDB_Withdraw commitment = {
- .amount_with_fee = value,
+ .amount_with_fee = global_value,
.age_restricted = false,
.max_age = 0,
.noreveal_index = 0,
@@ -1451,7 +1449,7 @@ run (void *cls)
*/
TALER_wallet_withdraw_commit (
&reserve_pub,
- &amount,
+ &global_amount,
&global_fees.withdraw,
&h_planchets,
NULL,
@@ -1470,8 +1468,7 @@ run (void *cls)
&reserve_birthday,
&conflict));
GNUNET_assert (found);
- GNUNET_assert (! nonce_reuse);
- GNUNET_assert (! denom_unknown);
+ GNUNET_assert (! conflict);
GNUNET_assert (balance_ok);
h_commitment = commitment.h_commitment;
@@ -1481,12 +1478,12 @@ run (void *cls)
check_reserve (&reserve_pub,
0,
0,
- value.currency));
+ global_value.currency));
FAILIF (GNUNET_OK !=
check_reserve (&reserve_pub2,
- value.value,
- value.fraction,
- value.currency));
+ global_value.value,
+ global_value.fraction,
+ global_value.currency));
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
plugin->get_reserve_by_h_commitment (plugin->cls,
&h_commitment,
@@ -1560,7 +1557,7 @@ run (void *cls)
= GNUNET_TIME_relative_to_timestamp (GNUNET_TIME_UNIT_MONTHS);
bd.wire_deadline
= GNUNET_TIME_relative_to_timestamp (GNUNET_TIME_UNIT_MONTHS);
- deposit.amount_with_fee = value;
+ deposit.amount_with_fee = global_value;
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
plugin->do_deposit (plugin->cls,
&bd,
@@ -1583,7 +1580,7 @@ run (void *cls)
RND_BLK (&refund.details.merchant_sig);
refund.details.h_contract_terms = bd.h_contract_terms;
refund.details.rtransaction_id = 1;
- refund.details.refund_amount = value;
+ refund.details.refund_amount = global_value;
refund.details.refund_fee = global_fees.refund;
RND_BLK (&refund.details.merchant_sig);
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
@@ -1617,7 +1614,7 @@ run (void *cls)
refresh.coin = deposit.coin;
RND_BLK (&refresh.coin_sig);
RND_BLK (&refresh.rc);
- refresh.amount_with_fee = value;
+ refresh.amount_with_fee = global_value;
refresh.noreveal_index = MELT_NOREVEAL_INDEX;
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
plugin->do_melt (plugin->cls,
@@ -1690,7 +1687,7 @@ run (void *cls)
new_dkp[cnt] = create_denom_key_pair (RSA_KEY_SIZE,
now,
- &value,
+ &global_value,
&global_fees);
GNUNET_assert (NULL != new_dkp[cnt]);
new_denom_pubs[cnt] = new_dkp[cnt]->pub;
@@ -1862,7 +1859,7 @@ run (void *cls)
&pre_reserve.balance));
FAILIF (0 !=
TALER_amount_cmp (&delta,
- &value));
+ &global_value));
}
FAILIF (GNUNET_OK !=
@@ -1892,7 +1889,7 @@ run (void *cls)
check_reserve (&reserve_pub2,
0,
0,
- value.currency));
+ global_value.currency));
now = GNUNET_TIME_timestamp_get ();
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
plugin->insert_reserve_closed (plugin->cls,
@@ -1900,14 +1897,14 @@ run (void *cls)
now,
sndr,
&wire_out_wtid,
- &value,
+ &global_value,
&fee_closing,
0));
FAILIF (GNUNET_OK !=
check_reserve (&reserve_pub,
0,
0,
- value.currency));
+ global_value.currency));
result = 7;
FAILIF (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS !=
plugin->commit (plugin->cls));
@@ -1961,10 +1958,10 @@ run (void *cls)
break;
case TALER_EXCHANGEDB_RO_WITHDRAW_COINS:
{
- struct TALER_EXCHANGEDB_Withdraw *withdraw =
+ struct TALER_EXCHANGEDB_Withdraw *rh_withdraw =
rh_head->details.withdraw;
FAILIF (0 !=
- GNUNET_memcmp (&withdraw->reserve_pub,
+ GNUNET_memcmp (&rh_withdraw->reserve_pub,
&reserve_pub));
#pragma message "maybe more tests!?"
}
@@ -1987,7 +1984,7 @@ run (void *cls)
&deposit.coin.coin_pub));
FAILIF (0 !=
TALER_amount_cmp (&recoup->value,
- &value));
+ &global_value));
}
break;
case TALER_EXCHANGEDB_RO_EXCHANGE_TO_BANK:
@@ -2148,7 +2145,7 @@ run (void *cls)
FAILIF (0 != GNUNET_memcmp (&recoup->reserve_pub,
&reserve_pub));
FAILIF (0 != TALER_amount_cmp (&recoup->value,
- &value));
+ &global_value));
matched |= 8;
break;
}
@@ -2195,7 +2192,7 @@ run (void *cls)
bd.receiver_wire_account,
&bd.wire_salt,
&h_wire_wt);
- deposit.amount_with_fee = value;
+ deposit.amount_with_fee = global_value;
bd.refund_deadline = deadline;
bd.wire_deadline = deadline;
result = 8;