From 516f365670235f9dac97defa1b586d0503f8e310 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Thu, 22 May 2025 14:38:00 +0200 Subject: [PATCH] libcamera: matrix: Fix compilation error in inverse() function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some gcc versions report uninitialized variable usage: In member function ‘constexpr T& libcamera::Span::operator[](size_type) const [with T = unsigned int]’, inlined from ‘void libcamera::matrixInvert(Span, Span, unsigned int, Span, Span)::MatrixAccessor::swap(unsigned int, unsigned int) [with T = float]’ at ../../src/libcamera/matrix.cpp:194:13, inlined from ‘bool libcamera::matrixInvert(Span, Span, unsigned int, Span, Span) [with T = float]’ at ../../src/libcamera/matrix.cpp:255:14: ../../include/libcamera/base/span.h:362:76: error: ‘row’ may be used uninitialized [-Werror=maybe-uninitialized] 362 | constexpr reference operator[](size_type idx) const { return data()[idx]; } | ~~~~~~^ ../../src/libcamera/matrix.cpp: In function ‘bool libcamera::matrixInvert(Span, Span, unsigned int, Span, Span) [with T = float]’: ../../src/libcamera/matrix.cpp:232:30: note: ‘row’ was declared here 232 | unsigned int row; | ^~~ This is a false positive. Fix it by initializing the variable when declaring it. Fixes: 6287ceff5aba ("libcamera: matrix: Add inverse() function") Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham Tested-by: Barnabás Pőcze Tested-by: Milan Zamazal --- src/libcamera/matrix.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcamera/matrix.cpp b/src/libcamera/matrix.cpp index ed22263b5..b7c07e896 100644 --- a/src/libcamera/matrix.cpp +++ b/src/libcamera/matrix.cpp @@ -229,7 +229,7 @@ bool matrixInvert(Span dataIn, Span dataOut, unsigned int dim, * Locate the next pivot. To improve numerical stability, use * the row with the largest value in the pivot's column. */ - unsigned int row; + unsigned int row = pivot; T maxValue{ 0 }; for (unsigned int i = pivot; i < dim; ++i) {