Embedded Linux Library
 help / color / mirror / Atom feed
From: Bastien Nocera <hadess@hadess.net>
To: ell@lists.linux.dev
Cc: Bastien Nocera <hadess@hadess.net>
Subject: [PATCH 1/4] unit: Fix incorrect basename usage
Date: Tue, 17 Mar 2026 15:28:54 +0100	[thread overview]
Message-ID: <20260317143018.628844-2-hadess@hadess.net> (raw)
In-Reply-To: <20260317143018.628844-1-hadess@hadess.net>

The code called basename(), which requires either relying on the GNU
libc, or including libgen.h to get access to the POSIX implementation.

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.

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=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -O0 -g -DHAVE_CONFIG_H '-DUNITDIR="/home/runner/work/wrapdb/wrapdb/subprojects/ell-0.83/unit/"' '-DCERTDIR="/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]
   65 |         base = basename(tmp_path);
      |                ^
../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
   20 | const char *l_basename(const char *path);
      |             ^
../subprojects/ell-0.83/unit/test-path.c:65:7: error: incompatible integer to pointer conversion assigning to 'char *' from 'int' [-Wint-conversion]
   65 |         base = basename(tmp_path);
      |              ^ ~~~~~~~~~~~~~~~~~~
---
 unit/test-path.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

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 = "/foo:/bar:/dir:fr";
 	static const char *can_find = "/tmp";
 	char *tmp_path = l_strdup("/tmp/foobarXXXXXX.tmp");
-	char *base;
+	const char *base;
 	char *path;
 	int fd;
 
 	fd = L_TFR(mkostemps(tmp_path, 4, O_CLOEXEC));
 	assert(fd > 0);
 	L_TFR(close(fd));
-	base = basename(tmp_path);
+	base = l_basename(tmp_path);
 
 	assert(l_path_find(base, cant_find, F_OK) == NULL);
 
-- 
2.53.0


  reply	other threads:[~2026-03-17 14:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-17 14:28 [PATCH 0/4] More build fixes Bastien Nocera
2026-03-17 14:28 ` Bastien Nocera [this message]
     [not found]   ` <D98F0DC1-9621-4E61-887A-CCA145F16AFF@bluewin.ch>
2026-03-18 16:17     ` [PATCH 1/4] unit: Fix incorrect basename usage Bastien Nocera
2026-03-17 14:28 ` [PATCH 2/4] ell: Fix rawmemchr implementation warning in Alpine/clang Bastien Nocera
2026-03-17 14:28 ` [PATCH 3/4] ell: Fix cert_pkcs12_pbkdf() warning under Alpine/clang Bastien Nocera
2026-03-17 14:28 ` [PATCH 4/4] unit: Skip hwdb test when hwdb isn't available Bastien Nocera
2026-04-16  9:18 ` [PATCH 0/4] More build fixes Bastien Nocera

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260317143018.628844-2-hadess@hadess.net \
    --to=hadess@hadess.net \
    --cc=ell@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox