Skip to content

Commit

Permalink
mraa: Use posix basename
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
kraj authored and tingleby committed Jan 23, 2024
1 parent 60d99f1 commit 47c3850
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/mraa.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#endif

#include <dlfcn.h>
#include <libgen.h>
#include <pwd.h>
#include <sched.h>
#include <stddef.h>
Expand Down Expand Up @@ -341,9 +342,11 @@ static int
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
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++;
}
free(tmp);
return 0;
}

Expand Down

0 comments on commit 47c3850

Please sign in to comment.