{"id":22103,"url":"https://patchwork.libcamera.org/api/patches/22103/?format=json","web_url":"https://patchwork.libcamera.org/patch/22103/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20241126180302.685265-1-pobrn@protonmail.com>","date":"2024-11-26T18:03:05","name":"[v1] libcamera: Don't copy `StreamConfiguration` when iterating","commit_ref":"4e557e544bce6da8c00c73de2dfe76403bbf8c00","pull_url":null,"state":"accepted","archived":false,"hash":"8b6f5ae2571774b7d69b12be06eba116597a9b50","submitter":{"id":133,"url":"https://patchwork.libcamera.org/api/people/133/?format=json","name":"Pőcze Barnabás","email":"pobrn@protonmail.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/22103/mbox/","series":[{"id":4824,"url":"https://patchwork.libcamera.org/api/series/4824/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4824","date":"2024-11-26T18:03:05","name":"[v1] libcamera: Don't copy `StreamConfiguration` when iterating","version":1,"mbox":"https://patchwork.libcamera.org/series/4824/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/22103/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/22103/checks/","tags":{},"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 5CEFEC3200\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 26 Nov 2024 18:03:17 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4C00466084;\n\tTue, 26 Nov 2024 19:03:16 +0100 (CET)","from mail-10630.protonmail.ch (mail-10630.protonmail.ch\n\t[79.135.106.30])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C94C665FC9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 26 Nov 2024 19:03:13 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=protonmail.com header.i=@protonmail.com\n\theader.b=\"PdT/xg4f\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com;\n\ts=protonmail3; t=1732644191; x=1732903391;\n\tbh=JmUP8o0i9WGI1KB7pfbtZt+zNHFItTb8O419XnxdwbY=;\n\th=Date:To:From:Subject:Message-ID:Feedback-ID:From:To:Cc:Date:\n\tSubject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector:\n\tList-Unsubscribe:List-Unsubscribe-Post;\n\tb=PdT/xg4fAG/N/5ZIV1K0GzVrTQkAH2MHBT2tFib5Plv/dA6HxGDqSnrvo5OuWusRV\n\tE2Q4BCNSZ+ZFdPFp/sB39dDMjPgfIrDdtgoHekToXTqYCNOfzfaHcCE3NbJ53BAxvW\n\tdVCmIKZj3AJtCQaKQTb/s5Ye7D1cn0pf+TjAhnqFMUjesjdR94xPfz31q+jKs48q7S\n\tC0QdtahscijWhu1MU5+MIYtEs/86XSrwYuUUoniT1awA9SSfMcuFdJoEK32J8rqaHE\n\t+fDepfxVTidGymEq9TIJcvocuSkXbSBkBW8TmTOYYa6GaTtEfEYJ8cDx94G01OwXjq\n\tHhAM+WsoMmQ0w==","Date":"Tue, 26 Nov 2024 18:03:05 +0000","To":"libcamera-devel@lists.libcamera.org","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <pobrn@protonmail.com>","Subject":"[PATCH v1] libcamera: Don't copy `StreamConfiguration` when\n\titerating","Message-ID":"<20241126180302.685265-1-pobrn@protonmail.com>","Feedback-ID":"20568564:user:proton","X-Pm-Message-ID":"1092274ac55c45e4b3db78d4957c5b9025092fcc","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Transfer-Encoding":"quoted-printable","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"A copy is made in the range-based for loop, and thus all modifications\ndone in the for loop body are lost, and not actually applied to\nthe object in the container.\n\nFix that by taking a reference in the range-based for loop.\n\nFixes: 4217c9f1aa863c (\"libcamera: camera: Zero streams before validate()\")\nFixes: 613d5402673eb9 (\"pipeline: raspberrypi: Fix handling of colour spaces\")\nSigned-off-by: Barnabás Pőcze <pobrn@protonmail.com>\n---\n src/libcamera/camera.cpp                            | 4 ++--\n src/libcamera/pipeline/rpi/common/pipeline_base.cpp | 4 ++--\n 2 files changed, 4 insertions(+), 4 deletions(-)","diff":"diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\nindex 7507e9dd..4c865a46 100644\n--- a/src/libcamera/camera.cpp\n+++ b/src/libcamera/camera.cpp\n@@ -1178,8 +1178,8 @@ int Camera::configure(CameraConfiguration *config)\n \tif (ret < 0)\n \t\treturn ret;\n \n-\tfor (auto it : *config)\n-\t\tit.setStream(nullptr);\n+\tfor (auto &cfg : *config)\n+\t\tcfg.setStream(nullptr);\n \n \tif (config->validate() != CameraConfiguration::Valid) {\n \t\tLOG(Camera, Error)\ndiff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp\nindex 9e2d9d23..6f278b29 100644\n--- a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp\n+++ b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp\n@@ -105,7 +105,7 @@ CameraConfiguration::Status RPiCameraConfiguration::validateColorSpaces([[maybe_\n \tStatus status = Valid;\n \tyuvColorSpace_.reset();\n \n-\tfor (auto cfg : config_) {\n+\tfor (auto &cfg : config_) {\n \t\t/* First fix up raw streams to have the \"raw\" colour space. */\n \t\tif (PipelineHandlerBase::isRaw(cfg.pixelFormat)) {\n \t\t\t/* If there was no value here, that doesn't count as \"adjusted\". */\n@@ -130,7 +130,7 @@ CameraConfiguration::Status RPiCameraConfiguration::validateColorSpaces([[maybe_\n \trgbColorSpace_->range = ColorSpace::Range::Full;\n \n \t/* Go through the streams again and force everyone to the same colour space. */\n-\tfor (auto cfg : config_) {\n+\tfor (auto &cfg : config_) {\n \t\tif (cfg.colorSpace == ColorSpace::Raw)\n \t\t\tcontinue;\n \n","prefixes":["v1"]}