From 9a0cd9a50d89e9d39a1a19cc09a725cad16e6588 Mon Sep 17 00:00:00 2001 From: Ben Wiederhake Date: Sat, 22 Aug 2020 17:02:15 +0200 Subject: [PATCH] Kernel: Prevent confusing silent misuse of PCI::Address --- Kernel/PCI/Definitions.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Kernel/PCI/Definitions.h b/Kernel/PCI/Definitions.h index 7c003f331fa..767ff73cc19 100644 --- a/Kernel/PCI/Definitions.h +++ b/Kernel/PCI/Definitions.h @@ -89,7 +89,7 @@ inline const LogStream& operator<<(const LogStream& stream, const ID value) } struct Address { public: - Address() {} + Address() { } Address(u16 seg) : m_seg(seg) , m_bus(0) @@ -116,6 +116,13 @@ public: bool is_null() const { return !m_bus && !m_slot && !m_function; } operator bool() const { return !is_null(); } + // Disable default implementations that would use surprising integer promotion. + bool operator==(const Address&) const = delete; + bool operator<=(const Address&) const = delete; + bool operator>=(const Address&) const = delete; + bool operator<(const Address&) const = delete; + bool operator>(const Address&) const = delete; + u16 seg() const { return m_seg; } u8 bus() const { return m_bus; } u8 slot() const { return m_slot; }