{"id":3783,"url":"https://patchwork.libcamera.org/api/1.1/patches/3783/?format=json","web_url":"https://patchwork.libcamera.org/patch/3783/","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":"<20200513091255.7109-1-jacopo@jmondi.org>","date":"2020-05-13T09:12:55","name":"[libcamera-devel] libcamera: controls: Replace array designated initializer","commit_ref":null,"pull_url":null,"state":"superseded","archived":true,"hash":"c09d6cf6acb1b20ce57c2f1c928f6c652df301bf","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/1.1/people/3/?format=json","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"delegate":{"id":15,"url":"https://patchwork.libcamera.org/api/1.1/users/15/?format=json","username":"jmondi","first_name":"Jacopo","last_name":"Mondi","email":"jacopo@jmondi.org"},"mbox":"https://patchwork.libcamera.org/patch/3783/mbox/","series":[{"id":901,"url":"https://patchwork.libcamera.org/api/1.1/series/901/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=901","date":"2020-05-13T09:12:55","name":"[libcamera-devel] libcamera: controls: Replace array designated initializer","version":1,"mbox":"https://patchwork.libcamera.org/series/901/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/3783/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/3783/checks/","tags":{},"headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay11.mail.gandi.net (relay11.mail.gandi.net\n\t[217.70.178.231])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5EBE5603DE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 13 May 2020 11:09:43 +0200 (CEST)","from localhost.localdomain (2-224-242-101.ip172.fastwebnet.it\n\t[2.224.242.101]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay11.mail.gandi.net (Postfix) with ESMTPSA id 9ABDD10001D;\n\tWed, 13 May 2020 09:09:42 +0000 (UTC)"],"From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Wed, 13 May 2020 11:12:55 +0200","Message-Id":"<20200513091255.7109-1-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.26.2","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH] libcamera: controls: Replace array\n\tdesignated initializer","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>","X-List-Received-Date":"Wed, 13 May 2020 09:09:43 -0000"},"content":"Since version 10.0 the LLVM clang++ compiler emits warning to report\nusage of array designated initializer, a C99 feature that was only\nsupported through an extension of the compiler and will be not valid\nanymore in C++20.\n\n>From https://releases.llvm.org/10.0.0/tools/clang/docs/ReleaseNotes.html\nThe new warnings -Wc99-designator and -Wreorder-init-list warn about\nuses of C99 initializers in C++ mode for cases that are valid in C99 but\nnot in C++20.\n\nThis generates the following build error in the controls.cpp file:\n../src/libcamera/controls.cpp:54:2: error: array designators are a C99 extension [-Werror,-Wc99-designator]\n        [ControlTypeNone]               = 0,\n        ^~~~~~~~~~~~~~~~~\n\nFix this by replacing the plain C array with an std:map<>.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n\n---\nI would have liked the map to be immutable, but I can't due to missing\noverloading for operator[]:\nerror: no viable overloaded operator[] for type 'const std::map<unsigned int, size_t>'\n\nTested with clang++ 10.0.0 and g++ 9.3.0.1\n---\n src/libcamera/controls.cpp | 21 +++++++++++----------\n 1 file changed, 11 insertions(+), 10 deletions(-)\n\n--\n2.26.2","diff":"diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp\nindex 08df7f29e938..eaef45a5f62c 100644\n--- a/src/libcamera/controls.cpp\n+++ b/src/libcamera/controls.cpp\n@@ -8,6 +8,7 @@\n #include <libcamera/controls.h>\n\n #include <iomanip>\n+#include <map>\n #include <sstream>\n #include <string>\n #include <string.h>\n@@ -50,16 +51,16 @@ LOG_DEFINE_CATEGORY(Controls)\n\n namespace {\n\n-static constexpr size_t ControlValueSize[] = {\n-\t[ControlTypeNone]\t\t= 0,\n-\t[ControlTypeBool]\t\t= sizeof(bool),\n-\t[ControlTypeByte]\t\t= sizeof(uint8_t),\n-\t[ControlTypeInteger32]\t\t= sizeof(int32_t),\n-\t[ControlTypeInteger64]\t\t= sizeof(int64_t),\n-\t[ControlTypeFloat]\t\t= sizeof(float),\n-\t[ControlTypeString]\t\t= sizeof(char),\n-\t[ControlTypeRectangle]\t\t= sizeof(Rectangle),\n-\t[ControlTypeSize]\t\t= sizeof(Size),\n+std::map<unsigned int, size_t> ControlValueSize = {\n+\t{ ControlTypeNone,\t0  },\n+\t{ ControlTypeBool,\tsizeof(bool) },\n+\t{ ControlTypeByte,\tsizeof(uint8_t) },\n+\t{ ControlTypeInteger32,\tsizeof(int32_t) },\n+\t{ ControlTypeInteger64,\tsizeof(int64_t) },\n+\t{ ControlTypeFloat,\tsizeof(float) },\n+\t{ ControlTypeString,\tsizeof(char) },\n+\t{ ControlTypeRectangle,\tsizeof(Rectangle) },\n+\t{ ControlTypeSize,\tsizeof(Size) },\n };\n\n } /* namespace */\n","prefixes":["libcamera-devel"]}