{"id":14874,"url":"https://patchwork.libcamera.org/api/1.1/patches/14874/?format=json","web_url":"https://patchwork.libcamera.org/patch/14874/","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":"<20211130033820.18235-21-laurent.pinchart@ideasonboard.com>","date":"2021-11-30T03:38:18","name":"[libcamera-devel,v4,20/22] libcamera: base: shared_fd: Add comparison operators","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"9454159863dea9abe1d18bc402e0558bbd2326f1","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/14874/mbox/","series":[{"id":2776,"url":"https://patchwork.libcamera.org/api/1.1/series/2776/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2776","date":"2021-11-30T03:37:58","name":"libcamera: Introduce UniqueFD","version":4,"mbox":"https://patchwork.libcamera.org/series/2776/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/14874/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/14874/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 308D5C324F\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 30 Nov 2021 03:39:15 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D2D76605C5;\n\tTue, 30 Nov 2021 04:39:14 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 24ECC605B4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 30 Nov 2021 04:38:58 +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 B358A11C5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 30 Nov 2021 04:38:57 +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=\"AwEdTUv7\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1638243537;\n\tbh=coQj4WjDhPVcXGO++CaKss9us4nnKmA0FYDetl8KRgw=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=AwEdTUv7hdshLmmKHUpMD9C5XSZuI2M2euS3g0CzDJuWgOn5tCtjWsuczHDhsOmyl\n\t0WIIMb7xuNseSDAZQBwaeyB1e/B/To0QZBoSH/oC+HKhFXgqWpvaPT07mP7r0OW66v\n\tpds7X6JUelo99c3EjLbrrKXLjD3y113U49tsUV3c=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Tue, 30 Nov 2021 05:38:18 +0200","Message-Id":"<20211130033820.18235-21-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.32.0","In-Reply-To":"<20211130033820.18235-1-laurent.pinchart@ideasonboard.com>","References":"<20211130033820.18235-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v4 20/22] libcamera: base: shared_fd: Add\n\tcomparison 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>\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 a786885ceb32..1dd51a7f046b 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 05b6892f7e19..56dc579258c7 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] lhs 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] lhs 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 f035e16859f8..f313566c5561 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","20/22"]}