summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta-multimedia/recipes-multimedia/libcamera/libcamera/0001-rpi-Use-malloc-instead-of-variable-length-arrays.patch41
-rw-r--r--meta-multimedia/recipes-multimedia/libcamera/libcamera/0002-options-Replace-use-of-VLAs-in-C.patch128
-rw-r--r--meta-multimedia/recipes-multimedia/libcamera/libcamera_0.4.0.bb (renamed from meta-multimedia/recipes-multimedia/libcamera/libcamera_0.3.0.bb)6
3 files changed, 2 insertions, 173 deletions
diff --git a/meta-multimedia/recipes-multimedia/libcamera/libcamera/0001-rpi-Use-malloc-instead-of-variable-length-arrays.patch b/meta-multimedia/recipes-multimedia/libcamera/libcamera/0001-rpi-Use-malloc-instead-of-variable-length-arrays.patch
deleted file mode 100644
index 0ca2082c03..0000000000
--- a/meta-multimedia/recipes-multimedia/libcamera/libcamera/0001-rpi-Use-malloc-instead-of-variable-length-arrays.patch
+++ /dev/null
@@ -1,41 +0,0 @@
1From a3e25b6aa9775c43336e30d3b350f54c085a32c8 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Tue, 20 Feb 2024 18:44:23 -0800
4Subject: [PATCH] rpi: Use malloc instead of variable length arrays
5
6Clang-18+ diagnoses this as error
7
8| ../git/src/ipa/rpi/controller/rpi/alsc.cpp:499:10: error: variable length arrays in C++ are a Clang extension [-Werror,-Wvla-cxx-extension] | 499 | int xLo[X], xHi[X];
9| | ^
10
11Upstream-Status: Denied [https://lists.libcamera.org/pipermail/libcamera-devel/2024-February/040536.html]
12Signed-off-by: Khem Raj <raj.khem@gmail.com>
13---
14 src/ipa/rpi/controller/rpi/alsc.cpp | 7 +++++--
15 1 file changed, 5 insertions(+), 2 deletions(-)
16
17diff --git a/src/ipa/rpi/controller/rpi/alsc.cpp b/src/ipa/rpi/controller/rpi/alsc.cpp
18index 67029fc3..6eca9fb7 100644
19--- a/src/ipa/rpi/controller/rpi/alsc.cpp
20+++ b/src/ipa/rpi/controller/rpi/alsc.cpp
21@@ -496,8 +496,8 @@ void resampleCalTable(const Array2D<double> &calTableIn,
22 * Precalculate and cache the x sampling locations and phases to save
23 * recomputing them on every row.
24 */
25- int xLo[X], xHi[X];
26- double xf[X];
27+ int *xLo = (int *)malloc(X * sizeof(int)), *xHi = (int *)malloc(X * sizeof(int));
28+ double *xf = (double *)malloc(X * sizeof(double));
29 double scaleX = cameraMode.sensorWidth /
30 (cameraMode.width * cameraMode.scaleX);
31 double xOff = cameraMode.cropX / (double)cameraMode.sensorWidth;
32@@ -539,6 +539,9 @@ void resampleCalTable(const Array2D<double> &calTableIn,
33 *(out++) = above * (1 - yf) + below * yf;
34 }
35 }
36+ free(xf);
37+ free(xHi);
38+ free(xLo);
39 }
40
41 /* Calculate chrominance statistics (R/G and B/G) for each region. */
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
deleted file mode 100644
index 473820653e..0000000000
--- a/meta-multimedia/recipes-multimedia/libcamera/libcamera/0002-options-Replace-use-of-VLAs-in-C.patch
+++ /dev/null
@@ -1,128 +0,0 @@
1From 6e4736180fcaffdb06acf52fd3eb50ba5baa3d2a 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] 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 | 12 ++++++++++--
18 src/libcamera/ipc_unixsocket.cpp | 13 +++++++++----
19 2 files changed, 19 insertions(+), 6 deletions(-)
20
21diff --git a/src/apps/common/options.cpp b/src/apps/common/options.cpp
22index 4f7e8691..3656f3c1 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*)malloc(optionsMap_.size() * 3 + 2);
32+ struct option *longOptions = (struct option*)malloc(sizeof(struct option) * (optionsMap_.size() + 1));
33 unsigned int ids = 0;
34 unsigned int idl = 0;
35
36@@ -935,12 +935,16 @@ OptionsParser::Options OptionsParser::parse(int argc, char **argv)
37 std::cerr << argv[optind - 1] << std::endl;
38
39 usage();
40+ free(shortOptions);
41+ free(longOptions);
42 return options;
43 }
44
45 const Option &option = *optionsMap_[c];
46 if (!parseValue(option, optarg, &options)) {
47 usage();
48+ free(shortOptions);
49+ free(longOptions);
50 return options;
51 }
52 }
53@@ -949,10 +953,14 @@ OptionsParser::Options OptionsParser::parse(int argc, char **argv)
54 std::cerr << "Invalid non-option argument '" << argv[optind]
55 << "'" << std::endl;
56 usage();
57+ free(shortOptions);
58+ free(longOptions);
59 return options;
60 }
61
62 options.valid_ = true;
63+ free(shortOptions);
64+ free(longOptions);
65 return options;
66 }
67
68diff --git a/src/libcamera/ipc_unixsocket.cpp b/src/libcamera/ipc_unixsocket.cpp
69index 1980d374..3bd861cb 100644
70--- a/src/libcamera/ipc_unixsocket.cpp
71+++ b/src/libcamera/ipc_unixsocket.cpp
72@@ -8,6 +8,7 @@
73 #include "libcamera/internal/ipc_unixsocket.h"
74
75 #include <array>
76+#include <cstdint>
77 #include <poll.h>
78 #include <string.h>
79 #include <sys/socket.h>
80@@ -247,8 +248,8 @@ int IPCUnixSocket::sendData(const void *buffer, size_t length,
81 iov[0].iov_base = const_cast<void *>(buffer);
82 iov[0].iov_len = length;
83
84- char buf[CMSG_SPACE(num * sizeof(uint32_t))];
85- memset(buf, 0, sizeof(buf));
86+ char *buf = (char*)malloc(CMSG_SPACE(num * sizeof(uint32_t)));
87+ memset((void*)buf, 0, sizeof(buf));
88
89 struct cmsghdr *cmsg = (struct cmsghdr *)buf;
90 cmsg->cmsg_len = CMSG_LEN(num * sizeof(uint32_t));
91@@ -270,9 +271,11 @@ int IPCUnixSocket::sendData(const void *buffer, size_t length,
92 int ret = -errno;
93 LOG(IPCUnixSocket, Error)
94 << "Failed to sendmsg: " << strerror(-ret);
95+ free(buf);
96 return ret;
97 }
98
99+ free(buf);
100 return 0;
101 }
102
103@@ -283,8 +286,8 @@ int IPCUnixSocket::recvData(void *buffer, size_t length,
104 iov[0].iov_base = buffer;
105 iov[0].iov_len = length;
106
107- char buf[CMSG_SPACE(num * sizeof(uint32_t))];
108- memset(buf, 0, sizeof(buf));
109+ char *buf = (char*)malloc(CMSG_SPACE(num * sizeof(uint32_t)));
110+ memset((void*)buf, 0, sizeof(buf));
111
112 struct cmsghdr *cmsg = (struct cmsghdr *)buf;
113 cmsg->cmsg_len = CMSG_LEN(num * sizeof(uint32_t));
114@@ -305,12 +308,14 @@ int IPCUnixSocket::recvData(void *buffer, size_t length,
115 if (ret != -EAGAIN)
116 LOG(IPCUnixSocket, Error)
117 << "Failed to recvmsg: " << strerror(-ret);
118+ free(buf);
119 return ret;
120 }
121
122 if (fds)
123 memcpy(fds, CMSG_DATA(cmsg), num * sizeof(uint32_t));
124
125+ free(buf);
126 return 0;
127 }
128
diff --git a/meta-multimedia/recipes-multimedia/libcamera/libcamera_0.3.0.bb b/meta-multimedia/recipes-multimedia/libcamera/libcamera_0.4.0.bb
index 857f565fb7..682e56739f 100644
--- a/meta-multimedia/recipes-multimedia/libcamera/libcamera_0.3.0.bb
+++ b/meta-multimedia/recipes-multimedia/libcamera/libcamera_0.4.0.bb
@@ -11,11 +11,9 @@ LIC_FILES_CHKSUM = "\
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 \ 13 file://0001-media_device-Add-bool-return-type-to-unlock.patch \
14 file://0002-options-Replace-use-of-VLAs-in-C.patch \
15 file://0001-rpi-Use-malloc-instead-of-variable-length-arrays.patch \
16" 14"
17 15
18SRCREV = "aee16c06913422a0ac84ee3217f87a9795e3c2d9" 16SRCREV = "35ed4b91291d9f3d08e4b51acfb51163e65df8f8"
19 17
20PE = "1" 18PE = "1"
21 19
@@ -46,7 +44,7 @@ RDEPENDS:${PN} = "${@bb.utils.contains('DISTRO_FEATURES', 'wayland qt', 'qtwayla
46inherit meson pkgconfig python3native 44inherit meson pkgconfig python3native
47 45
48do_configure:prepend() { 46do_configure:prepend() {
49 sed -i -e 's|py_compile=True,||' ${S}/utils/ipc/mojo/public/tools/mojom/mojom/generate/template_expander.py 47 sed -i -e 's|py_compile=True,||' ${S}/utils/codegen/ipc/mojo/public/tools/mojom/mojom/generate/template_expander.py
50} 48}
51 49
52do_install:append() { 50do_install:append() {