kern: fix various comment/style hygiene issues (thanks @liamwhite)

This commit is contained in:
Michael Scire 2023-12-27 23:24:35 -07:00
parent 3217df147e
commit e09ba765a1
7 changed files with 14 additions and 16 deletions

View File

@ -96,7 +96,7 @@ namespace ams::nxboot::loader {
} }
void Uncompress(void *dst, size_t dst_size, const void *src, size_t src_size) { 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(); Lz4Uncompressor(dst, dst_size, src, src_size).Uncompress();
} }

View File

@ -107,7 +107,6 @@ namespace ams::kern {
R_UNLESS(cur_sessions < max, svc::ResultOutOfSessions()); R_UNLESS(cur_sessions < max, svc::ResultOutOfSessions());
new_sessions = cur_sessions + 1; new_sessions = cur_sessions + 1;
} while (!m_num_sessions.CompareExchangeWeak<std::memory_order_relaxed>(cur_sessions, new_sessions)); } while (!m_num_sessions.CompareExchangeWeak<std::memory_order_relaxed>(cur_sessions, new_sessions));
} }
/* Atomically update the peak session tracking. */ /* Atomically update the peak session tracking. */
@ -182,7 +181,6 @@ namespace ams::kern {
R_UNLESS(cur_sessions < max, svc::ResultOutOfSessions()); R_UNLESS(cur_sessions < max, svc::ResultOutOfSessions());
new_sessions = cur_sessions + 1; new_sessions = cur_sessions + 1;
} while (!m_num_sessions.CompareExchangeWeak<std::memory_order_relaxed>(cur_sessions, new_sessions)); } while (!m_num_sessions.CompareExchangeWeak<std::memory_order_relaxed>(cur_sessions, new_sessions));
} }
/* Atomically update the peak session tracking. */ /* Atomically update the peak session tracking. */

View File

@ -3624,7 +3624,7 @@ namespace ams::kern {
R_UNLESS(this->Contains(address, size), svc::ResultInvalidCurrentMemory()); R_UNLESS(this->Contains(address, size), svc::ResultInvalidCurrentMemory());
/* Get the source permission. */ /* Get the source permission. */
const auto src_perm = static_cast<KMemoryPermission>((test_perm == KMemoryPermission_UserReadWrite) ? KMemoryPermission_KernelReadWrite | KMemoryPermission_NotMapped : KMemoryPermission_UserRead); const auto src_perm = static_cast<KMemoryPermission>((test_perm == KMemoryPermission_UserReadWrite) ? (KMemoryPermission_KernelReadWrite | KMemoryPermission_NotMapped) : KMemoryPermission_UserRead);
/* Get aligned extents. */ /* Get aligned extents. */
const KProcessAddress aligned_src_start = util::AlignDown(GetInteger(address), PageSize); 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; const size_t src_map_size = src_map_end - src_map_start;
/* Ensure that we clean up appropriately if we fail after this. */ /* Ensure that we clean up appropriately if we fail after this. */
const auto src_perm = static_cast<KMemoryPermission>((test_perm == KMemoryPermission_UserReadWrite) ? KMemoryPermission_KernelReadWrite | KMemoryPermission_NotMapped : KMemoryPermission_UserRead); const auto src_perm = static_cast<KMemoryPermission>((test_perm == KMemoryPermission_UserReadWrite) ? (KMemoryPermission_KernelReadWrite | KMemoryPermission_NotMapped) : KMemoryPermission_UserRead);
ON_RESULT_FAILURE { ON_RESULT_FAILURE {
if (src_map_end > src_map_start) { if (src_map_end > src_map_start) {
src_page_table.CleanupForIpcClientOnServerSetupFailure(updater.GetPageList(), src_map_start, src_map_size, src_perm); 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)); R_TRY(this->Operate(updater.GetPageList(), cur_address, map_pages, cur_pg, map_properties, OperationType_MapFirstGroup, false));
} }
} }

View File

@ -36,7 +36,7 @@ namespace ams::kern {
/* Cleanup the session list. */ /* Cleanup the session list. */
while (true) { while (true) {
/* Get the last session in the list */ /* Get the last session in the list. */
KServerSession *session = nullptr; KServerSession *session = nullptr;
{ {
KScopedSchedulerLock sl; KScopedSchedulerLock sl;
@ -56,7 +56,7 @@ namespace ams::kern {
/* Cleanup the light session list. */ /* Cleanup the light session list. */
while (true) { while (true) {
/* Get the last session in the list */ /* Get the last session in the list. */
KLightServerSession *session = nullptr; KLightServerSession *session = nullptr;
{ {
KScopedSchedulerLock sl; KScopedSchedulerLock sl;

View File

@ -650,7 +650,7 @@ namespace ams::kern {
const auto src_state = src_user ? KMemoryState_FlagReferenceCounted : KMemoryState_FlagLinearMapped; 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. */ /* Determine the source permission. User buffer should be unmapped + read, TLS should be user readable. */
const KMemoryPermission src_perm = static_cast<KMemoryPermission>(src_user ? KMemoryPermission_NotMapped | KMemoryPermission_KernelRead : KMemoryPermission_UserRead); const KMemoryPermission src_perm = static_cast<KMemoryPermission>(src_user ? (KMemoryPermission_NotMapped | KMemoryPermission_KernelRead) : KMemoryPermission_UserRead);
/* Perform the fast part of the copy. */ /* Perform the fast part of the copy. */
R_TRY(src_page_table.CopyMemoryFromLinearToKernel(reinterpret_cast<uintptr_t>(dst_msg_ptr) + offset_words, fast_size, src_message_buffer + offset_words, R_TRY(src_page_table.CopyMemoryFromLinearToKernel(reinterpret_cast<uintptr_t>(dst_msg_ptr) + offset_words, fast_size, src_message_buffer + offset_words,
@ -753,7 +753,7 @@ namespace ams::kern {
/* Perform the pointer data copy. */ /* Perform the pointer data copy. */
const bool dst_heap = dst_user && dst_recv_list.IsToMessageBuffer(); const bool dst_heap = dst_user && dst_recv_list.IsToMessageBuffer();
const auto dst_state = dst_heap ? KMemoryState_FlagReferenceCounted : KMemoryState_FlagLinearMapped; const auto dst_state = dst_heap ? KMemoryState_FlagReferenceCounted : KMemoryState_FlagLinearMapped;
const KMemoryPermission dst_perm = static_cast<KMemoryPermission>(dst_heap ? KMemoryPermission_NotMapped | KMemoryPermission_KernelReadWrite : KMemoryPermission_UserReadWrite); const KMemoryPermission dst_perm = static_cast<KMemoryPermission>(dst_heap ? (KMemoryPermission_NotMapped | KMemoryPermission_KernelReadWrite) : KMemoryPermission_UserReadWrite);
R_TRY(dst_page_table.CopyMemoryFromUserToLinear(recv_pointer, recv_size, R_TRY(dst_page_table.CopyMemoryFromUserToLinear(recv_pointer, recv_size,
dst_state, dst_state, dst_state, dst_state,
dst_perm, dst_perm,
@ -911,7 +911,7 @@ namespace ams::kern {
const auto dst_state = dst_user ? KMemoryState_FlagReferenceCounted : KMemoryState_FlagLinearMapped; 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. */ /* Determine the dst permission. User buffer should be unmapped + read, TLS should be user readable. */
const KMemoryPermission dst_perm = static_cast<KMemoryPermission>(dst_user ? KMemoryPermission_NotMapped | KMemoryPermission_KernelReadWrite : KMemoryPermission_UserReadWrite); const KMemoryPermission dst_perm = static_cast<KMemoryPermission>(dst_user ? (KMemoryPermission_NotMapped | KMemoryPermission_KernelReadWrite) : KMemoryPermission_UserReadWrite);
/* Perform the fast part of the copy. */ /* Perform the fast part of the copy. */
R_TRY(dst_page_table.CopyMemoryFromKernelToLinear(dst_message_buffer + offset_words, fast_size, R_TRY(dst_page_table.CopyMemoryFromKernelToLinear(dst_message_buffer + offset_words, fast_size,

View File

@ -143,7 +143,7 @@ namespace ams::kern::svc {
/* Get the process page table. */ /* Get the process page table. */
auto &page_table = GetCurrentProcess().GetPageTable(); auto &page_table = GetCurrentProcess().GetPageTable();
/* Lock the mesage buffer. */ /* Lock the message buffer. */
R_TRY(page_table.LockForIpcUserBuffer(nullptr, message, buffer_size)); R_TRY(page_table.LockForIpcUserBuffer(nullptr, message, buffer_size));
{ {
@ -186,7 +186,7 @@ namespace ams::kern::svc {
/* Commit our reservation. */ /* Commit our reservation. */
event_reservation.Commit(); 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 { ON_SCOPE_EXIT {
event->GetReadableEvent().Close(); event->GetReadableEvent().Close();
event->Close(); event->Close();
@ -215,7 +215,7 @@ namespace ams::kern::svc {
/* Get the process page table. */ /* Get the process page table. */
auto &page_table = GetCurrentProcess().GetPageTable(); auto &page_table = GetCurrentProcess().GetPageTable();
/* Lock the mesage buffer. */ /* Lock the message buffer. */
R_TRY(page_table.LockForIpcUserBuffer(nullptr, message, buffer_size)); R_TRY(page_table.LockForIpcUserBuffer(nullptr, message, buffer_size));
/* Ensure that if we fail and aren't terminating that we unlock the user buffer. */ /* 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. */ /* Get the process page table. */
auto &page_table = GetCurrentProcess().GetPageTable(); auto &page_table = GetCurrentProcess().GetPageTable();
/* Lock the mesage buffer, getting its physical address. */ /* Lock the message buffer, getting its physical address. */
KPhysicalAddress message_paddr; KPhysicalAddress message_paddr;
R_TRY(page_table.LockForIpcUserBuffer(std::addressof(message_paddr), message, buffer_size)); R_TRY(page_table.LockForIpcUserBuffer(std::addressof(message_paddr), message, buffer_size));

View File

@ -96,7 +96,7 @@ namespace ams::kern::svc {
/* Add the client to the handle table. */ /* Add the client to the handle table. */
R_TRY(handle_table.Add(out_client, std::addressof(port->GetClientPort()))); 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); }; ON_RESULT_FAILURE { handle_table.Remove(*out_client); };
/* Add the server to the handle table. */ /* Add the server to the handle table. */