mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 07:07:45 +00:00
Kernel: Make it possible for KBufferBuilder creation to fail
This patch adds KBufferBuilder::try_create() and treats it like anything else that can fail. And so, failure to allocate the initial internal buffer of the builder will now propagate an ENOMEM to the caller. :^)
This commit is contained in:
parent
be613b9ef6
commit
300402cc14
9 changed files with 30 additions and 13 deletions
|
@ -47,7 +47,7 @@ void Inode::sync()
|
|||
|
||||
KResultOr<NonnullOwnPtr<KBuffer>> Inode::read_entire(OpenFileDescription* description) const
|
||||
{
|
||||
KBufferBuilder builder;
|
||||
auto builder = TRY(KBufferBuilder::try_create());
|
||||
|
||||
u8 buffer[4096];
|
||||
off_t offset = 0;
|
||||
|
|
|
@ -323,7 +323,7 @@ StringView Plan9FS::Message::Decoder::read_data()
|
|||
}
|
||||
|
||||
Plan9FS::Message::Message(Plan9FS& fs, Type type)
|
||||
: m_builder()
|
||||
: m_builder(KBufferBuilder::try_create().release_value()) // FIXME: Don't assume KBufferBuilder allocation success.
|
||||
, m_tag(fs.allocate_tag())
|
||||
, m_type(type)
|
||||
, m_have_been_built(false)
|
||||
|
|
|
@ -480,7 +480,7 @@ KResultOr<size_t> ProcFSProcessPropertyInode::read_bytes(off_t offset, size_t co
|
|||
VERIFY(buffer.user_or_kernel_ptr());
|
||||
|
||||
if (!description) {
|
||||
KBufferBuilder builder;
|
||||
auto builder = TRY(KBufferBuilder::try_create());
|
||||
auto process = Process::from_pid(associated_pid());
|
||||
if (!process)
|
||||
return KResult(ESRCH);
|
||||
|
@ -579,7 +579,7 @@ KResult ProcFSProcessPropertyInode::refresh_data(OpenFileDescription& descriptio
|
|||
if (!cached_data)
|
||||
return ENOMEM;
|
||||
}
|
||||
KBufferBuilder builder;
|
||||
auto builder = TRY(KBufferBuilder::try_create());
|
||||
TRY(try_to_acquire_data(*process, builder));
|
||||
return build_from_cached_data(builder, static_cast<ProcFSInodeData&>(*cached_data));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue