From 40fdcd01463f106ecabcc5b6dbbc1c9dc7203d38 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Mon, 1 Dec 2025 13:58:53 +0000 Subject: [PATCH] fish: Fix const correctness in strrchr MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In C23, strchr or strrchr on a const parameter now returns a const pointer. We saw this error: destpaths.c: In function ‘complete_dest_paths_generator’: destpaths.c:165:9: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers] 165 | p = strrchr (text, '/'); | ^ --- fish/destpaths.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/fish/destpaths.c b/fish/destpaths.c index 3463e731d..7547921cc 100644 --- a/fish/destpaths.c +++ b/fish/destpaths.c @@ -159,7 +159,7 @@ complete_dest_paths_generator (const char *text, int state) * in that directory, otherwise list everything in / */ CLEANUP_FREE char *dir = NULL; - char *p; + const char *p; struct guestfs_dirent_list *dirents; p = strrchr (text, '/'); @@ -175,13 +175,14 @@ complete_dest_paths_generator (const char *text, int state) for (i = 0; i < dirents->len; ++i) { int err; + char *v; if (STRNEQ (dirents->val[i].name, ".") && STRNEQ (dirents->val[i].name, "..")) { if (STREQ (dir, "/")) - err = asprintf (&p, "/%s", dirents->val[i].name); + err = asprintf (&v, "/%s", dirents->val[i].name); else - err = asprintf (&p, "%s/%s", dir, dirents->val[i].name); + err = asprintf (&v, "%s/%s", dir, dirents->val[i].name); if (err >= 0) { if (!xalloc_oversized (nr_words+1, sizeof (struct word))) { struct word *w; @@ -194,7 +195,7 @@ complete_dest_paths_generator (const char *text, int state) } else { words = w; - words[nr_words].name = p; + words[nr_words].name = v; if (dirents->val[i].ftyp == 'u' || dirents->val[i].ftyp == 'l' || dirents->val[i].ftyp == '?') {