]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsfd: fix const qualifier warning in strnrstr
authorKarel Zak <kzak@redhat.com>
Thu, 27 Nov 2025 15:38:18 +0000 (16:38 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 8 Dec 2025 13:48:07 +0000 (14:48 +0100)
Fix const qualifier discarded warning in strnrstr().
This warning is reported by gcc 15 which defaults to the C23 standard.

The function returns a non-const pointer into the haystack parameter,
and callers modify the string through that pointer. Therefore, the
haystack parameter should be char * rather than const char *.

Signed-off-by: Karel Zak <kzak@redhat.com>
(cherry picked from commit 935f2ab21add95059a92208f69ef578708307481)

lsfd-cmd/file.c

index 32b08693db20b4c1c491d8afb5560f381ce0195f..5ea3ccc572d4f86f3926d91b90b3d5709753a4ad 100644 (file)
@@ -387,7 +387,7 @@ void decode_source(char *buf, size_t bufsize,
                         dev_minor);
 }
 
-static char *strnrstr(const char *haystack, const char *needle, size_t needle_len)
+static char *strnrstr(char *haystack, const char *needle, size_t needle_len)
 {
        char *last = strstr(haystack, needle);
        if (last == NULL)