1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 07:27:45 +00:00

Kernel: Don't use naked new statements in init process

Instead, try to create the device objects in separate static methods,
and if we fail for some odd reason to allocate memory for such devices,
just panic with that reason.
This commit is contained in:
Liav A 2021-06-18 11:37:26 +03:00 committed by Andreas Kling
parent fba3c77a04
commit 29f9a38f76
11 changed files with 74 additions and 18 deletions

View file

@ -13,7 +13,7 @@ namespace Kernel {
class FullDevice final : public CharacterDevice {
AK_MAKE_ETERNAL
public:
FullDevice();
static NonnullRefPtr<FullDevice> must_create();
virtual ~FullDevice() override;
// ^Device
@ -21,6 +21,8 @@ public:
virtual String device_name() const override { return "full"; }
private:
FullDevice();
// ^CharacterDevice
virtual KResultOr<size_t> read(FileDescription&, u64, UserOrKernelBuffer&, size_t) override;
virtual KResultOr<size_t> write(FileDescription&, u64, const UserOrKernelBuffer&, size_t) override;