Re: [PATCH 1/4] unit: Fix incorrect basename usage

Bastien Nocera <[email protected]> Wed, 18 Mar 2026 17:17:07 +0100
Newsgroups dev.linux.lists.ell
Message-ID <[email protected]>
On Wed, 2026-03-18 at 02:14 +0100, Phil Hodges wrote:
> found cant_find meaning can't find expected cannot_find
>=20
> An English teacher taught me to expand the apostrophe in written
> English,
> long before we ever wanted to use apostrophe in an identifier.
>=20
> "cant" looks ignorant and wrong.

I'm having a hard time figuring out how this is relevant as I'm not
touching any lines of code that mention "cant_find", that you didn't
put the mailing-list in copy where folks that might have written this
code might read it, and that your idea of what is a proper identifier
is probably antiquated.

"ignorant and wrong" alright.

>=20
>=20
> On 17 Mar 2026, at 15:28, Bastien Nocera <[email protected]> wrote:
>=20
> The code called basename(), which requires either relying on the GNU
> libc, or including libgen.h to get access to the POSIX
> implementation.
>=20
> As neither was done, and the output of basename() was not freed, it's
> likely that the intent was to use the library-exported l_basename()
> instead which does not output an allocated string.
>=20
> ninja: job failed: clang -Isubprojects/ell-0.83/unit/test-path.p -
> Isubprojects/ell-0.83/unit -I../subprojects/ell-0.83/unit -
> Isubprojects/ell-0.83 -I../subprojects/ell-0.83 -fdiagnostics-
> color=3Dalways -D_FILE_OFFSET_BITS=3D64 -Wall -Winvalid-pch -O0 -g -
> DHAVE_CONFIG_H '-
> DUNITDIR=3D"/home/runner/work/wrapdb/wrapdb/subprojects/ell-
> 0.83/unit/"' '-
> DCERTDIR=3D"/home/runner/work/wrapdb/wrapdb/_build/subprojects/ell-
> 0.83/unit/"' -MD -MQ subprojects/ell-0.83/unit/test-path.p/test-
> path.c.o -MF subprojects/ell-0.83/unit/test-path.p/test-path.c.o.d -o
> subprojects/ell-0.83/unit/test-path.p/test-path.c.o -c
> ../subprojects/ell-0.83/unit/test-path.c
> ../subprojects/ell-0.83/unit/test-path.c:65:9: error: call to
> undeclared function 'basename'; ISO C99 and later do not support
> implicit function declarations [-Wimplicit-function-declaration]
> =C2=A0 65 |=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 base =3D base=
name(tmp_path);
> =C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ^
> ../subprojects/ell-0.83/unit/test-path.c:65:9: note: did you mean
> 'l_basename'?
> ../subprojects/ell-0.83/ell/path.h:20:13: note: 'l_basename' declared
> here
> =C2=A0 20 | const char *l_basename(const char *path);
> =C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0 ^
> ../subprojects/ell-0.83/unit/test-path.c:65:7: error: incompatible
> integer to pointer conversion assigning to 'char *' from 'int' [-
> Wint-conversion]
> =C2=A0 65 |=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 base =3D base=
name(tmp_path);
> =C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ^ ~~~~~~~~~~~~~~~~~~
> ---
> unit/test-path.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>=20
> diff --git a/unit/test-path.c b/unit/test-path.c
> index 1f744234c395..f01fa526aaa1 100644
> --- a/unit/test-path.c
> +++ b/unit/test-path.c
> @@ -55,14 +55,14 @@ static void test_path_find(const void *data)
> 	static const char *cant_find =3D "/foo:/bar:/dir:fr";
> 	static const char *can_find =3D "/tmp";
> 	char *tmp_path =3D l_strdup("/tmp/foobarXXXXXX.tmp");
> -	char *base;
> +	const char *base;
> 	char *path;
> 	int fd;
>=20
> 	fd =3D L_TFR(mkostemps(tmp_path, 4, O_CLOEXEC));
> 	assert(fd > 0);
> 	L_TFR(close(fd));
> -	base =3D basename(tmp_path);
> +	base =3D l_basename(tmp_path);
>=20
> 	assert(l_path_find(base, cant_find, F_OK) =3D=3D NULL);