From patchwork Sun Feb 3 10:55:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 483 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B8A3060DB5 for ; Sun, 3 Feb 2019 11:55:21 +0100 (CET) Received: from localhost.localdomain (218.182-78-194.adsl-static.isp.belgacom.be [194.78.182.218]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 53D7CD4A; Sun, 3 Feb 2019 11:55:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1549191321; bh=cTDa7n0mr9Kx1YntMoNasC58iWTcQWo6rIPhFluuJ7Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SZN14kJgvvTvIiBRV5CjYkjOSO/Dxq9n3oo7Hk+asgsHkATzyZf6FsuLNP7fsXF5g p6lxTwEYY94UsVxcwaQldJsfS9On0AanjTsyhS/hQRLMw975SA06zd6L9cxV/GzFD5 eZogvbQwxNQ9ZSq/M5aM3mdZfqNucy6O9y5zT1ec= From: Kieran Bingham To: LibCamera Devel Date: Sun, 3 Feb 2019 11:55:14 +0100 Message-Id: <20190203105517.5355-3-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190203105517.5355-1-kieran.bingham@ideasonboard.com> References: <20190203105517.5355-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 2/5] libcamera: buffer: Fix setDmabuf operations X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Feb 2019 10:55:22 -0000 The setDmabuf validation for the input FD was incorrect. Fix this, and update the documentation and error reporting. Signed-off-by: Kieran Bingham --- src/libcamera/buffer.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/libcamera/buffer.cpp b/src/libcamera/buffer.cpp index 6dfebfc6bb28..c86847daf193 100644 --- a/src/libcamera/buffer.cpp +++ b/src/libcamera/buffer.cpp @@ -43,6 +43,8 @@ Buffer::~Buffer() * \brief Set the dmabuf file handle backing the buffer * * The \a fd dmabuf file handle is duplicated and stored. + * + * \return 0 on success or a negative error value otherwise. */ int Buffer::setDmabuf(int fd) { @@ -51,12 +53,19 @@ int Buffer::setDmabuf(int fd) fd_ = -1; } - if (fd != -1) - return 0; + if (fd < 0) { + LOG(Buffer, Error) << "Invalid DMABuf FD provided"; + return -EINVAL; + } fd_ = dup(fd); - if (fd_ == -1) - return -errno; + if (fd_ == -1) { + int ret = -errno; + LOG(Buffer, Error) + << "Failed to duplicate Dmabuf: " << strerror(-ret); + + return ret; + } return 0; }