]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
daemon/http.c nit: fix const-warnings with C23 docs-pkg-ubuntu-2-5fknxw/deployments/8783
authorVladimír Čunát <vladimir.cunat@nic.cz>
Thu, 26 Mar 2026 11:56:44 +0000 (12:56 +0100)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Thu, 26 Mar 2026 12:04:28 +0000 (13:04 +0100)
Interestingly, with C23, functions like strstr()
return a const-qualified pointer iff one was passed to them.
Right now we ran into this in Arch CI (unreleased gcc 15 version):
https://gitlab.nic.cz/knot/knot-resolver/-/jobs/1713767

daemon/http.c

index fbfb765185d365d8ec1c9baa0cee85b29587b8aa..d2909ba115fc40fccbf4c1d4aa25e9639919adfd 100644 (file)
@@ -121,7 +121,7 @@ static int check_uri(const char* path)
        if (!path)
                return kr_error(EINVAL);
 
-       char *query_mark = strstr(path, "?");
+       const char *query_mark = strstr(path, "?");
 
        /* calculating of endpoint_len - for POST or GET method */
        endpoint_len = (query_mark) ? query_mark - path - 1 : strlen(path) - 1;
@@ -167,16 +167,16 @@ static int process_uri_path(struct pl_http_sess_data *ctx, const char* path, int
 
        static const char key[] = "dns=";
        static const char *delim = "&";
-       char *beg, *end;
+       const char *beg, *end;
        uint8_t *dest;
        uint32_t remaining;
 
-       char *query_mark = strstr(path, "?");
+       const char *query_mark = strstr(path, "?");
        if (!query_mark || strlen(query_mark) == 0) /* no parameters in path */
                return kr_error(EINVAL);
 
        /* go over key:value pair */
-       for (beg = strtok(query_mark + 1, delim); beg != NULL; beg = strtok(NULL, delim)) {
+       for (beg = strtok((char *)query_mark + 1, delim); beg != NULL; beg = strtok(NULL, delim)) {
                if (!strncmp(beg, key, 4)) /* dns variable in path found */
                        break;
        }