Kernel/Storage: Migrate the partition code to use the ErrorOr container

That code used the old AK::Result container, which leads to overly
complicated initialization flow when trying to figure out the correct
partition table type. Instead, when using the ErrorOr container the code
is much simpler and more understandable.
This commit is contained in:
Liav A 2022-04-25 19:54:06 +03:00 committed by Linus Groh
parent 19912a0b32
commit 5ed3f7c6bf
Notes: sideshowbarker 2024-07-17 11:29:39 +09:00
9 changed files with 39 additions and 50 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, Liav A. <liavalb@hotmail.co.il>
* Copyright (c) 2020-2022, Liav A. <liavalb@hotmail.co.il>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -47,11 +47,11 @@ struct [[gnu::packed]] GUIDPartitionHeader {
u32 crc32_entries_array;
};
Result<NonnullOwnPtr<GUIDPartitionTable>, PartitionTable::Error> GUIDPartitionTable::try_to_initialize(StorageDevice const& device)
ErrorOr<NonnullOwnPtr<GUIDPartitionTable>> GUIDPartitionTable::try_to_initialize(StorageDevice const& device)
{
auto table = adopt_nonnull_own_or_enomem(new (nothrow) GUIDPartitionTable(device)).release_value_but_fixme_should_propagate_errors();
auto table = TRY(adopt_nonnull_own_or_enomem(new (nothrow) GUIDPartitionTable(device)));
if (!table->is_valid())
return { PartitionTable::Error::Invalid };
return Error::from_errno(EINVAL);
return table;
}