aboutsummaryrefslogtreecommitdiffstats
path: root/meta-oe/recipes-extended/mraa/mraa/0001-mraa-Use-posix-basename.patch
blob: 4f07eae631118a589c2fd965dee219f96aa91a48 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
From 30f78cb2775358dacd10b02c0ba2ec0c3ba2945d Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Sun, 31 Dec 2023 19:16:35 -0800
Subject: [PATCH 1/2] 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>
---
Upstream-Status: Submitted [https://github.com/eclipse/mraa/pull/1125]
 src/mraa.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/mraa.c b/src/mraa.c
index 653ea1fa..b556d045 100644
--- a/src/mraa.c
+++ b/src/mraa.c
@@ -12,6 +12,7 @@
 #endif
 
 #include <dlfcn.h>
+#include <libgen.h>
 #include <pwd.h>
 #include <sched.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)
 {
     // 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;
 }
 
-- 
2.43.0