From 7989aa01ac4d48dbb5dda7a106a270fe381f2852 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=EA=A6=AB=EA=A6=B6=EA=A6=8F=EA=A7=80=EA=A6=A6?= =?UTF-8?q?=EA=A6=BF=EA=A6=A7=EA=A6=AE=EA=A6=91=EA=A6=A9=EA=A6=AD=EA=A7=80?= Date: Thu, 15 Sep 2022 09:18:44 +0800 Subject: const qualifiers for arguments when there won't be any more memory allocated for them. The redirect inline function params are swapped a bit. --- shopify.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'shopify.c') diff --git a/shopify.c b/shopify.c index f8f8ae2..a718ecf 100644 --- a/shopify.c +++ b/shopify.c @@ -51,7 +51,7 @@ extern inline void request_init(); extern inline void request_token(const char *, const char *, const char *, const char *, char **); extern inline void request_cleanup(); -extern inline void token_parse(char *, struct session *); +extern inline void token_parse(const char *, struct session *); void shopify_init() { @@ -80,7 +80,7 @@ static enum MHD_Result getparam(void *cls, enum MHD_ValueKind kind, return MHD_YES; } -static inline void clear(struct shopify_param params[]) +static inline void clear(const struct shopify_param params[]) { int i = 0; while (params[i].key) { @@ -163,7 +163,7 @@ bool shopify_valid(struct MHD_Connection *conn, const char *url, } static inline int redirect(const char *host, const char *id, - struct MHD_Response **resp, struct MHD_Connection *conn) + struct MHD_Connection *conn, struct MHD_Response **resp) { char url[EMBEDDEDAPP_URL_LEN + strlen(host) + strlen(id) + 1]; sprintf(url, EMBEDDEDAPP_URL, host, id); @@ -172,11 +172,11 @@ static inline int redirect(const char *host, const char *id, return MHD_queue_response(conn, MHD_HTTP_PERMANENT_REDIRECT, *resp); } -enum MHD_Result shopify_respond(struct shopify_param params[], const char *url, - const char *redir_url, const char *app_url, const char *app_id, - const char *key, const char *secret_key, const char *toml_path, - const char *html_path, struct MHD_Connection *conn, - struct MHD_Response **resp) +enum MHD_Result shopify_respond(const struct shopify_param params[], + const char *url, const char *redir_url, const char *app_url, + const char *app_id, const char *key, const char *secret_key, + const char *toml_path, const char *html_path, + struct MHD_Connection *conn, struct MHD_Response **resp) { int nparams = 0; while (params[nparams].key) @@ -214,7 +214,7 @@ enum MHD_Result shopify_respond(struct shopify_param params[], const char *url, request_token(decoded_host, key, secret_key, code, &token); token_parse(token, session); free(token); - ret = redirect(decoded_host, app_id, resp, conn); + ret = redirect(decoded_host, app_id, conn, resp); } else if (session && session->token) { if (embedded) { int fd = open(html_path, O_RDONLY); @@ -229,7 +229,7 @@ enum MHD_Result shopify_respond(struct shopify_param params[], const char *url, "Content-Security-Policy", frame); ret = MHD_queue_response(conn, MHD_HTTP_OK, *resp); } else - ret = redirect(decoded_host, app_id, resp, conn); + ret = redirect(decoded_host, app_id, conn, resp); } else { const size_t decoded_host_len = strlen(decoded_host); char *scopes = NULL; -- cgit v1.2.3