1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 08:58:11 +00:00

Kernel/VirtIO: Use proper error propagation from the get_config method

This allows us to drop null-checks at call-sites, thus simplifying the
code and reducing the chance of nullptr-dereference errors.
This commit is contained in:
Liav A 2023-04-26 17:19:05 +03:00 committed by Andreas Kling
parent 87a32ab869
commit bc3eb6d65f
4 changed files with 7 additions and 11 deletions

View file

@ -22,9 +22,7 @@ UNMAP_AFTER_INIT NonnullLockRefPtr<Console> Console::must_create(PCI::DeviceIden
UNMAP_AFTER_INIT ErrorOr<void> Console::initialize_virtio_resources()
{
TRY(Device::initialize_virtio_resources());
auto const* cfg = get_config(VirtIO::ConfigurationType::Device);
if (!cfg)
return Error::from_errno(ENODEV);
auto const* cfg = TRY(get_config(VirtIO::ConfigurationType::Device));
bool success = negotiate_features([&](u64 supported_features) {
u64 negotiated = 0;
if (is_feature_set(supported_features, VIRTIO_CONSOLE_F_SIZE))