From 113f3891d13a15b87827a8b1b33508231a1409b7 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 1 Mar 2020 17:51:46 +0100 Subject: [PATCH] removing dead code, using more named constants, checking return values better --- src/auditor/taler-auditor-httpd.c | 2 +- src/auditor/taler-auditor.c | 18 +++++++++--------- src/exchange/taler-exchange-aggregator.c | 8 ++++---- src/exchange/taler-exchange-httpd.c | 2 ++ src/exchange/taler-exchange-httpd_keystate.c | 2 +- .../taler-exchange-httpd_transfers_get.c | 2 +- src/mhd/mhd_legal.c | 14 +++++++------- src/pq/pq_query_helper.c | 4 ---- src/testing/testing_api_helpers_bank.c | 1 - 9 files changed, 25 insertions(+), 28 deletions(-) diff --git a/src/auditor/taler-auditor-httpd.c b/src/auditor/taler-auditor-httpd.c index 043d5b148..ff069f2aa 100644 --- a/src/auditor/taler-auditor-httpd.c +++ b/src/auditor/taler-auditor-httpd.c @@ -232,7 +232,7 @@ signal_loop (void) } if (EINTR == errno) { - ret = 2; + /* ignore, do the loop again */ continue; } switch (c) diff --git a/src/auditor/taler-auditor.c b/src/auditor/taler-auditor.c index d211bd94a..2d33987b3 100644 --- a/src/auditor/taler-auditor.c +++ b/src/auditor/taler-auditor.c @@ -772,7 +772,7 @@ get_denomination_info_by_hash (const struct GNUNET_HashCode *dh, NULL); if (qs <= 0) { - if (0 == qs) + if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Denomination %s not found\n", TALER_B2S (dh)); @@ -3774,10 +3774,10 @@ refresh_session_cb (void *cls, cc->qs = qs; return GNUNET_SYSERR; } - if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != - check_known_coin (coin_pub, - denom_pub, - amount_with_fee)) + qs = check_known_coin (coin_pub, + denom_pub, + amount_with_fee); + if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs) { GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); cc->qs = qs; @@ -4152,10 +4152,10 @@ deposit_cb (void *cls, cc->qs = qs; return GNUNET_SYSERR; } - if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != - check_known_coin (coin_pub, - denom_pub, - amount_with_fee)) + qs = check_known_coin (coin_pub, + denom_pub, + amount_with_fee); + if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs) { GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); cc->qs = qs; diff --git a/src/exchange/taler-exchange-aggregator.c b/src/exchange/taler-exchange-aggregator.c index 1a8889fda..bf066d846 100644 --- a/src/exchange/taler-exchange-aggregator.c +++ b/src/exchange/taler-exchange-aggregator.c @@ -405,6 +405,7 @@ update_fees (struct WireAccount *wa, &p->master_sig); if (qs < 0) { + GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); TALER_EXCHANGEDB_fees_free (wa->af); wa->af = NULL; return NULL; @@ -854,10 +855,9 @@ deposit_cb (void *cls, au->session); if (NULL == af) { - if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) - qs = GNUNET_DB_STATUS_HARD_ERROR; - GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); - return qs; + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Could not get or persist wire fees. Aborting run.\n"); + return GNUNET_DB_STATUS_HARD_ERROR; } au->wire_fee = af->wire_fee; } diff --git a/src/exchange/taler-exchange-httpd.c b/src/exchange/taler-exchange-httpd.c index 153bb19f8..0061ac862 100644 --- a/src/exchange/taler-exchange-httpd.c +++ b/src/exchange/taler-exchange-httpd.c @@ -615,6 +615,8 @@ handle_mhd_request (void *cls, /* strange, should start with '/', treat as just "/" */ url = "/"; start = strchr (url + 1, '/'); + if (NULL == start) + start = ""; ret = proceed_with_handler (ecls->rh, connection, start, diff --git a/src/exchange/taler-exchange-httpd_keystate.c b/src/exchange/taler-exchange-httpd_keystate.c index add201aa6..9be78e5e4 100644 --- a/src/exchange/taler-exchange-httpd_keystate.c +++ b/src/exchange/taler-exchange-httpd_keystate.c @@ -2338,7 +2338,7 @@ TEH_KS_sign (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, /* This *can* happen if the exchange's keys are not properly maintained. */ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _ ("Cannot sign request, no valid keys available\n")); + "Cannot sign request, no valid keys available\n"); return GNUNET_SYSERR; } *pub = key_state->current_sign_key_issue.issue.signkey_pub; diff --git a/src/exchange/taler-exchange-httpd_transfers_get.c b/src/exchange/taler-exchange-httpd_transfers_get.c index 713b43a58..e7fceb494 100644 --- a/src/exchange/taler-exchange-httpd_transfers_get.c +++ b/src/exchange/taler-exchange-httpd_transfers_get.c @@ -434,7 +434,7 @@ track_transfer_transaction (void *cls, if (0 >= qs) { if ( (GNUNET_DB_STATUS_HARD_ERROR == qs) || - (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS) ) + (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) ) { GNUNET_break (0); *mhd_ret = TALER_MHD_reply_with_error (connection, diff --git a/src/mhd/mhd_legal.c b/src/mhd/mhd_legal.c index f99289a2f..051c87e9c 100644 --- a/src/mhd/mhd_legal.c +++ b/src/mhd/mhd_legal.c @@ -403,7 +403,7 @@ load_terms (struct TALER_MHD_Legal *legal, GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "fstat", fn); - (void) close (fd); + GNUENT_break (0 == close (fd)); GNUNET_free (fn); return; } @@ -412,7 +412,7 @@ load_terms (struct TALER_MHD_Legal *legal, GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "fstat-size", fn); - (void) close (fd); + GNUNET_break (0 == close (fd)); GNUNET_free (fn); return; } @@ -427,7 +427,7 @@ load_terms (struct TALER_MHD_Legal *legal, { GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "malloc"); - (void) close (fd); + GNUNET_break (0 == close (fd)); GNUNET_free (fn); return; } @@ -440,12 +440,12 @@ load_terms (struct TALER_MHD_Legal *legal, GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "read", fn); - (void) close (fd); + GNUNET_break (0 == close (fd)); GNUNET_free (buf); GNUNET_free (fn); return; } - (void) close (fd); + GNUNET_break (0 == close (fd)); GNUNET_free (fn); /* append to global list of terms of service */ @@ -501,7 +501,7 @@ load_language (struct TALER_MHD_Legal *legal, continue; load_terms (legal, path, lang, fn); } - closedir (d); + GNUNET_break (0 == closedir (d)); GNUNET_free (dname); } @@ -577,7 +577,7 @@ TALER_MHD_legal_load (const struct GNUNET_CONFIGURATION_Handle *cfg, continue; load_language (legal, path, lang); } - closedir (d); + GNUNET_break (0 == closedir (d)); GNUNET_free (path); return legal; } diff --git a/src/pq/pq_query_helper.c b/src/pq/pq_query_helper.c index 3eef30079..f558cbccf 100644 --- a/src/pq/pq_query_helper.c +++ b/src/pq/pq_query_helper.c @@ -248,8 +248,6 @@ qconv_round_time (void *cls, GNUNET_assert (sizeof (struct GNUNET_TIME_AbsoluteNBO) == data_len); GNUNET_assert (scratch_length > 0); GNUNET_break (NULL == cls); - if (1 != param_length) - return -1; tmp = *at; GNUNET_assert (GNUNET_OK == GNUNET_TIME_round_abs (&tmp)); @@ -316,8 +314,6 @@ qconv_round_time_abs (void *cls, GNUNET_assert (1 == param_length); GNUNET_assert (sizeof (struct GNUNET_TIME_AbsoluteNBO) == data_len); GNUNET_break (NULL == cls); - if (1 != param_length) - return -1; tmp = GNUNET_TIME_absolute_ntoh (*at); GNUNET_assert (GNUNET_OK == GNUNET_TIME_round_abs (&tmp)); diff --git a/src/testing/testing_api_helpers_bank.c b/src/testing/testing_api_helpers_bank.c index 35ef4792f..3cfb693ae 100644 --- a/src/testing/testing_api_helpers_bank.c +++ b/src/testing/testing_api_helpers_bank.c @@ -430,7 +430,6 @@ TALER_TESTING_prepare_fakebank (const char *config_filename, GNUNET_CONFIGURATION_destroy (cfg); return GNUNET_SYSERR; } - bc->exchange_auth.method = TALER_BANK_AUTH_NONE; { char *exchange_xtalerbank_account;