diff options
author | Idan Horowitz <idan.horowitz@gmail.com> | 2021-12-29 01:00:29 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-12-29 12:04:15 +0100 |
commit | 4a3a947df3f9722065b5c938a75d9d651ae1ff03 (patch) | |
tree | 9adc5d0def88e2494ad95b3a4f861f701e31f402 | |
parent | d7ec5d042f60ce2a31569a75383eaa4551f86217 (diff) | |
download | serenity-4a3a947df3f9722065b5c938a75d9d651ae1ff03.zip |
Kernel: Rename File::{before_removing => will_be_destroyed}
This will allow File and it's descendants to use RefCounted instead of
having a custom implementation of unref. (Since RefCounted calls
will_be_destroyed automatically)
This commit also removes an erroneous call to `before_removing` in
AHCIPort, this is a duplicate call, as the only reference to the device
is immediately dropped following the call, which in turns calls
`before_removing` via File::unref.
-rw-r--r-- | Kernel/Devices/Device.cpp | 2 | ||||
-rw-r--r-- | Kernel/Devices/Device.h | 2 | ||||
-rw-r--r-- | Kernel/FileSystem/File.cpp | 2 | ||||
-rw-r--r-- | Kernel/FileSystem/File.h | 2 | ||||
-rw-r--r-- | Kernel/Storage/ATA/AHCIPort.cpp | 1 | ||||
-rw-r--r-- | Kernel/TTY/SlavePTY.cpp | 2 |
6 files changed, 5 insertions, 6 deletions
diff --git a/Kernel/Devices/Device.cpp b/Kernel/Devices/Device.cpp index 5f239dc3ff..65454e1d9b 100644 --- a/Kernel/Devices/Device.cpp +++ b/Kernel/Devices/Device.cpp @@ -131,7 +131,7 @@ void Device::after_inserting() }); } -void Device::before_removing() +void Device::will_be_destroyed() { VERIFY(m_sysfs_component); SysFSComponentRegistry::the().devices_list().with_exclusive([&](auto& list) -> void { diff --git a/Kernel/Devices/Device.h b/Kernel/Devices/Device.h index 100a8d7a83..383584885c 100644 --- a/Kernel/Devices/Device.h +++ b/Kernel/Devices/Device.h @@ -47,7 +47,7 @@ public: GroupID gid() const { return m_gid; } virtual bool is_device() const override { return true; } - virtual void before_removing() override; + virtual void will_be_destroyed() override; virtual void after_inserting(); void process_next_queued_request(Badge<AsyncDeviceRequest>, const AsyncDeviceRequest&); diff --git a/Kernel/FileSystem/File.cpp b/Kernel/FileSystem/File.cpp index 527d48d922..612ad2ffce 100644 --- a/Kernel/FileSystem/File.cpp +++ b/Kernel/FileSystem/File.cpp @@ -24,7 +24,7 @@ bool File::unref() const { if (deref_base()) return false; - const_cast<File&>(*this).before_removing(); + const_cast<File&>(*this).will_be_destroyed(); delete this; return true; } diff --git a/Kernel/FileSystem/File.h b/Kernel/FileSystem/File.h index 891eae69fe..6c2c9388cb 100644 --- a/Kernel/FileSystem/File.h +++ b/Kernel/FileSystem/File.h @@ -75,7 +75,7 @@ class File , public Weakable<File> { public: virtual bool unref() const; - virtual void before_removing() { } + virtual void will_be_destroyed() { } virtual ~File(); virtual ErrorOr<NonnullRefPtr<OpenFileDescription>> open(int options); diff --git a/Kernel/Storage/ATA/AHCIPort.cpp b/Kernel/Storage/ATA/AHCIPort.cpp index 3cac75f344..b84c39317f 100644 --- a/Kernel/Storage/ATA/AHCIPort.cpp +++ b/Kernel/Storage/ATA/AHCIPort.cpp @@ -77,7 +77,6 @@ void AHCIPort::handle_interrupt() m_connected_device->prepare_for_unplug(); StorageManagement::the().remove_device(*m_connected_device); g_io_work->queue([this]() { - m_connected_device->before_removing(); m_connected_device.clear(); }); } else { diff --git a/Kernel/TTY/SlavePTY.cpp b/Kernel/TTY/SlavePTY.cpp index 200072d4b0..512f54e383 100644 --- a/Kernel/TTY/SlavePTY.cpp +++ b/Kernel/TTY/SlavePTY.cpp @@ -29,7 +29,7 @@ bool SlavePTY::unref() const return true; }); if (did_hit_zero) { - const_cast<SlavePTY&>(*this).before_removing(); + const_cast<SlavePTY&>(*this).will_be_destroyed(); delete this; } return did_hit_zero; |