From 0e2148d63b85025c37d4212162a522e47445acab Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 4 Jun 2023 12:28:55 +0200 Subject: -code cleanup --- .../taler-merchant-httpd_post-orders-ID-pay.c | 26 +++------------------- 1 file changed, 3 insertions(+), 23 deletions(-) (limited to 'src/backend/taler-merchant-httpd_post-orders-ID-pay.c') diff --git a/src/backend/taler-merchant-httpd_post-orders-ID-pay.c b/src/backend/taler-merchant-httpd_post-orders-ID-pay.c index bd68278c..04224ac5 100644 --- a/src/backend/taler-merchant-httpd_post-orders-ID-pay.c +++ b/src/backend/taler-merchant-httpd_post-orders-ID-pay.c @@ -2219,10 +2219,10 @@ static enum GNUNET_GenericReturnValue parse_pay (struct PayContext *pc) { const char *session_id = NULL; - json_t *coins; + const json_t *coins; struct GNUNET_JSON_Specification spec[] = { - GNUNET_JSON_spec_json ("coins", - &coins), + GNUNET_JSON_spec_array_const ("coins", + &coins), GNUNET_JSON_spec_mark_optional ( GNUNET_JSON_spec_string ("session_id", &session_id), @@ -2253,25 +2253,10 @@ parse_pay (struct PayContext *pc) /* use empty string as default if client didn't specify it */ pc->session_id = GNUNET_strdup (""); } - - if (! json_is_array (coins)) - { - GNUNET_break_op (0); - GNUNET_JSON_parse_free (spec); - return (MHD_YES == - TALER_MHD_reply_with_error (pc->connection, - MHD_HTTP_BAD_REQUEST, - TALER_EC_GENERIC_PARAMETER_MISSING, - "'coins' must be an array")) - ? GNUNET_NO - : GNUNET_SYSERR; - } - pc->coins_cnt = json_array_size (coins); if (pc->coins_cnt > MAX_COIN_ALLOWED_COINS) { GNUNET_break_op (0); - GNUNET_JSON_parse_free (spec); return (MHD_YES == TALER_MHD_reply_with_error ( pc->connection, @@ -2336,7 +2321,6 @@ parse_pay (struct PayContext *pc) if (GNUNET_YES != res) { GNUNET_break_op (0); - GNUNET_JSON_parse_free (spec); return res; } @@ -2347,7 +2331,6 @@ parse_pay (struct PayContext *pc) &pc->dc[j].cdd.coin_pub)) { GNUNET_break_op (0); - GNUNET_JSON_parse_free (spec); return (MHD_YES == TALER_MHD_reply_with_error (pc->connection, MHD_HTTP_BAD_REQUEST, @@ -2367,7 +2350,6 @@ parse_pay (struct PayContext *pc) TMH_currency)) { GNUNET_break_op (0); - GNUNET_JSON_parse_free (spec); return (MHD_YES == TALER_MHD_reply_with_error (pc->connection, MHD_HTTP_CONFLICT, @@ -2382,7 +2364,6 @@ parse_pay (struct PayContext *pc) if (dc->no_age_commitment != dc->no_minimum_age_sig) { GNUNET_break_op (0); - GNUNET_JSON_parse_free (spec); return (MHD_YES == TALER_MHD_reply_with_error ( pc->connection, @@ -2419,7 +2400,6 @@ parse_pay (struct PayContext *pc) } } } - GNUNET_JSON_parse_free (spec); return GNUNET_OK; } -- cgit v1.2.3