summaryrefslogtreecommitdiffstats
path: root/meta-multimedia
diff options
context:
space:
mode:
authorKhem Raj <raj.khem@gmail.com>2024-01-31 21:10:38 -0800
committerKhem Raj <raj.khem@gmail.com>2024-01-31 21:11:26 -0800
commit2aaf6b75a9582ee6492f65362d082969b6b1ee7d (patch)
treed5aa5286a41c9623cf2c04f40228b99e0289e10f /meta-multimedia
parent4cefe0196f7a2471b144413510d072d525e1a041 (diff)
downloadmeta-openembedded-2aaf6b75a9582ee6492f65362d082969b6b1ee7d.tar.gz
libcamera: Fix build with clang-18
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Diffstat (limited to 'meta-multimedia')
-rw-r--r--meta-multimedia/recipes-multimedia/libcamera/libcamera/0001-media_device-Add-bool-return-type-to-unlock.patch59
-rw-r--r--meta-multimedia/recipes-multimedia/libcamera/libcamera/0002-options-Replace-use-of-VLAs-in-C.patch91
-rw-r--r--meta-multimedia/recipes-multimedia/libcamera/libcamera_0.2.0.bb2
3 files changed, 152 insertions, 0 deletions
diff --git a/meta-multimedia/recipes-multimedia/libcamera/libcamera/0001-media_device-Add-bool-return-type-to-unlock.patch b/meta-multimedia/recipes-multimedia/libcamera/libcamera/0001-media_device-Add-bool-return-type-to-unlock.patch
new file mode 100644
index 000000000..12f034eff
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/libcamera/libcamera/0001-media_device-Add-bool-return-type-to-unlock.patch
@@ -0,0 +1,59 @@
1From 6914c4fd3d53c0c6ea304123bf57429bb64ec16f Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Wed, 31 Jan 2024 21:01:27 -0800
4Subject: [PATCH 1/2] media_device: Add bool return type to unlock()
5
6unlock uses lockf which is marked with __attribute__
7((warn_unused_result)) and compilers warn about it and some treat
8-Wunused-result as error with -Werror turned on, It would be good to
9check if lockf failed or succeeded, however, that piece is not changed
10with this, this fixes build with clang++ 18
11
12 ../git/src/libcamera/media_device.cpp:167:2: error: ignoring return value of function declared with 'warn_unused_result' attribute [-Werror,-Wunused-result]
13 167 | lockf(fd_.get(), F_ULOCK, 0);
14 | ^~~~~ ~~~~~~~~~~~~~~~~~~~~~
15 1 error generated.
16
17Upstream-Status: Submitted [https://lists.libcamera.org/pipermail/libcamera-devel/2024-February/040380.html]
18Signed-off-by: Khem Raj <raj.khem@gmail.com>
19---
20 include/libcamera/internal/media_device.h | 2 +-
21 src/libcamera/media_device.cpp | 6 +++---
22 2 files changed, 4 insertions(+), 4 deletions(-)
23
24diff --git a/include/libcamera/internal/media_device.h b/include/libcamera/internal/media_device.h
25index eb8cfde4..b09dfd16 100644
26--- a/include/libcamera/internal/media_device.h
27+++ b/include/libcamera/internal/media_device.h
28@@ -33,7 +33,7 @@ public:
29 bool busy() const { return acquired_; }
30
31 bool lock();
32- void unlock();
33+ bool unlock();
34
35 int populate();
36 bool isValid() const { return valid_; }
37diff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp
38index 2949816b..eaa2fdb0 100644
39--- a/src/libcamera/media_device.cpp
40+++ b/src/libcamera/media_device.cpp
41@@ -159,12 +159,12 @@ bool MediaDevice::lock()
42 *
43 * \sa lock()
44 */
45-void MediaDevice::unlock()
46+bool MediaDevice::unlock()
47 {
48 if (!fd_.isValid())
49- return;
50+ return false;
51
52- lockf(fd_.get(), F_ULOCK, 0);
53+ return lockf(fd_.get(), F_ULOCK, 0) == 0;
54 }
55
56 /**
57--
582.43.0
59
diff --git a/meta-multimedia/recipes-multimedia/libcamera/libcamera/0002-options-Replace-use-of-VLAs-in-C.patch b/meta-multimedia/recipes-multimedia/libcamera/libcamera/0002-options-Replace-use-of-VLAs-in-C.patch
new file mode 100644
index 000000000..95f321782
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/libcamera/libcamera/0002-options-Replace-use-of-VLAs-in-C.patch
@@ -0,0 +1,91 @@
1From c80d273a57547aec9353d888aa316bf6560cf1ba Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Wed, 31 Jan 2024 21:04:28 -0800
4Subject: [PATCH 2/2] options: Replace use of VLAs in C++
5
6Clang++ 18 is fussy about this with new warning checks.
7
8 ../git/src/apps/common/options.cpp:882:20: error: variable length arrays in C++ are a Clang extension [-Werror,-Wvla-cxx-extension]
9 882 | char shortOptions[optionsMap_.size() * 3 + 2];
10 | ^~~~~~~~~~~~~~~~~~~~~~~~~~
11
12Therefore replace using VLAs with alloca and malloc/free
13
14Upstream-Status: Submitted [https://lists.libcamera.org/pipermail/libcamera-devel/2024-February/040381.html]
15Signed-off-by: Khem Raj <raj.khem@gmail.com>
16---
17 src/apps/common/options.cpp | 4 ++--
18 src/libcamera/ipc_unixsocket.cpp | 12 ++++++++----
19 2 files changed, 10 insertions(+), 6 deletions(-)
20
21diff --git a/src/apps/common/options.cpp b/src/apps/common/options.cpp
22index 4f7e8691..b020f603 100644
23--- a/src/apps/common/options.cpp
24+++ b/src/apps/common/options.cpp
25@@ -879,8 +879,8 @@ OptionsParser::Options OptionsParser::parse(int argc, char **argv)
26 * Allocate short and long options arrays large enough to contain all
27 * options.
28 */
29- char shortOptions[optionsMap_.size() * 3 + 2];
30- struct option longOptions[optionsMap_.size() + 1];
31+ char *shortOptions = (char*)alloca(optionsMap_.size() * 3 + 2);
32+ struct option *longOptions = (struct option*)alloca(optionsMap_.size() + 1);
33 unsigned int ids = 0;
34 unsigned int idl = 0;
35
36diff --git a/src/libcamera/ipc_unixsocket.cpp b/src/libcamera/ipc_unixsocket.cpp
37index 1980d374..3a7f8ee6 100644
38--- a/src/libcamera/ipc_unixsocket.cpp
39+++ b/src/libcamera/ipc_unixsocket.cpp
40@@ -247,8 +247,8 @@ int IPCUnixSocket::sendData(const void *buffer, size_t length,
41 iov[0].iov_base = const_cast<void *>(buffer);
42 iov[0].iov_len = length;
43
44- char buf[CMSG_SPACE(num * sizeof(uint32_t))];
45- memset(buf, 0, sizeof(buf));
46+ char *buf = (char*)malloc(CMSG_SPACE(num * sizeof(uint32_t)));
47+ memset((void*)buf, 0, sizeof(buf));
48
49 struct cmsghdr *cmsg = (struct cmsghdr *)buf;
50 cmsg->cmsg_len = CMSG_LEN(num * sizeof(uint32_t));
51@@ -270,9 +270,11 @@ int IPCUnixSocket::sendData(const void *buffer, size_t length,
52 int ret = -errno;
53 LOG(IPCUnixSocket, Error)
54 << "Failed to sendmsg: " << strerror(-ret);
55+ free(buf);
56 return ret;
57 }
58
59+ free(buf);
60 return 0;
61 }
62
63@@ -283,8 +285,8 @@ int IPCUnixSocket::recvData(void *buffer, size_t length,
64 iov[0].iov_base = buffer;
65 iov[0].iov_len = length;
66
67- char buf[CMSG_SPACE(num * sizeof(uint32_t))];
68- memset(buf, 0, sizeof(buf));
69+ char *buf = (char*)malloc(CMSG_SPACE(num * sizeof(uint32_t)));
70+ memset((void*)buf, 0, sizeof(buf));
71
72 struct cmsghdr *cmsg = (struct cmsghdr *)buf;
73 cmsg->cmsg_len = CMSG_LEN(num * sizeof(uint32_t));
74@@ -305,12 +307,14 @@ int IPCUnixSocket::recvData(void *buffer, size_t length,
75 if (ret != -EAGAIN)
76 LOG(IPCUnixSocket, Error)
77 << "Failed to recvmsg: " << strerror(-ret);
78+ free(buf);
79 return ret;
80 }
81
82 if (fds)
83 memcpy(fds, CMSG_DATA(cmsg), num * sizeof(uint32_t));
84
85+ free(buf);
86 return 0;
87 }
88
89--
902.43.0
91
diff --git a/meta-multimedia/recipes-multimedia/libcamera/libcamera_0.2.0.bb b/meta-multimedia/recipes-multimedia/libcamera/libcamera_0.2.0.bb
index 3fd17f0a8..5b2e86336 100644
--- a/meta-multimedia/recipes-multimedia/libcamera/libcamera_0.2.0.bb
+++ b/meta-multimedia/recipes-multimedia/libcamera/libcamera_0.2.0.bb
@@ -10,6 +10,8 @@ LIC_FILES_CHKSUM = "\
10 10
11SRC_URI = " \ 11SRC_URI = " \
12 git://git.libcamera.org/libcamera/libcamera.git;protocol=https;branch=master \ 12 git://git.libcamera.org/libcamera/libcamera.git;protocol=https;branch=master \
13 file://0001-media_device-Add-bool-return-type-to-unlock.patch \
14 file://0002-options-Replace-use-of-VLAs-in-C.patch \
13" 15"
14 16
15SRCREV = "89227a428a82e724548399d35c98ea89566f9045" 17SRCREV = "89227a428a82e724548399d35c98ea89566f9045"