[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <mohlhuvljdnvmlyi7gcnufw5nvkplhylilllxon2xmxdiw3oyq@h4vm3kpxg4r6>
Date: Mon, 25 Aug 2025 11:01:50 -0500
From: Lucas De Marchi <lucas.demarchi@...el.com>
To: Carlos Llamas <cmllamas@...gle.com>
CC: Thomas Hellström <thomas.hellstrom@...ux.intel.com>,
Rodrigo Vivi <rodrigo.vivi@...el.com>, David Airlie <airlied@...il.com>,
Simona Vetter <simona@...ll.ch>, Matt Atwood <matthew.s.atwood@...el.com>,
<kernel-team@...roid.com>, <linux-kernel@...r.kernel.org>, Tiffany Yang
<ynaffit@...gle.com>, "open list:INTEL DRM XE DRIVER (Lunar Lake and newer)"
<intel-xe@...ts.freedesktop.org>, "open list:DRM DRIVERS"
<dri-devel@...ts.freedesktop.org>
Subject: Re: [PATCH v3] drm/xe: switch to local xbasename() helper
On Mon, Aug 25, 2025 at 03:57:42PM +0000, Carlos Llamas wrote:
>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, implement a local xbasename() helper based on strrchr() that
>provides the same functionality and avoids portability issues.
>
>Fixes: b0a2ee5567ab ("drm/xe: prepare xe_gen_wa_oob to be multi-use")
>Suggested-by: Lucas De Marchi <lucas.demarchi@...el.com>
>Reviewed-by: Tiffany Yang <ynaffit@...gle.com>
>Signed-off-by: Carlos Llamas <cmllamas@...gle.com>
Reviewed-by: Lucas De Marchi <lucas.demarchi@...el.com>
I'll push to drm-xe-next later today. Thanks.
Lucas De Marchi
>---
>v3:
> - Switch __basename() -> xbasename() per Lucas.
>
>v2:
>https://lore.kernel.org/all/20250821220054.3700783-1-cmllamas@google.com/
> - Wrap changes in a helper function per Lucas' feedback.
> - Fix typo in commit log: s/avoid/avoids/ per Tiffany.
> - Update commit log.
> - Collect tags.
>
>v1:
>https://lore.kernel.org/all/20250820201612.2549797-1-cmllamas@google.com/
> drivers/gpu/drm/xe/xe_gen_wa_oob.c | 10 +++++++++-
> 1 file changed, 9 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..247e41c1c48d 100644
>--- a/drivers/gpu/drm/xe/xe_gen_wa_oob.c
>+++ b/drivers/gpu/drm/xe/xe_gen_wa_oob.c
>@@ -123,11 +123,19 @@ static int parse(FILE *input, FILE *csource, FILE *cheader, char *prefix)
> return 0;
> }
>
>+/* Avoid GNU vs POSIX basename() discrepancy, just use our own */
>+static const char *xbasename(const char *s)
>+{
>+ const char *p = strrchr(s, '/');
>+
>+ return p ? p + 1 : s;
>+}
>+
> static int fn_to_prefix(const char *fn, char *prefix, size_t size)
> {
> size_t len;
>
>- fn = basename(fn);
>+ fn = xbasename(fn);
> len = strlen(fn);
>
> if (len > size - 1)
>--
>2.51.0.rc2.233.g662b1ed5c5-goog
>
Powered by blists - more mailing lists