1From 30f78cb2775358dacd10b02c0ba2ec0c3ba2945d Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Sun, 31 Dec 2023 19:16:35 -0800
4Subject: [PATCH 1/2] mraa: Use posix basename
5
6Musl has removed the declaration from string.h [1] which exposes the
7problem especially with clang-17+ compiler where implicit function
8declaration is flagged as error. Use posix basename and make a copy of
9string to operate on to emulate GNU basename behaviour.
10
11[1] https://git.musl-libc.org/cgit/musl/commit/?id=725e17ed6dff4d0cd22487bb64470881e86a92e7
12
13Signed-off-by: Khem Raj <raj.khem@gmail.com>
14---
15Upstream-Status: Submitted [https://github.com/eclipse/mraa/pull/1125]
16 src/mraa.c | 5 ++++-
17 1 file changed, 4 insertions(+), 1 deletion(-)
18
19diff --git a/src/mraa.c b/src/mraa.c
20index 653ea1fa..b556d045 100644
21--- a/src/mraa.c
22+++ b/src/mraa.c
23@@ -12,6 +12,7 @@
24 #endif
25
26 #include <dlfcn.h>
27+#include <libgen.h>
28 #include <pwd.h>
29 #include <sched.h>
30 #include <stddef.h>
31@@ -341,9 +342,11 @@ static int
32 mraa_count_iio_devices(const char* path, const struct stat* sb, int flag, struct FTW* ftwb)
33 {
34     // we are only interested in files with specific names
35-    if (fnmatch(IIO_DEVICE_WILDCARD, basename(path), 0) == 0) {
36+    char* tmp = strdup(path);
37+    if (fnmatch(IIO_DEVICE_WILDCARD, basename(tmp), 0) == 0) {
38         num_iio_devices++;
39     }
40+    free(tmp);
41     return 0;
42 }
43
44--
452.43.0
46
47