From 84a40be0bce66cda800de7891f758a0c69afc7fa Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Wed, 8 Apr 2020 23:52:01 +0200 Subject: fix #6170 and rest of #6164 --- src/exchangedb/exchangedb_transactions.c | 18 +++++++++--------- src/exchangedb/plugin_exchangedb_postgres.c | 12 ++++++------ src/exchangedb/test_exchangedb.c | 6 +++--- 3 files changed, 18 insertions(+), 18 deletions(-) (limited to 'src/exchangedb') diff --git a/src/exchangedb/exchangedb_transactions.c b/src/exchangedb/exchangedb_transactions.c index ade7f9cf2..7fe65d523 100644 --- a/src/exchangedb/exchangedb_transactions.c +++ b/src/exchangedb/exchangedb_transactions.c @@ -55,7 +55,7 @@ TALER_EXCHANGEDB_calculate_transaction_list_totals ( { case TALER_EXCHANGEDB_TT_DEPOSIT: /* spent += pos->amount_with_fee */ - if (GNUNET_OK != + if (0 > TALER_amount_add (&spent, &spent, &pos->details.deposit->amount_with_fee)) @@ -67,7 +67,7 @@ TALER_EXCHANGEDB_calculate_transaction_list_totals ( break; case TALER_EXCHANGEDB_TT_MELT: /* spent += pos->amount_with_fee */ - if (GNUNET_OK != + if (0 > TALER_amount_add (&spent, &spent, &pos->details.melt->amount_with_fee)) @@ -78,7 +78,7 @@ TALER_EXCHANGEDB_calculate_transaction_list_totals ( break; case TALER_EXCHANGEDB_TT_REFUND: /* refunded += pos->refund_amount - pos->refund_fee */ - if (GNUNET_OK != + if (0 > TALER_amount_add (&refunded, &refunded, &pos->details.refund->refund_amount)) @@ -86,7 +86,7 @@ TALER_EXCHANGEDB_calculate_transaction_list_totals ( GNUNET_break (0); return GNUNET_SYSERR; } - if (GNUNET_OK != + if (0 > TALER_amount_add (&spent, &spent, &pos->details.refund->refund_fee)) @@ -98,7 +98,7 @@ TALER_EXCHANGEDB_calculate_transaction_list_totals ( break; case TALER_EXCHANGEDB_TT_OLD_COIN_RECOUP: /* refunded += pos->value */ - if (GNUNET_OK != + if (0 > TALER_amount_add (&refunded, &refunded, &pos->details.old_coin_recoup->value)) @@ -109,7 +109,7 @@ TALER_EXCHANGEDB_calculate_transaction_list_totals ( break; case TALER_EXCHANGEDB_TT_RECOUP: /* spent += pos->value */ - if (GNUNET_OK != + if (0 > TALER_amount_add (&spent, &spent, &pos->details.recoup->value)) @@ -120,7 +120,7 @@ TALER_EXCHANGEDB_calculate_transaction_list_totals ( break; case TALER_EXCHANGEDB_TT_RECOUP_REFRESH: /* spent += pos->value */ - if (GNUNET_OK != + if (0 > TALER_amount_add (&spent, &spent, &pos->details.recoup_refresh->value)) @@ -134,7 +134,7 @@ TALER_EXCHANGEDB_calculate_transaction_list_totals ( if (have_refund) { /* If we gave any refund, also discount ONE deposit fee */ - if (GNUNET_OK != + if (0 > TALER_amount_add (&refunded, &refunded, &deposit_fee)) @@ -144,7 +144,7 @@ TALER_EXCHANGEDB_calculate_transaction_list_totals ( } } /* spent = spent - refunded */ - if (GNUNET_SYSERR == + if (0 > TALER_amount_subtract (&spent, &spent, &refunded)) diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c index a639b133d..5ecefe5eb 100644 --- a/src/exchangedb/plugin_exchangedb_postgres.c +++ b/src/exchangedb/plugin_exchangedb_postgres.c @@ -1987,7 +1987,7 @@ postgres_reserves_in_insert (void *cls, never actually have to rollback anything. */struct TALER_EXCHANGEDB_Reserve updated_reserve; updated_reserve.pub = reserve.pub; - if (GNUNET_OK != + if (0 > TALER_amount_add (&updated_reserve.balance, &reserve.balance, balance)) @@ -2160,7 +2160,7 @@ postgres_insert_withdraw_info ( qs = GNUNET_DB_STATUS_HARD_ERROR; return qs; } - if (GNUNET_SYSERR == + if (0 > TALER_amount_subtract (&reserve.balance, &reserve.balance, &collectable->amount_with_fee)) @@ -5083,7 +5083,7 @@ postgres_insert_reserve_closed ( TALER_PQ_query_param_amount (closing_fee), GNUNET_PQ_query_param_end }; - int ret; + enum TALER_AmountArithmeticResult ret; enum GNUNET_DB_QueryStatus qs; qs = GNUNET_PQ_eval_prepared_non_select (session->conn, @@ -5108,7 +5108,7 @@ postgres_insert_reserve_closed ( ret = TALER_amount_subtract (&reserve.balance, &reserve.balance, amount_with_fee); - if (GNUNET_SYSERR == ret) + if (ret < 0) { /* The reserve history was checked to make sure there is enough of a balance left before we tried this; however, concurrent operations may have changed @@ -5118,7 +5118,7 @@ postgres_insert_reserve_closed ( TALER_B2S (reserve_pub)); return GNUNET_DB_STATUS_HARD_ERROR; } - GNUNET_break (GNUNET_NO == ret); + GNUNET_break (TALER_AAR_RESULT_ZERO == ret); return reserves_update (cls, session, &reserve); @@ -6839,7 +6839,7 @@ postgres_insert_recoup_request ( GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); return qs; } - if (GNUNET_SYSERR == + if (0 > TALER_amount_add (&reserve.balance, &reserve.balance, amount)) diff --git a/src/exchangedb/test_exchangedb.c b/src/exchangedb/test_exchangedb.c index a92721641..eea484e94 100644 --- a/src/exchangedb/test_exchangedb.c +++ b/src/exchangedb/test_exchangedb.c @@ -1264,7 +1264,7 @@ test_wire_out (struct TALER_EXCHANGEDB_Session *session, coin_value_wt = deposit->amount_with_fee; coin_fee_wt = fee_deposit; - GNUNET_assert (GNUNET_OK == + GNUNET_assert (0 < TALER_amount_subtract (&transfer_value_wt, &coin_value_wt, &coin_fee_wt)); @@ -1728,7 +1728,7 @@ run (void *cls) plugin->reserves_get (plugin->cls, session, &post_reserve)); - FAILIF (GNUNET_OK != + FAILIF (0 >= TALER_amount_subtract (&delta, &post_reserve.balance, &pre_reserve.balance)); @@ -1743,7 +1743,7 @@ run (void *cls) &recoup_cb, &coin_blind)); - GNUNET_assert (GNUNET_OK == + GNUNET_assert (0 <= TALER_amount_add (&amount_with_fee, &value, &value)); -- cgit v1.2.3