mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 17:17:45 +00:00
Kernel: Make Device::after_inserting to return ErrorOr<void>
Instead of just returning nothing, let's return Error or nothing. This would help later on with error propagation in case of failure during this method. This also makes us more paranoid about failure in this method, so when initializing a DisplayConnector we safely tear down the internal members of the object. This applies the same for a StorageDevice object, but its after_inserting method is much smaller compared to the DisplayConnector overriden method.
This commit is contained in:
parent
15c0efede9
commit
25bb293629
9 changed files with 61 additions and 26 deletions
|
@ -32,13 +32,14 @@ void Device::after_inserting_add_to_device_management()
|
|||
DeviceManagement::the().after_inserting_device({}, *this);
|
||||
}
|
||||
|
||||
void Device::after_inserting()
|
||||
ErrorOr<void> Device::after_inserting()
|
||||
{
|
||||
after_inserting_add_to_device_management();
|
||||
VERIFY(!m_sysfs_component);
|
||||
auto sys_fs_component = SysFSDeviceComponent::must_create(*this);
|
||||
m_sysfs_component = sys_fs_component;
|
||||
after_inserting_add_to_device_identifier_directory();
|
||||
return {};
|
||||
}
|
||||
|
||||
void Device::will_be_destroyed()
|
||||
|
|
|
@ -50,7 +50,7 @@ public:
|
|||
|
||||
virtual bool is_device() const override { return true; }
|
||||
virtual void will_be_destroyed() override;
|
||||
virtual void after_inserting();
|
||||
virtual ErrorOr<void> after_inserting();
|
||||
virtual bool is_openable_by_jailed_processes() const { return false; }
|
||||
void process_next_queued_request(Badge<AsyncDeviceRequest>, AsyncDeviceRequest const&);
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ public:
|
|||
requires(requires(Args... args) { DeviceType::try_create(args...); })
|
||||
{
|
||||
auto device = TRY(DeviceType::try_create(forward<Args>(args)...));
|
||||
device->after_inserting();
|
||||
TRY(device->after_inserting());
|
||||
return device;
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ public:
|
|||
static inline ErrorOr<NonnullLockRefPtr<DeviceType>> try_create_device(Args&&... args)
|
||||
{
|
||||
auto device = TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) DeviceType(forward<Args>(args)...)));
|
||||
device->after_inserting();
|
||||
TRY(device->after_inserting());
|
||||
return device;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue