From 61c0e3ca920f5033bd006092c55b6eb5743cd501 Mon Sep 17 00:00:00 2001 From: sin-ack Date: Sun, 15 Aug 2021 08:33:12 +0000 Subject: [PATCH] Kernel: Simplify OOM handling in ISO9660FileSystem --- Kernel/FileSystem/ISO9660FileSystem.cpp | 12 ++---------- Kernel/FileSystem/ISO9660FileSystem.h | 6 +----- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/Kernel/FileSystem/ISO9660FileSystem.cpp b/Kernel/FileSystem/ISO9660FileSystem.cpp index 7149063929..35b6eddbfd 100644 --- a/Kernel/FileSystem/ISO9660FileSystem.cpp +++ b/Kernel/FileSystem/ISO9660FileSystem.cpp @@ -184,11 +184,7 @@ private: KResultOr> ISO9660FS::try_create(FileDescription& description) { - auto result = adopt_ref_if_nonnull(new (nothrow) ISO9660FS(description)); - if (!result) { - return ENOMEM; - } - return result.release_nonnull(); + return adopt_nonnull_ref_or_enomem(new (nothrow) ISO9660FS(description)); } ISO9660FS::ISO9660FS(FileDescription& description) @@ -632,11 +628,7 @@ ISO9660Inode::~ISO9660Inode() KResultOr> ISO9660Inode::try_create_from_directory_record(ISO9660FS& fs, ISO::DirectoryRecordHeader const& record, StringView const& name) { - auto result = adopt_ref_if_nonnull(new (nothrow) ISO9660Inode(fs, record, name)); - if (!result) { - return ENOMEM; - } - return result.release_nonnull(); + return adopt_nonnull_ref_or_enomem(new (nothrow) ISO9660Inode(fs, record, name)); } void ISO9660Inode::create_metadata() diff --git a/Kernel/FileSystem/ISO9660FileSystem.h b/Kernel/FileSystem/ISO9660FileSystem.h index b581531624..b11aba3893 100644 --- a/Kernel/FileSystem/ISO9660FileSystem.h +++ b/Kernel/FileSystem/ISO9660FileSystem.h @@ -293,11 +293,7 @@ public: static KResultOr> try_create(u32 extent, u32 length, OwnPtr blocks) { - auto result = adopt_ref_if_nonnull(new (nothrow) DirectoryEntry(extent, length, move(blocks))); - if (!result) { - return ENOMEM; - } - return result.release_nonnull(); + return adopt_nonnull_ref_or_enomem(new (nothrow) DirectoryEntry(extent, length, move(blocks))); } private: