mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:47:34 +00:00
Kernel: Tidy up AnonymousFile construction a bit
- Rename create() => try_create() - Use adopt_nonnull_ref_or_enomem()
This commit is contained in:
parent
9a1fdb523f
commit
4012099338
2 changed files with 6 additions and 6 deletions
|
@ -13,9 +13,9 @@ namespace Kernel {
|
|||
|
||||
class AnonymousFile final : public File {
|
||||
public:
|
||||
static RefPtr<AnonymousFile> create(NonnullRefPtr<Memory::AnonymousVMObject> vmobject)
|
||||
static KResultOr<NonnullRefPtr<AnonymousFile>> try_create(NonnullRefPtr<Memory::AnonymousVMObject> vmobject)
|
||||
{
|
||||
return adopt_ref_if_nonnull(new (nothrow) AnonymousFile(move(vmobject)));
|
||||
return adopt_nonnull_ref_or_enomem(new (nothrow) AnonymousFile(move(vmobject)));
|
||||
}
|
||||
|
||||
virtual ~AnonymousFile() override;
|
||||
|
|
|
@ -33,10 +33,10 @@ KResultOr<FlatPtr> Process::sys$anon_create(size_t size, int options)
|
|||
if (maybe_vmobject.is_error())
|
||||
return maybe_vmobject.error();
|
||||
|
||||
auto anon_file = AnonymousFile::create(maybe_vmobject.release_value());
|
||||
if (!anon_file)
|
||||
return ENOMEM;
|
||||
auto description_or_error = FileDescription::try_create(*anon_file);
|
||||
auto anon_file_or_error = AnonymousFile::try_create(maybe_vmobject.release_value());
|
||||
if (anon_file_or_error.is_error())
|
||||
return anon_file_or_error.error();
|
||||
auto description_or_error = FileDescription::try_create(anon_file_or_error.release_value());
|
||||
if (description_or_error.is_error())
|
||||
return description_or_error.error();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue