modpost: Do not discard const qualifier in match()

match() receives 'sym' as RO string. But strstr() does not return non-const
char, which here implicitly casts away the const qualifier. Declare 'here'
as 'const char *' to fix the following warning by Clang:

../scripts/mod/modpost.c:870:10: warning: initializing 'char *' with an expression of type 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
  870 |                         char *here = strstr(sym, bare);
      |                               ^      ~~~~~~~~~~~~~~~~~

Change-Id: I3df77d2cd975ff965517b9319ea8013cc6ce2561
Signed-off-by: Tashfin Shakeer Rhythm <tashfinshakeerrhythm@gmail.com>
This commit is contained in:
Tashfin Shakeer Rhythm authored and Flicker372 committed 2026-08-05 17:58:04 +08:00
1 parent 96ff985949
commit 662289eeb3
1 file changed
+1 -1
+1 -1
View File
@@ -804,7 +804,7 @@ static int match(const char *sym, const char * const pat[])
/* "*foo*" */
if (*p == '*' && *endp == '*') {
char *bare = NOFAIL(strndup(p + 1, strlen(p) - 2));
char *here = strstr(sym, bare);
const char *here = strstr(sym, bare);
free(bare);
if (here != NULL)