1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 04:17:35 +00:00

Kernel: Make Device request creation return KResultOr

This allows us to propagate errors in a bunch of new places.
This commit is contained in:
Andreas Kling 2021-09-07 16:40:54 +02:00
parent a01b19c878
commit 9669bf29f6
4 changed files with 24 additions and 11 deletions

View file

@ -48,9 +48,9 @@ public:
void process_next_queued_request(Badge<AsyncDeviceRequest>, const AsyncDeviceRequest&);
template<typename AsyncRequestType, typename... Args>
NonnullRefPtr<AsyncRequestType> make_request(Args&&... args)
KResultOr<NonnullRefPtr<AsyncRequestType>> try_make_request(Args&&... args)
{
auto request = adopt_ref(*new AsyncRequestType(*this, forward<Args>(args)...));
auto request = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) AsyncRequestType(*this, forward<Args>(args)...)));
SpinlockLocker lock(m_requests_lock);
bool was_empty = m_requests.is_empty();
m_requests.append(request);