From patchwork Mon Jun 29 16:29:32 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= X-Patchwork-Id: 27088 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 21736C3261 for ; Mon, 29 Jun 2026 16:30:52 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4BBEC65F3D; Mon, 29 Jun 2026 18:30:37 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="OKK1vQ77"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CE35465F04 for ; Mon, 29 Jun 2026 18:30:22 +0200 (CEST) Received: from pb-laptop.local (185.221.140.128.nat.pool.zt.hu [185.221.140.128]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id AFAC68D4 for ; Mon, 29 Jun 2026 18:29:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1782750579; bh=K6Mvvbe+ry8dhA9unPPH9k/Yv6jmPD7iXc8rogky2lU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=OKK1vQ779RneQBfw02WMk+FTyiTDgfl53mGPC7a6g/Vbp7uhb2xbWMG6GxHD36qvX k5EKBAB6R0ihpJbCKy4dLq/+XuByJ3PGVmsDhr2K2Kd11q++hlnPREUUwkbDGt1BeU hEah+OSvW5urjAg1ZFqTK09hFVf8KBPOVsPMSOe4= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [RFC PATCH v1 09/54] v4l2: v4l2_camera: Remove repated index checks Date: Mon, 29 Jun 2026 18:29:32 +0200 Message-ID: <20260629163017.863145-10-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260629163017.863145-1-barnabas.pocze@ideasonboard.com> References: <20260629163017.863145-1-barnabas.pocze@ideasonboard.com> 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" Check only once if the buffer index is valid. Signed-off-by: Barnabás Pőcze --- src/v4l2/v4l2_camera_proxy.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp index 03cd4810cc..b4f06c1c51 100644 --- a/src/v4l2/v4l2_camera_proxy.cpp +++ b/src/v4l2/v4l2_camera_proxy.cpp @@ -582,8 +582,7 @@ int V4L2CameraProxy::vidioc_querybuf(V4L2CameraFile *file, struct v4l2_buffer *a if (arg->index >= bufferCount_) return -EINVAL; - if (!validateBufferType(arg->type) || - arg->index >= bufferCount_) + if (!validateBufferType(arg->type)) return -EINVAL; updateBuffers(); @@ -641,8 +640,7 @@ int V4L2CameraProxy::vidioc_qbuf(V4L2CameraFile *file, struct v4l2_buffer *arg) return -EBUSY; if (!validateBufferType(arg->type) || - !validateMemoryType(arg->memory) || - arg->index >= bufferCount_) + !validateMemoryType(arg->memory)) return -EINVAL; int ret = vcam_->qbuf(arg->index);