From be5f08e6c3d605fb2beb1fdd1c2f10818b1e1812 Mon Sep 17 00:00:00 2001 From: default Date: Tue, 2 May 2023 06:49:00 +0200 Subject: Use xs_replace_n() where it suits. --- webfinger.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'webfinger.c') diff --git a/webfinger.c b/webfinger.c index eb6b2ad..f56b6f2 100644 --- a/webfinger.c +++ b/webfinger.c @@ -21,7 +21,7 @@ int webfinger_request(const char *qs, char **actor, char **user) if (xs_startswith(qs, "https:/" "/")) { /* actor query: pick the host */ - xs *s = xs_replace(qs, "https:/" "/", ""); + xs *s = xs_replace_n(qs, "https:/" "/", "", 1); l = xs_split_n(s, "/", 1); @@ -74,7 +74,7 @@ int webfinger_request(const char *qs, char **actor, char **user) char *subject = xs_dict_get(obj, "subject"); if (subject) - *user = xs_replace(subject, "acct:", ""); + *user = xs_replace_n(subject, "acct:", "", 1); } if (actor != NULL) { @@ -136,7 +136,7 @@ int webfinger_get_handler(d_char *req, char *q_path, else if (xs_startswith(resource, "acct:")) { /* it's an account name */ - xs *an = xs_replace(resource, "acct:", ""); + xs *an = xs_replace_n(resource, "acct:", "", 1); xs *l = NULL; /* strip a possible leading @ */ -- cgit v1.2.3 From 185aac23876f9ae5d9b613f8b9abd517c3ab3b4d Mon Sep 17 00:00:00 2001 From: default Date: Thu, 4 May 2023 09:28:36 +0200 Subject: Added -Wextra to C flags. --- Makefile | 2 +- activitypub.c | 2 ++ html.c | 3 +++ httpd.c | 6 ++++++ mastoapi.c | 13 +++++++++++++ webfinger.c | 2 ++ 6 files changed, 27 insertions(+), 1 deletion(-) (limited to 'webfinger.c') diff --git a/Makefile b/Makefile index 710d61f..7dbd9e7 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ PREFIX=/usr/local PREFIX_MAN=$(PREFIX)/man -CFLAGS?=-g -Wall +CFLAGS?=-g -Wall -Wextra all: snac diff --git a/activitypub.c b/activitypub.c index 86d33df..c25b733 100644 --- a/activitypub.c +++ b/activitypub.c @@ -1524,6 +1524,8 @@ int activitypub_post_handler(const xs_dict *req, const char *q_path, char **body, int *b_size, char **ctype) /* processes an input message */ { + (void)b_size; + int status = 202; /* accepted */ char *i_ctype = xs_dict_get(req, "content-type"); snac snac; diff --git a/html.c b/html.c index 3ba7930..3ebe70d 100644 --- a/html.c +++ b/html.c @@ -1551,6 +1551,9 @@ int html_post_handler(const xs_dict *req, const char *q_path, char *payload, int p_size, char **body, int *b_size, char **ctype) { + (void)p_size; + (void)ctype; + int status = 0; snac snac; char *uid, *p_path; diff --git a/httpd.c b/httpd.c index 5520457..fe93727 100644 --- a/httpd.c +++ b/httpd.c @@ -49,6 +49,8 @@ int server_get_handler(xs_dict *req, char *q_path, { int status = 0; + (void)req; + /* is it the server root? */ if (*q_path == '\0') { /* try to open greeting.html */ @@ -285,6 +287,8 @@ static jmp_buf on_break; void term_handler(int s) { + (void)s; + longjmp(on_break, 1); } @@ -401,6 +405,8 @@ static void *background_thread(void *arg) { time_t purge_time; + (void)arg; + /* first purge time */ purge_time = time(NULL) + 10 * 60; diff --git a/mastoapi.c b/mastoapi.c index c51c933..2413edb 100644 --- a/mastoapi.c +++ b/mastoapi.c @@ -175,6 +175,8 @@ const char *login_page = "" int oauth_get_handler(const xs_dict *req, const char *q_path, char **body, int *b_size, char **ctype) { + (void)b_size; + if (!xs_startswith(q_path, "/oauth/")) return 0; @@ -227,6 +229,9 @@ int oauth_post_handler(const xs_dict *req, const char *q_path, const char *payload, int p_size, char **body, int *b_size, char **ctype) { + (void)p_size; + (void)b_size; + if (!xs_startswith(q_path, "/oauth/")) return 0; @@ -815,6 +820,8 @@ int process_auth_token(snac *snac, const xs_dict *req) int mastoapi_get_handler(const xs_dict *req, const char *q_path, char **body, int *b_size, char **ctype) { + (void)b_size; + if (!xs_startswith(q_path, "/api/v1/") && !xs_startswith(q_path, "/api/v2/")) return 0; @@ -1474,6 +1481,9 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path, const char *payload, int p_size, char **body, int *b_size, char **ctype) { + (void)p_size; + (void)b_size; + if (!xs_startswith(q_path, "/api/v1/") && !xs_startswith(q_path, "/api/v2/")) return 0; @@ -1898,6 +1908,9 @@ int mastoapi_put_handler(const xs_dict *req, const char *q_path, const char *payload, int p_size, char **body, int *b_size, char **ctype) { + (void)p_size; + (void)b_size; + if (!xs_startswith(q_path, "/api/v1/") && !xs_startswith(q_path, "/api/v2/")) return 0; diff --git a/webfinger.c b/webfinger.c index f56b6f2..765c469 100644 --- a/webfinger.c +++ b/webfinger.c @@ -104,6 +104,8 @@ int webfinger_get_handler(d_char *req, char *q_path, { int status; + (void)b_size; + if (strcmp(q_path, "/.well-known/webfinger") != 0) return 0; -- cgit v1.2.3