From patchwork Mon Mar 3 15:16:34 2025 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: 22907 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 2EAAEC3257 for ; Mon, 3 Mar 2025 15:16:40 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 95A4D687EB; Mon, 3 Mar 2025 16:16:39 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="IX9Bp6dZ"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DE07368777 for ; Mon, 3 Mar 2025 16:16:37 +0100 (CET) Received: from pb-laptop.local (185.221.143.4.nat.pool.zt.hu [185.221.143.4]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 66F98169 for ; Mon, 3 Mar 2025 16:15:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1741014906; bh=NvoZMa3UUzzZ/6/e3z1ZQfZ6iob6Kkxxmojt96hB8Sg=; h=From:To:Subject:Date:From; b=IX9Bp6dZblpCsqD4dweUbJzfMaTfKvXHNhQpK6OEc1XhSnQfSqrxUUmlIQieUZWue LZQOCg6ufj39WrZ0M3W37MznkIFrF9umXNjH/HevMCSAi9YciB95IBvRcwGzKMn9kD 2IS8LSLALjmQR+Jgqr33HlSntV/j/UEOr0nOK4Ws= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [PATCH v1] libcamera: request: addBuffer(): Do not destroy fence on failure Date: Mon, 3 Mar 2025 16:16:34 +0100 Message-ID: <20250303151634.734176-1-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.48.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" Take the unique pointer to the `Fence` object by rvalue reference so that it is not destroyed if the function returns an error code and does not take ownership of the unique pointer. Signed-off-by: Barnabás Pőcze --- include/libcamera/request.h | 2 +- src/libcamera/request.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/libcamera/request.h b/include/libcamera/request.h index e214a9d13..0c5939f7b 100644 --- a/include/libcamera/request.h +++ b/include/libcamera/request.h @@ -53,7 +53,7 @@ public: ControlList &metadata() { return *metadata_; } const BufferMap &buffers() const { return bufferMap_; } int addBuffer(const Stream *stream, FrameBuffer *buffer, - std::unique_ptr fence = nullptr); + std::unique_ptr &&fence = {}); FrameBuffer *findBuffer(const Stream *stream) const; uint32_t sequence() const; diff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp index b206ac132..7d02f09fd 100644 --- a/src/libcamera/request.cpp +++ b/src/libcamera/request.cpp @@ -468,7 +468,7 @@ void Request::reuse(ReuseFlag flags) * \retval -EINVAL The buffer does not reference a valid Stream */ int Request::addBuffer(const Stream *stream, FrameBuffer *buffer, - std::unique_ptr fence) + std::unique_ptr &&fence) { if (!stream) { LOG(Request, Error) << "Invalid stream reference";