From 64502c8d4a3c0f440bf265a5ad03be00653957ba Mon Sep 17 00:00:00 2001 From: Paul Elder Date: Wed, 24 Jan 2024 16:56:04 +0900 Subject: apps: common: dng_writer: Add a default case for switch-case on a modulo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Clearly all cases in the switch are already satisfied, but some compilers fail to realize this and spit out an error: Compiler version: gcc 11.2.0 "aarch64-buildroot-linux-gnu-gcc.br_real (Buildroot 2021.11) 11.2.0" ../../src/apps/common/dng_writer.cpp: In function ‘void thumbScanlineIPU3(const FormatInfo&, void*, const void*, unsigned int, unsigned int)’: ../../src/apps/common/dng_writer.cpp:277:55: error: ‘val4’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 277 | uint8_t value = (val1 + val2 + val3 + val4) >> 10; | ^~~~ ../../src/apps/common/dng_writer.cpp:277:48: error: ‘val3’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 277 | uint8_t value = (val1 + val2 + val3 + val4) >> 10; | ^~~~ ../../src/apps/common/dng_writer.cpp:277:41: error: ‘val2’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 277 | uint8_t value = (val1 + val2 + val3 + val4) >> 10; | ^~~~ ../../src/apps/common/dng_writer.cpp:277:34: error: ‘val1’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 277 | uint8_t value = (val1 + val2 + val3 + val4) >> 10; | ^~~~ Add a default case for the switch-case on a modulo to silence this. Bug: https://bugs.libcamera.org/show_bug.cgi?id=207 Signed-off-by: Paul Elder Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart Signed-off-by: Laurent Pinchart --- src/apps/common/dng_writer.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/apps') diff --git a/src/apps/common/dng_writer.cpp b/src/apps/common/dng_writer.cpp index c945edce..82bc065a 100644 --- a/src/apps/common/dng_writer.cpp +++ b/src/apps/common/dng_writer.cpp @@ -248,6 +248,7 @@ void thumbScanlineIPU3([[maybe_unused]] const FormatInfo &info, void *output, uint16_t val1, val2, val3, val4; switch (pixelInBlock % 4) { + default: case 0: val1 = (in[1] & 0x03) << 14 | (in[0] & 0xff) << 6; val2 = (in[2] & 0x0f) << 12 | (in[1] & 0xfc) << 4; -- cgit v1.2.1