From patchwork Mon May 18 16:48:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 3807 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 9679E603DA for ; Mon, 18 May 2020 18:48:19 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="q6WIXzRT"; dkim-atps=neutral Received: from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 76C4D258; Mon, 18 May 2020 18:48:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1589820499; bh=ifo4Yx+iYu6gckImVvYYLDHliMrg84kcCjWWQrTMQEk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q6WIXzRT4p03ltGs7QcKHChRRfBSnLxAYwYNTMKIvxWNV/DZ/cpZBxzb9IQYkmyWu jTd7BdHUQDVuhokDBkDtreMONudQAJCI3lSLrN8sgdQ4tsOSY+PF4SfAaZannBZvhW M0GJMsT7pFth2CkuFjl3jraoOSsMolPaiJDgGDUQ= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Mon, 18 May 2020 19:48:04 +0300 Message-Id: <20200518164804.10088-3-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200518164804.10088-1-laurent.pinchart@ideasonboard.com> References: <20200518164804.10088-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/3] libcamera: v4l2_videodevice: Use FileDescriptor "fd move" constructor 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: , X-List-Received-Date: Mon, 18 May 2020 16:48:19 -0000 Use the newly added "fd move" constructor of the FileDescriptor class to avoid dup() + close(). Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund Reviewed-by: Naushir Patuck --- src/libcamera/v4l2_videodevice.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp index fbe55bc6f54f..3614b2ed1cbc 100644 --- a/src/libcamera/v4l2_videodevice.cpp +++ b/src/libcamera/v4l2_videodevice.cpp @@ -1276,14 +1276,7 @@ FileDescriptor V4L2VideoDevice::exportDmabufFd(unsigned int index, return FileDescriptor(); } - FileDescriptor fd(expbuf.fd); - /* - * FileDescriptor takes a duplicate of fd, so we must close the - * original here, otherwise it will be left dangling. - */ - ::close(expbuf.fd); - - return fd; + return FileDescriptor(std::move(expbuf.fd)); } /**