1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 05:37:34 +00:00

Kernel: Stop using the make<T> factory method in the Kernel

As make<T> is infallible, it really should not be used anywhere in the
Kernel. Instead replace with fallible `new (nothrow)` calls, that will
eventually be error-propagated.
This commit is contained in:
Idan Horowitz 2022-02-03 16:33:46 +02:00 committed by Andreas Kling
parent e5e7cb822a
commit 8289727fac
6 changed files with 7 additions and 7 deletions

View file

@ -11,7 +11,7 @@ namespace Kernel {
Result<NonnullOwnPtr<EBRPartitionTable>, PartitionTable::Error> EBRPartitionTable::try_to_initialize(const StorageDevice& device)
{
auto table = make<EBRPartitionTable>(device);
auto table = adopt_nonnull_own_or_enomem(new (nothrow) EBRPartitionTable(device)).release_value_but_fixme_should_propagate_errors();
if (table->is_protective_mbr())
return { PartitionTable::Error::MBRProtective };
if (!table->is_valid())

View file

@ -49,7 +49,7 @@ struct [[gnu::packed]] GUIDPartitionHeader {
Result<NonnullOwnPtr<GUIDPartitionTable>, PartitionTable::Error> GUIDPartitionTable::try_to_initialize(const StorageDevice& device)
{
auto table = make<GUIDPartitionTable>(device);
auto table = adopt_nonnull_own_or_enomem(new (nothrow) GUIDPartitionTable(device)).release_value_but_fixme_should_propagate_errors();
if (!table->is_valid())
return { PartitionTable::Error::Invalid };
return table;

View file

@ -17,7 +17,7 @@ namespace Kernel {
Result<NonnullOwnPtr<MBRPartitionTable>, PartitionTable::Error> MBRPartitionTable::try_to_initialize(const StorageDevice& device)
{
auto table = make<MBRPartitionTable>(device);
auto table = adopt_nonnull_own_or_enomem(new (nothrow) MBRPartitionTable(device)).release_value_but_fixme_should_propagate_errors();
if (table->contains_ebr())
return { PartitionTable::Error::ContainsEBR };
if (table->is_protective_mbr())
@ -29,7 +29,7 @@ Result<NonnullOwnPtr<MBRPartitionTable>, PartitionTable::Error> MBRPartitionTabl
OwnPtr<MBRPartitionTable> MBRPartitionTable::try_to_initialize(const StorageDevice& device, u32 start_lba)
{
auto table = make<MBRPartitionTable>(device, start_lba);
auto table = adopt_nonnull_own_or_enomem(new (nothrow) MBRPartitionTable(device, start_lba)).release_value_but_fixme_should_propagate_errors();
if (!table->is_valid())
return {};
return table;