From patchwork Wed Jan 24 07:56:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 19468 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 99271C323E for ; Wed, 24 Jan 2024 07:56:21 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id AEC5462949; Wed, 24 Jan 2024 08:56:20 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="mE4jJJzr"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CE1A261D23 for ; Wed, 24 Jan 2024 08:56:18 +0100 (CET) Received: from pyrite.hamster-moth.ts.net (h175-177-049-156.catv02.itscom.jp [175.177.49.156]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 8C7A9BEB; Wed, 24 Jan 2024 08:55:03 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1706082904; bh=yaxxWlCzAwmFr8go2TpRU7rt6eCC8e7ZUfjiOtqs61k=; h=From:To:Cc:Subject:Date:From; b=mE4jJJzrd2cA6k6pNe1fum4mgwVHzerI10eAvoJyTP9eaBvDnZEmAajFYZ7HhtprL PEMaJaMaRs24DOeRC4k8nJlJZAmi/I82v+NMn08uw6C0cXFSEV3rOvj1Vl5E4FjG79 5fcraQoKIgRh8455cSwleChvV8zrnri5Py9nX4k4= From: Paul Elder To: libcamera-devel@lists.libcamera.org Subject: [PATCH] apps: common: dng_writer: Add a default case for switch-case on a modulo Date: Wed, 24 Jan 2024 16:56:04 +0900 Message-Id: <20240124075604.2635498-1-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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 --- 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;