{"id":1528,"url":"https://patchwork.libcamera.org/api/1.1/patches/1528/?format=json","web_url":"https://patchwork.libcamera.org/patch/1528/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20190629113922.17119-1-niklas.soderlund@ragnatech.se>","date":"2019-06-29T11:39:22","name":"[libcamera-devel,v3] libcamera: v4l2_device: Fix variable-sized object initialization","commit_ref":"0116a940ba0232b625ab84bb90bb1bc3ddd47658","pull_url":null,"state":"accepted","archived":false,"hash":"03d8ccf2637ec0e7acce212ad400193ed893e3ba","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/1.1/people/5/?format=json","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/1528/mbox/","series":[{"id":381,"url":"https://patchwork.libcamera.org/api/1.1/series/381/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=381","date":"2019-06-29T11:39:22","name":"[libcamera-devel,v3] libcamera: v4l2_device: Fix variable-sized object initialization","version":3,"mbox":"https://patchwork.libcamera.org/series/381/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/1528/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/1528/checks/","tags":{},"headers":{"Return-Path":"<niklas.soderlund@ragnatech.se>","Received":["from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net\n\t[195.74.38.227])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C1A1960BF8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 29 Jun 2019 13:39:28 +0200 (CEST)","from bismarck.berto.se (unknown [145.14.112.32])\n\tby bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA\n\tid 8420131c-9a62-11e9-8601-0050569116f7;\n\tSat, 29 Jun 2019 13:39:15 +0200 (CEST)"],"X-Halon-ID":"8420131c-9a62-11e9-8601-0050569116f7","Authorized-sender":"niklas@soderlund.pp.se","From":"=?utf-8?q?Niklas_S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","To":"libcamera-devel@lists.libcamera.org","Date":"Sat, 29 Jun 2019 13:39:22 +0200","Message-Id":"<20190629113922.17119-1-niklas.soderlund@ragnatech.se>","X-Mailer":"git-send-email 2.22.0","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","Subject":"[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":"Sat, 29 Jun 2019 11:39:29 -0000"},"content":"Compiling with clang renders errors as a variable-sized arrays are not\nallowed to be initialized. Solve this by using memset() for v4l2Ctrls\nwhich 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      ^~~~~\nFixes: eb068f4e67eedacd (\"libcamera: v4l2_device: Implement get and set controls\")\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/libcamera/v4l2_device.cpp | 11 +++++++----\n 1 file changed, 7 insertions(+), 4 deletions(-)","diff":"diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\nindex 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","prefixes":["libcamera-devel","v3"]}