1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:47:44 +00:00

Kernel/SysFS: Prevent allocation for component name during construction

Instead, allocate before constructing the object and pass NonnullOwnPtr
of KString to the object if needed. Some classes can determine their
names as they have a known attribute to look for or have a static name.
This commit is contained in:
Liav A 2021-12-12 16:33:08 +02:00 committed by Andreas Kling
parent 4daf07e69f
commit 478f543899
17 changed files with 116 additions and 65 deletions

View file

@ -66,11 +66,12 @@ public:
protected:
virtual ErrorOr<NonnullOwnPtr<KBuffer>> try_to_generate_buffer() const = 0;
explicit BIOSSysFSComponent(StringView name);
BIOSSysFSComponent();
};
class DMIEntryPointExposedBlob : public BIOSSysFSComponent {
public:
virtual StringView name() const override { return "smbios_entry_point"sv; }
static NonnullRefPtr<DMIEntryPointExposedBlob> create(PhysicalAddress dmi_entry_point, size_t blob_size);
private:
@ -82,6 +83,7 @@ private:
class SMBIOSExposedTable : public BIOSSysFSComponent {
public:
virtual StringView name() const override { return "DMI"sv; }
static NonnullRefPtr<SMBIOSExposedTable> create(PhysicalAddress, size_t blob_size);
private:
@ -94,6 +96,7 @@ private:
class BIOSSysFSDirectory : public SysFSDirectory {
public:
virtual StringView name() const override { return "bios"sv; }
static ErrorOr<NonnullRefPtr<BIOSSysFSDirectory>> try_create(FirmwareSysFSDirectory&);
void create_components();