From c7b841056e61faefd0d9ffb28dd6d9229e173c78 Mon Sep 17 00:00:00 2001 From: lizzie Date: Wed, 18 Mar 2026 00:08:19 +0000 Subject: [PATCH] fix pragma once in even MORE core stuff --- src/core/file_sys/fs_save_data_types.h | 2 +- src/core/file_sys/fsmitm_romfsbuild.cpp | 3 +++ src/core/file_sys/fsmitm_romfsbuild.h | 3 +++ src/core/hle/kernel/svc/svc_memory.cpp | 22 +++++++++---------- .../hle/kernel/svc/svc_process_memory.cpp | 6 ++--- .../hle/service/olsc/native_handle_holder.h | 2 ++ .../olsc/transfer_task_list_controller.h | 2 ++ src/core/hle/service/ro/ro_results.h | 3 +++ 8 files changed, 28 insertions(+), 15 deletions(-) diff --git a/src/core/file_sys/fs_save_data_types.h b/src/core/file_sys/fs_save_data_types.h index 133494bb1c..f164293544 100644 --- a/src/core/file_sys/fs_save_data_types.h +++ b/src/core/file_sys/fs_save_data_types.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project diff --git a/src/core/file_sys/fsmitm_romfsbuild.cpp b/src/core/file_sys/fsmitm_romfsbuild.cpp index 5652aa1947..fffb8b5f37 100644 --- a/src/core/file_sys/fsmitm_romfsbuild.cpp +++ b/src/core/file_sys/fsmitm_romfsbuild.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later diff --git a/src/core/file_sys/fsmitm_romfsbuild.h b/src/core/file_sys/fsmitm_romfsbuild.h index 35f02d0d09..38bf8749e8 100644 --- a/src/core/file_sys/fsmitm_romfsbuild.h +++ b/src/core/file_sys/fsmitm_romfsbuild.h @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later diff --git a/src/core/hle/kernel/svc/svc_memory.cpp b/src/core/hle/kernel/svc/svc_memory.cpp index 740e11ff87..b79396abba 100644 --- a/src/core/hle/kernel/svc/svc_memory.cpp +++ b/src/core/hle/kernel/svc/svc_memory.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project @@ -11,7 +11,11 @@ namespace Kernel::Svc { namespace { -constexpr bool IsValidSetMemoryPermission(MemoryPermission perm) { +[[nodiscard]] inline constexpr bool IsValidSetAddressRange(u64 address, u64 size) { + return address + size > address; +} + +[[nodiscard]] inline constexpr bool IsValidSetMemoryPermission(MemoryPermission perm) { switch (perm) { case MemoryPermission::None: case MemoryPermission::Read: @@ -22,13 +26,6 @@ constexpr bool IsValidSetMemoryPermission(MemoryPermission perm) { } } -// Checks if address + size is greater than the given address -// This can return false if the size causes an overflow of a 64-bit type -// or if the given size is zero. -constexpr bool IsValidAddressRange(u64 address, u64 size) { - return address + size > address; -} - // Helper function that performs the common sanity checks for svcMapMemory // and svcUnmapMemory. This is doable, as both functions perform their sanitizing // in the same order. @@ -54,14 +51,17 @@ Result MapUnmapMemorySanityChecks(const KProcessPageTable& manager, u64 dst_addr R_THROW(ResultInvalidSize); } - if (!IsValidAddressRange(dst_addr, size)) { + // Checks if address + size is greater than the given address + // This can return false if the size causes an overflow of a 64-bit type + // or if the given size is zero. + if (!IsValidSetAddressRange(dst_addr, size)) { LOG_ERROR(Kernel_SVC, "Destination is not a valid address range, addr=0x{:016X}, size=0x{:016X}", dst_addr, size); R_THROW(ResultInvalidCurrentMemory); } - if (!IsValidAddressRange(src_addr, size)) { + if (!IsValidSetAddressRange(src_addr, size)) { LOG_ERROR(Kernel_SVC, "Source is not a valid address range, addr=0x{:016X}, size=0x{:016X}", src_addr, size); R_THROW(ResultInvalidCurrentMemory); diff --git a/src/core/hle/kernel/svc/svc_process_memory.cpp b/src/core/hle/kernel/svc/svc_process_memory.cpp index 3313118dfa..fe3b14b2ba 100644 --- a/src/core/hle/kernel/svc/svc_process_memory.cpp +++ b/src/core/hle/kernel/svc/svc_process_memory.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project @@ -11,11 +11,11 @@ namespace Kernel::Svc { namespace { -constexpr bool IsValidAddressRange(u64 address, u64 size) { +[[nodiscard]] inline constexpr bool IsValidAddressRange(u64 address, u64 size) { return address + size > address; } -constexpr bool IsValidProcessMemoryPermission(Svc::MemoryPermission perm) { +[[nodiscard]] inline constexpr bool IsValidProcessMemoryPermission(Svc::MemoryPermission perm) { switch (perm) { case Svc::MemoryPermission::None: case Svc::MemoryPermission::Read: diff --git a/src/core/hle/service/olsc/native_handle_holder.h b/src/core/hle/service/olsc/native_handle_holder.h index 985c60d1cb..e0eac50c28 100644 --- a/src/core/hle/service/olsc/native_handle_holder.h +++ b/src/core/hle/service/olsc/native_handle_holder.h @@ -4,6 +4,8 @@ // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#pragma once + #include "core/hle/service/cmif_types.h" #include "core/hle/service/service.h" diff --git a/src/core/hle/service/olsc/transfer_task_list_controller.h b/src/core/hle/service/olsc/transfer_task_list_controller.h index 72dbf610d8..4ac770b477 100644 --- a/src/core/hle/service/olsc/transfer_task_list_controller.h +++ b/src/core/hle/service/olsc/transfer_task_list_controller.h @@ -4,6 +4,8 @@ // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#pragma once + #include "core/hle/service/cmif_types.h" #include "core/hle/service/service.h" diff --git a/src/core/hle/service/ro/ro_results.h b/src/core/hle/service/ro/ro_results.h index 1f96caa15c..906378bc7f 100644 --- a/src/core/hle/service/ro/ro_results.h +++ b/src/core/hle/service/ro/ro_results.h @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later