[{"id":28710,"web_url":"https://patchwork.libcamera.org/comment/28710/","msgid":"<b1GDpgJJatCeUuW0kp4sTq02whqwG9LCotH38ZEi7ZzF3BLxCISDInvrOG56t3AaF3AuOqfPoUa7BxDFDbF_T3O8Vz40VPAJEfqyde61-Hs=@protonmail.com>","date":"2024-02-21T14:04:02","subject":"Re: [PATCH] rpi: Use alloca instead of variable length arrays","submitter":{"id":133,"url":"https://patchwork.libcamera.org/api/people/133/","name":"Pőcze Barnabás","email":"pobrn@protonmail.com"},"content":"Hi\n\n\n2024. február 21., szerda 3:46 keltezéssel, Khem Raj <raj.khem@gmail.com> írta:\n\n> Clang-18+ diagnoses this as error\n> \n> | ../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];\n> |       |                 ^\n> \n> Signed-off-by: Khem Raj <raj.khem@gmail.com>\n> ---\n>  src/ipa/rpi/controller/rpi/alsc.cpp | 4 ++--\n>  1 file changed, 2 insertions(+), 2 deletions(-)\n> \n> diff --git a/src/ipa/rpi/controller/rpi/alsc.cpp b/src/ipa/rpi/controller/rpi/alsc.cpp\n> index 8a205c60..8c0ae8eb 100644\n> --- a/src/ipa/rpi/controller/rpi/alsc.cpp\n> +++ b/src/ipa/rpi/controller/rpi/alsc.cpp\n> @@ -496,8 +496,8 @@ void resampleCalTable(const Array2D<double> &calTableIn,\n>  \t * Precalculate and cache the x sampling locations and phases to save\n>  \t * recomputing them on every row.\n>  \t */\n> -\tint xLo[X], xHi[X];\n> -\tdouble xf[X];\n> +\tint *xLo = (int*)alloca(X), *xHi = (int*)alloca(X);\n> +\tdouble *xf = (double*)alloca(X);\n>  \tdouble scaleX = cameraMode.sensorWidth /\n>  \t\t\t(cameraMode.width * cameraMode.scaleX);\n>  \tdouble xOff = cameraMode.cropX / (double)cameraMode.sensorWidth;\n> --\n> 2.43.2\n\n\nThis change is incorrect, the allocated sizes are insufficient. Also I am not\nsure going from VLA to alloca is really an improvement. Maybe the warning should\nbe turned off. Or dynamic stack allocation should be eliminated altogether.\n\n\nRegards,\nBarnabás Pőcze","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 97B39C0F1B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 21 Feb 2024 14:04:34 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 105A062813;\n\tWed, 21 Feb 2024 15:04:34 +0100 (CET)","from mail-4322.protonmail.ch (mail-4322.protonmail.ch\n\t[185.70.43.22])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3332761C9D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 21 Feb 2024 15:04:32 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=protonmail.com header.i=@protonmail.com\n\theader.b=\"YBcEydry\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com;\n\ts=protonmail3; t=1708524269; x=1708783469;\n\tbh=mNmxZ4X5hLw3iNFfWgzDMvTfqVvNvF+BzUqaVbtuAis=;\n\th=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References:\n\tFeedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID:\n\tMessage-ID:BIMI-Selector;\n\tb=YBcEydry6ZMijE9PODWMgR8hTVHi30CRTPnovabhTPSog8FnhpgcSRe5HybssUiov\n\tIgHQHnH+cLGoKc90UC4SurHdcLSqSrA6BMizFVHrMs8Xj7rfNJgz6eP6/mhspju+G5\n\tWI6TAmJraKVU4bq9S86/cHutpds1e72j2f63RMEMdzrIiPUUeP5vrRVT62/PjUZNLj\n\tY6ubhxQvUUcQVd0qoeMViaQaRE8OeRDLYjuVo3hjaKeKll6kqR/8cjql4NYpSirfS3\n\tVp1DVCn2bRw3Z3wuBX3XNXj9wKdCyG86CbPZynWo4h570HM8opH0bRscu2Q5Y69q2a\n\thg4NBtcXI+ZlQ==","Date":"Wed, 21 Feb 2024 14:04:02 +0000","To":"Khem Raj <raj.khem@gmail.com>","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <pobrn@protonmail.com>","Subject":"Re: [PATCH] rpi: Use alloca instead of variable length arrays","Message-ID":"<b1GDpgJJatCeUuW0kp4sTq02whqwG9LCotH38ZEi7ZzF3BLxCISDInvrOG56t3AaF3AuOqfPoUa7BxDFDbF_T3O8Vz40VPAJEfqyde61-Hs=@protonmail.com>","In-Reply-To":"<20240221024638.1486832-1-raj.khem@gmail.com>","References":"<20240221024638.1486832-1-raj.khem@gmail.com>","Feedback-ID":"20568564:user:proton","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Transfer-Encoding":"quoted-printable","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]