Private
Public Access
2
0

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 <raj.khem@gmail.com>
This commit is contained in:
Khem Raj
2023-12-31 19:16:35 -08:00
committed by Tom Ingleby
parent 60d99f1a59
commit 47c3850cdd

View File

@@ -12,6 +12,7 @@
#endif #endif
#include <dlfcn.h> #include <dlfcn.h>
#include <libgen.h>
#include <pwd.h> #include <pwd.h>
#include <sched.h> #include <sched.h>
#include <stddef.h> #include <stddef.h>
@@ -341,9 +342,11 @@ static int
mraa_count_iio_devices(const char* path, const struct stat* sb, int flag, struct FTW* ftwb) mraa_count_iio_devices(const char* path, const struct stat* sb, int flag, struct FTW* ftwb)
{ {
// we are only interested in files with specific names // we are only interested in files with specific names
if (fnmatch(IIO_DEVICE_WILDCARD, basename(path), 0) == 0) { char* tmp = strdup(path);
if (fnmatch(IIO_DEVICE_WILDCARD, basename(tmp), 0) == 0) {
num_iio_devices++; num_iio_devices++;
} }
free(tmp);
return 0; return 0;
} }