[libcamera-devel] [PATCH v2 4/4] v4l2: Adapt to utils::enumerate() usage of named fields

Laurent Pinchart laurent.pinchart at ideasonboard.com
Sat May 15 06:05:11 CEST 2021


This will be squashed with "v4l2: Replace manual loop counters with
utils::enumerate()" if "libcamera: utils: enumerate: Use named fields
for result" is accepted.

Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
---
 src/v4l2/v4l2_compat_manager.cpp | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/v4l2/v4l2_compat_manager.cpp b/src/v4l2/v4l2_compat_manager.cpp
index 96dbcdf28f04..bf5bf8e3223d 100644
--- a/src/v4l2/v4l2_compat_manager.cpp
+++ b/src/v4l2/v4l2_compat_manager.cpp
@@ -83,8 +83,9 @@ int V4L2CompatManager::start()
 	 * created here to wrap a camera device.
 	 */
 	auto cameras = cm_->cameras();
-	for (auto [index, camera] : utils::enumerate(cameras)) {
-		V4L2CameraProxy *proxy = new V4L2CameraProxy(index, camera);
+	for (const auto camera : utils::enumerate(cameras)) {
+		V4L2CameraProxy *proxy = new V4L2CameraProxy(camera.index,
+							     camera.value);
 		proxies_.emplace_back(proxy);
 	}
 
@@ -118,9 +119,9 @@ int V4L2CompatManager::getCameraIndex(int fd)
 		return -1;
 
 	auto cameras = cm_->cameras();
-	for (auto [index, camera] : utils::enumerate(cameras)) {
-		if (camera == target)
-			return index;
+	for (const auto camera : utils::enumerate(cameras)) {
+		if (camera.value == target)
+			return camera.index;
 	}
 
 	return -1;
-- 
Regards,

Laurent Pinchart



More information about the libcamera-devel mailing list