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