From patchwork Thu Sep 2 04:23:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 13600 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 32725C324A for ; Thu, 2 Sep 2021 04:23:34 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 98BA469173; Thu, 2 Sep 2021 06:23:33 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="DWjuTxzx"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id AE5F269167 for ; Thu, 2 Sep 2021 06:23:27 +0200 (CEST) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 5317D45E; Thu, 2 Sep 2021 06:23:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1630556607; bh=lQuIPtySiPaYQ3lohbAWNwQ8tei909kkgfLYGjUF/Bs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DWjuTxzxXQH5REDGGm0AQ1EYeORXzPKqfzTMwvQ5iF68t6gazwo0NG9MzIyXz+1BH 9kD7uk/tEHn3R5FISCjR1+qbQHI4fmau3249gDYyvN4wUQfGLWfh7aykHB5Jzutlu4 +A/8ojKCIPbqVuA1fz4vhqh1s1C19n64etDgSzT4= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Thu, 2 Sep 2021 07:23:03 +0300 Message-Id: <20210902042303.2254-13-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210902042303.2254-1-laurent.pinchart@ideasonboard.com> References: <20210902042303.2254-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH v1 12/12] libcamera: v4l2_videodevice: Use utils::enumerate() 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" Replace a manual counter with the utils::enumerate() utility function. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham Reviewed-by: Hirokazu Honda --- src/libcamera/v4l2_videodevice.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp index b80b9038a914..8a7d847c060e 100644 --- a/src/libcamera/v4l2_videodevice.cpp +++ b/src/libcamera/v4l2_videodevice.cpp @@ -1338,13 +1338,12 @@ std::unique_ptr V4L2VideoDevice::createBuffer(unsigned int index) planes.resize(formatInfo_->numPlanes()); const FileDescriptor &fd = planes[0].fd; size_t offset = 0; - for (size_t i = 0; i < planes.size(); ++i) { - planes[i].fd = fd; - planes[i].offset = offset; - + for (auto [i, plane] : utils::enumerate(planes)) { + plane.fd = fd; + plane.offset = offset; /* \todo Take the V4L2 stride into account */ - planes[i].length = formatInfo_->planeSize(format_.size, i); - offset += planes[i].length; + plane.length = formatInfo_->planeSize(format_.size, i); + offset += plane.length; } }