]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
namei: fix const qualifier warning in readlink_to_namei
authorKarel Zak <kzak@redhat.com>
Thu, 27 Nov 2025 15:44:47 +0000 (16:44 +0100)
committerKarel Zak <kzak@redhat.com>
Thu, 27 Nov 2025 15:44:47 +0000 (16:44 +0100)
Fix const qualifier discarded warning in readlink_to_namei().
This warning is reported by gcc 15 which defaults to the C23 standard.

The strrchr() function returns a pointer into a const string, so the
receiving variable must be declared as const char *.

Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/namei.c

index 3bfe216e39a853641a2822c69a8ee0e691ab0562..768ae00d7abdc2b4276653ce67ebfeb1dc769a6d 100644 (file)
@@ -100,7 +100,7 @@ readlink_to_namei(struct namei *nm, const char *path)
        if (sz < 1)
                err(EXIT_FAILURE, _("failed to read symlink: %s"), path);
        if (*sym != '/') {
-               char *p = strrchr(path, '/');
+               const char *p = strrchr(path, '/');
 
                if (p) {
                        isrel = 1;