[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-exchange] 04/06: check return value from TALER_amoun
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-exchange] 04/06: check return value from TALER_amount_get_zero |
Date: |
Fri, 06 Oct 2017 21:11:43 +0200 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository exchange.
commit dbab0c658734c14436a89bd7fc76b295cbcf5448
Author: Christian Grothoff <address@hidden>
AuthorDate: Fri Oct 6 20:54:42 2017 +0200
check return value from TALER_amount_get_zero
---
src/exchange-lib/exchange_api_common.c | 13 +++++++------
src/exchange-lib/exchange_api_reserve.c | 10 ++++++----
src/exchange/taler-exchange-aggregator.c | 5 +++--
src/exchange/taler-exchange-httpd_db.c | 21 +++++++++++----------
src/exchange/taler-exchange-httpd_payback.c | 11 ++++++-----
.../taler-exchange-httpd_reserve_withdraw.c | 5 +++--
src/exchange/taler-exchange-httpd_responses.c | 5 +++--
7 files changed, 39 insertions(+), 31 deletions(-)
diff --git a/src/exchange-lib/exchange_api_common.c
b/src/exchange-lib/exchange_api_common.c
index 99086a7..9d2a827 100644
--- a/src/exchange-lib/exchange_api_common.c
+++ b/src/exchange-lib/exchange_api_common.c
@@ -42,7 +42,6 @@ TALER_EXCHANGE_verify_coin_history (const char *currency,
struct TALER_Amount *total)
{
size_t len;
- size_t off;
int add;
struct TALER_Amount rtotal;
@@ -57,11 +56,13 @@ TALER_EXCHANGE_verify_coin_history (const char *currency,
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
- TALER_amount_get_zero (currency,
- total);
- TALER_amount_get_zero (currency,
- &rtotal);
- for (off=0;off<len;off++)
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_get_zero (currency,
+ total));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_get_zero (currency,
+ &rtotal));
+ for (size_t off=0;off<len;off++)
{
json_t *transaction;
struct TALER_Amount amount;
diff --git a/src/exchange-lib/exchange_api_reserve.c
b/src/exchange-lib/exchange_api_reserve.c
index 644a991..40c9d49 100644
--- a/src/exchange-lib/exchange_api_reserve.c
+++ b/src/exchange-lib/exchange_api_reserve.c
@@ -104,10 +104,12 @@ parse_reserve_history (struct TALER_EXCHANGE_Handle
*exchange,
struct TALER_Amount total_out;
size_t off;
- TALER_amount_get_zero (currency,
- &total_in);
- TALER_amount_get_zero (currency,
- &total_out);
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_get_zero (currency,
+ &total_in));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_get_zero (currency,
+ &total_out));
uuid_off = 0;
for (off=0;off<history_length;off++)
{
diff --git a/src/exchange/taler-exchange-aggregator.c
b/src/exchange/taler-exchange-aggregator.c
index 011cb98..eb97edb 100644
--- a/src/exchange/taler-exchange-aggregator.c
+++ b/src/exchange/taler-exchange-aggregator.c
@@ -1006,8 +1006,9 @@ expired_reserve_cb (void *cls,
/* Closing fee higher than remaining balance, close
without wire transfer. */
closing_fee = left;
- TALER_amount_get_zero (left->currency,
- &amount_without_fee);
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_get_zero (left->currency,
+ &amount_without_fee));
}
/* NOTE: sizeof (*reserve_pub) == sizeof (wtid) right now, but to
diff --git a/src/exchange/taler-exchange-httpd_db.c
b/src/exchange/taler-exchange-httpd_db.c
index f2e1f7b..30bc33e 100644
--- a/src/exchange/taler-exchange-httpd_db.c
+++ b/src/exchange/taler-exchange-httpd_db.c
@@ -39,7 +39,7 @@
* attempts to commit the transaction. Upon soft failures,
* retries @a cb a few times. Upon hard or persistent soft
* errors, generates an error message for @a connection.
- *
+ *
* @param connection MHD connection to run @a cb for
* @param[out] set to MHD response code, if transaction failed
* @param cb callback implementing transaction logic
@@ -68,13 +68,13 @@ TEH_DB_run_transaction (struct MHD_Connection *connection,
{
enum GNUNET_DB_QueryStatus qs;
- if (GNUNET_OK !=
- TEH_plugin->start (TEH_plugin->cls,
- session))
- {
+ if (GNUNET_OK !=
+ TEH_plugin->start (TEH_plugin->cls,
+ session))
+ {
GNUNET_break (0);
if (NULL != mhd_ret)
- *mhd_ret = TEH_RESPONSE_reply_internal_db_error (connection,
+ *mhd_ret = TEH_RESPONSE_reply_internal_db_error (connection,
TALER_EC_DB_START_FAILED);
return GNUNET_SYSERR;
}
@@ -84,12 +84,12 @@ TEH_DB_run_transaction (struct MHD_Connection *connection,
mhd_ret);
if (0 > qs)
TEH_plugin->rollback (TEH_plugin->cls,
- session);
+ session);
if (GNUNET_DB_STATUS_HARD_ERROR == qs)
return GNUNET_SYSERR;
if (0 <= qs)
qs = TEH_plugin->commit (TEH_plugin->cls,
- session);
+ session);
if (GNUNET_DB_STATUS_HARD_ERROR == qs)
{
if (NULL != mhd_ret)
@@ -132,8 +132,9 @@ TEH_DB_calculate_transaction_list_totals (struct
TALER_EXCHANGEDB_TransactionLis
struct TALER_EXCHANGEDB_TransactionList *pos;
struct TALER_Amount refunded;
- TALER_amount_get_zero (spent.currency,
- &refunded);
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_get_zero (spent.currency,
+ &refunded));
for (pos = tl; NULL != pos; pos = pos->next)
{
switch (pos->type)
diff --git a/src/exchange/taler-exchange-httpd_payback.c
b/src/exchange/taler-exchange-httpd_payback.c
index 8b4051c..d8e1dd8 100644
--- a/src/exchange/taler-exchange-httpd_payback.c
+++ b/src/exchange/taler-exchange-httpd_payback.c
@@ -115,7 +115,7 @@ struct PaybackContext
* Details about the coin.
*/
const struct TALER_CoinPublicInfo *coin;
-
+
/**
* Key used to blind the coin.
*/
@@ -174,7 +174,7 @@ payback_transaction (void *cls,
struct TALER_EXCHANGEDB_TransactionList *tl;
struct TALER_Amount spent;
enum GNUNET_DB_QueryStatus qs;
-
+
/* Check whether a payback is allowed, and if so, to which
reserve / account the money should go */
qs = TEH_plugin->get_reserve_by_h_blind (TEH_plugin->cls,
@@ -214,8 +214,9 @@ payback_transaction (void *cls,
}
return qs;
}
- TALER_amount_get_zero (pc->value.currency,
- &spent);
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_get_zero (pc->value.currency,
+ &spent));
if (GNUNET_OK !=
TEH_DB_calculate_transaction_list_totals (tl,
&spent,
@@ -386,7 +387,7 @@ verify_and_execute_payback (struct MHD_Connection
*connection,
&payback_transaction,
&pc))
return mhd_ret;
-
+
return reply_payback_success (connection,
&coin->coin_pub,
&pc.reserve_pub,
diff --git a/src/exchange/taler-exchange-httpd_reserve_withdraw.c
b/src/exchange/taler-exchange-httpd_reserve_withdraw.c
index 4dad473..c410cea 100644
--- a/src/exchange/taler-exchange-httpd_reserve_withdraw.c
+++ b/src/exchange/taler-exchange-httpd_reserve_withdraw.c
@@ -309,8 +309,9 @@ withdraw_transaction (void *cls,
if (0 == (res & 2))
{
/* did not encounter any withdraw operations, set to zero */
- TALER_amount_get_zero (deposit_total.currency,
- &withdraw_total);
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_get_zero (deposit_total.currency,
+ &withdraw_total));
}
/* All reserve balances should be non-negative */
if (GNUNET_SYSERR ==
diff --git a/src/exchange/taler-exchange-httpd_responses.c
b/src/exchange/taler-exchange-httpd_responses.c
index e461a95..1b45a0c 100644
--- a/src/exchange/taler-exchange-httpd_responses.c
+++ b/src/exchange/taler-exchange-httpd_responses.c
@@ -879,8 +879,9 @@ TEH_RESPONSE_compile_reserve_history (const struct
TALER_EXCHANGEDB_ReserveHisto
if (0 == (2 & ret))
{
/* did not encounter any withdraw operations, set to zero */
- TALER_amount_get_zero (deposit_total.currency,
- &withdraw_total);
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_get_zero (deposit_total.currency,
+ &withdraw_total));
}
if (GNUNET_SYSERR ==
TALER_amount_subtract (balance,
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [taler-exchange] branch master updated (85a2d3d -> 800c54b), gnunet, 2017/10/06
- [GNUnet-SVN] [taler-exchange] 06/06: do not potentially pass -1 to fcntl(), gnunet, 2017/10/06
- [GNUnet-SVN] [taler-exchange] 04/06: check return value from TALER_amount_get_zero,
gnunet <=
- [GNUnet-SVN] [taler-exchange] 02/06: fix indentation, gnunet, 2017/10/06
- [GNUnet-SVN] [taler-exchange] 01/06: fix signed calls to isalpha/isdigit/isspace etc., gnunet, 2017/10/06
- [GNUnet-SVN] [taler-exchange] 03/06: check return value from TALER_JSON_hash, gnunet, 2017/10/06
- [GNUnet-SVN] [taler-exchange] 05/06: better logging if IBAN validation fails, also avoid potentially unbounded stack allocation, gnunet, 2017/10/06