diff options
| author | Felix Morgner <felix.morgner@ost.ch> | 2026-09-09 23:02:20 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@ost.ch> | 2026-09-09 23:02:20 +0200 |
| commit | b99b79d8080cc1491f96069677d9ce0b7775a4f0 (patch) | |
| tree | 1f7a4534926a79ee6376770c63cccd2aa9e37442 /arch/x86_64 | |
| parent | 9438d08cc7a7f814d8d1b0cb13f4db176fc53aeb (diff) | |
| download | kernel-b99b79d8080cc1491f96069677d9ce0b7775a4f0.tar.xz kernel-b99b79d8080cc1491f96069677d9ce0b7775a4f0.zip | |
chore: replace some naked pointers
The coding guidelines explicitly prohibit the use of "naked"/C-style
pointers. However, there were some prominent examples in the kapi and
the core kernel source. This changeset replaces them with the
appropriate smart pointer types.
Diffstat (limited to 'arch/x86_64')
| -rw-r--r-- | arch/x86_64/arch/devices/cpu/core.cpp | 5 | ||||
| -rw-r--r-- | arch/x86_64/arch/devices/cpu/core.hpp | 4 | ||||
| -rw-r--r-- | arch/x86_64/arch/devices/cpu/lapic.cpp | 5 | ||||
| -rw-r--r-- | arch/x86_64/arch/devices/cpu/lapic.hpp | 4 | ||||
| -rw-r--r-- | arch/x86_64/arch/devices/pit.cpp | 6 | ||||
| -rw-r--r-- | arch/x86_64/arch/devices/pit.hpp | 4 | ||||
| -rw-r--r-- | arch/x86_64/arch/drivers/cpu/lapic.cpp | 10 | ||||
| -rw-r--r-- | arch/x86_64/arch/drivers/cpu/lapic.hpp | 3 | ||||
| -rw-r--r-- | arch/x86_64/arch/drivers/pit.cpp | 4 | ||||
| -rw-r--r-- | arch/x86_64/arch/drivers/pit.hpp | 2 |
10 files changed, 29 insertions, 18 deletions
diff --git a/arch/x86_64/arch/devices/cpu/core.cpp b/arch/x86_64/arch/devices/cpu/core.cpp index ac06850e..13d4652d 100644 --- a/arch/x86_64/arch/devices/cpu/core.cpp +++ b/arch/x86_64/arch/devices/cpu/core.cpp @@ -6,6 +6,7 @@ #include <kapi/devices.hpp> #include <kstd/format.hpp> +#include <kstd/memory.hpp> #include <cstddef> #include <cstdint> @@ -29,11 +30,11 @@ namespace arch::devices::cpu return m_id; } - auto core::query_facet(kapi::capabilities::facet_id facet) -> void * + auto core::query_facet(kapi::capabilities::facet_id facet) -> kstd::observer_ptr<void> { if (facet == bus::core_signature::id) { - return static_cast<bus::core_signature *>(this); + return kstd::make_observer<bus::core_signature>(this); } return device::query_facet(facet); diff --git a/arch/x86_64/arch/devices/cpu/core.hpp b/arch/x86_64/arch/devices/cpu/core.hpp index cd5ac65c..ad965da1 100644 --- a/arch/x86_64/arch/devices/cpu/core.hpp +++ b/arch/x86_64/arch/devices/cpu/core.hpp @@ -6,6 +6,8 @@ #include <kapi/capabilities/facet_id.hpp> #include <kapi/devices.hpp> +#include <kstd/memory.hpp> + #include <cstddef> #include <cstdint> @@ -20,7 +22,7 @@ namespace arch::devices::cpu [[nodiscard]] auto hardware_id() const noexcept -> std::uint64_t override; protected: - auto query_facet(kapi::capabilities::facet_id facet) -> void * override; + auto query_facet(kapi::capabilities::facet_id facet) -> kstd::observer_ptr<void> override; private: std::uint64_t m_id; diff --git a/arch/x86_64/arch/devices/cpu/lapic.cpp b/arch/x86_64/arch/devices/cpu/lapic.cpp index 280ebbca..d8571a8f 100644 --- a/arch/x86_64/arch/devices/cpu/lapic.cpp +++ b/arch/x86_64/arch/devices/cpu/lapic.cpp @@ -6,6 +6,7 @@ #include <kapi/devices.hpp> #include <kstd/format.hpp> +#include <kstd/memory.hpp> #include <cstddef> #include <cstdint> @@ -29,11 +30,11 @@ namespace arch::devices::cpu return m_is_bsp; } - auto lapic::query_facet(kapi::capabilities::facet_id facet) -> void * + auto lapic::query_facet(kapi::capabilities::facet_id facet) -> kstd::observer_ptr<void> { if (facet == bus::lapic_signature::id) { - return static_cast<bus::lapic_signature *>(this); + return kstd::make_observer<bus::lapic_signature>(this); } return device::query_facet(facet); diff --git a/arch/x86_64/arch/devices/cpu/lapic.hpp b/arch/x86_64/arch/devices/cpu/lapic.hpp index 52ae40ae..3f91968e 100644 --- a/arch/x86_64/arch/devices/cpu/lapic.hpp +++ b/arch/x86_64/arch/devices/cpu/lapic.hpp @@ -6,6 +6,8 @@ #include <kapi/capabilities/facet_id.hpp> #include <kapi/devices.hpp> +#include <kstd/memory.hpp> + #include <cstddef> #include <cstdint> @@ -20,7 +22,7 @@ namespace arch::devices::cpu [[nodiscard]] auto is_bsp() const noexcept -> bool override; protected: - auto query_facet(kapi::capabilities::facet_id facet) -> void * override; + auto query_facet(kapi::capabilities::facet_id facet) -> kstd::observer_ptr<void> override; private: std::uint64_t m_id; diff --git a/arch/x86_64/arch/devices/pit.cpp b/arch/x86_64/arch/devices/pit.cpp index 83443c93..6de23865 100644 --- a/arch/x86_64/arch/devices/pit.cpp +++ b/arch/x86_64/arch/devices/pit.cpp @@ -5,6 +5,8 @@ #include <kapi/capabilities/facet_id.hpp> #include <kapi/devices.hpp> +#include <kstd/memory.hpp> + #include <string_view> namespace arch::devices @@ -19,11 +21,11 @@ namespace arch::devices return "pit"; } - auto pit::query_facet(kapi::capabilities::facet_id facet) -> void * + auto pit::query_facet(kapi::capabilities::facet_id facet) -> kstd::observer_ptr<void> { if (facet == arch::bus::isa_signature::id) { - return static_cast<arch::bus::isa_signature *>(this); + return kstd::make_observer<arch::bus::isa_signature>(this); } return kapi::devices::device::query_facet(facet); diff --git a/arch/x86_64/arch/devices/pit.hpp b/arch/x86_64/arch/devices/pit.hpp index 08bf423a..ddd6d8a3 100644 --- a/arch/x86_64/arch/devices/pit.hpp +++ b/arch/x86_64/arch/devices/pit.hpp @@ -6,6 +6,8 @@ #include <kapi/capabilities/facet_id.hpp> #include <kapi/devices.hpp> +#include <kstd/memory.hpp> + #include <string_view> namespace arch::devices @@ -25,7 +27,7 @@ namespace arch::devices [[nodiscard]] auto isa_name() const -> std::string_view override; protected: - auto query_facet(kapi::capabilities::facet_id facet) -> void * override; + auto query_facet(kapi::capabilities::facet_id facet) -> kstd::observer_ptr<void> override; }; } // namespace arch::devices diff --git a/arch/x86_64/arch/drivers/cpu/lapic.cpp b/arch/x86_64/arch/drivers/cpu/lapic.cpp index c02c3df6..3b7c2d45 100644 --- a/arch/x86_64/arch/drivers/cpu/lapic.cpp +++ b/arch/x86_64/arch/drivers/cpu/lapic.cpp @@ -104,7 +104,7 @@ namespace arch::drivers::cpu auto lapic::probe(kapi::devices::device & device) -> kstd::result<void> { - auto * signature = device.facet<arch::bus::lapic_signature>(); + auto const signature = device.facet<arch::bus::lapic_signature>(); if (!signature) { return kstd::failure(make_error_code(kstd::errc::invalid_argument)); @@ -142,8 +142,8 @@ namespace arch::drivers::cpu write_register(registers::spurious_interrupt_vector, lapic_enable_bit | spurious_interrupt_vector); - kstd::println("[ARCH:DRV] LAPIC initialized. version: {#x} | max_lvt_entry: {} | eoi_suppression: {:s}", - version, highest_lvt_entry_index, supports_eoi_broadcast_suppression); + kstd::println("[ARCH:DRV] LAPIC initialized. version: {#x} | max_lvt_entry: {} | eoi_suppression: {:s}", version, + highest_lvt_entry_index, supports_eoi_broadcast_suppression); } else { @@ -172,11 +172,11 @@ namespace arch::drivers::cpu *reg = value; } - auto lapic::query_facet(kapi::capabilities::facet_id facet) -> void * + auto lapic::query_facet(kapi::capabilities::facet_id facet) -> kstd::observer_ptr<void> { if (facet == arch::bus::lapic_claim::id) { - return static_cast<arch::bus::lapic_claim *>(this); + return kstd::make_observer<arch::bus::lapic_claim>(this); } return kapi::devices::driver::query_facet(facet); diff --git a/arch/x86_64/arch/drivers/cpu/lapic.hpp b/arch/x86_64/arch/drivers/cpu/lapic.hpp index 678d364a..52533d9a 100644 --- a/arch/x86_64/arch/drivers/cpu/lapic.hpp +++ b/arch/x86_64/arch/drivers/cpu/lapic.hpp @@ -8,6 +8,7 @@ #include <kapi/memory.hpp> #include <kapi/tracked_mutex.hpp> +#include <kstd/memory.hpp> #include <kstd/result.hpp> #include <cstddef> @@ -27,7 +28,7 @@ namespace arch::drivers::cpu [[nodiscard]] auto name() const noexcept -> std::string_view override; protected: - auto query_facet(kapi::capabilities::facet_id facet) -> void * override; + auto query_facet(kapi::capabilities::facet_id facet) -> kstd::observer_ptr<void> override; private: enum struct registers : std::ptrdiff_t; diff --git a/arch/x86_64/arch/drivers/pit.cpp b/arch/x86_64/arch/drivers/pit.cpp index e6e98796..6a768fc9 100644 --- a/arch/x86_64/arch/drivers/pit.cpp +++ b/arch/x86_64/arch/drivers/pit.cpp @@ -124,11 +124,11 @@ namespace arch::drivers return kapi::interrupts::status::handled; } - auto pit::query_facet(kapi::capabilities::facet_id facet) -> void * + auto pit::query_facet(kapi::capabilities::facet_id facet) -> kstd::observer_ptr<void> { if (facet == arch::bus::isa_claim::id) { - return static_cast<arch::bus::isa_claim *>(this); + return kstd::make_observer<arch::bus::isa_claim>(this); } return kapi::devices::driver::query_facet(facet); diff --git a/arch/x86_64/arch/drivers/pit.hpp b/arch/x86_64/arch/drivers/pit.hpp index ad8add4b..f5be5a17 100644 --- a/arch/x86_64/arch/drivers/pit.hpp +++ b/arch/x86_64/arch/drivers/pit.hpp @@ -33,7 +33,7 @@ namespace arch::drivers [[nodiscard]] auto name() const noexcept -> std::string_view override; protected: - auto query_facet(kapi::capabilities::facet_id facet) -> void * override; + auto query_facet(kapi::capabilities::facet_id facet) -> kstd::observer_ptr<void> override; private: struct data |
