[{"id":28622,"web_url":"https://patchwork.libcamera.org/comment/28622/","msgid":"<170609634556.1011926.14790608747822937954@ping.linuxembedded.co.uk>","date":"2024-01-24T11:39:05","subject":"Re: [PATCH] apps: common: dng_writer: Add a default case for\n\tswitch-case on a modulo","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Paul Elder (2024-01-24 07:56:04)\n> Clearly all cases in the switch are already satisfied, but some\n> compilers fail to realize this and spit out an error:\n> \n> Compiler version: gcc 11.2.0 \"aarch64-buildroot-linux-gnu-gcc.br_real (Buildroot 2021.11) 11.2.0\"\n> \n> ../../src/apps/common/dng_writer.cpp: In function ‘void thumbScanlineIPU3(const FormatInfo&, void*, const void*, unsigned int, unsigned int)’:\n> ../../src/apps/common/dng_writer.cpp:277:55: error: ‘val4’ may be used uninitialized in this function [-Werror=maybe-uninitialized]\n>   277 |                 uint8_t value = (val1 + val2 + val3 + val4) >> 10;\n>       |                                                       ^~~~\n> ../../src/apps/common/dng_writer.cpp:277:48: error: ‘val3’ may be used uninitialized in this function [-Werror=maybe-uninitialized]\n>   277 |                 uint8_t value = (val1 + val2 + val3 + val4) >> 10;\n>       |                                                ^~~~\n> ../../src/apps/common/dng_writer.cpp:277:41: error: ‘val2’ may be used uninitialized in this function [-Werror=maybe-uninitialized]\n>   277 |                 uint8_t value = (val1 + val2 + val3 + val4) >> 10;\n>       |                                         ^~~~\n> ../../src/apps/common/dng_writer.cpp:277:34: error: ‘val1’ may be used uninitialized in this function [-Werror=maybe-uninitialized]\n>   277 |                 uint8_t value = (val1 + val2 + val3 + val4) >> 10;\n>       |                                  ^~~~\n> \n> Add a default case for the switch-case on a modulo to silence this.\n> \n> Bug: https://bugs.libcamera.org/show_bug.cgi?id=207\n> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> ---\n>  src/apps/common/dng_writer.cpp | 1 +\n>  1 file changed, 1 insertion(+)\n> \n> diff --git a/src/apps/common/dng_writer.cpp b/src/apps/common/dng_writer.cpp\n> index c945edce7..82bc065a5 100644\n> --- a/src/apps/common/dng_writer.cpp\n> +++ b/src/apps/common/dng_writer.cpp\n> @@ -248,6 +248,7 @@ void thumbScanlineIPU3([[maybe_unused]] const FormatInfo &info, void *output,\n>  \n>                 uint16_t val1, val2, val3, val4;\n>                 switch (pixelInBlock % 4) {\n> +               default:\n>                 case 0:\n>                         val1 = (in[1] & 0x03) << 14 | (in[0] & 0xff) << 6;\n>                         val2 = (in[2] & 0x0f) << 12 | (in[1] & 0xfc) << 4;\n> -- \n> 2.39.2\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 4CED7C323E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 24 Jan 2024 11:39:11 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 784EB6294D;\n\tWed, 24 Jan 2024 12:39:10 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C0BAF61D30\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 24 Jan 2024 12:39:08 +0100 (CET)","from pendragon.ideasonboard.com\n\t(aztw-30-b2-v4wan-166917-cust845.vm26.cable.virginm.net\n\t[82.37.23.78])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 5E88BA06;\n\tWed, 24 Jan 2024 12:37:54 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"emJKuUhS\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1706096274;\n\tbh=+Y/VVjTwJkDIIoFuFoDJweO2dkWwVuRqK2ldMg2TTlM=;\n\th=In-Reply-To:References:Subject:From:To:Date:From;\n\tb=emJKuUhSaaWwsfpv6yF6zG7MFuzp5IU8OPzs+2ghdReIEqate9TJVbw4OHSZOQjw+\n\tOxVSXHuSQ6AV3bTRIxV0QxrYjaNXtC9GU2A4Z8jtsJli5Z3UfIVOMs07n/bB2Fh0HA\n\t++I4eMQrs5dHEWGNKHNgXRrLpJ0mgpWQDNsiLcmM=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20240124075604.2635498-1-paul.elder@ideasonboard.com>","References":"<20240124075604.2635498-1-paul.elder@ideasonboard.com>","Subject":"Re: [PATCH] apps: common: dng_writer: Add a default case for\n\tswitch-case on a modulo","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"Paul Elder <paul.elder@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Wed, 24 Jan 2024 11:39:05 +0000","Message-ID":"<170609634556.1011926.14790608747822937954@ping.linuxembedded.co.uk>","User-Agent":"alot/0.10","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":28623,"web_url":"https://patchwork.libcamera.org/comment/28623/","msgid":"<20240124152005.GB10598@pendragon.ideasonboard.com>","date":"2024-01-24T15:20:05","subject":"Re: [PATCH] apps: common: dng_writer: Add a default case for\n\tswitch-case on a modulo","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Wed, Jan 24, 2024 at 11:39:05AM +0000, Kieran Bingham wrote:\n> Quoting Paul Elder (2024-01-24 07:56:04)\n> > Clearly all cases in the switch are already satisfied, but some\n> > compilers fail to realize this and spit out an error:\n> > \n> > Compiler version: gcc 11.2.0 \"aarch64-buildroot-linux-gnu-gcc.br_real (Buildroot 2021.11) 11.2.0\"\n> > \n> > ../../src/apps/common/dng_writer.cpp: In function ‘void thumbScanlineIPU3(const FormatInfo&, void*, const void*, unsigned int, unsigned int)’:\n> > ../../src/apps/common/dng_writer.cpp:277:55: error: ‘val4’ may be used uninitialized in this function [-Werror=maybe-uninitialized]\n> >   277 |                 uint8_t value = (val1 + val2 + val3 + val4) >> 10;\n> >       |                                                       ^~~~\n> > ../../src/apps/common/dng_writer.cpp:277:48: error: ‘val3’ may be used uninitialized in this function [-Werror=maybe-uninitialized]\n> >   277 |                 uint8_t value = (val1 + val2 + val3 + val4) >> 10;\n> >       |                                                ^~~~\n> > ../../src/apps/common/dng_writer.cpp:277:41: error: ‘val2’ may be used uninitialized in this function [-Werror=maybe-uninitialized]\n> >   277 |                 uint8_t value = (val1 + val2 + val3 + val4) >> 10;\n> >       |                                         ^~~~\n> > ../../src/apps/common/dng_writer.cpp:277:34: error: ‘val1’ may be used uninitialized in this function [-Werror=maybe-uninitialized]\n> >   277 |                 uint8_t value = (val1 + val2 + val3 + val4) >> 10;\n> >       |                                  ^~~~\n> > \n> > Add a default case for the switch-case on a modulo to silence this.\n> > \n> > Bug: https://bugs.libcamera.org/show_bug.cgi?id=207\n> > Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n> \n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\nI'm really curious to know what gcc is thinking, but that doesn't\nprevent me from saying\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> > ---\n> >  src/apps/common/dng_writer.cpp | 1 +\n> >  1 file changed, 1 insertion(+)\n> > \n> > diff --git a/src/apps/common/dng_writer.cpp b/src/apps/common/dng_writer.cpp\n> > index c945edce7..82bc065a5 100644\n> > --- a/src/apps/common/dng_writer.cpp\n> > +++ b/src/apps/common/dng_writer.cpp\n> > @@ -248,6 +248,7 @@ void thumbScanlineIPU3([[maybe_unused]] const FormatInfo &info, void *output,\n> >  \n> >                 uint16_t val1, val2, val3, val4;\n> >                 switch (pixelInBlock % 4) {\n> > +               default:\n> >                 case 0:\n> >                         val1 = (in[1] & 0x03) << 14 | (in[0] & 0xff) << 6;\n> >                         val2 = (in[2] & 0x0f) << 12 | (in[1] & 0xfc) << 4;","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 48728BDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 24 Jan 2024 15:20:10 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 277E66294D;\n\tWed, 24 Jan 2024 16:20:09 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B457661D30\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 24 Jan 2024 16:20:07 +0100 (CET)","from pendragon.ideasonboard.com (89-27-53-110.bb.dnainternet.fi\n\t[89.27.53.110])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 1AE71A06;\n\tWed, 24 Jan 2024 16:18:53 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"qiteWBRl\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1706109533;\n\tbh=1Yk1p6EpcvBBjqfccWiFmkgdEISMWXLatB5MW06r4SI=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=qiteWBRlp6+HAhT9q/S+jQiPe/4bsrO39Xo6f7OrZA0uB59TsZQf3/jwkvvdh1xVV\n\taSGDdEhe35LbzrSbKbNu94+dqmppzzB+ktRfA/PQkHA/QFGTTUiUHfL7jqYbvR1vs6\n\tcnfxsdmKyMkrLAg4tI6hO2yr1Miyfg0w2EnC7X5I=","Date":"Wed, 24 Jan 2024 17:20:05 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Subject":"Re: [PATCH] apps: common: dng_writer: Add a default case for\n\tswitch-case on a modulo","Message-ID":"<20240124152005.GB10598@pendragon.ideasonboard.com>","References":"<20240124075604.2635498-1-paul.elder@ideasonboard.com>\n\t<170609634556.1011926.14790608747822937954@ping.linuxembedded.co.uk>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<170609634556.1011926.14790608747822937954@ping.linuxembedded.co.uk>","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]