summaryrefslogtreecommitdiff
path: root/src/qcam/main.cpp
diff options
context:
space:
mode:
authorMarco Felsch <m.felsch@pengutronix.de>2022-09-02 16:11:36 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2022-09-05 17:55:45 +0300
commit5771125bfa4ae6c51a214d42933c393352395a89 (patch)
tree639570ecc5a3ccf8f9cfd405b4c3db6075fb42c6 /src/qcam/main.cpp
parenta03ce60cf969b7b26b25c785f64cb5662635b702 (diff)
qcam: viewfinder_gl: Fix maybe-uninitialized warnings
Commit 251f0534b74b ("qcam: viewfinder_gl: Take color space into account for YUV rendering") introduced maybe-uninitialized warnings with gcc 11 and 12 when compiling with -O3. Both compilers warn that ../../src/qcam/viewfinder_gl.cpp: In member function ‘void ViewFinderGL::selectColorSpace(const libcamera::ColorSpace&)’: ../../src/qcam/viewfinder_gl.cpp:392:21: error: ‘offset’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 391 | fragmentShaderDefines_.append(QString("#define YUV2RGB_Y_OFFSET %1") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 392 | .arg(offset, 0, 'f', 1)); | ~~~~^~~~~~~~~~~~~~~~~~~ Additionally, gcc 12 warns that ../../src/qcam/viewfinder_gl.cpp: In member function ‘void ViewFinderGL::selectColorSpace(const libcamera::ColorSpace&)’: ../../src/qcam/viewfinder_gl.cpp:379:36: error: ‘yuv2rgb’ may be used uninitialized [-Werror=maybe-uninitialized] 379 | yuv2rgb[i] *= 255.0 / 219.0; ../../src/qcam/viewfinder_gl.cpp:330:31: note: ‘yuv2rgb’ declared here 330 | std::array<double, 9> yuv2rgb; | While this should never happen here, the compiler isn't necessarily wrong, as C++17 allows initializing a scoped enum from an integer using direct-list-initialization, even if the integer value doesn't match any of the enumerators for the scoped enum ([1]). Whether this is valid or borderline paranoia from gcc may be debatable, but in any case it can't be classified as blatantly wrong. Fix the warnings by adding default cases to the switch statements in ViewFinderGL::selectColorSpace(). Which case is selected as the default doesn't matter, as this is not meant to happen. [1] https://en.cppreference.com/w/cpp/language/enum#enum_relaxed_init_cpp17 Bug: https://bugs.libcamera.org/show_bug.cgi?id=143 Fixes: 251f0534b74b ("qcam: viewfinder_gl: Take color space into account for YUV rendering") Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Rewrote commit message, added a default case for the encoding switch. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Diffstat (limited to 'src/qcam/main.cpp')
0 files changed, 0 insertions, 0 deletions