]> 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>
Mon, 8 Dec 2025 13:48:07 +0000 (14:48 +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>
(cherry picked from commit e318417f00982bf496fd2359853b07ada3e3c544)

misc-utils/namei.c

index 0a9ed8df80eb50bdb8613bfe19e1aa60386fcc4e..2c304928475ef5f12a4b81fffc6bd2f24ba105ff 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;