From patchwork Tue Dec 1 08:37:58 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: 29119 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 833F9C3304 for ; Tue, 1 Dec 2026 08:38:18 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 48D696AAB4; Tue, 1 Dec 2026 09:38:14 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="ouwRjiFz"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9A3886AA9D for ; Tue, 1 Dec 2026 09:38:09 +0100 (CET) Received: from pb-laptop.local (185.182.215.119.nat.pool.zt.hu [185.182.215.119]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 9BD07C23 for ; Tue, 1 Dec 2026 09:35:31 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1796114131; bh=Nrr/rVAKq5n8WzIORoe++vMtssPGYVbe210K+gckveo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ouwRjiFzgrtAdaCHXPHWFJJquj8lPx55JY/S2h3uKvA7i1da/g4M4whXUfaPnWND9 IAE5fD+fPEUxiVOfBEiha8rJxYBkuKdTIOqOFd33qkN3AxtwtG9xWz0OPJ/NW9LjuO YeMEwxu1xS/bZlcn1Xl4tBKEKRiDXvCoFXGD/KtQ= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [PATCH v1 2/9] v4l2: v4l2_camera: Remove repated index checks Date: Tue, 1 Dec 2026 09:37:58 +0100 Message-ID: <20261201083805.496809-3-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261201083805.496809-1-barnabas.pocze@ideasonboard.com> References: <20261201083805.496809-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 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 8c29b4d02c..3c9ec8f9c6 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);