From 9eeda0dce4374e22aad4f1cf58a8661001dd3954 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 29 Aug 2020 01:34:20 +0200 Subject: fix filter logic --- src/backenddb/plugin_merchantdb_postgres.c | 2 ++ src/backenddb/test_merchantdb.c | 54 +++++++++++------------------- 2 files changed, 22 insertions(+), 34 deletions(-) (limited to 'src/backenddb') diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c index 37d1992f..98a608bc 100644 --- a/src/backenddb/plugin_merchantdb_postgres.c +++ b/src/backenddb/plugin_merchantdb_postgres.c @@ -4576,11 +4576,13 @@ lookup_reserves_cb (void *cls, TALER_amount_cmp (&merchant_initial_balance, &exchange_initial_balance)) continue; + break; case TALER_EXCHANGE_YNA_NO: if (0 != TALER_amount_cmp (&merchant_initial_balance, &exchange_initial_balance)) continue; + break; case TALER_EXCHANGE_YNA_ALL: break; } diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c index bc6fa514..4d33dfb1 100644 --- a/src/backenddb/test_merchantdb.c +++ b/src/backenddb/test_merchantdb.c @@ -705,12 +705,10 @@ test_instances (void) static void free_product (struct TALER_MERCHANTDB_ProductDetails *pd) { - if (NULL != pd->description) - GNUNET_free (pd->description); + GNUNET_free (pd->description); if (NULL != pd->description_i18n) json_decref (pd->description_i18n); - if (NULL != pd->unit) - GNUNET_free (pd->unit); + GNUNET_free (pd->unit); if (NULL != pd->image) json_decref (pd->image); if (NULL != pd->address) @@ -4831,6 +4829,7 @@ test_lookup_tip (const struct InstanceData *instance, struct GNUNET_TIME_Absolute expiration; char *exchange_url = NULL; struct TALER_ReservePrivateKeyP reserve_priv; + if (1 != plugin->lookup_tip (plugin->cls, instance->instance.id, &tip->details.tip_id, @@ -4842,8 +4841,7 @@ test_lookup_tip (const struct InstanceData *instance, { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Lookup tip failed\n"); - if (NULL != exchange_url) - GNUNET_free (exchange_url); + GNUNET_free (exchange_url); return 1; } if ((GNUNET_OK != TALER_amount_cmp_currency (&tip->details.total_amount, @@ -4862,12 +4860,10 @@ test_lookup_tip (const struct InstanceData *instance, { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Lookup tip failed: mismatched data\n"); - if (NULL != exchange_url) - GNUNET_free (exchange_url); + GNUNET_free (exchange_url); return 1; } - if (NULL != exchange_url) - GNUNET_free (exchange_url); + GNUNET_free (exchange_url); return 0; } @@ -4917,10 +4913,8 @@ test_lookup_tip_details (const struct InstanceData *instance, { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Lookup tip details failed\n"); - if (NULL != justification) - GNUNET_free (justification); - if (NULL != pickups) - GNUNET_free (pickups); + GNUNET_free (justification); + GNUNET_free (pickups); return 1; } if ((GNUNET_OK != TALER_amount_cmp_currency (&tip->details.total_amount, @@ -4940,13 +4934,13 @@ test_lookup_tip_details (const struct InstanceData *instance, { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Lookup tip details failed: mismatched data\n"); - if (NULL != justification) - GNUNET_free (justification); - if (NULL != pickups) - GNUNET_free (pickups); + GNUNET_free (justification); + GNUNET_free (pickups); return 1; } - memset (results_matching, 0, sizeof (unsigned int) * expected_pickups_length); + memset (results_matching, + 0, + sizeof (unsigned int) * expected_pickups_length); for (unsigned int i = 0; expected_pickups_length > i; ++i) { for (unsigned int j = 0; pickups_length > j; ++j) @@ -4972,10 +4966,8 @@ test_lookup_tip_details (const struct InstanceData *instance, { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Lookup tip details failed: mismatched data\n"); - if (NULL != justification) - GNUNET_free (justification); - if (NULL != pickups) - GNUNET_free (pickups); + GNUNET_free (justification); + GNUNET_free (pickups); return 1; } } @@ -4993,10 +4985,7 @@ free_rsa_signature_array (unsigned int sigs_length, struct GNUNET_CRYPTO_RsaSignature **sigs) { for (unsigned int i = 0; sigs_length > i; ++i) - { - if (NULL != sigs[i]) - GNUNET_free (sigs[i]); - } + GNUNET_free (sigs[i]); } @@ -5040,8 +5029,7 @@ test_lookup_pickup (const struct InstanceData *instance, { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Lookup pickup failed\n"); - if (NULL != exchange_url) - GNUNET_free (exchange_url); + GNUNET_free (exchange_url); free_rsa_signature_array (expected_sigs_length, sigs); return 1; @@ -5053,8 +5041,7 @@ test_lookup_pickup (const struct InstanceData *instance, { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Lookup pickup failed: mismatched data\n"); - if (NULL != exchange_url) - GNUNET_free (exchange_url); + GNUNET_free (exchange_url); free_rsa_signature_array (expected_sigs_length, sigs); return 1; @@ -5080,8 +5067,7 @@ test_lookup_pickup (const struct InstanceData *instance, { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Lookup pickup failed: mismatched data\n"); - if (NULL != exchange_url) - GNUNET_free (exchange_url); + GNUNET_free (exchange_url); free_rsa_signature_array (expected_sigs_length, sigs); return 1; @@ -5832,7 +5818,7 @@ lookup_refunds_detailed_cb (void *cls, { if (((cmp->refunds_to_cmp[i].timestamp.abs_value_us == timestamp.abs_value_us) || - !cmp->cmp_timestamps) && + ! cmp->cmp_timestamps) && (0 == GNUNET_memcmp (cmp->refunds_to_cmp[i].coin_pub, coin_pub)) && (0 == strcmp (cmp->refunds_to_cmp[i].exchange_url, -- cgit v1.2.3