linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/xe: replace basename() with portable strrchr()
@ 2025-08-20 20:16 Carlos Llamas
  2025-08-20 21:15 ` Lucas De Marchi
  2025-08-20 21:18 ` [PATCH] drm/xe: replace basename() with portable strrchr() Tiffany Yang
  0 siblings, 2 replies; 11+ messages in thread
From: Carlos Llamas @ 2025-08-20 20:16 UTC (permalink / raw)
  To: Lucas De Marchi, Thomas Hellström, Rodrigo Vivi,
	David Airlie, Simona Vetter, Matt Atwood
  Cc: kernel-team, linux-kernel, Carlos Llamas,
	open list:INTEL DRM XE DRIVER (Lunar Lake and newer),
	open list:DRM DRIVERS

Commit b0a2ee5567ab ("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 replace basename() with a strrchr() based implementation which
provides the same functionality and avoid portability issues.

Fixes: b0a2ee5567ab ("drm/xe: prepare xe_gen_wa_oob to be multi-use")
Signed-off-by: Carlos Llamas <cmllamas@google.com>
---
 drivers/gpu/drm/xe/xe_gen_wa_oob.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/xe/xe_gen_wa_oob.c b/drivers/gpu/drm/xe/xe_gen_wa_oob.c
index 6581cb0f0e59..0a94a045bcea 100644
--- a/drivers/gpu/drm/xe/xe_gen_wa_oob.c
+++ b/drivers/gpu/drm/xe/xe_gen_wa_oob.c
@@ -125,9 +125,11 @@ static int parse(FILE *input, FILE *csource, FILE *cheader, char *prefix)
 
 static int fn_to_prefix(const char *fn, char *prefix, size_t size)
 {
+	const char *base;
 	size_t len;
 
-	fn = basename(fn);
+	base = strrchr(fn, '/');
+	fn = base ? base + 1 : fn;
 	len = strlen(fn);
 
 	if (len > size - 1)
-- 
2.51.0.rc1.193.gad69d77794-goog


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2025-08-25 16:02 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-20 20:16 [PATCH] drm/xe: replace basename() with portable strrchr() Carlos Llamas
2025-08-20 21:15 ` Lucas De Marchi
2025-08-20 23:05   ` Carlos Llamas
2025-08-21 21:00     ` Lucas De Marchi
2025-08-21 21:32       ` Carlos Llamas
2025-08-21 22:00       ` [PATCH v2] drm/xe: switch to local __basename() helper Carlos Llamas
2025-08-23 11:56         ` Lucas De Marchi
2025-08-25 15:49           ` Carlos Llamas
2025-08-25 15:57           ` [PATCH v3] drm/xe: switch to local xbasename() helper Carlos Llamas
2025-08-25 16:01             ` Lucas De Marchi
2025-08-20 21:18 ` [PATCH] drm/xe: replace basename() with portable strrchr() Tiffany Yang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).