diff options
author | Andreas Kling <kling@serenityos.org> | 2021-09-06 18:41:16 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-06 18:56:51 +0200 |
commit | 9db8a142648e43ad56f234c4e9eeeeae92a348ae (patch) | |
tree | 5e0c05c5367f790b25e733ea4ee8d82a46734a30 /Kernel/Bus/USB | |
parent | 2065ced8f652794fbcf49fcd0608df781417bf76 (diff) | |
download | serenity-9db8a142648e43ad56f234c4e9eeeeae92a348ae.zip |
Kernel: Make SysFS and ProcFS generator functions return KResult
This allows us to propagate a whole bunch of KBufferBuilder errors.
Diffstat (limited to 'Kernel/Bus/USB')
-rw-r--r-- | Kernel/Bus/USB/SysFSUSB.cpp | 7 | ||||
-rw-r--r-- | Kernel/Bus/USB/SysFSUSB.h | 2 |
2 files changed, 4 insertions, 5 deletions
diff --git a/Kernel/Bus/USB/SysFSUSB.cpp b/Kernel/Bus/USB/SysFSUSB.cpp index 27842eab57..ab8a57f387 100644 --- a/Kernel/Bus/USB/SysFSUSB.cpp +++ b/Kernel/Bus/USB/SysFSUSB.cpp @@ -23,7 +23,7 @@ SysFSUSBDeviceInformation::~SysFSUSBDeviceInformation() { } -bool SysFSUSBDeviceInformation::output(KBufferBuilder& builder) +KResult SysFSUSBDeviceInformation::try_generate(KBufferBuilder& builder) { VERIFY(m_lock.is_locked()); JsonArraySerializer array { builder }; @@ -44,7 +44,7 @@ bool SysFSUSBDeviceInformation::output(KBufferBuilder& builder) obj.add("num_configurations", m_device->device_descriptor().num_configurations); obj.finish(); array.finish(); - return true; + return KSuccess; } KResult SysFSUSBDeviceInformation::refresh_data(FileDescription& description) const @@ -55,8 +55,7 @@ KResult SysFSUSBDeviceInformation::refresh_data(FileDescription& description) co cached_data = TRY(adopt_nonnull_own_or_enomem(new (nothrow) SysFSInodeData)); } KBufferBuilder builder; - if (!const_cast<SysFSUSBDeviceInformation&>(*this).output(builder)) - return ENOENT; + TRY(const_cast<SysFSUSBDeviceInformation&>(*this).try_generate(builder)); auto& typed_cached_data = static_cast<SysFSInodeData&>(*cached_data); typed_cached_data.buffer = builder.build(); if (!typed_cached_data.buffer) diff --git a/Kernel/Bus/USB/SysFSUSB.h b/Kernel/Bus/USB/SysFSUSB.h index 4ba0e20b09..674c0ff0d6 100644 --- a/Kernel/Bus/USB/SysFSUSB.h +++ b/Kernel/Bus/USB/SysFSUSB.h @@ -33,7 +33,7 @@ protected: NonnullRefPtr<USB::Device> m_device; private: - bool output(KBufferBuilder& builder); + KResult try_generate(KBufferBuilder&); virtual KResult refresh_data(FileDescription& description) const override; mutable Mutex m_lock { "SysFSUSBDeviceInformation" }; }; |