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
2026-02-12 02:44:21 +06:00
committed by Flicker372
parent 96ff985949
commit 662289eeb3

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)