diff options
author | Idan Horowitz <idan.horowitz@gmail.com> | 2021-08-19 22:45:07 +0300 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-08-19 23:49:53 +0200 |
commit | cf271183b4befeba7c96bd6ca25246b899e836bb (patch) | |
tree | 0361e7378750c2c4e45e5e01e273d6fe416555af /Kernel/ProcessSpecificExposed.cpp | |
parent | 1259dc362376e8011d20d4d9e2fcc49d5b7f9dc9 (diff) | |
download | serenity-cf271183b4befeba7c96bd6ca25246b899e836bb.zip |
Kernel: Make Process::current() return a Process& instead of Process*
This has several benefits:
1) We no longer just blindly derefence a null pointer in various places
2) We will get nicer runtime error messages if the current process does
turn out to be null in the call location
3) GCC no longer complains about possible nullptr dereferences when
compiling without KUBSAN
Diffstat (limited to 'Kernel/ProcessSpecificExposed.cpp')
-rw-r--r-- | Kernel/ProcessSpecificExposed.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Kernel/ProcessSpecificExposed.cpp b/Kernel/ProcessSpecificExposed.cpp index f322497459..d000ae45a3 100644 --- a/Kernel/ProcessSpecificExposed.cpp +++ b/Kernel/ProcessSpecificExposed.cpp @@ -24,7 +24,7 @@ KResultOr<size_t> Process::procfs_get_thread_stack(ThreadID thread_id, KBufferBu auto thread = Thread::from_tid(thread_id); if (!thread) return KResult(ESRCH); - bool show_kernel_addresses = Process::current()->is_superuser(); + bool show_kernel_addresses = Process::current().is_superuser(); bool kernel_address_added = false; for (auto address : Processor::capture_stack_trace(*thread, 1024)) { if (!show_kernel_addresses && !Memory::is_user_address(VirtualAddress { address })) { @@ -213,7 +213,7 @@ KResult Process::procfs_get_virtual_memory_stats(KBufferBuilder& builder) const { ScopedSpinLock lock(address_space().get_lock()); for (auto& region : address_space().regions()) { - if (!region->is_user() && !Process::current()->is_superuser()) + if (!region->is_user() && !Process::current().is_superuser()) continue; auto region_object = array.add_object(); region_object.add("readable", region->is_readable()); |