From patchwork Thu Feb 12 12:35:55 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 26135 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 68B28BDE6B for ; Thu, 12 Feb 2026 12:36:00 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7AA08621C7; Thu, 12 Feb 2026 13:35:59 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="pSjpn/nA"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A997F61FBF for ; Thu, 12 Feb 2026 13:35:57 +0100 (CET) Received: from killaraus.ideasonboard.com (2001-14ba-703d-e500--2a1.rev.dnainternet.fi [IPv6:2001:14ba:703d:e500::2a1]) by perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 74F30E70 for ; Thu, 12 Feb 2026 13:35:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1770899709; bh=OdhrwbxcTqjN3k+r0/4HQcjId+0GxsTiG/JQLs/VWIg=; h=From:To:Subject:Date:From; b=pSjpn/nAdjmly/NJWG1Pe5rXz3qh9xJjCj7OAs8P46xod2JpNE41GYkodZ7fBiNFR LGCBqj4BV9mdSmUMMVZpRylxgeWI4GPT7QcdpOQZkBKQPhIA3FkPPDfyHa2ReRj4MN xUNTdTPFWoUwJ1Vc6WGViGPYwWmfAwc9QPN0+ZeM= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Subject: [PATCH] libcamera: Replace iterators with structured bindings Date: Thu, 12 Feb 2026 14:35:55 +0200 Message-ID: <20260212123555.2686756-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.52.0 MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Use structured bindings when iterating over a map in range-based for loops. This improves readability. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham Reviewed-by: Barnabás Pőcze --- src/libcamera/pipeline/ipu3/ipu3.cpp | 11 +++-------- src/libcamera/pipeline/vimc/vimc.cpp | 3 +-- src/libcamera/v4l2_videodevice.cpp | 6 ++---- 3 files changed, 6 insertions(+), 14 deletions(-) base-commit: 1dcf9957a47fb54fce4fbae9daec0b587e52562e diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 0190f677e679..d1d4d85ebe76 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -791,8 +791,7 @@ void IPU3CameraData::cancelPendingRequests() while (!pendingRequests_.empty()) { Request *request = pendingRequests_.front(); - for (auto it : request->buffers()) { - FrameBuffer *buffer = it.second; + for (auto [stream, buffer] : request->buffers()) { buffer->_d()->cancel(); pipe()->completeBuffer(request, buffer); } @@ -1225,10 +1224,7 @@ void IPU3CameraData::paramsComputed(unsigned int id) return; /* Queue all buffers from the request aimed for the ImgU. */ - for (auto it : info->request->buffers()) { - const Stream *stream = it.first; - FrameBuffer *outbuffer = it.second; - + for (auto [stream, outbuffer] : info->request->buffers()) { if (stream == &outStream_) imgu_->output_->queueBuffer(outbuffer); else if (stream == &vfStream_) @@ -1304,8 +1300,7 @@ void IPU3CameraData::cio2BufferReady(FrameBuffer *buffer) /* If the buffer is cancelled force a complete of the whole request. */ if (buffer->metadata().status == FrameMetadata::FrameCancelled) { - for (auto it : request->buffers()) { - FrameBuffer *b = it.second; + for (auto [stream, b] : request->buffers()) { b->_d()->cancel(); pipe()->completeBuffer(request, b); } diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp index 4a03c149a617..025e7dbdd26f 100644 --- a/src/libcamera/pipeline/vimc/vimc.cpp +++ b/src/libcamera/pipeline/vimc/vimc.cpp @@ -607,8 +607,7 @@ void VimcCameraData::imageBufferReady(FrameBuffer *buffer) /* If the buffer is cancelled force a complete of the whole request. */ if (buffer->metadata().status == FrameMetadata::FrameCancelled) { - for (auto it : request->buffers()) { - FrameBuffer *b = it.second; + for (auto [stream, b] : request->buffers()) { b->_d()->cancel(); pipe->completeBuffer(request, b); } diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp index 25b61d049a0e..02c50886a084 100644 --- a/src/libcamera/v4l2_videodevice.cpp +++ b/src/libcamera/v4l2_videodevice.cpp @@ -2042,10 +2042,8 @@ int V4L2VideoDevice::streamOff() state_ = State::Stopping; /* Send back all queued buffers. */ - for (auto it : queuedBuffers_) { - FrameBuffer *buffer = it.second; - - cache_->put(it.first); + for (auto [id, buffer] : queuedBuffers_) { + cache_->put(id); buffer->_d()->cancel(); bufferReady.emit(buffer); }