From patchwork Thu Aug 8 17:30:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 20846 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 BE7D1BE173 for ; Thu, 8 Aug 2024 17:30:47 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E669A61955; Thu, 8 Aug 2024 19:30:46 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="o8QTJmPn"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4D64261955 for ; Thu, 8 Aug 2024 19:30:45 +0200 (CEST) Received: from Monstersaurus.tail69b4.ts.net (cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 539CC8D0; Thu, 8 Aug 2024 19:29:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1723138191; bh=p3Xa2aembf303Av+U1/qRVxlpKiDj1GeGl/f285RvVM=; h=From:To:Cc:Subject:Date:From; b=o8QTJmPnnmh/TaaJjfu6slmBoYAaU5JYMJDgoVW3LgFPoamWTBqiVf3FM0Z06cVHt BxGBqunPNoWZn0BTMLqnsemzCt7ECbgEajp3j4iTieyGnId14/uwVAkjlWcd0oSIE3 PZeLYOlienxl+lYAnVzgCSOIGNg8ukgvlC0XztZI= From: Kieran Bingham To: libcamera devel Cc: Stefan Klug , Kieran Bingham Subject: [PATCH] libcamera: v4l2_videodevice: Improve readability Date: Thu, 8 Aug 2024 18:30:41 +0100 Message-Id: <20240808173041.2505335-1-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.34.1 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" From: Stefan Klug The handling for the sequence number validation within V4L2VideoDevice::dequeueBuffer makes use of a std::optional, which can be used as a boolean in conditional statements. This has the impact in this use case that it can be mis-read to be interpretting the value for firstFrame_ which is assigned as teh buf.sequence. Remove this potential for confusion by making it clear that the first frame handling is only performed when firstFrame_ does not have a value assigned. Signed-off-by: Stefan Klug [Kieran: Rework commit message] Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- src/libcamera/v4l2_videodevice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp index 6f32521f3d6f..59379308d5b3 100644 --- a/src/libcamera/v4l2_videodevice.cpp +++ b/src/libcamera/v4l2_videodevice.cpp @@ -1841,7 +1841,7 @@ FrameBuffer *V4L2VideoDevice::dequeueBuffer() * Detect kernel drivers which do not reset the sequence number to zero * on stream start. */ - if (!firstFrame_) { + if (!firstFrame_.has_value()) { if (buf.sequence) LOG(V4L2, Info) << "Zero sequence expected for first frame (got "