[PATCH] apps: common: dng_writer: Add a default case for switch-case on a modulo
Paul Elder
paul.elder at ideasonboard.com
Wed Jan 24 08:56:04 CET 2024
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 <paul.elder at ideasonboard.com>
---
src/apps/common/dng_writer.cpp | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/apps/common/dng_writer.cpp b/src/apps/common/dng_writer.cpp
index c945edce7..82bc065a5 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;
--
2.39.2
More information about the libcamera-devel
mailing list