1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 14:28:12 +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:
Andreas Kling 2021-09-07 15:54:23 +02:00
parent be613b9ef6
commit 300402cc14
9 changed files with 30 additions and 13 deletions

View file

@ -54,7 +54,7 @@ KResult SysFSUSBDeviceInformation::refresh_data(OpenFileDescription& description
if (!cached_data) {
cached_data = TRY(adopt_nonnull_own_or_enomem(new (nothrow) SysFSInodeData));
}
KBufferBuilder builder;
auto builder = TRY(KBufferBuilder::try_create());
TRY(const_cast<SysFSUSBDeviceInformation&>(*this).try_generate(builder));
auto& typed_cached_data = static_cast<SysFSInodeData&>(*cached_data);
typed_cached_data.buffer = builder.build();