Skip to content

Commit 47c3850

Browse files
krajtingleby
authored andcommitted
mraa: Use posix basename
Musl has removed the declaration from string.h [1] which exposes the problem especially with clang-17+ compiler where implicit function declaration is flagged as error. Use posix basename and make a copy of string to operate on to emulate GNU basename behaviour. [1] https://git.musl-libc.org/cgit/musl/commit/?id=725e17ed6dff4d0cd22487bb64470881e86a92e7 Signed-off-by: Khem Raj <[email protected]>
1 parent 60d99f1 commit 47c3850

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/mraa.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#endif
1313

1414
#include <dlfcn.h>
15+
#include <libgen.h>
1516
#include <pwd.h>
1617
#include <sched.h>
1718
#include <stddef.h>
@@ -341,9 +342,11 @@ static int
341342
mraa_count_iio_devices(const char* path, const struct stat* sb, int flag, struct FTW* ftwb)
342343
{
343344
// we are only interested in files with specific names
344-
if (fnmatch(IIO_DEVICE_WILDCARD, basename(path), 0) == 0) {
345+
char* tmp = strdup(path);
346+
if (fnmatch(IIO_DEVICE_WILDCARD, basename(tmp), 0) == 0) {
345347
num_iio_devices++;
346348
}
349+
free(tmp);
347350
return 0;
348351
}
349352

0 commit comments

Comments
 (0)