libcamera: Replace VLAs with alloca

Signed-off-by: Khem Raj <raj.khem@gmail.com>
This commit is contained in:
Khem Raj 2024-02-20 18:48:22 -08:00
parent 7132d7b571
commit 1f1a607970
No known key found for this signature in database
GPG Key ID: BB053355919D3314
2 changed files with 35 additions and 0 deletions

View File

@ -0,0 +1,34 @@
From 7982e55ce3a8b3c60a47258ff7d37d0dd78c303d Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Tue, 20 Feb 2024 18:44:23 -0800
Subject: [PATCH] rpi: Use alloca instead of variable length arrays
Clang-18+ diagnoses this as error
| ../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];
| | ^
Upstream-Status: Submitted [https://lists.libcamera.org/pipermail/libcamera-devel/2024-February/040529.html]
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
src/ipa/rpi/controller/rpi/alsc.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/ipa/rpi/controller/rpi/alsc.cpp b/src/ipa/rpi/controller/rpi/alsc.cpp
index 8a205c60..8c0ae8eb 100644
--- a/src/ipa/rpi/controller/rpi/alsc.cpp
+++ b/src/ipa/rpi/controller/rpi/alsc.cpp
@@ -496,8 +496,8 @@ void resampleCalTable(const Array2D<double> &calTableIn,
* Precalculate and cache the x sampling locations and phases to save
* recomputing them on every row.
*/
- int xLo[X], xHi[X];
- double xf[X];
+ int *xLo = (int*)alloca(X), *xHi = (int*)alloca(X);
+ double *xf = (double*)alloca(X);
double scaleX = cameraMode.sensorWidth /
(cameraMode.width * cameraMode.scaleX);
double xOff = cameraMode.cropX / (double)cameraMode.sensorWidth;
--
2.43.2

View File

@ -12,6 +12,7 @@ SRC_URI = " \
git://git.libcamera.org/libcamera/libcamera.git;protocol=https;branch=master \
file://0001-media_device-Add-bool-return-type-to-unlock.patch \
file://0002-options-Replace-use-of-VLAs-in-C.patch \
file://0001-rpi-Use-alloca-instead-of-variable-length-arrays.patch \
"
SRCREV = "89227a428a82e724548399d35c98ea89566f9045"