merchant

Merchant backend to process payments, run by merchants
Log | Files | Refs | Submodules | README | LICENSE

commit 6856adaab2778b89f2fc99204c1065b0a965713d
parent 5b1a083c64aeb4ce5484028041026ee534fe6396
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sat, 21 Jun 2025 15:08:46 +0200

fixing misc compiler warnings

Diffstat:
Msrc/backend/taler-merchant-httpd.c | 45++++++++++++++++++++++++++++++---------------
Msrc/backend/taler-merchant-httpd.h | 4++--
Msrc/testing/testing_api_cmd_instance_token.c | 64+++++++++++++++++++++++++++++++++-------------------------------
3 files changed, 65 insertions(+), 48 deletions(-)

diff --git a/src/backend/taler-merchant-httpd.c b/src/backend/taler-merchant-httpd.c @@ -337,26 +337,35 @@ permission_in_scope (const char *permission_required, bool is_read_perm; bool is_write_perm; bool refreshable; + const char *last_dash; - perms_tmp = get_scope_permissions (scope, &refreshable); + perms_tmp = get_scope_permissions (scope, + &refreshable); if (NULL == perms_tmp) { GNUNET_break_op (0); return false; } - char *last_dash = strrchr (permission_required, '-'); + last_dash = strrchr (permission_required, + '-'); if (NULL != last_dash) { - is_write_perm = (0 == strcmp (last_dash, "-write")); - is_read_perm = (0 == strcmp (last_dash, "-read")); + is_write_perm = (0 == strcmp (last_dash, + "-write")); + is_read_perm = (0 == strcmp (last_dash, + "-read")); } - if (refreshable && 0 == strcmp ("token-refresh", permission_required)) + if (refreshable && + (0 == strcmp ("token-refresh", + permission_required)) ) return true; permissions = GNUNET_strdup (perms_tmp); { - char *perm = strtok (permissions, ","); + const char *perm = strtok (permissions, + ","); + if (NULL == perm) { GNUNET_free (permissions); @@ -364,29 +373,34 @@ permission_in_scope (const char *permission_required, } while (NULL != perm) { - if (0 == strcmp ("*", perm)) + if (0 == strcmp ("*", + perm)) { GNUNET_free (permissions); return true; } - if ((0 == strcmp ("*-write", perm)) && - (is_write_perm)) + if ( (0 == strcmp ("*-write", + perm)) && + (is_write_perm) ) { GNUNET_free (permissions); return true; } - if ((0 == strcmp ("*-read", perm)) && - (is_read_perm)) + if ( (0 == strcmp ("*-read", + perm)) && + (is_read_perm) ) { GNUNET_free (permissions); return true; } - if (0 == strcmp (permission_required, perm)) + if (0 == strcmp (permission_required, + perm)) { GNUNET_free (permissions); return true; } - perm = strtok (NULL, ","); + perm = strtok (NULL, + ","); } } GNUNET_free (permissions); @@ -395,7 +409,8 @@ permission_in_scope (const char *permission_required, bool -TMH_scope_is_subset (enum TMH_AuthScope as, enum TMH_AuthScope candidate) +TMH_scope_is_subset (enum TMH_AuthScope as, + enum TMH_AuthScope candidate) { const char*as_perms; const char*candidate_perms; @@ -485,7 +500,7 @@ TMH_check_auth (const char *token, } -enum GNUNET_GenericReturnValue +static enum GNUNET_GenericReturnValue TMH_check_auth_instance (const char *token, struct TMH_MerchantInstance *instance) { diff --git a/src/backend/taler-merchant-httpd.h b/src/backend/taler-merchant-httpd.h @@ -452,14 +452,14 @@ enum TMH_AuthScope /** * Full access is granted to everything. */ - TMH_AS_ADMIN = 7 | 1 << 31, + TMH_AS_ADMIN = 7 | 1 << 30, /** * /login access to renew the token is OK. * This is actually combined with other scopes * and not (usually) used as a scope itself. */ - TMH_AS_REFRESHABLE = 1 << 31, + TMH_AS_REFRESHABLE = 1 << 30, }; diff --git a/src/testing/testing_api_cmd_instance_token.c b/src/testing/testing_api_cmd_instance_token.c @@ -126,39 +126,41 @@ token_instance_cb (void *cls, GNUNET_assert (GNUNET_YES == tis->is_delete); break; case MHD_HTTP_OK: - GNUNET_assert (GNUNET_NO == tis->is_delete); - /* Get token */ - struct GNUNET_JSON_Specification spec[] = { - GNUNET_JSON_spec_string_copy ("access_token", - &tis->token), - GNUNET_JSON_spec_string ("scope", - &scope), - GNUNET_JSON_spec_bool ("refreshable", - &refreshable), - GNUNET_JSON_spec_timestamp ("expiration", - &duration), - GNUNET_JSON_spec_end () - }; - - if (GNUNET_OK != - GNUNET_JSON_parse (hr->reply, - spec, - &error_name, - &error_line)) { - char *js; - - js = json_dumps (hr->reply, - JSON_INDENT (1)); - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Parser failed on %s:%u for input `%s'\n", - error_name, - error_line, - js); - free (js); - TALER_TESTING_FAIL (tis->is); + /* Get token */ + struct GNUNET_JSON_Specification spec[] = { + GNUNET_JSON_spec_string_copy ("access_token", + &tis->token), + GNUNET_JSON_spec_string ("scope", + &scope), + GNUNET_JSON_spec_bool ("refreshable", + &refreshable), + GNUNET_JSON_spec_timestamp ("expiration", + &duration), + GNUNET_JSON_spec_end () + }; + + GNUNET_assert (GNUNET_NO == tis->is_delete); + if (GNUNET_OK != + GNUNET_JSON_parse (hr->reply, + spec, + &error_name, + &error_line)) + { + char *js; + + js = json_dumps (hr->reply, + JSON_INDENT (1)); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Parser failed on %s:%u for input `%s'\n", + error_name, + error_line, + js); + free (js); + TALER_TESTING_FAIL (tis->is); + } + break; } - break; case MHD_HTTP_BAD_REQUEST: /* likely invalid auth value, we do not check client-side */ break;