From a01b19c878f7c6971d1ffbde039d4792e7446990 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 7 Sep 2021 16:22:29 +0200 Subject: [PATCH] Kernel: Remove KBuffer::try_copy() in favor of try_create_with_bytes() These were already equivalent, so let's only have one of them. --- Kernel/KBuffer.h | 5 ----- Kernel/Net/IPv4Socket.cpp | 2 +- Kernel/Syscalls/module.cpp | 2 +- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/Kernel/KBuffer.h b/Kernel/KBuffer.h index 1059191842..0b161d3257 100644 --- a/Kernel/KBuffer.h +++ b/Kernel/KBuffer.h @@ -37,11 +37,6 @@ public: return buffer; } - static KResultOr> try_copy(const void* data, size_t size, Memory::Region::Access access = Memory::Region::Access::ReadWrite, StringView name = "KBuffer") - { - return try_create_with_bytes(ReadonlyBytes { data, size }, access, name); - } - [[nodiscard]] u8* data() { return m_region->vaddr().as_ptr(); } [[nodiscard]] u8 const* data() const { return m_region->vaddr().as_ptr(); } [[nodiscard]] size_t size() const { return m_size; } diff --git a/Kernel/Net/IPv4Socket.cpp b/Kernel/Net/IPv4Socket.cpp index bf155ed6f1..36b8750ca7 100644 --- a/Kernel/Net/IPv4Socket.cpp +++ b/Kernel/Net/IPv4Socket.cpp @@ -426,7 +426,7 @@ bool IPv4Socket::did_receive(const IPv4Address& source_address, u16 source_port, dbgln("IPv4Socket({}): did_receive refusing packet since queue is full.", this); return false; } - auto data_or_error = KBuffer::try_copy(packet.data(), packet.size()); + auto data_or_error = KBuffer::try_create_with_bytes(packet); if (data_or_error.is_error()) { dbgln("IPv4Socket: did_receive unable to allocate storage for incoming packet."); return false; diff --git a/Kernel/Syscalls/module.cpp b/Kernel/Syscalls/module.cpp index b7a05b18e3..4b1b17c3e1 100644 --- a/Kernel/Syscalls/module.cpp +++ b/Kernel/Syscalls/module.cpp @@ -45,7 +45,7 @@ KResultOr Process::sys$module_load(Userspace user_path, si elf_image->for_each_section_of_type(SHT_PROGBITS, [&](const ELF::Image::Section& section) { if (!section.size() || !section_loading_result.is_error()) return; - auto section_storage_or_error = KBuffer::try_copy(section.raw_data(), section.size(), Memory::Region::Access::ReadWriteExecute); + auto section_storage_or_error = KBuffer::try_create_with_bytes(ReadonlyBytes { section.raw_data(), section.size() }, Memory::Region::Access::ReadWriteExecute); if (section_storage_or_error.is_error()) { section_loading_result = section_storage_or_error.error(); return;