From 01018b74163f9122c75179a7c991b0aa0f8c603c Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Thu, 27 Nov 2025 16:46:22 +0100 Subject: [PATCH] whereis: fix const qualifier warnings for C23 Fix const qualifier discarded warnings in dirlist_add_subdir() and lookup() functions. These warnings are reported by gcc 15 which defaults to the C23 standard. The strchr() and strrchr() functions return pointers into const strings, so the receiving variables must be declared as const char *. Signed-off-by: Karel Zak --- misc-utils/whereis.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/misc-utils/whereis.c b/misc-utils/whereis.c index f705ac278..2e2ecda9e 100644 --- a/misc-utils/whereis.c +++ b/misc-utils/whereis.c @@ -270,7 +270,7 @@ static void dirlist_add_subdir(struct wh_dirlist **ls, int type, const char *dir char buf[PATH_MAX], *d; DIR *dirp; struct dirent *dp; - char *postfix; + const char *postfix; size_t len; postfix = strchr(dir, '*'); @@ -474,11 +474,12 @@ static void lookup(const char *pattern, struct wh_dirlist *ls, int want) { char patbuf[PATH_MAX] = { 0 }; int count = 0; - char *wait = NULL, *p; + char *wait = NULL; + const char *p; /* canonicalize pattern -- remove path suffix etc. */ p = strrchr(pattern, '/'); - p = p ? p + 1 : (char *) pattern; + p = p ? p + 1 : pattern; xstrncpy(patbuf, p, PATH_MAX); DBG(SEARCH, ul_debug("lookup dirs for '%s' (%s), want: %s %s %s", -- 2.47.3