summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
authorLenny Maiorani <lenny@colorado.edu>2021-01-10 16:29:28 -0700
committerAndreas Kling <kling@serenityos.org>2021-01-12 09:11:45 +0100
commite6f907a1556757c623fe660df0a43faf1b3d0eae (patch)
treea3a07081ec2ebdac050d776c61d2c908459bf343 /Kernel
parent9dc44bf8c427160bafd87205c42201cf9b11c0b4 (diff)
downloadserenity-e6f907a1556757c623fe660df0a43faf1b3d0eae.zip
AK: Simplify constructors and conversions from nullptr_t
Problem: - Many constructors are defined as `{}` rather than using the ` = default` compiler-provided constructor. - Some types provide an implicit conversion operator from `nullptr_t` instead of requiring the caller to default construct. This violates the C++ Core Guidelines suggestion to declare single-argument constructors explicit (https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c46-by-default-declare-single-argument-constructors-explicit). Solution: - Change default constructors to use the compiler-provided default constructor. - Remove implicit conversion operators from `nullptr_t` and change usage to enforce type consistency without conversion.
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/ACPI/MultiProcessorParser.cpp2
-rw-r--r--Kernel/CoreDump.cpp4
-rw-r--r--Kernel/Devices/SB16.cpp2
-rw-r--r--Kernel/FileSystem/FIFO.cpp4
-rw-r--r--Kernel/FileSystem/Plan9FileSystem.cpp6
-rw-r--r--Kernel/KBuffer.h4
-rw-r--r--Kernel/Lock.cpp2
-rw-r--r--Kernel/Net/E1000NetworkAdapter.cpp2
-rw-r--r--Kernel/Net/IPv4Socket.cpp4
-rw-r--r--Kernel/Net/LocalSocket.cpp4
-rw-r--r--Kernel/Net/NetworkTask.cpp2
-rw-r--r--Kernel/Net/Routing.cpp2
-rw-r--r--Kernel/Net/TCPSocket.cpp2
-rw-r--r--Kernel/PerformanceEventBuffer.cpp2
-rw-r--r--Kernel/Random.cpp2
-rw-r--r--Kernel/Storage/Partition/MBRPartitionTable.cpp2
-rw-r--r--Kernel/Storage/StorageManagement.cpp6
-rw-r--r--Kernel/Syscalls/execve.cpp3
-rw-r--r--Kernel/Syscalls/read.cpp2
-rw-r--r--Kernel/Syscalls/socket.cpp2
-rw-r--r--Kernel/Syscalls/thread.cpp2
-rw-r--r--Kernel/Syscalls/waitid.cpp2
-rw-r--r--Kernel/Syscalls/write.cpp2
-rw-r--r--Kernel/Tasks/FinalizerTask.cpp2
-rw-r--r--Kernel/Thread.cpp4
-rw-r--r--Kernel/Thread.h4
-rw-r--r--Kernel/VM/MemoryManager.cpp16
27 files changed, 44 insertions, 47 deletions
diff --git a/Kernel/ACPI/MultiProcessorParser.cpp b/Kernel/ACPI/MultiProcessorParser.cpp
index c458d4e7c5..5b27d14eeb 100644
--- a/Kernel/ACPI/MultiProcessorParser.cpp
+++ b/Kernel/ACPI/MultiProcessorParser.cpp
@@ -41,7 +41,7 @@ OwnPtr<MultiProcessorParser> MultiProcessorParser::autodetect()
{
auto floating_pointer = find_floating_pointer();
if (!floating_pointer.has_value())
- return nullptr;
+ return {};
return adopt_own(*new MultiProcessorParser(floating_pointer.value()));
}
diff --git a/Kernel/CoreDump.cpp b/Kernel/CoreDump.cpp
index 6c79afe365..5a8cccc489 100644
--- a/Kernel/CoreDump.cpp
+++ b/Kernel/CoreDump.cpp
@@ -45,12 +45,12 @@ OwnPtr<CoreDump> CoreDump::create(NonnullRefPtr<Process> process, const String&
{
if (!process->is_dumpable()) {
dbgln("Refusing to generate CoreDump for non-dumpable process {}", process->pid().value());
- return nullptr;
+ return {};
}
auto fd = create_target_file(process, output_path);
if (!fd)
- return nullptr;
+ return {};
return adopt_own(*new CoreDump(move(process), fd.release_nonnull()));
}
diff --git a/Kernel/Devices/SB16.cpp b/Kernel/Devices/SB16.cpp
index befb4051d3..c0430c7259 100644
--- a/Kernel/Devices/SB16.cpp
+++ b/Kernel/Devices/SB16.cpp
@@ -227,7 +227,7 @@ void SB16::handle_irq(const RegisterState&)
void SB16::wait_for_irq()
{
- m_irq_queue.wait_on(nullptr, "SB16");
+ m_irq_queue.wait_on({}, "SB16");
disable_irq();
}
diff --git a/Kernel/FileSystem/FIFO.cpp b/Kernel/FileSystem/FIFO.cpp
index b7ccd05ec4..d45de8d150 100644
--- a/Kernel/FileSystem/FIFO.cpp
+++ b/Kernel/FileSystem/FIFO.cpp
@@ -75,7 +75,7 @@ KResultOr<NonnullRefPtr<FileDescription>> FIFO::open_direction_blocking(FIFO::Di
if (m_writers == 0) {
locker.unlock();
- m_write_open_queue.wait_on(nullptr, "FIFO");
+ m_write_open_queue.wait_on({}, "FIFO");
locker.lock();
}
}
@@ -85,7 +85,7 @@ KResultOr<NonnullRefPtr<FileDescription>> FIFO::open_direction_blocking(FIFO::Di
if (m_readers == 0) {
locker.unlock();
- m_read_open_queue.wait_on(nullptr, "FIFO");
+ m_read_open_queue.wait_on({}, "FIFO");
locker.lock();
}
}
diff --git a/Kernel/FileSystem/Plan9FileSystem.cpp b/Kernel/FileSystem/Plan9FileSystem.cpp
index e466847524..52051bd253 100644
--- a/Kernel/FileSystem/Plan9FileSystem.cpp
+++ b/Kernel/FileSystem/Plan9FileSystem.cpp
@@ -531,7 +531,7 @@ KResult Plan9FS::post_message(Message& message, RefPtr<ReceiveCompletion> comple
while (size > 0) {
if (!description.can_write()) {
auto unblock_flags = Thread::FileBlocker::BlockFlags::None;
- if (Thread::current()->block<Thread::WriteBlocker>(nullptr, description, unblock_flags).was_interrupted())
+ if (Thread::current()->block<Thread::WriteBlocker>({}, description, unblock_flags).was_interrupted())
return KResult(-EINTR);
}
auto data_buffer = UserOrKernelBuffer::for_kernel_buffer(const_cast<u8*>(data));
@@ -552,7 +552,7 @@ KResult Plan9FS::do_read(u8* data, size_t size)
while (size > 0) {
if (!description.can_read()) {
auto unblock_flags = Thread::FileBlocker::BlockFlags::None;
- if (Thread::current()->block<Thread::ReadBlocker>(nullptr, description, unblock_flags).was_interrupted())
+ if (Thread::current()->block<Thread::ReadBlocker>({}, description, unblock_flags).was_interrupted())
return KResult(-EINTR);
}
auto data_buffer = UserOrKernelBuffer::for_kernel_buffer(data);
@@ -621,7 +621,7 @@ KResult Plan9FS::post_message_and_wait_for_a_reply(Message& message)
auto result = post_message(message, completion);
if (result.is_error())
return result;
- if (Thread::current()->block<Plan9FS::Blocker>(nullptr, *this, message, completion).was_interrupted())
+ if (Thread::current()->block<Plan9FS::Blocker>({}, *this, message, completion).was_interrupted())
return KResult(-EINTR);
if (completion->result.is_error()) {
diff --git a/Kernel/KBuffer.h b/Kernel/KBuffer.h
index 53ad60bf88..665610571a 100644
--- a/Kernel/KBuffer.h
+++ b/Kernel/KBuffer.h
@@ -128,7 +128,7 @@ public:
{
auto impl = KBufferImpl::try_create_with_size(size, access, name, strategy);
if (!impl)
- return nullptr;
+ return {};
return adopt_own(*new KBuffer(impl.release_nonnull()));
}
@@ -136,7 +136,7 @@ public:
{
auto impl = KBufferImpl::try_create_with_bytes(bytes, access, name, strategy);
if (!impl)
- return nullptr;
+ return {};
return adopt_own(*new KBuffer(impl.release_nonnull()));
}
diff --git a/Kernel/Lock.cpp b/Kernel/Lock.cpp
index f24b8d5fb3..f543bf22f7 100644
--- a/Kernel/Lock.cpp
+++ b/Kernel/Lock.cpp
@@ -123,7 +123,7 @@ void Lock::lock(Mode mode)
ASSERT_NOT_REACHED();
}
m_lock.store(false, AK::memory_order_release);
- } while (m_queue.wait_on(nullptr, m_name) == Thread::BlockResult::NotBlocked);
+ } while (m_queue.wait_on({}, m_name) == Thread::BlockResult::NotBlocked);
} else {
// I don't know *who* is using "m_lock", so just yield.
Scheduler::yield_from_critical();
diff --git a/Kernel/Net/E1000NetworkAdapter.cpp b/Kernel/Net/E1000NetworkAdapter.cpp
index 431e31d3d1..c6b8644432 100644
--- a/Kernel/Net/E1000NetworkAdapter.cpp
+++ b/Kernel/Net/E1000NetworkAdapter.cpp
@@ -457,7 +457,7 @@ void E1000NetworkAdapter::send_raw(ReadonlyBytes payload)
sti();
break;
}
- m_wait_queue.wait_on(nullptr, "E1000NetworkAdapter");
+ m_wait_queue.wait_on({}, "E1000NetworkAdapter");
}
#ifdef E1000_DEBUG
dbgln("E1000: Sent packet, status is now {:#02x}!", (u8)descriptor.status);
diff --git a/Kernel/Net/IPv4Socket.cpp b/Kernel/Net/IPv4Socket.cpp
index f8c6a3ac2b..2454a2f6df 100644
--- a/Kernel/Net/IPv4Socket.cpp
+++ b/Kernel/Net/IPv4Socket.cpp
@@ -255,7 +255,7 @@ KResultOr<size_t> IPv4Socket::receive_byte_buffered(FileDescription& description
locker.unlock();
auto unblocked_flags = Thread::FileDescriptionBlocker::BlockFlags::None;
- auto res = Thread::current()->block<Thread::ReadBlocker>(nullptr, description, unblocked_flags);
+ auto res = Thread::current()->block<Thread::ReadBlocker>({}, description, unblocked_flags);
locker.lock();
if (!((u32)unblocked_flags & (u32)Thread::FileDescriptionBlocker::BlockFlags::Read)) {
@@ -306,7 +306,7 @@ KResultOr<size_t> IPv4Socket::receive_packet_buffered(FileDescription& descripti
locker.unlock();
auto unblocked_flags = Thread::FileDescriptionBlocker::BlockFlags::None;
- auto res = Thread::current()->block<Thread::ReadBlocker>(nullptr, description, unblocked_flags);
+ auto res = Thread::current()->block<Thread::ReadBlocker>({}, description, unblocked_flags);
locker.lock();
if (!((u32)unblocked_flags & (u32)Thread::FileDescriptionBlocker::BlockFlags::Read)) {
diff --git a/Kernel/Net/LocalSocket.cpp b/Kernel/Net/LocalSocket.cpp
index bb15c43d4f..3ffc370877 100644
--- a/Kernel/Net/LocalSocket.cpp
+++ b/Kernel/Net/LocalSocket.cpp
@@ -192,7 +192,7 @@ KResult LocalSocket::connect(FileDescription& description, Userspace<const socka
}
auto unblock_flags = Thread::FileDescriptionBlocker::BlockFlags::None;
- if (Thread::current()->block<Thread::ConnectBlocker>(nullptr, description, unblock_flags).was_interrupted()) {
+ if (Thread::current()->block<Thread::ConnectBlocker>({}, description, unblock_flags).was_interrupted()) {
set_connect_side_role(Role::None);
return KResult(-EINTR);
}
@@ -329,7 +329,7 @@ KResultOr<size_t> LocalSocket::recvfrom(FileDescription& description, UserOrKern
}
} else if (!can_read(description, 0)) {
auto unblock_flags = Thread::FileDescriptionBlocker::BlockFlags::None;
- if (Thread::current()->block<Thread::ReadBlocker>(nullptr, description, unblock_flags).was_interrupted())
+ if (Thread::current()->block<Thread::ReadBlocker>({}, description, unblock_flags).was_interrupted())
return KResult(-EINTR);
}
if (!has_attached_peer(description) && socket_buffer->is_empty())
diff --git a/Kernel/Net/NetworkTask.cpp b/Kernel/Net/NetworkTask.cpp
index 18318e90f9..0951f6d0c9 100644
--- a/Kernel/Net/NetworkTask.cpp
+++ b/Kernel/Net/NetworkTask.cpp
@@ -114,7 +114,7 @@ void NetworkTask_main(void*)
for (;;) {
size_t packet_size = dequeue_packet(buffer, buffer_size, packet_timestamp);
if (!packet_size) {
- packet_wait_queue.wait_on(nullptr, "NetworkTask");
+ packet_wait_queue.wait_on({}, "NetworkTask");
continue;
}
if (packet_size < sizeof(EthernetFrameHeader)) {
diff --git a/Kernel/Net/Routing.cpp b/Kernel/Net/Routing.cpp
index 48330b6697..f9547b247f 100644
--- a/Kernel/Net/Routing.cpp
+++ b/Kernel/Net/Routing.cpp
@@ -230,7 +230,7 @@ RoutingDecision route_to(const IPv4Address& target, const IPv4Address& source, c
adapter->send({ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }, request);
Optional<MACAddress> addr;
- if (!Thread::current()->block<ARPTableBlocker>(nullptr, next_hop_ip, addr).was_interrupted()) {
+ if (!Thread::current()->block<ARPTableBlocker>({}, next_hop_ip, addr).was_interrupted()) {
if (addr.has_value()) {
#ifdef ROUTING_DEBUG
klog() << "Routing: Got ARP response using adapter " << adapter->name().characters() << " for " << next_hop_ip.to_string().characters() << " (" << addr.value().to_string().characters() << ")";
diff --git a/Kernel/Net/TCPSocket.cpp b/Kernel/Net/TCPSocket.cpp
index 5bb4aefaac..638602b8e6 100644
--- a/Kernel/Net/TCPSocket.cpp
+++ b/Kernel/Net/TCPSocket.cpp
@@ -400,7 +400,7 @@ KResult TCPSocket::protocol_connect(FileDescription& description, ShouldBlock sh
if (should_block == ShouldBlock::Yes) {
locker.unlock();
auto unblock_flags = Thread::FileBlocker::BlockFlags::None;
- if (Thread::current()->block<Thread::ConnectBlocker>(nullptr, description, unblock_flags).was_interrupted())
+ if (Thread::current()->block<Thread::ConnectBlocker>({}, description, unblock_flags).was_interrupted())
return KResult(-EINTR);
locker.lock();
ASSERT(setup_state() == SetupState::Completed);
diff --git a/Kernel/PerformanceEventBuffer.cpp b/Kernel/PerformanceEventBuffer.cpp
index b564c2ee35..851d3098da 100644
--- a/Kernel/PerformanceEventBuffer.cpp
+++ b/Kernel/PerformanceEventBuffer.cpp
@@ -89,7 +89,7 @@ OwnPtr<KBuffer> PerformanceEventBuffer::to_json(ProcessID pid, const String& exe
{
KBufferBuilder builder;
if (!to_json(builder, pid, executable_path))
- return nullptr;
+ return {};
return builder.build();
}
diff --git a/Kernel/Random.cpp b/Kernel/Random.cpp
index c89ab21274..12ec58fca6 100644
--- a/Kernel/Random.cpp
+++ b/Kernel/Random.cpp
@@ -69,7 +69,7 @@ KernelRng::KernelRng()
void KernelRng::wait_for_entropy()
{
if (!resource().is_ready()) {
- m_seed_queue.wait_on(nullptr, "KernelRng");
+ m_seed_queue.wait_on({}, "KernelRng");
}
}
diff --git a/Kernel/Storage/Partition/MBRPartitionTable.cpp b/Kernel/Storage/Partition/MBRPartitionTable.cpp
index 931081c628..b5d28fb7a2 100644
--- a/Kernel/Storage/Partition/MBRPartitionTable.cpp
+++ b/Kernel/Storage/Partition/MBRPartitionTable.cpp
@@ -54,7 +54,7 @@ OwnPtr<MBRPartitionTable> MBRPartitionTable::try_to_initialize(const StorageDevi
{
auto table = make<MBRPartitionTable>(device, start_lba);
if (!table->is_valid())
- return nullptr;
+ return {};
return table;
}
diff --git a/Kernel/Storage/StorageManagement.cpp b/Kernel/Storage/StorageManagement.cpp
index 539bd2e311..0718278ab0 100644
--- a/Kernel/Storage/StorageManagement.cpp
+++ b/Kernel/Storage/StorageManagement.cpp
@@ -90,16 +90,16 @@ OwnPtr<PartitionTable> StorageManagement::try_to_initialize_partition_table(cons
if (mbr_table_or_result.error() == PartitionTable::Error::MBRProtective) {
auto gpt_table_or_result = GUIDPartitionTable::try_to_initialize(device);
if (gpt_table_or_result.is_error())
- return nullptr;
+ return {};
return move(gpt_table_or_result.value());
}
if (mbr_table_or_result.error() == PartitionTable::Error::ConatinsEBR) {
auto ebr_table_or_result = EBRPartitionTable::try_to_initialize(device);
if (ebr_table_or_result.is_error())
- return nullptr;
+ return {};
return move(ebr_table_or_result.value());
}
- return nullptr;
+ return {};
}
NonnullRefPtrVector<DiskPartition> StorageManagement::enumerate_disk_partitions() const
diff --git a/Kernel/Syscalls/execve.cpp b/Kernel/Syscalls/execve.cpp
index 7a42d2366f..7ffce9787e 100644
--- a/Kernel/Syscalls/execve.cpp
+++ b/Kernel/Syscalls/execve.cpp
@@ -27,6 +27,7 @@
#include <AK/LexicalPath.h>
#include <AK/ScopeGuard.h>
#include <AK/TemporaryChange.h>
+#include <AK/WeakPtr.h>
#include <Kernel/FileSystem/Custody.h>
#include <Kernel/FileSystem/FileDescription.h>
#include <Kernel/PerformanceEventBuffer.h>
@@ -269,7 +270,7 @@ KResultOr<Process::LoadResult> Process::load_elf_object(FileDescription& object_
executable_size,
VirtualAddress(elf_image.program_header_table_offset()).offset(load_offset).get(),
elf_image.program_header_count(),
- master_tls_region ? master_tls_region->make_weak_ptr() : nullptr,
+ AK::try_make_weak_ptr(master_tls_region),
master_tls_size,
master_tls_alignment,
stack_region->make_weak_ptr()
diff --git a/Kernel/Syscalls/read.cpp b/Kernel/Syscalls/read.cpp
index 498024553f..0e8c820975 100644
--- a/Kernel/Syscalls/read.cpp
+++ b/Kernel/Syscalls/read.cpp
@@ -51,7 +51,7 @@ ssize_t Process::sys$read(int fd, Userspace<u8*> buffer, ssize_t size)
if (description->is_blocking()) {
if (!description->can_read()) {
auto unblock_flags = Thread::FileBlocker::BlockFlags::None;
- if (Thread::current()->block<Thread::ReadBlocker>(nullptr, *description, unblock_flags).was_interrupted())
+ if (Thread::current()->block<Thread::ReadBlocker>({}, *description, unblock_flags).was_interrupted())
return -EINTR;
if (!((u32)unblock_flags & (u32)Thread::FileBlocker::BlockFlags::Read))
return -EAGAIN;
diff --git a/Kernel/Syscalls/socket.cpp b/Kernel/Syscalls/socket.cpp
index 2fdf7f8b3b..0e596707c0 100644
--- a/Kernel/Syscalls/socket.cpp
+++ b/Kernel/Syscalls/socket.cpp
@@ -115,7 +115,7 @@ int Process::sys$accept(int accepting_socket_fd, Userspace<sockaddr*> user_addre
if (!socket.can_accept()) {
if (accepting_socket_description->is_blocking()) {
auto unblock_flags = Thread::FileBlocker::BlockFlags::None;
- if (Thread::current()->block<Thread::AcceptBlocker>(nullptr, *accepting_socket_description, unblock_flags).was_interrupted())
+ if (Thread::current()->block<Thread::AcceptBlocker>({}, *accepting_socket_description, unblock_flags).was_interrupted())
return -EINTR;
} else {
return -EAGAIN;
diff --git a/Kernel/Syscalls/thread.cpp b/Kernel/Syscalls/thread.cpp
index 3b8bc80c3d..31fe733f43 100644
--- a/Kernel/Syscalls/thread.cpp
+++ b/Kernel/Syscalls/thread.cpp
@@ -132,7 +132,7 @@ int Process::sys$join_thread(pid_t tid, Userspace<void**> exit_value)
// NOTE: pthread_join() cannot be interrupted by signals. Only by death.
for (;;) {
KResult try_join_result(KSuccess);
- auto result = current_thread->block<Thread::JoinBlocker>(nullptr, *thread, try_join_result, joinee_exit_value);
+ auto result = current_thread->block<Thread::JoinBlocker>({}, *thread, try_join_result, joinee_exit_value);
if (result == Thread::BlockResult::NotBlocked) {
if (try_join_result.is_error())
return try_join_result.error();
diff --git a/Kernel/Syscalls/waitid.cpp b/Kernel/Syscalls/waitid.cpp
index f98cdb6d85..6a7953ca4e 100644
--- a/Kernel/Syscalls/waitid.cpp
+++ b/Kernel/Syscalls/waitid.cpp
@@ -42,7 +42,7 @@ KResultOr<siginfo_t> Process::do_waitid(idtype_t idtype, int id, int options)
}
KResultOr<siginfo_t> result = KResult(KSuccess);
- if (Thread::current()->block<Thread::WaitBlocker>(nullptr, options, idtype, id, result).was_interrupted())
+ if (Thread::current()->block<Thread::WaitBlocker>({}, options, idtype, id, result).was_interrupted())
return KResult(-EINTR);
ASSERT(!result.is_error() || (options & WNOHANG) || result.error() != KSuccess);
return result;
diff --git a/Kernel/Syscalls/write.cpp b/Kernel/Syscalls/write.cpp
index 8eee56bb1e..f6c25e2e98 100644
--- a/Kernel/Syscalls/write.cpp
+++ b/Kernel/Syscalls/write.cpp
@@ -97,7 +97,7 @@ ssize_t Process::do_write(FileDescription& description, const UserOrKernelBuffer
return total_nwritten;
}
auto unblock_flags = Thread::FileBlocker::BlockFlags::None;
- if (Thread::current()->block<Thread::WriteBlocker>(nullptr, description, unblock_flags).was_interrupted()) {
+ if (Thread::current()->block<Thread::WriteBlocker>({}, description, unblock_flags).was_interrupted()) {
if (total_nwritten == 0)
return -EINTR;
}
diff --git a/Kernel/Tasks/FinalizerTask.cpp b/Kernel/Tasks/FinalizerTask.cpp
index b84af218c7..77c34560d4 100644
--- a/Kernel/Tasks/FinalizerTask.cpp
+++ b/Kernel/Tasks/FinalizerTask.cpp
@@ -36,7 +36,7 @@ void FinalizerTask::spawn()
finalizer_thread, "FinalizerTask", [](void*) {
Thread::current()->set_priority(THREAD_PRIORITY_LOW);
for (;;) {
- g_finalizer_wait_queue->wait_on(nullptr, "FinalizerTask");
+ g_finalizer_wait_queue->wait_on({}, "FinalizerTask");
if (g_finalizer_has_work.exchange(false, AK::MemoryOrder::memory_order_acq_rel) == true)
Thread::finalize_dying_threads();
diff --git a/Kernel/Thread.cpp b/Kernel/Thread.cpp
index 17849bd191..871187b45b 100644
--- a/Kernel/Thread.cpp
+++ b/Kernel/Thread.cpp
@@ -316,13 +316,13 @@ void Thread::relock_process(LockMode previous_locked, u32 lock_count_to_restore)
auto Thread::sleep(clockid_t clock_id, const timespec& duration, timespec* remaining_time) -> BlockResult
{
ASSERT(state() == Thread::Running);
- return Thread::current()->block<Thread::SleepBlocker>(nullptr, Thread::BlockTimeout(false, &duration, nullptr, clock_id), remaining_time);
+ return Thread::current()->block<Thread::SleepBlocker>({}, Thread::BlockTimeout(false, &duration, nullptr, clock_id), remaining_time);
}
auto Thread::sleep_until(clockid_t clock_id, const timespec& deadline) -> BlockResult
{
ASSERT(state() == Thread::Running);
- return Thread::current()->block<Thread::SleepBlocker>(nullptr, Thread::BlockTimeout(true, &deadline, nullptr, clock_id));
+ return Thread::current()->block<Thread::SleepBlocker>({}, Thread::BlockTimeout(true, &deadline, nullptr, clock_id));
}
const char* Thread::state_string() const
diff --git a/Kernel/Thread.h b/Kernel/Thread.h
index 7b21ef610c..afae991906 100644
--- a/Kernel/Thread.h
+++ b/Kernel/Thread.h
@@ -207,10 +207,6 @@ public:
: m_infinite(true)
{
}
- BlockTimeout(std::nullptr_t)
- : m_infinite(true)
- {
- }
explicit BlockTimeout(bool is_absolute, const timeval* time, const timespec* start_time = nullptr, clockid_t clock_id = CLOCK_MONOTONIC_COARSE)
: m_clock_id(clock_id)
, m_infinite(!time)
diff --git a/Kernel/VM/MemoryManager.cpp b/Kernel/VM/MemoryManager.cpp
index a21f854c00..941592f776 100644
--- a/Kernel/VM/MemoryManager.cpp
+++ b/Kernel/VM/MemoryManager.cpp
@@ -385,7 +385,7 @@ OwnPtr<Region> MemoryManager::allocate_contiguous_kernel_region(size_t size, con
ScopedSpinLock lock(s_mm_lock);
auto range = kernel_page_directory().range_allocator().allocate_anywhere(size);
if (!range.is_valid())
- return nullptr;
+ return {};
auto vmobject = ContiguousVMObject::create_with_size(size);
return allocate_kernel_region_with_vmobject(range, vmobject, name, access, user_accessible, cacheable);
}
@@ -396,10 +396,10 @@ OwnPtr<Region> MemoryManager::allocate_kernel_region(size_t size, const StringVi
ScopedSpinLock lock(s_mm_lock);
auto range = kernel_page_directory().range_allocator().allocate_anywhere(size);
if (!range.is_valid())
- return nullptr;
+ return {};
auto vmobject = AnonymousVMObject::create_with_size(size, strategy);
if (!vmobject)
- return nullptr;
+ return {};
return allocate_kernel_region_with_vmobject(range, vmobject.release_nonnull(), name, access, user_accessible, cacheable);
}
@@ -409,10 +409,10 @@ OwnPtr<Region> MemoryManager::allocate_kernel_region(PhysicalAddress paddr, size
ScopedSpinLock lock(s_mm_lock);
auto range = kernel_page_directory().range_allocator().allocate_anywhere(size);
if (!range.is_valid())
- return nullptr;
+ return {};
auto vmobject = AnonymousVMObject::create_for_physical_range(paddr, size);
if (!vmobject)
- return nullptr;
+ return {};
return allocate_kernel_region_with_vmobject(range, *vmobject, name, access, user_accessible, cacheable);
}
@@ -422,10 +422,10 @@ OwnPtr<Region> MemoryManager::allocate_kernel_region_identity(PhysicalAddress pa
ScopedSpinLock lock(s_mm_lock);
auto range = kernel_page_directory().identity_range_allocator().allocate_specific(VirtualAddress(paddr.get()), size);
if (!range.is_valid())
- return nullptr;
+ return {};
auto vmobject = AnonymousVMObject::create_for_physical_range(paddr, size);
if (!vmobject)
- return nullptr;
+ return {};
return allocate_kernel_region_with_vmobject(range, *vmobject, name, access, user_accessible, cacheable);
}
@@ -453,7 +453,7 @@ OwnPtr<Region> MemoryManager::allocate_kernel_region_with_vmobject(VMObject& vmo
ScopedSpinLock lock(s_mm_lock);
auto range = kernel_page_directory().range_allocator().allocate_anywhere(size);
if (!range.is_valid())
- return nullptr;
+ return {};
return allocate_kernel_region_with_vmobject(range, vmobject, name, access, user_accessible, cacheable);
}