From e09ba765a128e8bd7203f8bcd2abd70ecfcb9332 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Wed, 27 Dec 2023 23:24:35 -0700 Subject: [PATCH] kern: fix various comment/style hygiene issues (thanks @liamwhite) --- fusee/loader_stub/source/fusee_loader_uncompress.cpp | 2 +- libraries/libmesosphere/source/kern_k_client_port.cpp | 2 -- libraries/libmesosphere/source/kern_k_page_table_base.cpp | 6 +++--- libraries/libmesosphere/source/kern_k_server_port.cpp | 4 ++-- libraries/libmesosphere/source/kern_k_server_session.cpp | 6 +++--- libraries/libmesosphere/source/svc/kern_svc_ipc.cpp | 8 ++++---- libraries/libmesosphere/source/svc/kern_svc_port.cpp | 2 +- 7 files changed, 14 insertions(+), 16 deletions(-) diff --git a/fusee/loader_stub/source/fusee_loader_uncompress.cpp b/fusee/loader_stub/source/fusee_loader_uncompress.cpp index ace64588f..94ed4ff73 100644 --- a/fusee/loader_stub/source/fusee_loader_uncompress.cpp +++ b/fusee/loader_stub/source/fusee_loader_uncompress.cpp @@ -96,7 +96,7 @@ namespace ams::nxboot::loader { } void Uncompress(void *dst, size_t dst_size, const void *src, size_t src_size) { - /* Create an execute a decompressor. */ + /* Create and execute a decompressor. */ Lz4Uncompressor(dst, dst_size, src, src_size).Uncompress(); } diff --git a/libraries/libmesosphere/source/kern_k_client_port.cpp b/libraries/libmesosphere/source/kern_k_client_port.cpp index 11977334f..71ca3d7dd 100644 --- a/libraries/libmesosphere/source/kern_k_client_port.cpp +++ b/libraries/libmesosphere/source/kern_k_client_port.cpp @@ -107,7 +107,6 @@ namespace ams::kern { R_UNLESS(cur_sessions < max, svc::ResultOutOfSessions()); new_sessions = cur_sessions + 1; } while (!m_num_sessions.CompareExchangeWeak(cur_sessions, new_sessions)); - } /* Atomically update the peak session tracking. */ @@ -182,7 +181,6 @@ namespace ams::kern { R_UNLESS(cur_sessions < max, svc::ResultOutOfSessions()); new_sessions = cur_sessions + 1; } while (!m_num_sessions.CompareExchangeWeak(cur_sessions, new_sessions)); - } /* Atomically update the peak session tracking. */ diff --git a/libraries/libmesosphere/source/kern_k_page_table_base.cpp b/libraries/libmesosphere/source/kern_k_page_table_base.cpp index d1ee43054..4ec5834be 100644 --- a/libraries/libmesosphere/source/kern_k_page_table_base.cpp +++ b/libraries/libmesosphere/source/kern_k_page_table_base.cpp @@ -3624,7 +3624,7 @@ namespace ams::kern { R_UNLESS(this->Contains(address, size), svc::ResultInvalidCurrentMemory()); /* Get the source permission. */ - const auto src_perm = static_cast((test_perm == KMemoryPermission_UserReadWrite) ? KMemoryPermission_KernelReadWrite | KMemoryPermission_NotMapped : KMemoryPermission_UserRead); + const auto src_perm = static_cast((test_perm == KMemoryPermission_UserReadWrite) ? (KMemoryPermission_KernelReadWrite | KMemoryPermission_NotMapped) : KMemoryPermission_UserRead); /* Get aligned extents. */ const KProcessAddress aligned_src_start = util::AlignDown(GetInteger(address), PageSize); @@ -3953,7 +3953,7 @@ namespace ams::kern { const size_t src_map_size = src_map_end - src_map_start; /* Ensure that we clean up appropriately if we fail after this. */ - const auto src_perm = static_cast((test_perm == KMemoryPermission_UserReadWrite) ? KMemoryPermission_KernelReadWrite | KMemoryPermission_NotMapped : KMemoryPermission_UserRead); + const auto src_perm = static_cast((test_perm == KMemoryPermission_UserReadWrite) ? (KMemoryPermission_KernelReadWrite | KMemoryPermission_NotMapped) : KMemoryPermission_UserRead); ON_RESULT_FAILURE { if (src_map_end > src_map_start) { src_page_table.CleanupForIpcClientOnServerSetupFailure(updater.GetPageList(), src_map_start, src_map_size, src_perm); @@ -4488,7 +4488,7 @@ namespace ams::kern { } } - /* Map the papges. */ + /* Map the pages. */ R_TRY(this->Operate(updater.GetPageList(), cur_address, map_pages, cur_pg, map_properties, OperationType_MapFirstGroup, false)); } } diff --git a/libraries/libmesosphere/source/kern_k_server_port.cpp b/libraries/libmesosphere/source/kern_k_server_port.cpp index 765b14391..82223bfe3 100644 --- a/libraries/libmesosphere/source/kern_k_server_port.cpp +++ b/libraries/libmesosphere/source/kern_k_server_port.cpp @@ -36,7 +36,7 @@ namespace ams::kern { /* Cleanup the session list. */ while (true) { - /* Get the last session in the list */ + /* Get the last session in the list. */ KServerSession *session = nullptr; { KScopedSchedulerLock sl; @@ -56,7 +56,7 @@ namespace ams::kern { /* Cleanup the light session list. */ while (true) { - /* Get the last session in the list */ + /* Get the last session in the list. */ KLightServerSession *session = nullptr; { KScopedSchedulerLock sl; diff --git a/libraries/libmesosphere/source/kern_k_server_session.cpp b/libraries/libmesosphere/source/kern_k_server_session.cpp index 035aa3980..7c8c4e91c 100644 --- a/libraries/libmesosphere/source/kern_k_server_session.cpp +++ b/libraries/libmesosphere/source/kern_k_server_session.cpp @@ -650,7 +650,7 @@ namespace ams::kern { const auto src_state = src_user ? KMemoryState_FlagReferenceCounted : KMemoryState_FlagLinearMapped; /* Determine the source permission. User buffer should be unmapped + read, TLS should be user readable. */ - const KMemoryPermission src_perm = static_cast(src_user ? KMemoryPermission_NotMapped | KMemoryPermission_KernelRead : KMemoryPermission_UserRead); + const KMemoryPermission src_perm = static_cast(src_user ? (KMemoryPermission_NotMapped | KMemoryPermission_KernelRead) : KMemoryPermission_UserRead); /* Perform the fast part of the copy. */ R_TRY(src_page_table.CopyMemoryFromLinearToKernel(reinterpret_cast(dst_msg_ptr) + offset_words, fast_size, src_message_buffer + offset_words, @@ -753,7 +753,7 @@ namespace ams::kern { /* Perform the pointer data copy. */ const bool dst_heap = dst_user && dst_recv_list.IsToMessageBuffer(); const auto dst_state = dst_heap ? KMemoryState_FlagReferenceCounted : KMemoryState_FlagLinearMapped; - const KMemoryPermission dst_perm = static_cast(dst_heap ? KMemoryPermission_NotMapped | KMemoryPermission_KernelReadWrite : KMemoryPermission_UserReadWrite); + const KMemoryPermission dst_perm = static_cast(dst_heap ? (KMemoryPermission_NotMapped | KMemoryPermission_KernelReadWrite) : KMemoryPermission_UserReadWrite); R_TRY(dst_page_table.CopyMemoryFromUserToLinear(recv_pointer, recv_size, dst_state, dst_state, dst_perm, @@ -911,7 +911,7 @@ namespace ams::kern { const auto dst_state = dst_user ? KMemoryState_FlagReferenceCounted : KMemoryState_FlagLinearMapped; /* Determine the dst permission. User buffer should be unmapped + read, TLS should be user readable. */ - const KMemoryPermission dst_perm = static_cast(dst_user ? KMemoryPermission_NotMapped | KMemoryPermission_KernelReadWrite : KMemoryPermission_UserReadWrite); + const KMemoryPermission dst_perm = static_cast(dst_user ? (KMemoryPermission_NotMapped | KMemoryPermission_KernelReadWrite) : KMemoryPermission_UserReadWrite); /* Perform the fast part of the copy. */ R_TRY(dst_page_table.CopyMemoryFromKernelToLinear(dst_message_buffer + offset_words, fast_size, diff --git a/libraries/libmesosphere/source/svc/kern_svc_ipc.cpp b/libraries/libmesosphere/source/svc/kern_svc_ipc.cpp index 06393a3f7..a67b581cb 100644 --- a/libraries/libmesosphere/source/svc/kern_svc_ipc.cpp +++ b/libraries/libmesosphere/source/svc/kern_svc_ipc.cpp @@ -143,7 +143,7 @@ namespace ams::kern::svc { /* Get the process page table. */ auto &page_table = GetCurrentProcess().GetPageTable(); - /* Lock the mesage buffer. */ + /* Lock the message buffer. */ R_TRY(page_table.LockForIpcUserBuffer(nullptr, message, buffer_size)); { @@ -186,7 +186,7 @@ namespace ams::kern::svc { /* Commit our reservation. */ event_reservation.Commit(); - /* At end of scope, kill the standing references to the sub events. */ + /* At end of scope, kill the standing event references. */ ON_SCOPE_EXIT { event->GetReadableEvent().Close(); event->Close(); @@ -215,7 +215,7 @@ namespace ams::kern::svc { /* Get the process page table. */ auto &page_table = GetCurrentProcess().GetPageTable(); - /* Lock the mesage buffer. */ + /* Lock the message buffer. */ R_TRY(page_table.LockForIpcUserBuffer(nullptr, message, buffer_size)); /* Ensure that if we fail and aren't terminating that we unlock the user buffer. */ @@ -242,7 +242,7 @@ namespace ams::kern::svc { /* Get the process page table. */ auto &page_table = GetCurrentProcess().GetPageTable(); - /* Lock the mesage buffer, getting its physical address. */ + /* Lock the message buffer, getting its physical address. */ KPhysicalAddress message_paddr; R_TRY(page_table.LockForIpcUserBuffer(std::addressof(message_paddr), message, buffer_size)); diff --git a/libraries/libmesosphere/source/svc/kern_svc_port.cpp b/libraries/libmesosphere/source/svc/kern_svc_port.cpp index d4520d287..1ac5803d2 100644 --- a/libraries/libmesosphere/source/svc/kern_svc_port.cpp +++ b/libraries/libmesosphere/source/svc/kern_svc_port.cpp @@ -96,7 +96,7 @@ namespace ams::kern::svc { /* Add the client to the handle table. */ R_TRY(handle_table.Add(out_client, std::addressof(port->GetClientPort()))); - /* Ensure that we maintaing a clean handle state on exit. */ + /* Ensure that we maintain a clean handle state on exit. */ ON_RESULT_FAILURE { handle_table.Remove(*out_client); }; /* Add the server to the handle table. */