mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:27:35 +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:
parent
87a32ab869
commit
bc3eb6d65f
4 changed files with 7 additions and 11 deletions
|
@ -30,7 +30,7 @@ protected:
|
|||
virtual StringView class_name() const { return "VirtIO::Device"sv; }
|
||||
explicit Device(PCI::DeviceIdentifier const&);
|
||||
|
||||
Configuration const* get_config(ConfigurationType cfg_type, u32 index = 0) const
|
||||
ErrorOr<Configuration const*> get_config(ConfigurationType cfg_type, u32 index = 0) const
|
||||
{
|
||||
for (auto const& cfg : m_configs) {
|
||||
if (cfg.cfg_type != cfg_type)
|
||||
|
@ -41,7 +41,7 @@ protected:
|
|||
}
|
||||
return &cfg;
|
||||
}
|
||||
return nullptr;
|
||||
return Error::from_errno(ENXIO);
|
||||
}
|
||||
|
||||
template<typename F>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue