1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 11:34:59 +00:00

Kernel/Net: Don't allocate memory for adapters' names

Instead, use a FixedStringBuffer to store a string with up to 16 chars.
This commit is contained in:
Liav A 2023-08-12 00:41:18 +03:00 committed by Andrew Kaster
parent b2fd51f561
commit 3f63be949a
14 changed files with 40 additions and 40 deletions

View file

@ -83,12 +83,12 @@ RefPtr<NetworkAdapter> NetworkingManagement::lookup_by_name(StringView name) con
});
}
ErrorOr<NonnullOwnPtr<KString>> NetworkingManagement::generate_interface_name_from_pci_address(PCI::DeviceIdentifier const& device_identifier)
ErrorOr<FixedStringBuffer<IFNAMSIZ>> NetworkingManagement::generate_interface_name_from_pci_address(PCI::DeviceIdentifier const& device_identifier)
{
VERIFY(device_identifier.class_code().value() == 0x2);
// Note: This stands for e - "Ethernet", p - "Port" as for PCI bus, "s" for slot as for PCI slot
auto name = TRY(KString::formatted("ep{}s{}", device_identifier.address().bus(), device_identifier.address().device()));
VERIFY(!NetworkingManagement::the().lookup_by_name(name->view()));
auto name = TRY(FixedStringBuffer<IFNAMSIZ>::formatted("ep{}s{}", device_identifier.address().bus(), device_identifier.address().device()));
VERIFY(!NetworkingManagement::the().lookup_by_name(name.representable_view()));
return name;
}