[{"id":13320,"web_url":"https://patchwork.libcamera.org/comment/13320/","msgid":"<bf45428e-2a16-1dcb-f59d-9170d2e04115@ideasonboard.com>","date":"2020-10-21T10:09:13","subject":"Re: [libcamera-devel] [PATCH 2/2] libcamera: pipeline: simple:\n\tInitialize V4L2DeviceFormat before use","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Hi Laurent,\n\nOn 21/10/2020 03:47, Laurent Pinchart wrote:\n> The V4L2DeviceFormat has no default constructor. Zero it before use when\n> setting formats. Failure to do so leaves the planes uninitialized,\n> potentially causing memory corruption.\n> \n\nOh dear ;-)\n\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n\nIs this missing an explicit setting of the plane count? (based on the\ncontent of the previous patch?)\n\nBut I believe this looks correct:\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n\n> ---\n>  src/libcamera/pipeline/simple/converter.cpp | 6 +++---\n>  1 file changed, 3 insertions(+), 3 deletions(-)\n> \n> diff --git a/src/libcamera/pipeline/simple/converter.cpp b/src/libcamera/pipeline/simple/converter.cpp\n> index b4ee021f6210..b3705abcd626 100644\n> --- a/src/libcamera/pipeline/simple/converter.cpp\n> +++ b/src/libcamera/pipeline/simple/converter.cpp\n> @@ -72,7 +72,7 @@ std::vector<PixelFormat> SimpleConverter::formats(PixelFormat input)\n>  \t * Set the format on the input side (V4L2 output) of the converter to\n>  \t * enumerate the conversion capabilities on its output (V4L2 capture).\n>  \t */\n> -\tV4L2DeviceFormat format;\n> +\tV4L2DeviceFormat format = {};\n>  \tformat.fourcc = m2m_->output()->toV4L2PixelFormat(input);\n>  \tformat.size = { 1, 1 };\n>  \n> @@ -103,7 +103,7 @@ SizeRange SimpleConverter::sizes(const Size &input)\n>  \t * Set the size on the input side (V4L2 output) of the converter to\n>  \t * enumerate the scaling capabilities on its output (V4L2 capture).\n>  \t */\n> -\tV4L2DeviceFormat format;\n> +\tV4L2DeviceFormat format = {};\n>  \tformat.fourcc = V4L2PixelFormat();\n>  \tformat.size = input;\n>  \n> @@ -142,7 +142,7 @@ SizeRange SimpleConverter::sizes(const Size &input)\n>  int SimpleConverter::configure(PixelFormat inputFormat, const Size &inputSize,\n>  \t\t\t       StreamConfiguration *cfg)\n>  {\n> -\tV4L2DeviceFormat format;\n> +\tV4L2DeviceFormat format = {};\n>  \tint ret;\n>  \n>  \tV4L2PixelFormat videoFormat = m2m_->output()->toV4L2PixelFormat(inputFormat);\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 D7C09C3D3C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 21 Oct 2020 10:09:18 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5BF8961D98;\n\tWed, 21 Oct 2020 12:09:18 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8A53160353\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 21 Oct 2020 12:09:17 +0200 (CEST)","from [192.168.0.20]\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id EF97E92;\n\tWed, 21 Oct 2020 12:09:16 +0200 (CEST)"],"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=\"KQ7Vyjmx\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1603274957;\n\tbh=Bk0CAtpeWRhisesM+jAeT7Qmhe7XHU4mTmIzBx7O3Pk=;\n\th=Reply-To:Subject:To:References:From:Date:In-Reply-To:From;\n\tb=KQ7VyjmxD0qP7myis6f0+Y0kIc3O5OdRooALrpiUWZGBqp1ryv2P8kFl9TDdR33k2\n\tSB/oxHrbeM7xRNlgvDSS7luhVDpegHx29G9d99KEMm0Fes8q4LsHTehf0eJE+YvgwW\n\tzhavnZYEtWJGuBriTuhzoJnFB+2o0KLRf/+5ISw0=","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20201021024744.19047-1-laurent.pinchart@ideasonboard.com>\n\t<20201021024744.19047-2-laurent.pinchart@ideasonboard.com>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Autocrypt":"addr=kieran.bingham@ideasonboard.com; keydata=\n\tmQINBFYE/WYBEACs1PwjMD9rgCu1hlIiUA1AXR4rv2v+BCLUq//vrX5S5bjzxKAryRf0uHat\n\tV/zwz6hiDrZuHUACDB7X8OaQcwhLaVlq6byfoBr25+hbZG7G3+5EUl9cQ7dQEdvNj6V6y/SC\n\trRanWfelwQThCHckbobWiQJfK9n7rYNcPMq9B8e9F020LFH7Kj6YmO95ewJGgLm+idg1Kb3C\n\tpotzWkXc1xmPzcQ1fvQMOfMwdS+4SNw4rY9f07Xb2K99rjMwZVDgESKIzhsDB5GY465sCsiQ\n\tcSAZRxqE49RTBq2+EQsbrQpIc8XiffAB8qexh5/QPzCmR4kJgCGeHIXBtgRj+nIkCJPZvZtf\n\tKr2EAbc6tgg6DkAEHJb+1okosV09+0+TXywYvtEop/WUOWQ+zo+Y/OBd+8Ptgt1pDRyOBzL8\n\tRXa8ZqRf0Mwg75D+dKntZeJHzPRJyrlfQokngAAs4PaFt6UfS+ypMAF37T6CeDArQC41V3ko\n\tlPn1yMsVD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cSl+RIng5S/ThOBlwNlcKG7j7W2MC06BlTbdEkUp\n\tECzuuRBv8wX4OQl+hbWbB/VKIx5HKlLu1eypen/5lNVzSqMMIYkkZcjV2SWQyUGxSwq0O/sx\n\tS0A8/atCHUXOboUsn54qdxrVDaK+6jIAuo8JiRWctP16KjzUM7MO0/+4zllM8EY57rXrj48j\n\tsbEYX0YQnzaj+jO6kJtoZsIaYR7rMMq9aUAjyiaEZpmP1qF/2sYenDx0Fg2BSlLvLvXM0vU8\n\tpQk3kgDu7kb/7PRYrZvBsr21EIQoIjXbZxDz/o7z95frkP71EaICttZ6k9q5oxxA5WC6sTXc\n\tMW8zs8avFNuA9VpXt0YupJd2ijtZy2mpZNG02fFVXhIn4G807G7+9mhuC4XG5rKlBBUXTvPU\n\tAfYnB4JBDLmLzBFavQfvonSfbitgXwCG3vS+9HEwAjU30Bar1PEOmIbiAoMzuKeRm2LVpmq4\n\tWZw01QYHU/GUV/zHJSFk","Organization":"Ideas on Board","Message-ID":"<bf45428e-2a16-1dcb-f59d-9170d2e04115@ideasonboard.com>","Date":"Wed, 21 Oct 2020 11:09:13 +0100","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101\n\tThunderbird/68.10.0","MIME-Version":"1.0","In-Reply-To":"<20201021024744.19047-2-laurent.pinchart@ideasonboard.com>","Content-Language":"en-GB","Subject":"Re: [libcamera-devel] [PATCH 2/2] libcamera: pipeline: simple:\n\tInitialize V4L2DeviceFormat before use","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>","Reply-To":"kieran.bingham@ideasonboard.com","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":13343,"web_url":"https://patchwork.libcamera.org/comment/13343/","msgid":"<20201021131355.vwvowdo7ofdgzgr4@uno.localdomain>","date":"2020-10-21T13:13:55","subject":"Re: [libcamera-devel] [PATCH 2/2] libcamera: pipeline: simple:\n\tInitialize V4L2DeviceFormat before use","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Laurent,\n\nOn Wed, Oct 21, 2020 at 05:47:44AM +0300, Laurent Pinchart wrote:\n> The V4L2DeviceFormat has no default constructor. Zero it before use when\n\nIsn't it implicitly generated by the compiler ?\n\n> setting formats. Failure to do so leaves the planes uninitialized,\n> potentially causing memory corruption.\n>\n\nIf not, isn't it better to add it in the class ?\n\nThanks\n  j\n\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n>  src/libcamera/pipeline/simple/converter.cpp | 6 +++---\n>  1 file changed, 3 insertions(+), 3 deletions(-)\n>\n> diff --git a/src/libcamera/pipeline/simple/converter.cpp b/src/libcamera/pipeline/simple/converter.cpp\n> index b4ee021f6210..b3705abcd626 100644\n> --- a/src/libcamera/pipeline/simple/converter.cpp\n> +++ b/src/libcamera/pipeline/simple/converter.cpp\n> @@ -72,7 +72,7 @@ std::vector<PixelFormat> SimpleConverter::formats(PixelFormat input)\n>  \t * Set the format on the input side (V4L2 output) of the converter to\n>  \t * enumerate the conversion capabilities on its output (V4L2 capture).\n>  \t */\n> -\tV4L2DeviceFormat format;\n> +\tV4L2DeviceFormat format = {};\n>  \tformat.fourcc = m2m_->output()->toV4L2PixelFormat(input);\n>  \tformat.size = { 1, 1 };\n>\n> @@ -103,7 +103,7 @@ SizeRange SimpleConverter::sizes(const Size &input)\n>  \t * Set the size on the input side (V4L2 output) of the converter to\n>  \t * enumerate the scaling capabilities on its output (V4L2 capture).\n>  \t */\n> -\tV4L2DeviceFormat format;\n> +\tV4L2DeviceFormat format = {};\n>  \tformat.fourcc = V4L2PixelFormat();\n>  \tformat.size = input;\n>\n> @@ -142,7 +142,7 @@ SizeRange SimpleConverter::sizes(const Size &input)\n>  int SimpleConverter::configure(PixelFormat inputFormat, const Size &inputSize,\n>  \t\t\t       StreamConfiguration *cfg)\n>  {\n> -\tV4L2DeviceFormat format;\n> +\tV4L2DeviceFormat format = {};\n>  \tint ret;\n>\n>  \tV4L2PixelFormat videoFormat = m2m_->output()->toV4L2PixelFormat(inputFormat);\n> --\n> Regards,\n>\n> Laurent Pinchart\n>\n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","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 6EBF6BDB13\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 21 Oct 2020 13:13:59 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0951F61DAB;\n\tWed, 21 Oct 2020 15:13:59 +0200 (CEST)","from relay10.mail.gandi.net (relay10.mail.gandi.net\n\t[217.70.178.230])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B3C7160CE0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 21 Oct 2020 15:13:57 +0200 (CEST)","from uno.localdomain (93-34-118-233.ip49.fastwebnet.it\n\t[93.34.118.233]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay10.mail.gandi.net (Postfix) with ESMTPSA id 2BD3024000E;\n\tWed, 21 Oct 2020 13:13:56 +0000 (UTC)"],"Date":"Wed, 21 Oct 2020 15:13:55 +0200","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Message-ID":"<20201021131355.vwvowdo7ofdgzgr4@uno.localdomain>","References":"<20201021024744.19047-1-laurent.pinchart@ideasonboard.com>\n\t<20201021024744.19047-2-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20201021024744.19047-2-laurent.pinchart@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH 2/2] libcamera: pipeline: simple:\n\tInitialize V4L2DeviceFormat before use","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","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":13350,"web_url":"https://patchwork.libcamera.org/comment/13350/","msgid":"<ea2b5630-4f3e-06cc-8ba0-3911210878c7@ideasonboard.com>","date":"2020-10-21T13:31:10","subject":"Re: [libcamera-devel] [PATCH 2/2] libcamera: pipeline: simple:\n\tInitialize V4L2DeviceFormat before use","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Hrm,\n\nOn 21/10/2020 14:13, Jacopo Mondi wrote:\n> Hi Laurent,\n> \n> On Wed, Oct 21, 2020 at 05:47:44AM +0300, Laurent Pinchart wrote:\n>> The V4L2DeviceFormat has no default constructor. Zero it before use when\n> \n> Isn't it implicitly generated by the compiler ?\n> \n>> setting formats. Failure to do so leaves the planes uninitialized,\n>> potentially causing memory corruption.\n>>\n> \n> If not, isn't it better to add it in the class ?\n\nHrm, when I read the patch before, I assumed it was because it was just\na struct or such. Ok - so it's not a complicated class but ...\n\nBut indeed, this is marked as a class - so construction surely is suited\nto the constructor?\n\n--\nKieran\n\n\n\n> \n> Thanks\n>   j\n> \n>> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n>> ---\n>>  src/libcamera/pipeline/simple/converter.cpp | 6 +++---\n>>  1 file changed, 3 insertions(+), 3 deletions(-)\n>>\n>> diff --git a/src/libcamera/pipeline/simple/converter.cpp b/src/libcamera/pipeline/simple/converter.cpp\n>> index b4ee021f6210..b3705abcd626 100644\n>> --- a/src/libcamera/pipeline/simple/converter.cpp\n>> +++ b/src/libcamera/pipeline/simple/converter.cpp\n>> @@ -72,7 +72,7 @@ std::vector<PixelFormat> SimpleConverter::formats(PixelFormat input)\n>>  \t * Set the format on the input side (V4L2 output) of the converter to\n>>  \t * enumerate the conversion capabilities on its output (V4L2 capture).\n>>  \t */\n>> -\tV4L2DeviceFormat format;\n>> +\tV4L2DeviceFormat format = {};\n>>  \tformat.fourcc = m2m_->output()->toV4L2PixelFormat(input);\n>>  \tformat.size = { 1, 1 };\n>>\n>> @@ -103,7 +103,7 @@ SizeRange SimpleConverter::sizes(const Size &input)\n>>  \t * Set the size on the input side (V4L2 output) of the converter to\n>>  \t * enumerate the scaling capabilities on its output (V4L2 capture).\n>>  \t */\n>> -\tV4L2DeviceFormat format;\n>> +\tV4L2DeviceFormat format = {};\n>>  \tformat.fourcc = V4L2PixelFormat();\n>>  \tformat.size = input;\n>>\n>> @@ -142,7 +142,7 @@ SizeRange SimpleConverter::sizes(const Size &input)\n>>  int SimpleConverter::configure(PixelFormat inputFormat, const Size &inputSize,\n>>  \t\t\t       StreamConfiguration *cfg)\n>>  {\n>> -\tV4L2DeviceFormat format;\n>> +\tV4L2DeviceFormat format = {};\n>>  \tint ret;\n>>\n>>  \tV4L2PixelFormat videoFormat = m2m_->output()->toV4L2PixelFormat(inputFormat);\n>> --\n>> Regards,\n>>\n>> Laurent Pinchart\n>>\n>> _______________________________________________\n>> libcamera-devel mailing list\n>> libcamera-devel@lists.libcamera.org\n>> https://lists.libcamera.org/listinfo/libcamera-devel\n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel\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 C7C99BDB13\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 21 Oct 2020 13:31:15 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9472761DDB;\n\tWed, 21 Oct 2020 15:31:15 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7066561D7F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 21 Oct 2020 15:31:14 +0200 (CEST)","from [192.168.0.20]\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id C79AC92;\n\tWed, 21 Oct 2020 15:31:13 +0200 (CEST)"],"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=\"VJoDDgKD\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1603287074;\n\tbh=j4StdCK+a/2O27l2P2cLHaLEzmZgW2+oakaCCo7J/0I=;\n\th=Reply-To:Subject:To:Cc:References:From:Date:In-Reply-To:From;\n\tb=VJoDDgKDYUNrTpd35h02ZHHKfqj7M6u/emgvZsnOBMAN2OCA4XC4yAz2p5OVdOSeZ\n\tJ8AL6qJxqdSdjHWX6t259rK1196EvP9GULxiTeSE0hvhID2iBgk+Wei6tcBIzI+R2p\n\t4fTaKrOMv1IdBP1lc18DGjR5+ZocbUhqxiBkLKdQ=","To":"Jacopo Mondi <jacopo@jmondi.org>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>","References":"<20201021024744.19047-1-laurent.pinchart@ideasonboard.com>\n\t<20201021024744.19047-2-laurent.pinchart@ideasonboard.com>\n\t<20201021131355.vwvowdo7ofdgzgr4@uno.localdomain>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Autocrypt":"addr=kieran.bingham@ideasonboard.com; keydata=\n\tmQINBFYE/WYBEACs1PwjMD9rgCu1hlIiUA1AXR4rv2v+BCLUq//vrX5S5bjzxKAryRf0uHat\n\tV/zwz6hiDrZuHUACDB7X8OaQcwhLaVlq6byfoBr25+hbZG7G3+5EUl9cQ7dQEdvNj6V6y/SC\n\trRanWfelwQThCHckbobWiQJfK9n7rYNcPMq9B8e9F020LFH7Kj6YmO95ewJGgLm+idg1Kb3C\n\tpotzWkXc1xmPzcQ1fvQMOfMwdS+4SNw4rY9f07Xb2K99rjMwZVDg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\n\tvSj943LUeqEeRnIQpGH9BQJdizzIBQkLSKZiAAoJEKEeRnIQpGH9eYgQAJpjaWNgqNOnMTmD\n\tMJggbwjIotypzIXfhHNCeTkG7+qCDlSaBPclcPGYrTwCt0YWPU2TgGgJrVhYT20ierN8LUvj\n\t6qOPTd+Uk7NFzL65qkh80ZKNBFddx1AabQpSVQKbdcLb8OFs85kuSvFdgqZwgxA1vl4TFhNz\n\tPZ79NAmXLackAx3sOVFhk4WQaKRshCB7cSl+RIng5S/ThOBlwNlcKG7j7W2MC06BlTbdEkUp\n\tECzuuRBv8wX4OQl+hbWbB/VKIx5HKlLu1eypen/5lNVzSqMMIYkkZcjV2SWQyUGxSwq0O/sx\n\tS0A8/atCHUXOboUsn54qdxrVDaK+6jIAuo8JiRWctP16KjzUM7MO0/+4zllM8EY57rXrj48j\n\tsbEYX0YQnzaj+jO6kJtoZsIaYR7rMMq9aUAjyiaEZpmP1qF/2sYenDx0Fg2BSlLvLvXM0vU8\n\tpQk3kgDu7kb/7PRYrZvBsr21EIQoIjXbZxDz/o7z95frkP71EaICttZ6k9q5oxxA5WC6sTXc\n\tMW8zs8avFNuA9VpXt0YupJd2ijtZy2mpZNG02fFVXhIn4G807G7+9mhuC4XG5rKlBBUXTvPU\n\tAfYnB4JBDLmLzBFavQfvonSfbitgXwCG3vS+9HEwAjU30Bar1PEOmIbiAoMzuKeRm2LVpmq4\n\tWZw01QYHU/GUV/zHJSFk","Organization":"Ideas on Board","Message-ID":"<ea2b5630-4f3e-06cc-8ba0-3911210878c7@ideasonboard.com>","Date":"Wed, 21 Oct 2020 14:31:10 +0100","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101\n\tThunderbird/68.10.0","MIME-Version":"1.0","In-Reply-To":"<20201021131355.vwvowdo7ofdgzgr4@uno.localdomain>","Content-Language":"en-GB","Subject":"Re: [libcamera-devel] [PATCH 2/2] libcamera: pipeline: simple:\n\tInitialize V4L2DeviceFormat before use","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>","Reply-To":"kieran.bingham@ideasonboard.com","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":13351,"web_url":"https://patchwork.libcamera.org/comment/13351/","msgid":"<20201021133221.GB2158081@oden.dyn.berto.se>","date":"2020-10-21T13:32:21","subject":"Re: [libcamera-devel] [PATCH 2/2] libcamera: pipeline: simple:\n\tInitialize V4L2DeviceFormat before use","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Laurent,\n\nThanks for your work.\n\nOn 2020-10-21 05:47:44 +0300, Laurent Pinchart wrote:\n> The V4L2DeviceFormat has no default constructor. Zero it before use when\n> setting formats. Failure to do so leaves the planes uninitialized,\n> potentially causing memory corruption.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\n> ---\n>  src/libcamera/pipeline/simple/converter.cpp | 6 +++---\n>  1 file changed, 3 insertions(+), 3 deletions(-)\n> \n> diff --git a/src/libcamera/pipeline/simple/converter.cpp b/src/libcamera/pipeline/simple/converter.cpp\n> index b4ee021f6210..b3705abcd626 100644\n> --- a/src/libcamera/pipeline/simple/converter.cpp\n> +++ b/src/libcamera/pipeline/simple/converter.cpp\n> @@ -72,7 +72,7 @@ std::vector<PixelFormat> SimpleConverter::formats(PixelFormat input)\n>  \t * Set the format on the input side (V4L2 output) of the converter to\n>  \t * enumerate the conversion capabilities on its output (V4L2 capture).\n>  \t */\n> -\tV4L2DeviceFormat format;\n> +\tV4L2DeviceFormat format = {};\n>  \tformat.fourcc = m2m_->output()->toV4L2PixelFormat(input);\n>  \tformat.size = { 1, 1 };\n>  \n> @@ -103,7 +103,7 @@ SizeRange SimpleConverter::sizes(const Size &input)\n>  \t * Set the size on the input side (V4L2 output) of the converter to\n>  \t * enumerate the scaling capabilities on its output (V4L2 capture).\n>  \t */\n> -\tV4L2DeviceFormat format;\n> +\tV4L2DeviceFormat format = {};\n>  \tformat.fourcc = V4L2PixelFormat();\n>  \tformat.size = input;\n>  \n> @@ -142,7 +142,7 @@ SizeRange SimpleConverter::sizes(const Size &input)\n>  int SimpleConverter::configure(PixelFormat inputFormat, const Size &inputSize,\n>  \t\t\t       StreamConfiguration *cfg)\n>  {\n> -\tV4L2DeviceFormat format;\n> +\tV4L2DeviceFormat format = {};\n>  \tint ret;\n>  \n>  \tV4L2PixelFormat videoFormat = m2m_->output()->toV4L2PixelFormat(inputFormat);\n> -- \n> Regards,\n> \n> Laurent Pinchart\n> \n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","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 45A07C3D3C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 21 Oct 2020 13:32:25 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 11AF661DAB;\n\tWed, 21 Oct 2020 15:32:25 +0200 (CEST)","from mail-lf1-x142.google.com (mail-lf1-x142.google.com\n\t[IPv6:2a00:1450:4864:20::142])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id BAEEF61D7F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 21 Oct 2020 15:32:23 +0200 (CEST)","by mail-lf1-x142.google.com with SMTP id a7so3094113lfk.9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 21 Oct 2020 06:32:23 -0700 (PDT)","from localhost (h-209-203.A463.priv.bahnhof.se. [155.4.209.203])\n\tby smtp.gmail.com with ESMTPSA id 18sm435477ljq.0.2020.10.21.06.32.22\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 21 Oct 2020 06:32:22 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=ragnatech-se.20150623.gappssmtp.com\n\theader.i=@ragnatech-se.20150623.gappssmtp.com\n\theader.b=\"MNnBnD3n\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to;\n\tbh=fwlBkxrH9sevbOAcieiD+c9jKfjekcjO67qxJdpSIxo=;\n\tb=MNnBnD3n6ds2rUHRCQ4ZDdU8t1uO43quGLaR8zIvx3Ew1RZSqiDmLiAAVAolnxH2uz\n\tgUAgGyZaNL6P5Lm+36GSJTxpuOimtXEC4mzYDVo6h1JD895A9tCMAyW/psi0SkkJd0PL\n\tpUPkDR7rGPE/LAYusEvQP/O7+Xqgdma6JTi5zTutCh8+5Ga2CEcX63wQTsB/o9+ZGNFU\n\tVeZOV48wmOELGzI0I8AQLXzGiFbSyh2mIgD2aU+d8r+N6/ThQV+k2ljbell6nvKGtuBw\n\t9ydD2Kaum2n+qjWmv/tDkj70Mzj69/9oMu8O0KCPXKT/NjfMou2/aHIjj8zB+hmCYwXO\n\tvGJQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to;\n\tbh=fwlBkxrH9sevbOAcieiD+c9jKfjekcjO67qxJdpSIxo=;\n\tb=m6lW5+yNRbvo0PK9E+ylvcbKPfRDGNJhWyV2xcgcWBIM6ROn3rbSk2ujYjQbat1Q7V\n\tu34MOPfnEFeSoJt4eAEY5O1DsX15YCH8kuzzIxAUH6wygVLDEiVxaoQEHPwL1WYZCXNv\n\tkYBypT+80y17C0x0hlBLB2z7h0hwmlek81AzAqK3EtakU0/MYsvI3uvb6IVV/TTxeG8c\n\tnIPQM0zGZ5fo1PO5R7A2j+YKf8OmBkL4Lq5yvPm79pfn6DBXPwVjKCAKHM1zamL3lEQD\n\t6unZxueSL1TsHQkRi/qz15ZC+skX+2MJWWxaXeHwFBckqh+VF945Cps7bU5D3gO32a5H\n\tRdSQ==","X-Gm-Message-State":"AOAM533qbUAMu1dglRZpRO3v9K8gF5ImMYJl5eOguZAmqL8yX9fImy4J\n\t2l1AG0De6EW8to3rP+lkdOCagLb5+lJAdA==","X-Google-Smtp-Source":"ABdhPJystSqjN9oYlEn4sLQu1QzIx3JzdnciiVel/JprTODEYgPGT5hHHUI1b8uo/idpFe8nZGP4JA==","X-Received":"by 2002:a05:6512:358b:: with SMTP id\n\tm11mr1348677lfr.282.1603287143184; \n\tWed, 21 Oct 2020 06:32:23 -0700 (PDT)","Date":"Wed, 21 Oct 2020 15:32:21 +0200","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Message-ID":"<20201021133221.GB2158081@oden.dyn.berto.se>","References":"<20201021024744.19047-1-laurent.pinchart@ideasonboard.com>\n\t<20201021024744.19047-2-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20201021024744.19047-2-laurent.pinchart@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH 2/2] libcamera: pipeline: simple:\n\tInitialize V4L2DeviceFormat before use","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","Content-Type":"text/plain; charset=\"iso-8859-1\"","Content-Transfer-Encoding":"quoted-printable","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":13370,"web_url":"https://patchwork.libcamera.org/comment/13370/","msgid":"<20201021163053.GG3942@pendragon.ideasonboard.com>","date":"2020-10-21T16:30:53","subject":"Re: [libcamera-devel] [PATCH 2/2] libcamera: pipeline: simple:\n\tInitialize V4L2DeviceFormat before use","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jacopo,\n\nOn Wed, Oct 21, 2020 at 03:13:55PM +0200, Jacopo Mondi wrote:\n> On Wed, Oct 21, 2020 at 05:47:44AM +0300, Laurent Pinchart wrote:\n> > The V4L2DeviceFormat has no default constructor. Zero it before use when\n> \n> Isn't it implicitly generated by the compiler ?\n\nIt is, but the implicitly-defined constructor won't help us here:\n\n\"If the implicitly-declared default constructor is not defined as\ndeleted, it is defined (that is, a function body is generated and\ncompiled) by the compiler if odr-used, and it has the same effect as a\nuser-defined constructor with empty body and empty initializer list.\"\n\n(https://en.cppreference.com/w/cpp/language/default_constructor is an\ninteresting read)\n\n> > setting formats. Failure to do so leaves the planes uninitialized,\n> > potentially causing memory corruption.\n> \n> If not, isn't it better to add it in the class ?\n\nI had considered that, but wasn't sure, and was hoping nobody would ask\n;-)\n\nIt could make sense to replace the planes array and planesCount field\nwith an std::vector. A bit of a shame to have to use dynamic allocation\nwhen we know there will never be more than 3 planes though. I wish there\nwas a dynamic array container, with fixed memory preallocation and\ndynamic size up to the number of elements.\n\nAny preference between using a vector, and keeping it as-is with a\nconstructor that sets numPlanes to 0 ?\n\n> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > ---\n> >  src/libcamera/pipeline/simple/converter.cpp | 6 +++---\n> >  1 file changed, 3 insertions(+), 3 deletions(-)\n> >\n> > diff --git a/src/libcamera/pipeline/simple/converter.cpp b/src/libcamera/pipeline/simple/converter.cpp\n> > index b4ee021f6210..b3705abcd626 100644\n> > --- a/src/libcamera/pipeline/simple/converter.cpp\n> > +++ b/src/libcamera/pipeline/simple/converter.cpp\n> > @@ -72,7 +72,7 @@ std::vector<PixelFormat> SimpleConverter::formats(PixelFormat input)\n> >  \t * Set the format on the input side (V4L2 output) of the converter to\n> >  \t * enumerate the conversion capabilities on its output (V4L2 capture).\n> >  \t */\n> > -\tV4L2DeviceFormat format;\n> > +\tV4L2DeviceFormat format = {};\n> >  \tformat.fourcc = m2m_->output()->toV4L2PixelFormat(input);\n> >  \tformat.size = { 1, 1 };\n> >\n> > @@ -103,7 +103,7 @@ SizeRange SimpleConverter::sizes(const Size &input)\n> >  \t * Set the size on the input side (V4L2 output) of the converter to\n> >  \t * enumerate the scaling capabilities on its output (V4L2 capture).\n> >  \t */\n> > -\tV4L2DeviceFormat format;\n> > +\tV4L2DeviceFormat format = {};\n> >  \tformat.fourcc = V4L2PixelFormat();\n> >  \tformat.size = input;\n> >\n> > @@ -142,7 +142,7 @@ SizeRange SimpleConverter::sizes(const Size &input)\n> >  int SimpleConverter::configure(PixelFormat inputFormat, const Size &inputSize,\n> >  \t\t\t       StreamConfiguration *cfg)\n> >  {\n> > -\tV4L2DeviceFormat format;\n> > +\tV4L2DeviceFormat format = {};\n> >  \tint ret;\n> >\n> >  \tV4L2PixelFormat videoFormat = m2m_->output()->toV4L2PixelFormat(inputFormat);","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 2080EBDB13\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 21 Oct 2020 16:31:40 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E465B60E31;\n\tWed, 21 Oct 2020 18:31:39 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E38FA60995\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 21 Oct 2020 18:31:38 +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 7A0EDBB5;\n\tWed, 21 Oct 2020 18:31:38 +0200 (CEST)"],"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=\"vQoREzo9\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1603297898;\n\tbh=NyLoJ/Yttr8wSstHAPYI0FFduSk0MAvNlZT6NUHSgvg=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=vQoREzo9MOVnQUJZ8h5+JbCkVIuyoaffJi4DyUunPf90BAsCKi75RdAjv9WKj4n/6\n\tasSrr6ZQp3Zi/E0YjWjr1hqaG96ZoUDqbbnC76TwNjCi6XdsG7Vf0yfjrJTARffl83\n\t+isS6g1RXlzGVnjVZWRAUdwo2sVu2qsrLzJ90+YQ=","Date":"Wed, 21 Oct 2020 19:30:53 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Message-ID":"<20201021163053.GG3942@pendragon.ideasonboard.com>","References":"<20201021024744.19047-1-laurent.pinchart@ideasonboard.com>\n\t<20201021024744.19047-2-laurent.pinchart@ideasonboard.com>\n\t<20201021131355.vwvowdo7ofdgzgr4@uno.localdomain>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20201021131355.vwvowdo7ofdgzgr4@uno.localdomain>","Subject":"Re: [libcamera-devel] [PATCH 2/2] libcamera: pipeline: simple:\n\tInitialize V4L2DeviceFormat before use","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","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":13371,"web_url":"https://patchwork.libcamera.org/comment/13371/","msgid":"<20201021163607.GH3942@pendragon.ideasonboard.com>","date":"2020-10-21T16:36:07","subject":"Re: [libcamera-devel] [PATCH 2/2] libcamera: pipeline: simple:\n\tInitialize V4L2DeviceFormat before use","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Wed, Oct 21, 2020 at 07:30:53PM +0300, Laurent Pinchart wrote:\n> Hi Jacopo,\n> \n> On Wed, Oct 21, 2020 at 03:13:55PM +0200, Jacopo Mondi wrote:\n> > On Wed, Oct 21, 2020 at 05:47:44AM +0300, Laurent Pinchart wrote:\n> > > The V4L2DeviceFormat has no default constructor. Zero it before use when\n> > \n> > Isn't it implicitly generated by the compiler ?\n> \n> It is, but the implicitly-defined constructor won't help us here:\n> \n> \"If the implicitly-declared default constructor is not defined as\n> deleted, it is defined (that is, a function body is generated and\n> compiled) by the compiler if odr-used, and it has the same effect as a\n> user-defined constructor with empty body and empty initializer list.\"\n> \n> (https://en.cppreference.com/w/cpp/language/default_constructor is an\n> interesting read)\n> \n> > > setting formats. Failure to do so leaves the planes uninitialized,\n> > > potentially causing memory corruption.\n> > \n> > If not, isn't it better to add it in the class ?\n> \n> I had considered that, but wasn't sure, and was hoping nobody would ask\n> ;-)\n> \n> It could make sense to replace the planes array and planesCount field\n> with an std::vector. A bit of a shame to have to use dynamic allocation\n> when we know there will never be more than 3 planes though. I wish there\n> was a dynamic array container, with fixed memory preallocation and\n> dynamic size up to the number of elements.\n> \n> Any preference between using a vector, and keeping it as-is with a\n> constructor that sets numPlanes to 0 ?\n\nBy the way, we also have the option of using a default member\ninitializer\n(https://en.cppreference.com/w/cpp/language/data_members#Member_initialization):\n\ndiff --git a/include/libcamera/internal/v4l2_videodevice.h b/include/libcamera/internal/v4l2_videodevice.h\nindex 40ed87e17cfa..12eaf45a31ec 100644\n--- a/include/libcamera/internal/v4l2_videodevice.h\n+++ b/include/libcamera/internal/v4l2_videodevice.h\n@@ -160,7 +160,7 @@ public:\n \t\tuint32_t size;\n \t\tuint32_t bpl;\n \t} planes[3];\n-\tunsigned int planesCount;\n+\tunsigned int planesCount = 0;\n \n \tconst std::string toString() const;\n };\n\nTomi recently pointed this out. I don't like it much when there are\nexplicit constructors (as initialization is then split between the\nheader file and the cpp file), but for structures with no explicitly\ndefined constructor, I don't object.\n\n> > > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > > ---\n> > >  src/libcamera/pipeline/simple/converter.cpp | 6 +++---\n> > >  1 file changed, 3 insertions(+), 3 deletions(-)\n> > >\n> > > diff --git a/src/libcamera/pipeline/simple/converter.cpp b/src/libcamera/pipeline/simple/converter.cpp\n> > > index b4ee021f6210..b3705abcd626 100644\n> > > --- a/src/libcamera/pipeline/simple/converter.cpp\n> > > +++ b/src/libcamera/pipeline/simple/converter.cpp\n> > > @@ -72,7 +72,7 @@ std::vector<PixelFormat> SimpleConverter::formats(PixelFormat input)\n> > >  \t * Set the format on the input side (V4L2 output) of the converter to\n> > >  \t * enumerate the conversion capabilities on its output (V4L2 capture).\n> > >  \t */\n> > > -\tV4L2DeviceFormat format;\n> > > +\tV4L2DeviceFormat format = {};\n> > >  \tformat.fourcc = m2m_->output()->toV4L2PixelFormat(input);\n> > >  \tformat.size = { 1, 1 };\n> > >\n> > > @@ -103,7 +103,7 @@ SizeRange SimpleConverter::sizes(const Size &input)\n> > >  \t * Set the size on the input side (V4L2 output) of the converter to\n> > >  \t * enumerate the scaling capabilities on its output (V4L2 capture).\n> > >  \t */\n> > > -\tV4L2DeviceFormat format;\n> > > +\tV4L2DeviceFormat format = {};\n> > >  \tformat.fourcc = V4L2PixelFormat();\n> > >  \tformat.size = input;\n> > >\n> > > @@ -142,7 +142,7 @@ SizeRange SimpleConverter::sizes(const Size &input)\n> > >  int SimpleConverter::configure(PixelFormat inputFormat, const Size &inputSize,\n> > >  \t\t\t       StreamConfiguration *cfg)\n> > >  {\n> > > -\tV4L2DeviceFormat format;\n> > > +\tV4L2DeviceFormat format = {};\n> > >  \tint ret;\n> > >\n> > >  \tV4L2PixelFormat videoFormat = m2m_->output()->toV4L2PixelFormat(inputFormat);","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 3AF6FC3D3C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 21 Oct 2020 16:36:55 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id AE29B60E31;\n\tWed, 21 Oct 2020 18:36:54 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6FDC460995\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 21 Oct 2020 18:36:53 +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 E2A7DBB5;\n\tWed, 21 Oct 2020 18:36:52 +0200 (CEST)"],"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=\"smD23+tO\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1603298213;\n\tbh=wN179e3WbyFkvBjwg+Nl9mB4kTypsg1AwnqTovDKq2Y=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=smD23+tOQXNG4hAmwtyCbvHE8cblCrdiRBACOSytHCLg3X+YMFWGeFCdZTrbQ5D9y\n\t79sVj55roXGFRUfFtWtPrehJkb2FJ0DS6eS1Ecaz+QSiPsxwUTb2ZvsqvwOOi/Ld2C\n\twq9rxl4M7naDJqEN20D71mHsYMUUpp1LK6Txa2RM=","Date":"Wed, 21 Oct 2020 19:36:07 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Message-ID":"<20201021163607.GH3942@pendragon.ideasonboard.com>","References":"<20201021024744.19047-1-laurent.pinchart@ideasonboard.com>\n\t<20201021024744.19047-2-laurent.pinchart@ideasonboard.com>\n\t<20201021131355.vwvowdo7ofdgzgr4@uno.localdomain>\n\t<20201021163053.GG3942@pendragon.ideasonboard.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20201021163053.GG3942@pendragon.ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH 2/2] libcamera: pipeline: simple:\n\tInitialize V4L2DeviceFormat before use","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","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":13372,"web_url":"https://patchwork.libcamera.org/comment/13372/","msgid":"<20201021164044.gvu6zbpb7dbyzy2e@uno.localdomain>","date":"2020-10-21T16:40:44","subject":"Re: [libcamera-devel] [PATCH 2/2] libcamera: pipeline: simple:\n\tInitialize V4L2DeviceFormat before use","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Laurent,\n\nOn Wed, Oct 21, 2020 at 07:30:53PM +0300, Laurent Pinchart wrote:\n> Hi Jacopo,\n>\n> On Wed, Oct 21, 2020 at 03:13:55PM +0200, Jacopo Mondi wrote:\n> > On Wed, Oct 21, 2020 at 05:47:44AM +0300, Laurent Pinchart wrote:\n> > > The V4L2DeviceFormat has no default constructor. Zero it before use when\n> >\n> > Isn't it implicitly generated by the compiler ?\n>\n> It is, but the implicitly-defined constructor won't help us here:\n>\n> \"If the implicitly-declared default constructor is not defined as\n> deleted, it is defined (that is, a function body is generated and\n> compiled) by the compiler if odr-used, and it has the same effect as a\n> user-defined constructor with empty body and empty initializer list.\"\n>\n> (https://en.cppreference.com/w/cpp/language/default_constructor is an\n> interesting read)\n>\n\nAh, thanks for the pointer!\n\n> > > setting formats. Failure to do so leaves the planes uninitialized,\n> > > potentially causing memory corruption.\n> >\n> > If not, isn't it better to add it in the class ?\n>\n> I had considered that, but wasn't sure, and was hoping nobody would ask\n> ;-)\n\nI'm sorry :)\n\nBut once fixed in the constructor, it's fixed for good, isn't it ?\n\n>\n> It could make sense to replace the planes array and planesCount field\n> with an std::vector. A bit of a shame to have to use dynamic allocation\n> when we know there will never be more than 3 planes though. I wish there\n> was a dynamic array container, with fixed memory preallocation and\n> dynamic size up to the number of elements.\n\nCan't we use std::array<3> in that case ? Although std::array<> is\nhorrible to use :(\n\n>\n> Any preference between using a vector, and keeping it as-is with a\n> constructor that sets numPlanes to 0 ?\n\nTo me a constructor sounds quite right, but other options are fine\ntoo.\n\nThanks\n  j\n\n>\n> > > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > > ---\n> > >  src/libcamera/pipeline/simple/converter.cpp | 6 +++---\n> > >  1 file changed, 3 insertions(+), 3 deletions(-)\n> > >\n> > > diff --git a/src/libcamera/pipeline/simple/converter.cpp b/src/libcamera/pipeline/simple/converter.cpp\n> > > index b4ee021f6210..b3705abcd626 100644\n> > > --- a/src/libcamera/pipeline/simple/converter.cpp\n> > > +++ b/src/libcamera/pipeline/simple/converter.cpp\n> > > @@ -72,7 +72,7 @@ std::vector<PixelFormat> SimpleConverter::formats(PixelFormat input)\n> > >  \t * Set the format on the input side (V4L2 output) of the converter to\n> > >  \t * enumerate the conversion capabilities on its output (V4L2 capture).\n> > >  \t */\n> > > -\tV4L2DeviceFormat format;\n> > > +\tV4L2DeviceFormat format = {};\n> > >  \tformat.fourcc = m2m_->output()->toV4L2PixelFormat(input);\n> > >  \tformat.size = { 1, 1 };\n> > >\n> > > @@ -103,7 +103,7 @@ SizeRange SimpleConverter::sizes(const Size &input)\n> > >  \t * Set the size on the input side (V4L2 output) of the converter to\n> > >  \t * enumerate the scaling capabilities on its output (V4L2 capture).\n> > >  \t */\n> > > -\tV4L2DeviceFormat format;\n> > > +\tV4L2DeviceFormat format = {};\n> > >  \tformat.fourcc = V4L2PixelFormat();\n> > >  \tformat.size = input;\n> > >\n> > > @@ -142,7 +142,7 @@ SizeRange SimpleConverter::sizes(const Size &input)\n> > >  int SimpleConverter::configure(PixelFormat inputFormat, const Size &inputSize,\n> > >  \t\t\t       StreamConfiguration *cfg)\n> > >  {\n> > > -\tV4L2DeviceFormat format;\n> > > +\tV4L2DeviceFormat format = {};\n> > >  \tint ret;\n> > >\n> > >  \tV4L2PixelFormat videoFormat = m2m_->output()->toV4L2PixelFormat(inputFormat);\n>\n> --\n> Regards,\n>\n> Laurent Pinchart","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 EDDF1BDB13\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 21 Oct 2020 16:40:47 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9228F60F77;\n\tWed, 21 Oct 2020 18:40:47 +0200 (CEST)","from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net\n\t[217.70.183.201])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E527360995\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 21 Oct 2020 18:40:46 +0200 (CEST)","from uno.localdomain (93-34-118-233.ip49.fastwebnet.it\n\t[93.34.118.233]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay8-d.mail.gandi.net (Postfix) with ESMTPSA id 74B6A1BF20F;\n\tWed, 21 Oct 2020 16:40:46 +0000 (UTC)"],"X-Originating-IP":"93.34.118.233","Date":"Wed, 21 Oct 2020 18:40:44 +0200","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Message-ID":"<20201021164044.gvu6zbpb7dbyzy2e@uno.localdomain>","References":"<20201021024744.19047-1-laurent.pinchart@ideasonboard.com>\n\t<20201021024744.19047-2-laurent.pinchart@ideasonboard.com>\n\t<20201021131355.vwvowdo7ofdgzgr4@uno.localdomain>\n\t<20201021163053.GG3942@pendragon.ideasonboard.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20201021163053.GG3942@pendragon.ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH 2/2] libcamera: pipeline: simple:\n\tInitialize V4L2DeviceFormat before use","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","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":13376,"web_url":"https://patchwork.libcamera.org/comment/13376/","msgid":"<20201021183728.GL3942@pendragon.ideasonboard.com>","date":"2020-10-21T18:37:28","subject":"Re: [libcamera-devel] [PATCH 2/2] libcamera: pipeline: simple:\n\tInitialize V4L2DeviceFormat before use","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jacopo,\n\nOn Wed, Oct 21, 2020 at 06:40:44PM +0200, Jacopo Mondi wrote:\n> On Wed, Oct 21, 2020 at 07:30:53PM +0300, Laurent Pinchart wrote:\n> > On Wed, Oct 21, 2020 at 03:13:55PM +0200, Jacopo Mondi wrote:\n> > > On Wed, Oct 21, 2020 at 05:47:44AM +0300, Laurent Pinchart wrote:\n> > > > The V4L2DeviceFormat has no default constructor. Zero it before use when\n> > >\n> > > Isn't it implicitly generated by the compiler ?\n> >\n> > It is, but the implicitly-defined constructor won't help us here:\n> >\n> > \"If the implicitly-declared default constructor is not defined as\n> > deleted, it is defined (that is, a function body is generated and\n> > compiled) by the compiler if odr-used, and it has the same effect as a\n> > user-defined constructor with empty body and empty initializer list.\"\n> >\n> > (https://en.cppreference.com/w/cpp/language/default_constructor is an\n> > interesting read)\n> \n> Ah, thanks for the pointer!\n> \n> > > > setting formats. Failure to do so leaves the planes uninitialized,\n> > > > potentially causing memory corruption.\n> > >\n> > > If not, isn't it better to add it in the class ?\n> >\n> > I had considered that, but wasn't sure, and was hoping nobody would ask\n> > ;-)\n> \n> I'm sorry :)\n> \n> But once fixed in the constructor, it's fixed for good, isn't it ?\n\nYes, which is why it's probably best. I'll work on it.\n\n> > It could make sense to replace the planes array and planesCount field\n> > with an std::vector. A bit of a shame to have to use dynamic allocation\n> > when we know there will never be more than 3 planes though. I wish there\n> > was a dynamic array container, with fixed memory preallocation and\n> > dynamic size up to the number of elements.\n> \n> Can't we use std::array<3> in that case ? Although std::array<> is\n> horrible to use :(\n\nWe can use std::array<>, but it won't initialize the contents of the\narray by default. Furthermore, arrays have a fixed size, they don't\nembed and additional field that reports the number of elements actually\nused.\n\n> > Any preference between using a vector, and keeping it as-is with a\n> > constructor that sets numPlanes to 0 ?\n> \n> To me a constructor sounds quite right, but other options are fine\n> too.\n> \n> > > > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > > > ---\n> > > >  src/libcamera/pipeline/simple/converter.cpp | 6 +++---\n> > > >  1 file changed, 3 insertions(+), 3 deletions(-)\n> > > >\n> > > > diff --git a/src/libcamera/pipeline/simple/converter.cpp b/src/libcamera/pipeline/simple/converter.cpp\n> > > > index b4ee021f6210..b3705abcd626 100644\n> > > > --- a/src/libcamera/pipeline/simple/converter.cpp\n> > > > +++ b/src/libcamera/pipeline/simple/converter.cpp\n> > > > @@ -72,7 +72,7 @@ std::vector<PixelFormat> SimpleConverter::formats(PixelFormat input)\n> > > >  \t * Set the format on the input side (V4L2 output) of the converter to\n> > > >  \t * enumerate the conversion capabilities on its output (V4L2 capture).\n> > > >  \t */\n> > > > -\tV4L2DeviceFormat format;\n> > > > +\tV4L2DeviceFormat format = {};\n> > > >  \tformat.fourcc = m2m_->output()->toV4L2PixelFormat(input);\n> > > >  \tformat.size = { 1, 1 };\n> > > >\n> > > > @@ -103,7 +103,7 @@ SizeRange SimpleConverter::sizes(const Size &input)\n> > > >  \t * Set the size on the input side (V4L2 output) of the converter to\n> > > >  \t * enumerate the scaling capabilities on its output (V4L2 capture).\n> > > >  \t */\n> > > > -\tV4L2DeviceFormat format;\n> > > > +\tV4L2DeviceFormat format = {};\n> > > >  \tformat.fourcc = V4L2PixelFormat();\n> > > >  \tformat.size = input;\n> > > >\n> > > > @@ -142,7 +142,7 @@ SizeRange SimpleConverter::sizes(const Size &input)\n> > > >  int SimpleConverter::configure(PixelFormat inputFormat, const Size &inputSize,\n> > > >  \t\t\t       StreamConfiguration *cfg)\n> > > >  {\n> > > > -\tV4L2DeviceFormat format;\n> > > > +\tV4L2DeviceFormat format = {};\n> > > >  \tint ret;\n> > > >\n> > > >  \tV4L2PixelFormat videoFormat = m2m_->output()->toV4L2PixelFormat(inputFormat);","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 3E903BDB13\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 21 Oct 2020 18:38:16 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id AD09460986;\n\tWed, 21 Oct 2020 20:38:15 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 40C2C60361\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 21 Oct 2020 20:38:14 +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 B45D8BB5;\n\tWed, 21 Oct 2020 20:38:13 +0200 (CEST)"],"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=\"XRimix9n\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1603305493;\n\tbh=csgHl7Jk8+nqPlxl3ZsKP74eta1PLD0VYlFRhAppacw=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=XRimix9nHU5kAiRnZukfxe8Mroh5cm0O6ayGDTT0ymIB8WPLfqHXSAeob7ohYo8sV\n\t5M5G/DQrxgcyK7x9Kgj+jzKHus8r6xtJKMVHsfAHi80VUX0JjLQe2kbE9fw4KU5apP\n\tR5DS7QyvkuedozRN9l08rM/bqtBTPcsyO1yRTZV0=","Date":"Wed, 21 Oct 2020 21:37:28 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Message-ID":"<20201021183728.GL3942@pendragon.ideasonboard.com>","References":"<20201021024744.19047-1-laurent.pinchart@ideasonboard.com>\n\t<20201021024744.19047-2-laurent.pinchart@ideasonboard.com>\n\t<20201021131355.vwvowdo7ofdgzgr4@uno.localdomain>\n\t<20201021163053.GG3942@pendragon.ideasonboard.com>\n\t<20201021164044.gvu6zbpb7dbyzy2e@uno.localdomain>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20201021164044.gvu6zbpb7dbyzy2e@uno.localdomain>","Subject":"Re: [libcamera-devel] [PATCH 2/2] libcamera: pipeline: simple:\n\tInitialize V4L2DeviceFormat before use","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","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]