From: Karel Zak Date: Thu, 27 Nov 2025 15:46:22 +0000 (+0100) Subject: whereis: fix const qualifier warnings for C23 X-Git-Tag: v2.41.3~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1f58ebe18a233da355d6d50de766a232f72d29c2;p=thirdparty%2Futil-linux.git 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 (cherry picked from commit 01018b74163f9122c75179a7c991b0aa0f8c603c) --- diff --git a/misc-utils/whereis.c b/misc-utils/whereis.c index b575e57ae..310512b30 100644 --- a/misc-utils/whereis.c +++ b/misc-utils/whereis.c @@ -269,7 +269,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, '*'); @@ -473,11 +473,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",