commit 1e372424921730a7ebd7d086fc7faa81878f3f51
parent 3a7bb70e0141c109c14337a0fc3c0ba7d9632119
Author: Sam James <sam@gentoo.org>
Date: Tue, 27 Jan 2026 11:14:13 +0000
Fix -Wdiscarded-qualifiers with glibc-2.43
glibc-2.43 implements C23's const-preserving macros for stdlib functions,
which exposes some -Wdiscarded-qualifiers (missing consts) for us to fix.
Fixes https://gitlab.torproject.org/tpo/core/tor/-/issues/41198
Diffstat:
4 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/src/core/or/versions.c b/src/core/or/versions.c
@@ -286,7 +286,7 @@ tor_version_parse(const char *s, tor_version_t *out)
cp += 2;
out->svn_revision = (int) strtol(cp,&eos,10);
} else if (!strcmpstart(cp, "(git-")) {
- char *close_paren = strchr(cp, ')');
+ const char *close_paren = strchr(cp, ')');
int hexlen;
char digest[DIGEST_LEN];
if (! close_paren)
diff --git a/src/feature/dircommon/directory.c b/src/feature/dircommon/directory.c
@@ -360,7 +360,7 @@ http_get_header(const char *headers, const char *which)
const char *cp = headers;
while (cp) {
if (!strcasecmpstart(cp, which)) {
- char *eos;
+ const char *eos;
cp += strlen(which);
if ((eos = strchr(cp,'\r')))
return tor_strndup(cp, eos-cp);
diff --git a/src/lib/fs/path.c b/src/lib/fs/path.c
@@ -108,7 +108,8 @@ expand_filename(const char *filename)
rest = strlen(filename)>=2?(filename+2):"";
} else {
#ifdef HAVE_PWD_H
- char *username, *slash;
+ char *username;
+ const char *slash;
slash = strchr(filename, '/');
if (slash)
username = tor_strndup(filename+1,slash-filename-1);
diff --git a/src/test/test_util.c b/src/test/test_util.c
@@ -4173,11 +4173,11 @@ test_util_find_str_at_start_of_line(void *ptr)
"howdy world. how are you? i hope it's fine.\n"
"hello kitty\n"
"third line";
- char *line2 = strchr(long_string,'\n')+1;
- char *line3 = strchr(line2,'\n')+1;
+ const char *line2 = strchr(long_string,'\n')+1;
+ const char *line3 = strchr(line2,'\n')+1;
const char *short_string = "hello kitty\n"
"second line\n";
- char *short_line2 = strchr(short_string,'\n')+1;
+ const char *short_line2 = strchr(short_string,'\n')+1;
(void)ptr;