From 382c9b58f626b1d042bb93088e704945ae8222e7 Mon Sep 17 00:00:00 2001 From: Rudi Heitbaum Date: Sat, 7 Feb 2026 05:50:20 +0000 Subject: [PATCH] retain const qualifier from pointer Since glibc-2.43: For ISO C23, the functions bsearch, memchr, strchr, strpbrk, strrchr, strstr, wcschr, wcspbrk, wcsrchr, wcsstr and wmemchr that return pointers into their input arrays now have definitions as macros that return a pointer to a const-qualified type when the in put argument is a pointer to a const-qualified type. https://lists.gnu.org/archive/html/info-gnu/2026-01/msg00005.html fixes the follow warnings: - warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] Signed-off-by: Rudi Heitbaum --- src/modules/raop/module-raop-discover.c | 9 +++++---- src/pulse/util.c | 6 +++--- src/pulse/util.h | 2 +- src/pulse/xmalloc.c | 3 ++- src/pulsecore/parseaddr.c | 4 ++-- src/utils/pacat.c | 5 +++-- src/utils/pacmd.c | 2 +- src/utils/pactl.c | 5 +++-- src/utils/pasuspender.c | 3 ++- 9 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/modules/raop/module-raop-discover.c b/src/modules/raop/module-raop-discover.c index 2bbf46657..a7007c481 100644 --- a/src/modules/raop/module-raop-discover.c +++ b/src/modules/raop/module-raop-discover.c @@ -165,6 +165,7 @@ static void resolver_cb( struct userdata *u = userdata; struct tunnel *tnl; char *device = NULL, *nicename, *dname, *vname, *args; + const char *nicename2; char *tp = NULL, *et = NULL, *cn = NULL; char *ch = NULL, *ss = NULL, *sr = NULL; char *dm = NULL; @@ -183,10 +184,10 @@ static void resolver_cb( goto finish; } - if ((nicename = strstr(name, "@"))) { - ++nicename; - if (strlen(nicename) > 0) { - pa_log_debug("Found RAOP: %s", nicename); + if ((nicename2 = strstr(name, "@"))) { + ++nicename2; + if (strlen(nicename2) > 0) { + pa_log_debug("Found RAOP: %s", nicename2); nicename = pa_escape(nicename, "\"'"); } else nicename = NULL; diff --git a/src/pulse/util.c b/src/pulse/util.c index c7b828cc2..398885616 100644 --- a/src/pulse/util.c +++ b/src/pulse/util.c @@ -311,8 +311,8 @@ char *pa_get_binary_name(char *s, size_t l) { return NULL; } -char *pa_path_get_filename(const char *p) { - char *fn; +const char *pa_path_get_filename(const char *p) { + const char *fn; if (!p) return NULL; @@ -320,7 +320,7 @@ char *pa_path_get_filename(const char *p) { if ((fn = strrchr(p, PA_PATH_SEP_CHAR))) return fn+1; - return (char*) p; + return p; } char *pa_get_fqdn(char *s, size_t l) { diff --git a/src/pulse/util.h b/src/pulse/util.h index 0717a73f6..e3e78210e 100644 --- a/src/pulse/util.h +++ b/src/pulse/util.h @@ -49,7 +49,7 @@ char *pa_get_binary_name(char *s, size_t l); /** Return a pointer to the filename inside a path (which is the last * component). If passed NULL will return NULL. */ -char *pa_path_get_filename(const char *p); +const char *pa_path_get_filename(const char *p); /** Wait t milliseconds */ int pa_msleep(unsigned long t); diff --git a/src/pulse/xmalloc.c b/src/pulse/xmalloc.c index 1a535b3bc..d6ebc98af 100644 --- a/src/pulse/xmalloc.c +++ b/src/pulse/xmalloc.c @@ -105,7 +105,8 @@ char *pa_xstrdup(const char *s) { } char *pa_xstrndup(const char *s, size_t l) { - char *e, *r; + const char *e; + char *r; if (!s) return NULL; diff --git a/src/pulsecore/parseaddr.c b/src/pulsecore/parseaddr.c index c47544f76..caf59e84f 100644 --- a/src/pulsecore/parseaddr.c +++ b/src/pulsecore/parseaddr.c @@ -45,7 +45,7 @@ static char *parse_host(const char *s, uint16_t *ret_port) { pa_assert(ret_port); if (*s == '[') { - char *e; + const char *e; if (!(e = strchr(s+1, ']'))) return NULL; @@ -61,7 +61,7 @@ static char *parse_host(const char *s, uint16_t *ret_port) { return pa_xstrndup(s+1, (size_t) (e-s-1)); } else { - char *e; + const char *e; uint32_t p; if (!(e = strrchr(s, ':'))) diff --git a/src/utils/pacat.c b/src/utils/pacat.c index e656dee1b..53fec2feb 100644 --- a/src/utils/pacat.c +++ b/src/utils/pacat.c @@ -741,7 +741,8 @@ enum { int main(int argc, char *argv[]) { pa_mainloop* m = NULL; int ret = 1, c; - char *bn, *server = NULL; + const char *bn; + char *server = NULL; pa_time_event *time_event = NULL; const char *filename = NULL; /* type for pa_read/_write. passed as userdata to the callbacks */ @@ -1046,7 +1047,7 @@ int main(int argc, char *argv[]) { } if (file_format <= 0) { - char *extension; + const char *extension; if (filename && (extension = strrchr(filename, '.'))) file_format = pa_sndfile_format_from_string(extension+1); if (file_format <= 0) diff --git a/src/utils/pacmd.c b/src/utils/pacmd.c index 6eae6c427..82242967f 100644 --- a/src/utils/pacmd.c +++ b/src/utils/pacmd.c @@ -103,7 +103,7 @@ int main(int argc, char*argv[]) { struct pollfd *watch_socket, *watch_stdin, *watch_stdout; int stdin_type = 0, stdout_type = 0, fd_type = 0; - char *bn = NULL; + const char *bn = NULL; int c; static const struct option long_options[] = { diff --git a/src/utils/pactl.c b/src/utils/pactl.c index 922817fa7..d2f025d84 100644 --- a/src/utils/pactl.c +++ b/src/utils/pactl.c @@ -2732,7 +2732,8 @@ enum { int main(int argc, char *argv[]) { pa_mainloop *m = NULL; int ret = 1, c; - char *server = NULL, *opt_format = NULL, *bn; + const char *bn; + char *server = NULL, *opt_format = NULL; static const struct option long_options[] = { {"server", 1, NULL, 's'}, @@ -2848,7 +2849,7 @@ int main(int argc, char *argv[]) { if (optind+2 < argc) sample_name = pa_xstrdup(argv[optind+2]); else { - char *f = pa_path_get_filename(argv[optind+1]); + const char *f = pa_path_get_filename(argv[optind+1]); sample_name = pa_xstrndup(f, strcspn(f, ".")); } diff --git a/src/utils/pasuspender.c b/src/utils/pasuspender.c index 1f0c987fe..18f25ad12 100644 --- a/src/utils/pasuspender.c +++ b/src/utils/pasuspender.c @@ -240,7 +240,8 @@ enum { int main(int argc, char *argv[]) { pa_mainloop* m = NULL; int c, ret = 1; - char *server = NULL, *bn; + const char *bn; + char *server = NULL; static const struct option long_options[] = { {"server", 1, NULL, 's'},