[{"id":2056,"web_url":"https://patchwork.libcamera.org/comment/2056/","msgid":"<20190630090729.uyr7yfytgihh673u@uno.localdomain>","date":"2019-06-30T09:07:29","subject":"Re: [libcamera-devel] [PATCH v3] libcamera: v4l2_device: Fix\n\tvariable-sized object initialization","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Niklas,\n  thanks for the patch\n\nOn Sat, Jun 29, 2019 at 01:39:22PM +0200, Niklas Söderlund wrote:\n> Compiling with clang renders errors as a variable-sized arrays are not\n> allowed to be initialized. Solve this by using memset() for v4l2Ctrls\n> which is the only one of the two arrays that needs to be zeroed.\n>\n>     ../../src/libcamera/v4l2_device.cpp:155:37: error: variable-sized object may not be initialized\n>         const V4L2ControlInfo *controlInfo[count] = {};\n>                                            ^~~~~\n>     ../../src/libcamera/v4l2_device.cpp:156:36: error: variable-sized object may not be initialized\n> \t    struct v4l2_ext_control v4l2Ctrls[count] = {};\n> \t\t\t\t\t      ^~~~~\n>     ../../src/libcamera/v4l2_device.cpp:227:37: error: variable-sized object may not be initialized\n> \t    const V4L2ControlInfo *controlInfo[count] = {};\n> \t\t\t\t\t       ^~~~~\n>     ../../src/libcamera/v4l2_device.cpp:228:36: error: variable-sized object may not be initialized\n> \t    struct v4l2_ext_control v4l2Ctrls[count] = {};\n> \t\t\t\t\t      ^~~~~\n> Fixes: eb068f4e67eedacd (\"libcamera: v4l2_device: Implement get and set controls\")\n> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n\nThanks\n  j\n> ---\n>  src/libcamera/v4l2_device.cpp | 11 +++++++----\n>  1 file changed, 7 insertions(+), 4 deletions(-)\n>\n> diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\n> index f1821a7ba162e709..06939dead705459f 100644\n> --- a/src/libcamera/v4l2_device.cpp\n> +++ b/src/libcamera/v4l2_device.cpp\n> @@ -152,8 +152,10 @@ int V4L2Device::getControls(V4L2ControlList *ctrls)\n>  \tif (count == 0)\n>  \t\treturn 0;\n>\n> -\tconst V4L2ControlInfo *controlInfo[count] = {};\n> -\tstruct v4l2_ext_control v4l2Ctrls[count] = {};\n> +\tconst V4L2ControlInfo *controlInfo[count];\n> +\tstruct v4l2_ext_control v4l2Ctrls[count];\n> +\tmemset(v4l2Ctrls, 0, sizeof(v4l2Ctrls));\n> +\n>  \tfor (unsigned int i = 0; i < count; ++i) {\n>  \t\tconst V4L2Control *ctrl = ctrls->getByIndex(i);\n>  \t\tconst V4L2ControlInfo *info = getControlInfo(ctrl->id());\n> @@ -224,8 +226,9 @@ int V4L2Device::setControls(V4L2ControlList *ctrls)\n>  \tif (count == 0)\n>  \t\treturn 0;\n>\n> -\tconst V4L2ControlInfo *controlInfo[count] = {};\n> -\tstruct v4l2_ext_control v4l2Ctrls[count] = {};\n> +\tconst V4L2ControlInfo *controlInfo[count];\n> +\tstruct v4l2_ext_control v4l2Ctrls[count];\n> +\tmemset(v4l2Ctrls, 0, sizeof(v4l2Ctrls));\n>\n>  \tfor (unsigned int i = 0; i < count; ++i) {\n>  \t\tconst V4L2Control *ctrl = ctrls->getByIndex(i);\n> --\n> 2.22.0\n>\n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net\n\t[217.70.183.196])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4C8B36157C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 30 Jun 2019 11:06:14 +0200 (CEST)","from uno.localdomain (2-224-242-101.ip172.fastwebnet.it\n\t[2.224.242.101]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay4-d.mail.gandi.net (Postfix) with ESMTPSA id C28BDE0002;\n\tSun, 30 Jun 2019 09:06:13 +0000 (UTC)"],"X-Originating-IP":"2.224.242.101","Date":"Sun, 30 Jun 2019 11:07:29 +0200","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Niklas =?utf-8?q?S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190630090729.uyr7yfytgihh673u@uno.localdomain>","References":"<20190629113922.17119-1-niklas.soderlund@ragnatech.se>","MIME-Version":"1.0","Content-Type":"multipart/signed; micalg=pgp-sha256;\n\tprotocol=\"application/pgp-signature\"; boundary=\"cbb7fcjbl7bswqz2\"","Content-Disposition":"inline","In-Reply-To":"<20190629113922.17119-1-niklas.soderlund@ragnatech.se>","User-Agent":"NeoMutt/20180716","Subject":"Re: [libcamera-devel] [PATCH v3] libcamera: v4l2_device: Fix\n\tvariable-sized object initialization","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","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>","X-List-Received-Date":"Sun, 30 Jun 2019 09:06:14 -0000"}},{"id":2057,"web_url":"https://patchwork.libcamera.org/comment/2057/","msgid":"<20190630115245.GC20789@bigcity.dyn.berto.se>","date":"2019-06-30T11:52:45","subject":"Re: [libcamera-devel] [PATCH v3] libcamera: v4l2_device: Fix\n\tvariable-sized object initialization","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi, \n\nThis patch was pushed with Jacopo's tag, thanks!\n\nOn 2019-06-30 11:07:29 +0200, Jacopo Mondi wrote:\n> Hi Niklas,\n>   thanks for the patch\n> \n> On Sat, Jun 29, 2019 at 01:39:22PM +0200, Niklas Söderlund wrote:\n> > Compiling with clang renders errors as a variable-sized arrays are not\n> > allowed to be initialized. Solve this by using memset() for v4l2Ctrls\n> > which is the only one of the two arrays that needs to be zeroed.\n> >\n> >     ../../src/libcamera/v4l2_device.cpp:155:37: error: variable-sized object may not be initialized\n> >         const V4L2ControlInfo *controlInfo[count] = {};\n> >                                            ^~~~~\n> >     ../../src/libcamera/v4l2_device.cpp:156:36: error: variable-sized object may not be initialized\n> > \t    struct v4l2_ext_control v4l2Ctrls[count] = {};\n> > \t\t\t\t\t      ^~~~~\n> >     ../../src/libcamera/v4l2_device.cpp:227:37: error: variable-sized object may not be initialized\n> > \t    const V4L2ControlInfo *controlInfo[count] = {};\n> > \t\t\t\t\t       ^~~~~\n> >     ../../src/libcamera/v4l2_device.cpp:228:36: error: variable-sized object may not be initialized\n> > \t    struct v4l2_ext_control v4l2Ctrls[count] = {};\n> > \t\t\t\t\t      ^~~~~\n> > Fixes: eb068f4e67eedacd (\"libcamera: v4l2_device: Implement get and set controls\")\n> > Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n> \n> Thanks\n>   j\n> > ---\n> >  src/libcamera/v4l2_device.cpp | 11 +++++++----\n> >  1 file changed, 7 insertions(+), 4 deletions(-)\n> >\n> > diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\n> > index f1821a7ba162e709..06939dead705459f 100644\n> > --- a/src/libcamera/v4l2_device.cpp\n> > +++ b/src/libcamera/v4l2_device.cpp\n> > @@ -152,8 +152,10 @@ int V4L2Device::getControls(V4L2ControlList *ctrls)\n> >  \tif (count == 0)\n> >  \t\treturn 0;\n> >\n> > -\tconst V4L2ControlInfo *controlInfo[count] = {};\n> > -\tstruct v4l2_ext_control v4l2Ctrls[count] = {};\n> > +\tconst V4L2ControlInfo *controlInfo[count];\n> > +\tstruct v4l2_ext_control v4l2Ctrls[count];\n> > +\tmemset(v4l2Ctrls, 0, sizeof(v4l2Ctrls));\n> > +\n> >  \tfor (unsigned int i = 0; i < count; ++i) {\n> >  \t\tconst V4L2Control *ctrl = ctrls->getByIndex(i);\n> >  \t\tconst V4L2ControlInfo *info = getControlInfo(ctrl->id());\n> > @@ -224,8 +226,9 @@ int V4L2Device::setControls(V4L2ControlList *ctrls)\n> >  \tif (count == 0)\n> >  \t\treturn 0;\n> >\n> > -\tconst V4L2ControlInfo *controlInfo[count] = {};\n> > -\tstruct v4l2_ext_control v4l2Ctrls[count] = {};\n> > +\tconst V4L2ControlInfo *controlInfo[count];\n> > +\tstruct v4l2_ext_control v4l2Ctrls[count];\n> > +\tmemset(v4l2Ctrls, 0, sizeof(v4l2Ctrls));\n> >\n> >  \tfor (unsigned int i = 0; i < count; ++i) {\n> >  \t\tconst V4L2Control *ctrl = ctrls->getByIndex(i);\n> > --\n> > 2.22.0\n> >\n> > _______________________________________________\n> > libcamera-devel mailing list\n> > libcamera-devel@lists.libcamera.org\n> > https://lists.libcamera.org/listinfo/libcamera-devel","headers":{"Return-Path":"<niklas.soderlund@ragnatech.se>","Received":["from mail-lf1-x143.google.com (mail-lf1-x143.google.com\n\t[IPv6:2a00:1450:4864:20::143])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id EB38660BC0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 30 Jun 2019 13:52:47 +0200 (CEST)","by mail-lf1-x143.google.com with SMTP id p24so6843137lfo.6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 30 Jun 2019 04:52:47 -0700 (PDT)","from localhost (customer-145-14-112-32.stosn.net. [145.14.112.32])\n\tby smtp.gmail.com with ESMTPSA id\n\tr84sm2968501lja.54.2019.06.30.04.52.45\n\t(version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256);\n\tSun, 30 Jun 2019 04:52:46 -0700 (PDT)"],"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\t:user-agent; bh=OOPagV1wq0ZLj1ROQSD72zoix6PklHeGr2aLsv+yO0I=;\n\tb=TgNPJA1RnWzIBcAUxMROIjEnETAb9G9aftOMr34YJcWOuW/ZQwzWJKpo4J7C4FKoC5\n\tmi6oGQvRDdE49TIJzF+k5+oAS43/qt+KDtHmhxFaOS/+eAaGmAZ5SSPv5DmsGzIGy03e\n\tggxBry/Gz0XAOgqa9GeEQ/VCkO4L9N+blLFOssOvZ8motExgDBvitwm1RSlZ3S1QBHXM\n\tbEF72OhClYA/lvhG5NMGKlZj23Pt1tR+YdQRFL2lS5jd3btR/VUwZ5IrKK5tNbOOizK4\n\tmU6pTnssyUpiwLtP5DFjpDDTSd3drLnzKC2slPOrtoYGvucG66UEs1Q03S497XIL3P34\n\t5Q+A==","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:user-agent;\n\tbh=OOPagV1wq0ZLj1ROQSD72zoix6PklHeGr2aLsv+yO0I=;\n\tb=cZpKh/az/D7eaYLz+meavySceW4ZiYK16a6lQDj5tZDfFIM5ZRchshaE7PQy7EwFH3\n\t+A7rgFAzgMYvhR280foKnPCDDIk0XoUVXGlwS5PfeB1lRe4qG1DhyHqxyA3GGTVvzoV0\n\tf6GTD9dImHsbHzqLfY3sdtSNJ1KS9+CNXl1SCaD9+q/kMGcGcmH+Nxt81QZ7P716w2qG\n\t+o6rlDVYjtTT/iW8ECHR962nLP7EoYWTbwLtSSL2wgrfUjcnmFdIG4G3z21NtktE72r5\n\tu8HD0VljuCsyobKfNxP4vC3LAXhYXHVhvpIVyBa/mbsFc7PEV7DLChj2D/trvCMjt3Ps\n\tb5QQ==","X-Gm-Message-State":"APjAAAVVSvWHUzOTmL0l9smPTo4aNf2o28JeiPU0o0Vr6AeCbBakYez1\n\toc/fQCeZeL9oGQ6YsaDfgfdQskwwfnM=","X-Google-Smtp-Source":"APXvYqys54xi0tTRrpII1J1yhCXQLNe8a1OBmbJvmll03D+3IejCpb7PfddzhpyKxTjBdoygT+UgXA==","X-Received":"by 2002:ac2:5337:: with SMTP id f23mr9520505lfh.15.1561895567077;\n\tSun, 30 Jun 2019 04:52:47 -0700 (PDT)","Date":"Sun, 30 Jun 2019 13:52:45 +0200","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190630115245.GC20789@bigcity.dyn.berto.se>","References":"<20190629113922.17119-1-niklas.soderlund@ragnatech.se>\n\t<20190630090729.uyr7yfytgihh673u@uno.localdomain>","MIME-Version":"1.0","Content-Type":"text/plain; charset=iso-8859-1","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20190630090729.uyr7yfytgihh673u@uno.localdomain>","User-Agent":"Mutt/1.12.1 (2019-06-15)","Subject":"Re: [libcamera-devel] [PATCH v3] libcamera: v4l2_device: Fix\n\tvariable-sized object initialization","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","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>","X-List-Received-Date":"Sun, 30 Jun 2019 11:52:48 -0000"}}]