[{"id":24911,"web_url":"https://patchwork.libcamera.org/comment/24911/","msgid":"<20220903010825.GE113531@pyrite.rasen.tech>","date":"2022-09-03T01:08:25","subject":"Re: [libcamera-devel] [PATCH v2] qcam: viewfinder_gl: Fix\n\tmaybe-uninitialized warnings","submitter":{"id":97,"url":"https://patchwork.libcamera.org/api/people/97/","name":"Nicolas Dufresne via libcamera-devel","email":"libcamera-devel@lists.libcamera.org"},"content":"On Sat, Sep 03, 2022 at 03:35:13AM +0300, Laurent Pinchart via libcamera-devel wrote:\n> From: Marco Felsch <m.felsch@pengutronix.de>\n> \n> Commit 251f0534b74b (\"qcam: viewfinder_gl: Take color space into account\n> for YUV rendering\") introduced maybe-uninitialized warnings with gcc 11\n> and 12 when compiling with -O3. Both compilers warn that\n> \n> ../../src/qcam/viewfinder_gl.cpp: In member function ‘void ViewFinderGL::selectColorSpace(const libcamera::ColorSpace&)’:\n> ../../src/qcam/viewfinder_gl.cpp:392:21: error: ‘offset’ may be used uninitialized in this function [-Werror=maybe-uninitialized]\n>   391 |         fragmentShaderDefines_.append(QString(\"#define YUV2RGB_Y_OFFSET %1\")\n>       |                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n>   392 |                 .arg(offset, 0, 'f', 1));\n>       |                 ~~~~^~~~~~~~~~~~~~~~~~~\n> \n> Additionally, gcc 12 warns that\n> \n> ../../src/qcam/viewfinder_gl.cpp: In member function ‘void ViewFinderGL::selectColorSpace(const libcamera::ColorSpace&)’:\n> ../../src/qcam/viewfinder_gl.cpp:379:36: error: ‘yuv2rgb’ may be used uninitialized [-Werror=maybe-uninitialized]\n>   379 |                         yuv2rgb[i] *= 255.0 / 219.0;\n> ../../src/qcam/viewfinder_gl.cpp:330:31: note: ‘yuv2rgb’ declared here\n>   330 |         std::array<double, 9> yuv2rgb;\n>       |\n> \n> While this should never happen here, the compiler isn't necessarily\n> wrong, as C++17 allows initializing a scoped enum from an integer using\n> direct-list-initialization, even if the integer value doesn't match any\n> of the enumerators for the scoped enum ([1]). Whether this is valid or\n> borderline paranoia from gcc may be debatable, but in any case it can't\n> be classified as blatantly wrong. Fix the warnings by adding default\n> cases to the switch statements in ViewFinderGL::selectColorSpace().\n> Which case is selected as the default doesn't matter, as this is not\n> meant to happen.\n\nIf it's not meant to happen then maybe we should Fatal :D\n\njk imo indeed the \"sensible defaults\" that you chose below are\nsufficient.\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n> \n> [1] https://en.cppreference.com/w/cpp/language/enum#enum_relaxed_init_cpp17\n> \n> Fixes: 251f0534b74b (\"qcam: viewfinder_gl: Take color space into account for YUV rendering\")\n> Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>\n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> \n> Rewrote commit message, added a default case for the encoding switch.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n>  src/qcam/viewfinder_gl.cpp | 2 ++\n>  1 file changed, 2 insertions(+)\n> \n> diff --git a/src/qcam/viewfinder_gl.cpp b/src/qcam/viewfinder_gl.cpp\n> index e2aa24703ff0..38ddad58e09e 100644\n> --- a/src/qcam/viewfinder_gl.cpp\n> +++ b/src/qcam/viewfinder_gl.cpp\n> @@ -332,6 +332,7 @@ void ViewFinderGL::selectColorSpace(const libcamera::ColorSpace &colorSpace)\n>  \t/* OpenGL stores arrays in column-major order. */\n>  \tswitch (colorSpace.ycbcrEncoding) {\n>  \tcase libcamera::ColorSpace::YcbcrEncoding::None:\n> +\tdefault:\n>  \t\tyuv2rgb = {\n>  \t\t\t1.0000,  0.0000,  0.0000,\n>  \t\t\t0.0000,  1.0000,  0.0000,\n> @@ -368,6 +369,7 @@ void ViewFinderGL::selectColorSpace(const libcamera::ColorSpace &colorSpace)\n>  \n>  \tswitch (colorSpace.range) {\n>  \tcase libcamera::ColorSpace::Range::Full:\n> +\tdefault:\n>  \t\toffset = 0.0;\n>  \t\tbreak;\n>  \n> \n> base-commit: 251f0534b74bcb46c777aa0df34b1b4142b664f5\n> -- \n> Regards,\n> \n> Laurent Pinchart\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 13DDFC3272\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat,  3 Sep 2022 01:08:38 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 72D8962023;\n\tSat,  3 Sep 2022 03:08:37 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4C22162003\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat,  3 Sep 2022 03:08:35 +0200 (CEST)","from pyrite.rasen.tech (unknown [50.228.9.220])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 4179C51E;\n\tSat,  3 Sep 2022 03:08:34 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1662167317;\n\tbh=aLMU2rFFegkDXUb81k1lqWQvt2yOAWT1pTc50cMHACY=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=zNzku8SFFKUz28lWWPXSkD5VhhHLxX/HHFvzGM4a2B2tgA8Hy4hnDqfYajkbMCoMS\n\tff0IrJIwMOWYm+RjX3dLZTGNig2spog5MqOfB6CZYBa2/Lh5IU1c1BOMuvldmwzQ2G\n\t6y207xKl9zIUvr/V6SyMo9yyj0pHmr0MrcmvqbDhye1jYKDeUj5C0gQomcPEqCC6mW\n\txed5R2KoVslhVCOyyK4CPycFt6MWLk9AwJIjFLK46Uil/TigJbSublGzUtDvCQZ20p\n\thdkfVNUGeLrHX0K9UFTl2gAEQqz47hA0QFItaMckaSsIVEOumMt+a3VU3rO4UMq4W5\n\t5dGamtpdAadeQ==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1662167314;\n\tbh=aLMU2rFFegkDXUb81k1lqWQvt2yOAWT1pTc50cMHACY=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=G6yXhry1OoQurnF6OmezXoi8DDuZXOVY/GnjwdxUnSEGgCdhkctnqTuQXmHZUuz2x\n\tIDY/biDuuF07HvGCEtlmzjFQGAKiQHwmdfdmtuHBulAVSIr7/JrEe1alg3jAU5R9yF\n\tPQZvx1QlVKR0FGuIcbxmBAmZgrRAyrOvPasSbXPk="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"G6yXhry1\"; dkim-atps=neutral","Date":"Fri, 2 Sep 2022 21:08:25 -0400","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Message-ID":"<20220903010825.GE113531@pyrite.rasen.tech>","References":"<20220903003513.2516-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20220903003513.2516-1-laurent.pinchart@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v2] qcam: viewfinder_gl: Fix\n\tmaybe-uninitialized warnings","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>","From":"Paul Elder via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"paul.elder@ideasonboard.com","Cc":"mfe@pengutronix.de, libcamera-devel@lists.libcamera.org, drebert@web.de","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":24918,"web_url":"https://patchwork.libcamera.org/comment/24918/","msgid":"<YxNc5BMVjwPyNeV/@pendragon.ideasonboard.com>","date":"2022-09-03T13:55:48","subject":"Re: [libcamera-devel] [PATCH v2] qcam: viewfinder_gl: Fix\n\tmaybe-uninitialized warnings","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Paul,\n\nOn Fri, Sep 02, 2022 at 09:08:25PM -0400, paul.elder@ideasonboard.com wrote:\n> On Sat, Sep 03, 2022 at 03:35:13AM +0300, Laurent Pinchart via libcamera-devel wrote:\n> > From: Marco Felsch <m.felsch@pengutronix.de>\n> > \n> > Commit 251f0534b74b (\"qcam: viewfinder_gl: Take color space into account\n> > for YUV rendering\") introduced maybe-uninitialized warnings with gcc 11\n> > and 12 when compiling with -O3. Both compilers warn that\n> > \n> > ../../src/qcam/viewfinder_gl.cpp: In member function ‘void ViewFinderGL::selectColorSpace(const libcamera::ColorSpace&)’:\n> > ../../src/qcam/viewfinder_gl.cpp:392:21: error: ‘offset’ may be used uninitialized in this function [-Werror=maybe-uninitialized]\n> >   391 |         fragmentShaderDefines_.append(QString(\"#define YUV2RGB_Y_OFFSET %1\")\n> >       |                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n> >   392 |                 .arg(offset, 0, 'f', 1));\n> >       |                 ~~~~^~~~~~~~~~~~~~~~~~~\n> > \n> > Additionally, gcc 12 warns that\n> > \n> > ../../src/qcam/viewfinder_gl.cpp: In member function ‘void ViewFinderGL::selectColorSpace(const libcamera::ColorSpace&)’:\n> > ../../src/qcam/viewfinder_gl.cpp:379:36: error: ‘yuv2rgb’ may be used uninitialized [-Werror=maybe-uninitialized]\n> >   379 |                         yuv2rgb[i] *= 255.0 / 219.0;\n> > ../../src/qcam/viewfinder_gl.cpp:330:31: note: ‘yuv2rgb’ declared here\n> >   330 |         std::array<double, 9> yuv2rgb;\n> >       |\n> > \n> > While this should never happen here, the compiler isn't necessarily\n> > wrong, as C++17 allows initializing a scoped enum from an integer using\n> > direct-list-initialization, even if the integer value doesn't match any\n> > of the enumerators for the scoped enum ([1]). Whether this is valid or\n> > borderline paranoia from gcc may be debatable, but in any case it can't\n> > be classified as blatantly wrong. Fix the warnings by adding default\n> > cases to the switch statements in ViewFinderGL::selectColorSpace().\n> > Which case is selected as the default doesn't matter, as this is not\n> > meant to happen.\n> \n> If it's not meant to happen then maybe we should Fatal :D\n\nWithin libcamera I would have been tempted to do so, but in qcam, I\nthink I don't care that much (especially given that we have no LOG()\nthere).\n\n> jk imo indeed the \"sensible defaults\" that you chose below are\n> sufficient.\n> \n> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n> \n> > [1] https://en.cppreference.com/w/cpp/language/enum#enum_relaxed_init_cpp17\n> > \n> > Fixes: 251f0534b74b (\"qcam: viewfinder_gl: Take color space into account for YUV rendering\")\n> > Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>\n> > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > \n> > Rewrote commit message, added a default case for the encoding switch.\n> > \n> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > ---\n> >  src/qcam/viewfinder_gl.cpp | 2 ++\n> >  1 file changed, 2 insertions(+)\n> > \n> > diff --git a/src/qcam/viewfinder_gl.cpp b/src/qcam/viewfinder_gl.cpp\n> > index e2aa24703ff0..38ddad58e09e 100644\n> > --- a/src/qcam/viewfinder_gl.cpp\n> > +++ b/src/qcam/viewfinder_gl.cpp\n> > @@ -332,6 +332,7 @@ void ViewFinderGL::selectColorSpace(const libcamera::ColorSpace &colorSpace)\n> >  \t/* OpenGL stores arrays in column-major order. */\n> >  \tswitch (colorSpace.ycbcrEncoding) {\n> >  \tcase libcamera::ColorSpace::YcbcrEncoding::None:\n> > +\tdefault:\n> >  \t\tyuv2rgb = {\n> >  \t\t\t1.0000,  0.0000,  0.0000,\n> >  \t\t\t0.0000,  1.0000,  0.0000,\n> > @@ -368,6 +369,7 @@ void ViewFinderGL::selectColorSpace(const libcamera::ColorSpace &colorSpace)\n> >  \n> >  \tswitch (colorSpace.range) {\n> >  \tcase libcamera::ColorSpace::Range::Full:\n> > +\tdefault:\n> >  \t\toffset = 0.0;\n> >  \t\tbreak;\n> >  \n> > \n> > base-commit: 251f0534b74bcb46c777aa0df34b1b4142b664f5","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 8244FC0DA4\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat,  3 Sep 2022 13:56:03 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E071062034;\n\tSat,  3 Sep 2022 15:56:02 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1FE0661FBB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat,  3 Sep 2022 15:56:02 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 710E94A8;\n\tSat,  3 Sep 2022 15:56:01 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1662213362;\n\tbh=zuvLFAGJpqhAklsWP/HoszRkRVI7s1ORgI+mtvPT8ro=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=2e8ymNVxU7Ym223pRqvkNZL94b4Ms52BIcWnFroqJiV0DGECTIOu5cjoyMar0rSah\n\tmcbHmgyIbDvh53bRr6UNXzLTlJK2GshvyeCIjHq2HMBMIqgc6FQiX4QZriFQW4FrTY\n\tMlN5hK5Vejv24/Nw9HIq6S4GLYamkBf+8f+zCMWYmZ/8gcsp2x6EiEOUrE6WRsCt5n\n\tJ70DdScfniPuEMkJyGEubY8woSWiEua3k5F2yD6b949shAsK9634iRWX004gWpo7hB\n\tOwRzHfuL+jEoVlXRBHAY/FZJz1PrHVWFop39fxWXNuPYNYd9C1sJAL4efb6CerZ3Vz\n\tLJXGC6TDQY2+w==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1662213361;\n\tbh=zuvLFAGJpqhAklsWP/HoszRkRVI7s1ORgI+mtvPT8ro=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=msQjdY2C49tUL+uvMjHvXGz6lX8ub0zqi9YTx8pbei/8memgEuxw84u8q6Xbl2RCP\n\tU2nZumtDKdrY7yjfJ0eSF1wtHUzsKszmrTUtmxPSv+rxn1gKNLdaNwFlhpjW2vaodr\n\tvIuClmWppJ+7tjQsgYjNHW29CZUd+wPLxcsDGXww="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"msQjdY2C\"; dkim-atps=neutral","Date":"Sat, 3 Sep 2022 16:55:48 +0300","To":"paul.elder@ideasonboard.com","Message-ID":"<YxNc5BMVjwPyNeV/@pendragon.ideasonboard.com>","References":"<20220903003513.2516-1-laurent.pinchart@ideasonboard.com>\n\t<20220903010825.GE113531@pyrite.rasen.tech>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20220903010825.GE113531@pyrite.rasen.tech>","Subject":"Re: [libcamera-devel] [PATCH v2] qcam: viewfinder_gl: Fix\n\tmaybe-uninitialized warnings","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>","From":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"mfe@pengutronix.de, libcamera-devel@lists.libcamera.org, drebert@web.de","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":24929,"web_url":"https://patchwork.libcamera.org/comment/24929/","msgid":"<92844130-0906-aecb-f0e8-3b427512514e@ideasonboard.com>","date":"2022-09-05T06:33:00","subject":"Re: [libcamera-devel] [PATCH v2] qcam: viewfinder_gl: Fix\n\tmaybe-uninitialized warnings","submitter":{"id":86,"url":"https://patchwork.libcamera.org/api/people/86/","name":"Umang Jain","email":"umang.jain@ideasonboard.com"},"content":"Hi Laurent,\n\nThank you for the patch.\n\nOn 9/3/22 6:05 AM, Laurent Pinchart via libcamera-devel wrote:\n> From: Marco Felsch <m.felsch@pengutronix.de>\n>\n> Commit 251f0534b74b (\"qcam: viewfinder_gl: Take color space into account\n> for YUV rendering\") introduced maybe-uninitialized warnings with gcc 11\n> and 12 when compiling with -O3. Both compilers warn that\n>\n> ../../src/qcam/viewfinder_gl.cpp: In member function ‘void ViewFinderGL::selectColorSpace(const libcamera::ColorSpace&)’:\n> ../../src/qcam/viewfinder_gl.cpp:392:21: error: ‘offset’ may be used uninitialized in this function [-Werror=maybe-uninitialized]\n>    391 |         fragmentShaderDefines_.append(QString(\"#define YUV2RGB_Y_OFFSET %1\")\n>        |                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n>    392 |                 .arg(offset, 0, 'f', 1));\n>        |                 ~~~~^~~~~~~~~~~~~~~~~~~\n>\n> Additionally, gcc 12 warns that\n>\n> ../../src/qcam/viewfinder_gl.cpp: In member function ‘void ViewFinderGL::selectColorSpace(const libcamera::ColorSpace&)’:\n> ../../src/qcam/viewfinder_gl.cpp:379:36: error: ‘yuv2rgb’ may be used uninitialized [-Werror=maybe-uninitialized]\n>    379 |                         yuv2rgb[i] *= 255.0 / 219.0;\n> ../../src/qcam/viewfinder_gl.cpp:330:31: note: ‘yuv2rgb’ declared here\n>    330 |         std::array<double, 9> yuv2rgb;\n>        |\n>\n> While this should never happen here, the compiler isn't necessarily\n> wrong, as C++17 allows initializing a scoped enum from an integer using\n> direct-list-initialization, even if the integer value doesn't match any\n> of the enumerators for the scoped enum ([1]). Whether this is valid or\n> borderline paranoia from gcc may be debatable, but in any case it can't\n> be classified as blatantly wrong. Fix the warnings by adding default\n> cases to the switch statements in ViewFinderGL::selectColorSpace().\n> Which case is selected as the default doesn't matter, as this is not\n> meant to happen.\n>\n> [1] https://en.cppreference.com/w/cpp/language/enum#enum_relaxed_init_cpp17\n>\n> Fixes: 251f0534b74b (\"qcam: viewfinder_gl: Take color space into account for YUV rendering\")\n> Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>\n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n>\n> Rewrote commit message, added a default case for the encoding switch.\n>\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Umang Jain <umang.jain@ideasonboard.com>\n\n> ---\n>   src/qcam/viewfinder_gl.cpp | 2 ++\n>   1 file changed, 2 insertions(+)\n>\n> diff --git a/src/qcam/viewfinder_gl.cpp b/src/qcam/viewfinder_gl.cpp\n> index e2aa24703ff0..38ddad58e09e 100644\n> --- a/src/qcam/viewfinder_gl.cpp\n> +++ b/src/qcam/viewfinder_gl.cpp\n> @@ -332,6 +332,7 @@ void ViewFinderGL::selectColorSpace(const libcamera::ColorSpace &colorSpace)\n>   \t/* OpenGL stores arrays in column-major order. */\n>   \tswitch (colorSpace.ycbcrEncoding) {\n>   \tcase libcamera::ColorSpace::YcbcrEncoding::None:\n> +\tdefault:\n>   \t\tyuv2rgb = {\n>   \t\t\t1.0000,  0.0000,  0.0000,\n>   \t\t\t0.0000,  1.0000,  0.0000,\n> @@ -368,6 +369,7 @@ void ViewFinderGL::selectColorSpace(const libcamera::ColorSpace &colorSpace)\n>   \n>   \tswitch (colorSpace.range) {\n>   \tcase libcamera::ColorSpace::Range::Full:\n> +\tdefault:\n>   \t\toffset = 0.0;\n>   \t\tbreak;\n>   \n>\n> base-commit: 251f0534b74bcb46c777aa0df34b1b4142b664f5","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 CE380C0DA4\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  5 Sep 2022 06:33:07 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2D53B62052;\n\tMon,  5 Sep 2022 08:33:07 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1FE5C6041F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  5 Sep 2022 08:33:06 +0200 (CEST)","from [IPV6:2401:4900:1f3f:3b55:213a:3c32:c7d0:be1e] (unknown\n\t[IPv6:2401:4900:1f3f:3b55:213a:3c32:c7d0:be1e])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id AD7ED4A8;\n\tMon,  5 Sep 2022 08:33:04 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1662359587;\n\tbh=6n39v/S+8MRp8ZUHl/CytilUq2IxMfqiaUipAsFWmv8=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=vOaYXt6jkSfjwkyLAQIX6JbSbaVFhupaYGbXWMwDaTyJPDwVujh0AFvbgDhJpxrRm\n\twOjHWBVmQpU+dYishIcnhpQQPuVXjNsOkwIYMhcSky/P6Fd3EZXxkZ/8YMBMJuaMA4\n\tyItwL+icaXh2EqUJ8yDTdrYENrEVgWsAt9DKgSIOjEE6F0r4FG97ly7yO5LJWGu2mZ\n\tlE3rQbfVvxsgPITo7zHvX671+58T8YdDYAf8hbiXYuWlglWBRNSAqexQFvOuXg1E6w\n\tzCojeWFh+eVmqr1f7kHZJfoZTq/azh49urQDhUz1xEWf9kh1daHK26KtPDdjyKx/JX\n\tAk8QNs+BZ+A4Q==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1662359585;\n\tbh=6n39v/S+8MRp8ZUHl/CytilUq2IxMfqiaUipAsFWmv8=;\n\th=Date:Subject:To:Cc:References:From:In-Reply-To:From;\n\tb=T7sl1/nEyOBCtKRDuKelgAYNjscOGxPZ3V860hAMQf9+g9t2gh/xXqtic0nCPSO0J\n\t3vmxb0F7PVeq3tgKPeZWNNN+rKkaKT+eGk3txTHvRyWfKVJHqCkMgu1pjGaX/SqbiM\n\tV/HwvOWNab8kycgIyXSuLWn1veQPpFqOxDE7CwsE="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"T7sl1/nE\"; dkim-atps=neutral","Message-ID":"<92844130-0906-aecb-f0e8-3b427512514e@ideasonboard.com>","Date":"Mon, 5 Sep 2022 12:03:00 +0530","MIME-Version":"1.0","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101\n\tThunderbird/91.12.0","Content-Language":"en-US","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20220903003513.2516-1-laurent.pinchart@ideasonboard.com>","In-Reply-To":"<20220903003513.2516-1-laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"8bit","Subject":"Re: [libcamera-devel] [PATCH v2] qcam: viewfinder_gl: Fix\n\tmaybe-uninitialized warnings","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>","From":"Umang Jain via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Umang Jain <umang.jain@ideasonboard.com>","Cc":"mfe@pengutronix.de, drebert@web.de","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":24935,"web_url":"https://patchwork.libcamera.org/comment/24935/","msgid":"<20220905094524.utzv3fv7q6ggvocs@pengutronix.de>","date":"2022-09-05T09:45:24","subject":"Re: [libcamera-devel] [PATCH v2] qcam: viewfinder_gl: Fix\n\tmaybe-uninitialized warnings","submitter":{"id":89,"url":"https://patchwork.libcamera.org/api/people/89/","name":"Marco Felsch","email":"m.felsch@pengutronix.de"},"content":"Hi Laurent,\n\nthanks for the more detailed patch description and the rework.\n\nRegards,\n  Marco\n\nOn 22-09-03, Laurent Pinchart wrote:\n> From: Marco Felsch <m.felsch@pengutronix.de>\n> \n> Commit 251f0534b74b (\"qcam: viewfinder_gl: Take color space into account\n> for YUV rendering\") introduced maybe-uninitialized warnings with gcc 11\n> and 12 when compiling with -O3. Both compilers warn that\n> \n> ../../src/qcam/viewfinder_gl.cpp: In member function ‘void ViewFinderGL::selectColorSpace(const libcamera::ColorSpace&)’:\n> ../../src/qcam/viewfinder_gl.cpp:392:21: error: ‘offset’ may be used uninitialized in this function [-Werror=maybe-uninitialized]\n>   391 |         fragmentShaderDefines_.append(QString(\"#define YUV2RGB_Y_OFFSET %1\")\n>       |                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n>   392 |                 .arg(offset, 0, 'f', 1));\n>       |                 ~~~~^~~~~~~~~~~~~~~~~~~\n> \n> Additionally, gcc 12 warns that\n> \n> ../../src/qcam/viewfinder_gl.cpp: In member function ‘void ViewFinderGL::selectColorSpace(const libcamera::ColorSpace&)’:\n> ../../src/qcam/viewfinder_gl.cpp:379:36: error: ‘yuv2rgb’ may be used uninitialized [-Werror=maybe-uninitialized]\n>   379 |                         yuv2rgb[i] *= 255.0 / 219.0;\n> ../../src/qcam/viewfinder_gl.cpp:330:31: note: ‘yuv2rgb’ declared here\n>   330 |         std::array<double, 9> yuv2rgb;\n>       |\n> \n> While this should never happen here, the compiler isn't necessarily\n> wrong, as C++17 allows initializing a scoped enum from an integer using\n> direct-list-initialization, even if the integer value doesn't match any\n> of the enumerators for the scoped enum ([1]). Whether this is valid or\n> borderline paranoia from gcc may be debatable, but in any case it can't\n> be classified as blatantly wrong. Fix the warnings by adding default\n> cases to the switch statements in ViewFinderGL::selectColorSpace().\n> Which case is selected as the default doesn't matter, as this is not\n> meant to happen.\n> \n> [1] https://en.cppreference.com/w/cpp/language/enum#enum_relaxed_init_cpp17\n> \n> Fixes: 251f0534b74b (\"qcam: viewfinder_gl: Take color space into account for YUV rendering\")\n> Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>\n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> \n> Rewrote commit message, added a default case for the encoding switch.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n>  src/qcam/viewfinder_gl.cpp | 2 ++\n>  1 file changed, 2 insertions(+)\n> \n> diff --git a/src/qcam/viewfinder_gl.cpp b/src/qcam/viewfinder_gl.cpp\n> index e2aa24703ff0..38ddad58e09e 100644\n> --- a/src/qcam/viewfinder_gl.cpp\n> +++ b/src/qcam/viewfinder_gl.cpp\n> @@ -332,6 +332,7 @@ void ViewFinderGL::selectColorSpace(const libcamera::ColorSpace &colorSpace)\n>  \t/* OpenGL stores arrays in column-major order. */\n>  \tswitch (colorSpace.ycbcrEncoding) {\n>  \tcase libcamera::ColorSpace::YcbcrEncoding::None:\n> +\tdefault:\n>  \t\tyuv2rgb = {\n>  \t\t\t1.0000,  0.0000,  0.0000,\n>  \t\t\t0.0000,  1.0000,  0.0000,\n> @@ -368,6 +369,7 @@ void ViewFinderGL::selectColorSpace(const libcamera::ColorSpace &colorSpace)\n>  \n>  \tswitch (colorSpace.range) {\n>  \tcase libcamera::ColorSpace::Range::Full:\n> +\tdefault:\n>  \t\toffset = 0.0;\n>  \t\tbreak;\n>  \n> \n> base-commit: 251f0534b74bcb46c777aa0df34b1b4142b664f5\n> -- \n> Regards,\n> \n> Laurent Pinchart\n> \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 BA486C3272\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  5 Sep 2022 09:45:27 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 293496205C;\n\tMon,  5 Sep 2022 11:45:27 +0200 (CEST)","from metis.ext.pengutronix.de (metis.ext.pengutronix.de\n\t[IPv6:2001:67c:670:201:290:27ff:fe1d:cc33])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6995362054\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  5 Sep 2022 11:45:25 +0200 (CEST)","from ptx.hi.pengutronix.de ([2001:67c:670:100:1d::c0])\n\tby metis.ext.pengutronix.de with esmtps\n\t(TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92)\n\t(envelope-from <mfe@pengutronix.de>)\n\tid 1oV8fV-000780-03; Mon, 05 Sep 2022 11:45:25 +0200","from mfe by ptx.hi.pengutronix.de with local (Exim 4.92)\n\t(envelope-from <mfe@pengutronix.de>)\n\tid 1oV8fU-0005qA-Fv; Mon, 05 Sep 2022 11:45:24 +0200"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1662371127;\n\tbh=VhiRbq9oJr449dR5OYZLR/jDt8CFCIuE1fSD7iy6pN0=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=Y+CKArETHWXWzjaTWlQYiV1OfVxyNXzhMDiCDHaEIVmOrBg1znxZ2DeTVaOQ/FtQu\n\tjfEAb38o2i7NEOQP36aYEpkDD2v7lr9Dl6zqCTHB23jkz5BiRwSDxDQPkUqDiet2yX\n\tctotX2skCIu8gXJ6jGt+8QW/cPyszFC62rMKiF1n2kfhevm+GN6LakoyyxksLizuSR\n\tZRrSMIv0bZSfsJ7hgCDT/gX4eBVvmtzf3rApgVUrA7/1BJGSbkUQDF1dYa0WwI0TBU\n\t3AIT9M0wEa1udiGqMEJyrjpygoejWeP4LVVxmZ7pJpDsMlsBHr05cuOp0B7owbYNTB\n\teEuQxKOHZ2qcA==","Date":"Mon, 5 Sep 2022 11:45:24 +0200","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Message-ID":"<20220905094524.utzv3fv7q6ggvocs@pengutronix.de>","References":"<20220903003513.2516-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20220903003513.2516-1-laurent.pinchart@ideasonboard.com>","User-Agent":"NeoMutt/20180716","X-SA-Exim-Connect-IP":"2001:67c:670:100:1d::c0","X-SA-Exim-Mail-From":"mfe@pengutronix.de","X-SA-Exim-Scanned":"No (on metis.ext.pengutronix.de);\n\tSAEximRunCond expanded to false","X-PTX-Original-Recipient":"libcamera-devel@lists.libcamera.org","Subject":"Re: [libcamera-devel] [PATCH v2] qcam: viewfinder_gl: Fix\n\tmaybe-uninitialized warnings","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>","From":"Marco Felsch via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Marco Felsch <m.felsch@pengutronix.de>","Cc":"libcamera-devel@lists.libcamera.org, drebert@web.de","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]