{"id":14885,"url":"https://patchwork.libcamera.org/api/1.1/patches/14885/?format=json","web_url":"https://patchwork.libcamera.org/patch/14885/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20211130102925.2141-1-laurent.pinchart@ideasonboard.com>","date":"2021-11-30T10:29:25","name":"[libcamera-devel,v4.1,20/22] libcamera: base: shared_fd: Add comparison operators","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"717445007d6d3997653480697a1a9593c44fefb3","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/1.1/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/14885/mbox/","series":[{"id":2781,"url":"https://patchwork.libcamera.org/api/1.1/series/2781/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2781","date":"2021-11-30T10:27:16","name":null,"version":1,"mbox":"https://patchwork.libcamera.org/series/2781/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/14885/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/14885/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id DC14CBF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 30 Nov 2021 10:29:55 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9C3C4605B4;\n\tTue, 30 Nov 2021 11:29:55 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DD25960230\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 30 Nov 2021 11:29:54 +0100 (CET)","from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 82E2B2A5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 30 Nov 2021 11:29:54 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"Rgqt0BWM\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1638268194;\n\tbh=zD7PVBrd0Zys+/UrSnfIrQO6Z/Vdw0HKIob0YULoxW8=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=Rgqt0BWMTD8LGTwbCXScAyp5KWcwf+sCkHyx6afNonYaLpsDj3yymUuvlMQQ7V3oG\n\tMv7QZUHJgcZy4A6pSbtKNxouLNUyYnl4rrYeHdYjqPeL4wCFyY6bQqUaQHTNvj60r/\n\tZ1Dhh29m7yhwAOWeDUjRxcq30l3rcxbebifHXtmY=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Tue, 30 Nov 2021 12:29:25 +0200","Message-Id":"<20211130102925.2141-1-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.32.0","In-Reply-To":"<20211130033820.18235-21-laurent.pinchart@ideasonboard.com>","References":"<20211130033820.18235-21-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v4.1 20/22] libcamera: base: shared_fd:\n\tAdd comparison operators","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Add == and != comparison operators between two SharedFD instances, and\nuse them to replace manuel get() calls.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Hirokazu Honda <hiroh@chromium.org>\n---\nChanges since v4:\n\n- Fix typos in documentation\n\nThis patch will move after 21/22 (the fd() to get() rename) in the next\nversion.\n\n---\n include/libcamera/base/shared_fd.h | 10 ++++++++++\n src/libcamera/base/shared_fd.cpp   | 26 ++++++++++++++++++++++++++\n src/libcamera/framebuffer.cpp      |  2 +-\n 3 files changed, 37 insertions(+), 1 deletion(-)","diff":"diff --git a/include/libcamera/base/shared_fd.h b/include/libcamera/base/shared_fd.h\nindex 202192240110..e53a8b88601e 100644\n--- a/include/libcamera/base/shared_fd.h\n+++ b/include/libcamera/base/shared_fd.h\n@@ -46,4 +46,14 @@ private:\n \tstd::shared_ptr<Descriptor> fd_;\n };\n \n+static inline bool operator==(const SharedFD &lhs, const SharedFD &rhs)\n+{\n+\treturn lhs.get() == rhs.get();\n+}\n+\n+static inline bool operator!=(const SharedFD &lhs, const SharedFD &rhs)\n+{\n+\treturn !(lhs == rhs);\n+}\n+\n } /* namespace libcamera */\ndiff --git a/src/libcamera/base/shared_fd.cpp b/src/libcamera/base/shared_fd.cpp\nindex bb35b448995d..bd2ab5aa25b7 100644\n--- a/src/libcamera/base/shared_fd.cpp\n+++ b/src/libcamera/base/shared_fd.cpp\n@@ -214,6 +214,32 @@ SharedFD &SharedFD::operator=(SharedFD &&other)\n  * instance is invalid\n  */\n \n+/**\n+ * \\fn bool operator==(const SharedFD &lhs, const SharedFD &rhs)\n+ * \\brief Compare the owned file descriptors of two SharedFD for equality\n+ * \\param[in] lhs The first SharedFD\n+ * \\param[in] rhs The second SharedFD\n+ *\n+ * Two file descriptors are considered equal if they have the same numerical\n+ * value. File descriptors with different values that both reference the same\n+ * file (for instance obtained using dup()) are considered not equal.\n+ *\n+ * \\return True if the two file descriptors are equal, false otherwise\n+ */\n+\n+/**\n+ * \\fn bool operator!=(const SharedFD &lhs, const SharedFD &rhs)\n+ * \\brief Compare the owned file descriptors of two SharedFD for equality\n+ * \\param[in] lhs The first SharedFD\n+ * \\param[in] rhs The second SharedFD\n+ *\n+ * Two file descriptors are considered equal if they have the same numerical\n+ * value. File descriptors with different values that both reference the same\n+ * file (for instance obtained using dup()) are considered not equal.\n+ *\n+ * \\return True if the two file descriptors are not equal, false otherwise\n+ */\n+\n /**\n  * \\brief Duplicate a SharedFD\n  *\ndiff --git a/src/libcamera/framebuffer.cpp b/src/libcamera/framebuffer.cpp\nindex ee93ba4da3d5..8857049ec33b 100644\n--- a/src/libcamera/framebuffer.cpp\n+++ b/src/libcamera/framebuffer.cpp\n@@ -258,7 +258,7 @@ FrameBuffer::FrameBuffer(const std::vector<Plane> &planes, unsigned int cookie)\n \t\t * Two different dmabuf file descriptors may still refer to the\n \t\t * same dmabuf instance. Check this using inodes.\n \t\t */\n-\t\tif (plane.fd.fd() != planes_[0].fd.fd()) {\n+\t\tif (plane.fd != planes_[0].fd) {\n \t\t\tif (!inode)\n \t\t\t\tinode = fileDescriptorInode(planes_[0].fd);\n \t\t\tif (fileDescriptorInode(plane.fd) != inode) {\n","prefixes":["libcamera-devel","v4.1","20/22"]}