Skip to content

Commit 75671d9

Browse files
Carlos Llamasrodrigovivi
authored andcommitted
drm/xe: switch to local xbasename() helper
Commit b0a2ee5 ("drm/xe: prepare xe_gen_wa_oob to be multi-use") introduced a call to basename(). The GNU version of this function is not portable and fails to build with alternative libc implementations like musl or bionic. This causes the following build error: drivers/gpu/drm/xe/xe_gen_wa_oob.c:130:12: error: assignment to ‘const char *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion] 130 | fn = basename(fn); | ^ While a POSIX version of basename() could be used, it would require a separate header plus the behavior differs from GNU version in that it might modify its argument. Not great. Instead, implement a local xbasename() helper based on strrchr() that provides the same functionality and avoids portability issues. Fixes: b0a2ee5 ("drm/xe: prepare xe_gen_wa_oob to be multi-use") Suggested-by: Lucas De Marchi <lucas.demarchi@intel.com> Reviewed-by: Tiffany Yang <ynaffit@google.com> Signed-off-by: Carlos Llamas <cmllamas@google.com> Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com> Link: https://lore.kernel.org/r/20250825155743.1132433-1-cmllamas@google.com Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com> (cherry picked from commit 41be792) Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
1 parent 16ca06a commit 75671d9

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

drivers/gpu/drm/xe/xe_gen_wa_oob.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,19 @@ static int parse(FILE *input, FILE *csource, FILE *cheader, char *prefix)
123123
return 0;
124124
}
125125

126+
/* Avoid GNU vs POSIX basename() discrepancy, just use our own */
127+
static const char *xbasename(const char *s)
128+
{
129+
const char *p = strrchr(s, '/');
130+
131+
return p ? p + 1 : s;
132+
}
133+
126134
static int fn_to_prefix(const char *fn, char *prefix, size_t size)
127135
{
128136
size_t len;
129137

130-
fn = basename(fn);
138+
fn = xbasename(fn);
131139
len = strlen(fn);
132140

133141
if (len > size - 1)

0 commit comments

Comments
 (0)