1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-16 17:55:06 +00:00

Kernel: Move KBufferBuilder to the fallible KBuffer API

KBufferBuilder::build() now returns an OwnPtr<KBuffer> and can fail.
Clients of the API have been updated to handle that situation.
This commit is contained in:
Andreas Kling 2020-12-18 14:10:10 +01:00
parent d936d86332
commit 8e79bde2b7
18 changed files with 121 additions and 100 deletions

View file

@ -71,7 +71,7 @@ void Inode::sync()
}
}
KResultOr<KBuffer> Inode::read_entire(FileDescription* descriptor) const
KResultOr<NonnullOwnPtr<KBuffer>> Inode::read_entire(FileDescription* descriptor) const
{
KBufferBuilder builder;
@ -96,7 +96,10 @@ KResultOr<KBuffer> Inode::read_entire(FileDescription* descriptor) const
return KResult(nread);
}
return builder.build();
auto entire_file = builder.build();
if (!entire_file)
return KResult(-ENOMEM);
return entire_file.release_nonnull();
}
KResultOr<NonnullRefPtr<Custody>> Inode::resolve_as_link(Custody& base, RefPtr<Custody>* out_parent, int options, int symlink_recursion_level) const
@ -109,7 +112,7 @@ KResultOr<NonnullRefPtr<Custody>> Inode::resolve_as_link(Custody& base, RefPtr<C
return contents_or.error();
auto& contents = contents_or.value();
auto path = StringView(contents.data(), contents.size());
auto path = StringView(contents->data(), contents->size());
return VFS::the().resolve_path(path, base, out_parent, options, symlink_recursion_level);
}