libcamera: Use multiple of sizeof as malloc size

Signed-off-by: Khem Raj <raj.khem@gmail.com>
This commit is contained in:
Hubert Wiśniewski 2024-08-01 09:03:46 +02:00 committed by Khem Raj
parent 195d6196c6
commit 4642c541c4
No known key found for this signature in database
GPG Key ID: BB053355919D3314
2 changed files with 6 additions and 8 deletions

View File

@ -1,4 +1,4 @@
From 11cc6dbd45f0880beea64cdc514f57484b90bc39 Mon Sep 17 00:00:00 2001
From a3e25b6aa9775c43336e30d3b350f54c085a32c8 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 malloc instead of variable length arrays
@ -8,16 +8,14 @@ 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]
Upstream-Status: Denied [https://lists.libcamera.org/pipermail/libcamera-devel/2024-February/040536.html]
Signed-off-by: Khem Raj <raj.khem@gmail.com>
s
---
src/ipa/rpi/controller/rpi/alsc.cpp | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/ipa/rpi/controller/rpi/alsc.cpp b/src/ipa/rpi/controller/rpi/alsc.cpp
index 8a205c60..a7d42614 100644
index 67029fc3..6eca9fb7 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,
@ -26,8 +24,8 @@ index 8a205c60..a7d42614 100644
*/
- int xLo[X], xHi[X];
- double xf[X];
+ int *xLo = (int*)malloc(X), *xHi = (int*)malloc(X);
+ double *xf = (double*)malloc(X);
+ int *xLo = (int *)malloc(X * sizeof(int)), *xHi = (int *)malloc(X * sizeof(int));
+ double *xf = (double *)malloc(X * sizeof(double));
double scaleX = cameraMode.sensorWidth /
(cameraMode.width * cameraMode.scaleX);
double xOff = cameraMode.cropX / (double)cameraMode.sensorWidth;

View File

@ -12,7 +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 \
file://0001-rpi-Use-malloc-instead-of-variable-length-arrays.patch \
"
SRCREV = "aee16c06913422a0ac84ee3217f87a9795e3c2d9"