kernel: prefer std::addressof

This commit is contained in:
Liam
2023-03-07 12:01:07 -05:00
parent 641783df8f
commit ac6cbb7134
21 changed files with 139 additions and 134 deletions

View File

@ -153,7 +153,7 @@ Result GetInfo(Core::System& system, u64* result, InfoType info_id_type, Handle
}
Handle resource_handle{};
R_TRY(handle_table.Add(&resource_handle, resource_limit));
R_TRY(handle_table.Add(std::addressof(resource_handle), resource_limit));
*result = resource_handle;
R_SUCCEED();
@ -234,7 +234,7 @@ Result GetInfo(Core::System& system, u64* result, InfoType info_id_type, Handle
// Get a new handle for the current process.
Handle tmp;
R_TRY(handle_table.Add(&tmp, current_process));
R_TRY(handle_table.Add(std::addressof(tmp), current_process));
// Set the output.
*result = tmp;

View File

@ -79,7 +79,7 @@ Result ReplyAndReceive(Core::System& system, s32* out_index, uint64_t handles_ad
while (true) {
// Wait for an object.
s32 index;
Result result = KSynchronizationObject::Wait(kernel, &index, objs.data(),
Result result = KSynchronizationObject::Wait(kernel, std::addressof(index), objs.data(),
static_cast<s32>(objs.size()), timeout_ns);
if (result == ResultTimedOut) {
R_RETURN(result);

View File

@ -33,7 +33,7 @@ Result QueryProcessMemory(Core::System& system, uint64_t out_memory_info, PageIn
auto& memory{system.Memory()};
const auto memory_info{process->PageTable().QueryInfo(address).GetSvcMemoryInfo()};
memory.WriteBlock(out_memory_info, &memory_info, sizeof(memory_info));
memory.WriteBlock(out_memory_info, std::addressof(memory_info), sizeof(memory_info));
//! This is supposed to be part of the QueryInfo call.
*out_page_info = {};

View File

@ -21,7 +21,7 @@ Result CreateResourceLimit(Core::System& system, Handle* out_handle) {
SCOPE_EXIT({ resource_limit->Close(); });
// Initialize the resource limit.
resource_limit->Initialize(&system.CoreTiming());
resource_limit->Initialize(std::addressof(system.CoreTiming()));
// Register the limit.
KResourceLimit::Register(kernel, resource_limit);

View File

@ -29,7 +29,7 @@ void SvcWrap_CallSecureMonitor64(Core::System& system) {
args.r[i] = core.GetReg(i);
}
CallSecureMonitor64(system, &args);
CallSecureMonitor64(system, std::addressof(args));
for (int i = 0; i < 8; i++) {
core.SetReg(i, args.r[i]);
@ -43,7 +43,7 @@ void SvcWrap_CallSecureMonitor64From32(Core::System& system) {
args.r[i] = static_cast<u32>(core.GetReg(i));
}
CallSecureMonitor64From32(system, &args);
CallSecureMonitor64From32(system, std::addressof(args));
for (int i = 0; i < 8; i++) {
core.SetReg(i, args.r[i]);

View File

@ -21,7 +21,8 @@ Result CreateSession(Core::System& system, Handle* out_server, Handle* out_clien
// Reserve a new session from the process resource limit.
// FIXME: LimitableResource_SessionCountMax
KScopedResourceReservation session_reservation(&process, LimitableResource::SessionCountMax);
KScopedResourceReservation session_reservation(std::addressof(process),
LimitableResource::SessionCountMax);
if (session_reservation.Succeeded()) {
session = T::Create(system.Kernel());
} else {
@ -30,7 +31,7 @@ Result CreateSession(Core::System& system, Handle* out_server, Handle* out_clien
// // We couldn't reserve a session. Check that we support dynamically expanding the
// // resource limit.
// R_UNLESS(process.GetResourceLimit() ==
// &system.Kernel().GetSystemResourceLimit(), ResultLimitReached);
// std::addressof(system.Kernel().GetSystemResourceLimit()), ResultLimitReached);
// R_UNLESS(KTargetSystem::IsDynamicResourceLimitsEnabled(), ResultLimitReached());
// // Try to allocate a session from unused slab memory.
@ -75,7 +76,7 @@ Result CreateSession(Core::System& system, Handle* out_server, Handle* out_clien
T::Register(system.Kernel(), session);
// Add the server session to the handle table.
R_TRY(handle_table.Add(out_server, &session->GetServerSession()));
R_TRY(handle_table.Add(out_server, std::addressof(session->GetServerSession())));
// Ensure that we maintain a clean handle state on exit.
ON_RESULT_FAILURE {
@ -83,7 +84,7 @@ Result CreateSession(Core::System& system, Handle* out_server, Handle* out_clien
};
// Add the client session to the handle table.
R_RETURN(handle_table.Add(out_client, &session->GetClientSession()));
R_RETURN(handle_table.Add(out_client, std::addressof(session->GetClientSession())));
}
} // namespace

View File

@ -42,9 +42,9 @@ Result CreateThread(Core::System& system, Handle* out_handle, VAddr entry_point,
R_UNLESS(process.CheckThreadPriority(priority), ResultInvalidPriority);
// Reserve a new thread from the process resource limit (waiting up to 100ms).
KScopedResourceReservation thread_reservation(&process, LimitableResource::ThreadCountMax, 1,
system.CoreTiming().GetGlobalTimeNs().count() +
100000000);
KScopedResourceReservation thread_reservation(
std::addressof(process), LimitableResource::ThreadCountMax, 1,
system.CoreTiming().GetGlobalTimeNs().count() + 100000000);
R_UNLESS(thread_reservation.Succeeded(), ResultLimitReached);
// Create the thread.
@ -56,7 +56,7 @@ Result CreateThread(Core::System& system, Handle* out_handle, VAddr entry_point,
{
KScopedLightLock lk{process.GetStateLock()};
R_TRY(KThread::InitializeUserThread(system, thread, entry_point, arg, stack_bottom,
priority, core_id, &process));
priority, core_id, std::addressof(process)));
}
// Set the thread name for debugging purposes.

View File

@ -43,7 +43,7 @@ Result CreateTransferMemory(Core::System& system, Handle* out, VAddr address, u6
auto& handle_table = process.GetHandleTable();
// Reserve a new transfer memory from the process resource limit.
KScopedResourceReservation trmem_reservation(&process,
KScopedResourceReservation trmem_reservation(std::addressof(process),
LimitableResource::TransferMemoryCountMax);
R_UNLESS(trmem_reservation.Succeeded(), ResultLimitReached);