ams: replace most remaining operator & with std::addressof

This commit is contained in:
Michael Scire
2021-10-09 14:49:53 -07:00
parent ce8aacef21
commit 1ab0bd1765
109 changed files with 587 additions and 586 deletions

View File

@@ -78,10 +78,10 @@ namespace ams::emummc {
struct {
char file_path[MaxDirLen + 1];
char nintendo_path[MaxDirLen + 1];
} *paths = reinterpret_cast<decltype(paths)>(&path_storage);
} *paths = reinterpret_cast<decltype(paths)>(std::addressof(path_storage));
/* Retrieve paths from secure monitor. */
AMS_ABORT_UNLESS(spl::smc::AtmosphereGetEmummcConfig(&g_exo_config, paths, 0) == spl::smc::Result::Success);
AMS_ABORT_UNLESS(spl::smc::AtmosphereGetEmummcConfig(std::addressof(g_exo_config), paths, 0) == spl::smc::Result::Success);
const Storage storage = static_cast<Storage>(g_exo_config.base_cfg.type);
g_is_emummc = g_exo_config.base_cfg.magic == StorageMagic && storage != Storage_Emmc;

View File

@@ -113,7 +113,7 @@ namespace ams {
svc::lp64::MemoryInfo mem_info;
svc::PageInfo page_info;
if (R_SUCCEEDED(svc::QueryMemory(std::addressof(mem_info), std::addressof(page_info), cur_fp)) && (mem_info.permission & svc::MemoryPermission_Read) == svc::MemoryPermission_Read) {
std::memcpy(&cur_frame, reinterpret_cast<void *>(cur_fp), sizeof(cur_frame));
std::memcpy(std::addressof(cur_frame), reinterpret_cast<void *>(cur_fp), sizeof(cur_frame));
} else {
break;
}
@@ -145,7 +145,7 @@ namespace ams {
}
/* Just call the user exception handler. */
::ams::ExceptionHandler(&ams_ctx);
::ams::ExceptionHandler(std::addressof(ams_ctx));
}
NORETURN void AbortImpl();

View File

@@ -21,7 +21,7 @@ namespace ams::exosphere {
ApiInfo GetApiInfo() {
u64 exosphere_cfg;
if (spl::smc::GetConfig(&exosphere_cfg, 1, spl::ConfigItem::ExosphereApiVersion) != spl::smc::Result::Success) {
if (spl::smc::GetConfig(std::addressof(exosphere_cfg), 1, spl::ConfigItem::ExosphereApiVersion) != spl::smc::Result::Success) {
R_ABORT_UNLESS(ResultNotPresent());
}

View File

@@ -143,7 +143,7 @@ namespace ams::boot2 {
if (IsAllowedLaunchProgram(loc)) {
/* Launch, lightly validate result. */
{
const auto launch_result = pm::shell::LaunchProgram(&process_id, loc, launch_flags);
const auto launch_result = pm::shell::LaunchProgram(std::addressof(process_id), loc, launch_flags);
AMS_ABORT_UNLESS(!(svc::ResultOutOfResource::Includes(launch_result)));
AMS_ABORT_UNLESS(!(svc::ResultOutOfMemory::Includes(launch_result)));
AMS_ABORT_UNLESS(!(svc::ResultLimitReached::Includes(launch_result)));
@@ -178,13 +178,13 @@ namespace ams::boot2 {
bool IsForceMaintenance() {
u8 force_maintenance = 1;
settings::fwdbg::GetSettingsItemValue(&force_maintenance, sizeof(force_maintenance), "boot", "force_maintenance");
settings::fwdbg::GetSettingsItemValue(std::addressof(force_maintenance), sizeof(force_maintenance), "boot", "force_maintenance");
return force_maintenance != 0;
}
bool IsHtcEnabled() {
u8 enable_htc = 0;
settings::fwdbg::GetSettingsItemValue(&enable_htc, sizeof(enable_htc), "atmosphere", "enable_htc");
settings::fwdbg::GetSettingsItemValue(std::addressof(enable_htc), sizeof(enable_htc), "atmosphere", "enable_htc");
return enable_htc != 0;
}
@@ -195,7 +195,7 @@ namespace ams::boot2 {
}
u8 enable_ams_lm = 0;
settings::fwdbg::GetSettingsItemValue(&enable_ams_lm, sizeof(enable_ams_lm), "atmosphere", "enable_log_manager");
settings::fwdbg::GetSettingsItemValue(std::addressof(enable_ams_lm), sizeof(enable_ams_lm), "atmosphere", "enable_log_manager");
return enable_ams_lm != 0;
}
@@ -215,7 +215,7 @@ namespace ams::boot2 {
void IterateOverFlaggedProgramsOnSdCard(F f) {
/* Validate that the contents directory exists. */
fs::DirectoryHandle contents_dir;
if (R_FAILED(fs::OpenDirectory(&contents_dir, "sdmc:/atmosphere/contents", fs::OpenDirectoryMode_Directory))) {
if (R_FAILED(fs::OpenDirectory(std::addressof(contents_dir), "sdmc:/atmosphere/contents", fs::OpenDirectoryMode_Directory))) {
return;
}
ON_SCOPE_EXIT { fs::CloseDirectory(contents_dir); };
@@ -223,7 +223,7 @@ namespace ams::boot2 {
/* Iterate over entries in the contents directory */
fs::DirectoryEntry entry;
s64 count;
while (R_SUCCEEDED(fs::ReadDirectory(&count, &entry, contents_dir, 1)) && count == 1) {
while (R_SUCCEEDED(fs::ReadDirectory(std::addressof(count), std::addressof(entry), contents_dir, 1)) && count == 1) {
/* Check that the subdirectory can be converted to a program id. */
if (std::strlen(entry.name) == 2 * sizeof(ncm::ProgramId) && IsHexadecimal(entry.name)) {
/* Check if we've already launched the program. */
@@ -252,12 +252,12 @@ namespace ams::boot2 {
util::SNPrintf(path, sizeof(path), "sdmc:/atmosphere/contents/%016lx/mitm.lst", static_cast<u64>(program_id));
fs::FileHandle f;
if (R_FAILED(fs::OpenFile(&f, path, fs::OpenMode_Read))) {
if (R_FAILED(fs::OpenFile(std::addressof(f), path, fs::OpenMode_Read))) {
return;
}
ON_SCOPE_EXIT { fs::CloseFile(f); };
R_ABORT_UNLESS(fs::ReadFile(&mitm_list_size, f, 0, mitm_list, sizeof(mitm_list)));
R_ABORT_UNLESS(fs::ReadFile(std::addressof(mitm_list_size), f, 0, mitm_list, sizeof(mitm_list)));
}
/* Validate read size. */
@@ -352,7 +352,7 @@ namespace ams::boot2 {
/* Retrieve setting from the database. */
u8 force_maintenance = 0;
settings::fwdbg::GetSettingsItemValue(&force_maintenance, sizeof(force_maintenance), "boot", "force_maintenance");
settings::fwdbg::GetSettingsItemValue(std::addressof(force_maintenance), sizeof(force_maintenance), "boot", "force_maintenance");
}
/* Launch pcv. */

View File

@@ -121,7 +121,7 @@ namespace ams::capsrv::server::jpeg {
cinfo.do_block_smoothing = input.block_smoothing;
/* Start decompression. */
R_UNLESS(jpeg_start_decompress(&cinfo) == TRUE, capsrv::ResultAlbumInvalidFileData());
R_UNLESS(jpeg_start_decompress(std::addressof(cinfo)) == TRUE, capsrv::ResultAlbumInvalidFileData());
/* Check the parameters. */
CAPSRV_ASSERT(cinfo.output_width == input.width);
@@ -169,7 +169,7 @@ namespace ams::capsrv::server::jpeg {
}
/* Finish the decompression. */
R_UNLESS(jpeg_finish_decompress(&cinfo) == TRUE, capsrv::ResultAlbumInvalidFileData());
R_UNLESS(jpeg_finish_decompress(std::addressof(cinfo)) == TRUE, capsrv::ResultAlbumInvalidFileData());
} else {
/* Some unknown error was caught by our handler. */
return capsrv::ResultAlbumInvalidFileData();

View File

@@ -373,9 +373,9 @@ namespace ams::cfg {
.override_key = g_default_override_key,
.cheat_enable_key = g_default_cheat_enable_key,
};
std::memset(&config.locale, 0xCC, sizeof(config.locale));
std::memset(std::addressof(config.locale), 0xCC, sizeof(config.locale));
ParseIniFile(ContentSpecificIniHandler, path, &config);
ParseIniFile(ContentSpecificIniHandler, path, std::addressof(config));
return config;
}
@@ -399,7 +399,7 @@ namespace ams::cfg {
RefreshOverrideConfiguration();
/* If we can't read the key state, don't override anything. */
if (R_FAILED(hid::GetKeysHeld(&status.keys_held))) {
if (R_FAILED(hid::GetKeysHeld(std::addressof(status.keys_held)))) {
return status;
}

View File

@@ -37,7 +37,7 @@ namespace ams::cfg {
Result CheckSdCardServicesReady() {
for (size_t i = 0; i < NumRequiredServicesForSdCardAccess; i++) {
bool service_present = false;
R_TRY(sm::HasService(&service_present, RequiredServicesForSdCardAccess[i]));
R_TRY(sm::HasService(std::addressof(service_present), RequiredServicesForSdCardAccess[i]));
if (!service_present) {
return fs::ResultSdCardNotPresent();
}
@@ -54,14 +54,14 @@ namespace ams::cfg {
Result TryInitializeSdCard() {
R_TRY(CheckSdCardServicesReady());
R_ABORT_UNLESS(fsOpenSdCardFileSystem(&g_sd_card_filesystem));
R_ABORT_UNLESS(fsOpenSdCardFileSystem(std::addressof(g_sd_card_filesystem)));
g_sd_card_initialized = true;
return ResultSuccess();
}
void InitializeSdCard() {
WaitSdCardServicesReadyImpl();
R_ABORT_UNLESS(fsOpenSdCardFileSystem(&g_sd_card_filesystem));
R_ABORT_UNLESS(fsOpenSdCardFileSystem(std::addressof(g_sd_card_filesystem)));
g_sd_card_initialized = true;
}

View File

@@ -42,7 +42,7 @@ namespace ams::fssrv::impl {
R_UNLESS(size >= 0, fs::ResultInvalidSize());
size_t read_size = 0;
R_TRY(this->base_file->Read(&read_size, offset, buffer.GetPointer(), static_cast<size_t>(size), option));
R_TRY(this->base_file->Read(std::addressof(read_size), offset, buffer.GetPointer(), static_cast<size_t>(size), option));
out.SetValue(read_size);
return ResultSuccess();
@@ -82,7 +82,7 @@ namespace ams::fssrv::impl {
auto read_lock = this->parent_filesystem->AcquireCacheInvalidationReadLock();
fs::FileQueryRangeInfo info;
R_TRY(this->base_file->OperateRange(&info, sizeof(info), fs::OperationId::QueryRange, offset, size, nullptr, 0));
R_TRY(this->base_file->OperateRange(std::addressof(info), sizeof(info), fs::OperationId::QueryRange, offset, size, nullptr, 0));
out->Merge(info);
}
@@ -268,7 +268,7 @@ namespace ams::fssrv::impl {
/* TODO: N retries on fs::ResultDataCorrupted, we may want to eventually. */
std::unique_ptr<fs::fsa::IFile> file;
R_TRY(this->base_fs->OpenFile(&file, normalizer.GetPath(), static_cast<fs::OpenMode>(mode)));
R_TRY(this->base_fs->OpenFile(std::addressof(file), normalizer.GetPath(), static_cast<fs::OpenMode>(mode)));
/* TODO: This is a hack to get the mitm API to work. Better solution? */
const auto target_object_id = file->GetDomainObjectId();
@@ -296,7 +296,7 @@ namespace ams::fssrv::impl {
/* TODO: N retries on fs::ResultDataCorrupted, we may want to eventually. */
std::unique_ptr<fs::fsa::IDirectory> dir;
R_TRY(this->base_fs->OpenDirectory(&dir, normalizer.GetPath(), static_cast<fs::OpenDirectoryMode>(mode)));
R_TRY(this->base_fs->OpenDirectory(std::addressof(dir), normalizer.GetPath(), static_cast<fs::OpenDirectoryMode>(mode)));
/* TODO: This is a hack to get the mitm API to work. Better solution? */
const auto target_object_id = dir->GetDomainObjectId();

View File

@@ -84,7 +84,7 @@ namespace ams::fssrv::impl {
auto read_lock = this->AcquireCacheInvalidationReadLock();
fs::StorageQueryRangeInfo info;
R_TRY(this->base_storage->OperateRange(&info, sizeof(info), fs::OperationId::QueryRange, offset, size, nullptr, 0));
R_TRY(this->base_storage->OperateRange(std::addressof(info), sizeof(info), fs::OperationId::QueryRange, offset, size, nullptr, 0));
out->Merge(info);
}

View File

@@ -96,7 +96,7 @@ namespace ams::fssystem {
fs::DirectoryEntryType type;
/* Check that the working directory exists. */
R_TRY_CATCH(this->base_fs->GetEntryType(&type, WorkingDirectoryPath)) {
R_TRY_CATCH(this->base_fs->GetEntryType(std::addressof(type), WorkingDirectoryPath)) {
/* If path isn't found, create working directory and committed directory. */
R_CATCH(fs::ResultPathNotFound) {
R_TRY(this->base_fs->CreateDirectory(WorkingDirectoryPath));
@@ -105,7 +105,7 @@ namespace ams::fssystem {
} R_END_TRY_CATCH;
/* Now check for the committed directory. */
R_TRY_CATCH(this->base_fs->GetEntryType(&type, CommittedDirectoryPath)) {
R_TRY_CATCH(this->base_fs->GetEntryType(std::addressof(type), CommittedDirectoryPath)) {
/* Committed doesn't exist, so synchronize and rename. */
R_CATCH(fs::ResultPathNotFound) {
R_TRY(this->SynchronizeDirectory(SynchronizingDirectoryPath, WorkingDirectoryPath));
@@ -148,7 +148,7 @@ namespace ams::fssystem {
/* Get a work buffer to work with. */
std::unique_ptr<u8[]> work_buf;
size_t work_buf_size;
R_TRY(this->AllocateWorkBuffer(&work_buf, &work_buf_size, IdealWorkBufferSize));
R_TRY(this->AllocateWorkBuffer(std::addressof(work_buf), std::addressof(work_buf_size), IdealWorkBufferSize));
/* Copy the directory recursively. */
return fssystem::CopyDirectoryRecursively(this->base_fs, dst, src, work_buf.get(), work_buf_size);
@@ -165,7 +165,7 @@ namespace ams::fssystem {
/* Normalize it. */
constexpr size_t WorkingDirectoryPathLength = sizeof(WorkingDirectoryPath) - 1;
size_t normalized_length;
return fs::PathNormalizer::Normalize(out + WorkingDirectoryPathLength - 1, &normalized_length, relative_path, out_size - (WorkingDirectoryPathLength - 1));
return fs::PathNormalizer::Normalize(out + WorkingDirectoryPathLength - 1, std::addressof(normalized_length), relative_path, out_size - (WorkingDirectoryPathLength - 1));
}
void DirectorySaveDataFileSystem::OnWritableFileClose() {
@@ -183,7 +183,7 @@ namespace ams::fssystem {
/* Get a work buffer to work with. */
std::unique_ptr<u8[]> work_buf;
size_t work_buf_size;
R_TRY(this->AllocateWorkBuffer(&work_buf, &work_buf_size, IdealWorkBufferSize));
R_TRY(this->AllocateWorkBuffer(std::addressof(work_buf), std::addressof(work_buf_size), IdealWorkBufferSize));
/* Copy the directory recursively. */
R_TRY(fssystem::CopyDirectoryRecursively(this->base_fs, save_fs, fs::PathNormalizer::RootPath, fs::PathNormalizer::RootPath, work_buf.get(), work_buf_size));
@@ -198,7 +198,7 @@ namespace ams::fssystem {
std::scoped_lock lk(this->accessor_mutex);
std::unique_ptr<fs::fsa::IFile> base_file;
R_TRY(this->base_fs->OpenFile(&base_file, full_path, mode));
R_TRY(this->base_fs->OpenFile(std::addressof(base_file), full_path, mode));
std::unique_ptr<DirectorySaveDataFile> file(new (std::nothrow) DirectorySaveDataFile(std::move(base_file), this, mode));
R_UNLESS(file != nullptr, fs::ResultAllocationFailureInDirectorySaveDataFileSystem());

View File

@@ -72,7 +72,7 @@ namespace ams::fssystem {
Result CopyFile(fs::fsa::IFileSystem *dst_fs, fs::fsa::IFileSystem *src_fs, const char *dst_parent_path, const char *src_path, const fs::DirectoryEntry *entry, void *work_buf, size_t work_buf_size) {
/* Open source file. */
std::unique_ptr<fs::fsa::IFile> src_file;
R_TRY(src_fs->OpenFile(&src_file, src_path, fs::OpenMode_Read));
R_TRY(src_fs->OpenFile(std::addressof(src_file), src_path, fs::OpenMode_Read));
/* Open dst file. */
std::unique_ptr<fs::fsa::IFile> dst_file;
@@ -83,7 +83,7 @@ namespace ams::fssystem {
AMS_ABORT_UNLESS(original_size < sizeof(dst_path));
R_TRY(dst_fs->CreateFile(dst_path, entry->file_size));
R_TRY(dst_fs->OpenFile(&dst_file, dst_path, fs::OpenMode_Write));
R_TRY(dst_fs->OpenFile(std::addressof(dst_file), dst_path, fs::OpenMode_Write));
}
/* Read/Write file in work buffer sized chunks. */
@@ -91,7 +91,7 @@ namespace ams::fssystem {
s64 offset = 0;
while (remaining > 0) {
size_t read_size;
R_TRY(src_file->Read(&read_size, offset, work_buf, work_buf_size, fs::ReadOption()));
R_TRY(src_file->Read(std::addressof(read_size), offset, work_buf, work_buf_size, fs::ReadOption()));
R_TRY(dst_file->Write(offset, work_buf, read_size, fs::WriteOption()));
remaining -= read_size;
@@ -132,7 +132,7 @@ namespace ams::fssystem {
return ResultSuccess();
},
[&](const char *path, const fs::DirectoryEntry &entry) -> Result { /* On File */
return CopyFile(dst_fs, src_fs, dst_path_buf, path, &entry, work_buf, work_buf_size);
return CopyFile(dst_fs, src_fs, dst_path_buf, path, std::addressof(entry), work_buf, work_buf_size);
}
);
}

View File

@@ -87,7 +87,7 @@ namespace ams::kvdb {
/* Read and validate header. */
ArchiveHeader header;
R_TRY(this->Read(&header, sizeof(header)));
R_TRY(this->Read(std::addressof(header), sizeof(header)));
R_TRY(header.Validate());
*out = header.entry_count;
@@ -100,7 +100,7 @@ namespace ams::kvdb {
/* Peek the next entry header. */
ArchiveEntryHeader header;
R_TRY(this->Peek(&header, sizeof(header)));
R_TRY(this->Peek(std::addressof(header), sizeof(header)));
R_TRY(header.Validate());
*out_key_size = header.key_size;
@@ -114,7 +114,7 @@ namespace ams::kvdb {
/* Read the next entry header. */
ArchiveEntryHeader header;
R_TRY(this->Read(&header, sizeof(header)));
R_TRY(this->Read(std::addressof(header), sizeof(header)));
R_TRY(header.Validate());
/* Key size and Value size must be correct. */
@@ -142,7 +142,7 @@ namespace ams::kvdb {
AMS_ABORT_UNLESS(this->offset == 0);
ArchiveHeader header = ArchiveHeader::Make(entry_count);
R_ABORT_UNLESS(this->Write(&header, sizeof(header)));
R_ABORT_UNLESS(this->Write(std::addressof(header), sizeof(header)));
}
void ArchiveWriter::WriteEntry(const void *key, size_t key_size, const void *value, size_t value_size) {
@@ -150,7 +150,7 @@ namespace ams::kvdb {
AMS_ABORT_UNLESS(this->offset != 0);
ArchiveEntryHeader header = ArchiveEntryHeader::Make(key_size, value_size);
R_ABORT_UNLESS(this->Write(&header, sizeof(header)));
R_ABORT_UNLESS(this->Write(std::addressof(header), sizeof(header)));
R_ABORT_UNLESS(this->Write(key, key_size));
R_ABORT_UNLESS(this->Write(value, value_size));
}

View File

@@ -24,12 +24,12 @@ namespace ams::ldr::pm {
}
Result GetProgramInfo(ProgramInfo *out, const ncm::ProgramLocation &loc) {
return ldrPmGetProgramInfo(reinterpret_cast<const NcmProgramLocation *>(&loc), reinterpret_cast<LoaderProgramInfo *>(out));
return ldrPmGetProgramInfo(reinterpret_cast<const NcmProgramLocation *>(std::addressof(loc)), reinterpret_cast<LoaderProgramInfo *>(out));
}
Result PinProgram(PinId *out, const ncm::ProgramLocation &loc) {
static_assert(sizeof(*out) == sizeof(u64), "PinId definition!");
return ldrPmPinProgram(reinterpret_cast<const NcmProgramLocation *>(&loc), reinterpret_cast<u64 *>(out));
return ldrPmPinProgram(reinterpret_cast<const NcmProgramLocation *>(std::addressof(loc)), reinterpret_cast<u64 *>(out));
}
Result UnpinProgram(PinId pin_id) {
@@ -42,7 +42,7 @@ namespace ams::ldr::pm {
Result AtmosphereGetProgramInfo(ProgramInfo *out, cfg::OverrideStatus *out_status, const ncm::ProgramLocation &loc) {
static_assert(sizeof(*out_status) == sizeof(CfgOverrideStatus), "CfgOverrideStatus definition!");
return ldrPmAtmosphereGetProgramInfo(reinterpret_cast<LoaderProgramInfo *>(out), reinterpret_cast<CfgOverrideStatus *>(out_status), reinterpret_cast<const NcmProgramLocation *>(&loc));
return ldrPmAtmosphereGetProgramInfo(reinterpret_cast<LoaderProgramInfo *>(out), reinterpret_cast<CfgOverrideStatus *>(out_status), reinterpret_cast<const NcmProgramLocation *>(std::addressof(loc)));
}
Result SetEnabledProgramVerification(bool enabled) {
@@ -52,7 +52,7 @@ namespace ams::ldr::pm {
Result AtmospherePinProgram(PinId *out, const ncm::ProgramLocation &loc, const cfg::OverrideStatus &status) {
static_assert(sizeof(*out) == sizeof(u64), "PinId definition!");
static_assert(sizeof(status) == sizeof(CfgOverrideStatus), "CfgOverrideStatus definition!");
return ldrPmAtmospherePinProgram(reinterpret_cast<u64 *>(out), reinterpret_cast<const NcmProgramLocation *>(&loc), reinterpret_cast<const CfgOverrideStatus *>(&status));
return ldrPmAtmospherePinProgram(reinterpret_cast<u64 *>(out), reinterpret_cast<const NcmProgramLocation *>(std::addressof(loc)), reinterpret_cast<const CfgOverrideStatus *>(std::addressof(status)));
}
}

View File

@@ -43,10 +43,10 @@ namespace ams::lm {
u64 pid_placeholder = 0;
#define NX_SERVICE_ASSUME_NON_DOMAIN
R_TRY(serviceDispatchIn(&m_srv, 0, pid_placeholder,
R_TRY(serviceDispatchIn(std::addressof(m_srv), 0, pid_placeholder,
.in_send_pid = true,
.out_num_objects = 1,
.out_objects = &logger_srv,
.out_objects = std::addressof(logger_srv),
));
#undef NX_SERVICE_ASSUME_NON_DOMAIN
}

View File

@@ -32,14 +32,14 @@ namespace ams::lm {
public:
/* Actual commands. */
Result Log(const sf::InAutoSelectBuffer &message) {
return serviceDispatch(&m_srv, 0,
return serviceDispatch(std::addressof(m_srv), 0,
.buffer_attrs = { SfBufferAttr_In | SfBufferAttr_HipcAutoSelect },
.buffers = { { message.GetPointer(), message.GetSize() } },
);
}
Result SetDestination(u32 destination) {
return serviceDispatchIn(&m_srv, 1, destination);
return serviceDispatchIn(std::addressof(m_srv), 1, destination);
}
};
static_assert(lm::IsILogger<RemoteLogger>);

View File

@@ -43,11 +43,11 @@ namespace ams::lmem::impl {
}
constexpr inline ExpHeapHead *GetExpHeapHead(HeapHead *heap_head) {
return &heap_head->impl_head.exp_heap_head;
return std::addressof(heap_head->impl_head.exp_heap_head);
}
constexpr inline const ExpHeapHead *GetExpHeapHead(const HeapHead *heap_head) {
return &heap_head->impl_head.exp_heap_head;
return std::addressof(heap_head->impl_head.exp_heap_head);
}
constexpr inline HeapHead *GetHeapHead(ExpHeapHead *exp_heap_head) {
@@ -197,7 +197,7 @@ namespace ams::lmem::impl {
/* Locate the block. */
for (auto it = head->free_list.begin(); it != head->free_list.end(); it++) {
ExpHeapMemoryBlockHead *cur_free_block = &*it;
ExpHeapMemoryBlockHead *cur_free_block = std::addressof(*it);
if (cur_free_block < region->start) {
prev_free_block_it = it;
@@ -220,9 +220,9 @@ namespace ams::lmem::impl {
auto insertion_it = head->free_list.begin();
if (prev_free_block_it != head->free_list.end()) {
/* There's a previous free block, so we want to insert as the next iterator. */
if (GetMemoryBlockEnd(&*prev_free_block_it) == region->start) {
if (GetMemoryBlockEnd(std::addressof(*prev_free_block_it)) == region->start) {
/* We can coalesce, so do so. */
free_region.start = &*prev_free_block_it;
free_region.start = std::addressof(*prev_free_block_it);
insertion_it = head->free_list.erase(prev_free_block_it);
} else {
/* We can't coalesce, so just select the next iterator. */
@@ -249,7 +249,7 @@ namespace ams::lmem::impl {
void *ConvertFreeBlockToUsedBlock(ExpHeapHead *head, ExpHeapMemoryBlockHead *block_head, void *block, size_t size, AllocationDirection direction) {
/* Calculate freed memory regions. */
MemoryRegion free_region_front;
GetMemoryBlockRegion(&free_region_front, block_head);
GetMemoryBlockRegion(std::addressof(free_region_front), block_head);
MemoryRegion free_region_back{ .start = reinterpret_cast<void *>(reinterpret_cast<uintptr_t>(block) + size), .end = free_region_front.end, };
/* Adjust end of head region. */
@@ -308,12 +308,12 @@ namespace ams::lmem::impl {
size_t best_size = std::numeric_limits<size_t>::max();
for (auto it = exp_heap_head->free_list.begin(); it != exp_heap_head->free_list.end(); it++) {
const uintptr_t absolute_block_start = reinterpret_cast<uintptr_t>(GetMemoryBlockStart(&*it));
const uintptr_t absolute_block_start = reinterpret_cast<uintptr_t>(GetMemoryBlockStart(std::addressof(*it)));
const uintptr_t block_start = util::AlignUp(absolute_block_start, alignment);
const size_t block_offset = block_start - absolute_block_start;
if (it->block_size >= size + block_offset && best_size > it->block_size) {
found_block_head = &*it;
found_block_head = std::addressof(*it);
found_block = reinterpret_cast<void *>(block_start);
best_size = it->block_size;
@@ -342,12 +342,12 @@ namespace ams::lmem::impl {
size_t best_size = std::numeric_limits<size_t>::max();
for (auto it = exp_heap_head->free_list.rbegin(); it != exp_heap_head->free_list.rend(); it++) {
const uintptr_t absolute_block_start = reinterpret_cast<uintptr_t>(GetMemoryBlockStart(&*it));
const uintptr_t absolute_block_start = reinterpret_cast<uintptr_t>(GetMemoryBlockStart(std::addressof(*it)));
const uintptr_t block_start = util::AlignUp(absolute_block_start, alignment);
const size_t block_offset = block_start - absolute_block_start;
if (it->block_size >= size + block_offset && best_size > it->block_size) {
found_block_head = &*it;
found_block_head = std::addressof(*it);
found_block = reinterpret_cast<void *>(block_start);
best_size = it->block_size;
@@ -396,7 +396,7 @@ namespace ams::lmem::impl {
}
/* Get the memory block end, make sure it really is the last block. */
ExpHeapMemoryBlockHead *block = &exp_heap_head->free_list.back();
ExpHeapMemoryBlockHead *block = std::addressof(exp_heap_head->free_list.back());
void * const block_start = GetMemoryBlockStart(block);
const size_t block_size = block->block_size;
void * const block_end = reinterpret_cast<void *>(reinterpret_cast<uintptr_t>(block_start) + block_size);
@@ -460,11 +460,11 @@ namespace ams::lmem::impl {
MemoryRegion region;
/* Erase the heap from the used list, and coalesce it with adjacent blocks. */
GetMemoryBlockRegion(&region, block);
GetMemoryBlockRegion(std::addressof(region), block);
exp_heap_head->used_list.erase(exp_heap_head->used_list.iterator_to(*block));
/* Coalesce with adjacent blocks. */
const bool coalesced = CoalesceFreedRegion(exp_heap_head, &region);
const bool coalesced = CoalesceFreedRegion(exp_heap_head, std::addressof(region));
AMS_ASSERT(coalesced);
AMS_UNUSED(coalesced);
}
@@ -493,8 +493,8 @@ namespace ams::lmem::impl {
ExpHeapMemoryBlockHead *next_block_head = nullptr;
for (auto it = exp_heap_head->free_list.begin(); it != exp_heap_head->free_list.end(); it++) {
if (&*it == cur_block_end) {
next_block_head = &*it;
if (std::addressof(*it) == cur_block_end) {
next_block_head = std::addressof(*it);
break;
}
}
@@ -508,7 +508,7 @@ namespace ams::lmem::impl {
{
/* Get block region. */
MemoryRegion new_free_region;
GetMemoryBlockRegion(&new_free_region, next_block_head);
GetMemoryBlockRegion(std::addressof(new_free_region), next_block_head);
/* Remove the next block from the free list. */
auto insertion_it = exp_heap_head->free_list.erase(exp_heap_head->free_list.iterator_to(*next_block_head));
@@ -539,7 +539,7 @@ namespace ams::lmem::impl {
/* Try to free the new memory. */
block_head->block_size = size;
if (!CoalesceFreedRegion(exp_heap_head, &new_free_region)) {
if (!CoalesceFreedRegion(exp_heap_head, std::addressof(new_free_region))) {
/* We didn't shrink the block successfully, so restore the size. */
block_head->block_size = original_block_size;
}
@@ -567,9 +567,9 @@ namespace ams::lmem::impl {
size_t max_size = std::numeric_limits<size_t>::min();
size_t min_offset = std::numeric_limits<size_t>::max();
for (const auto &it : GetExpHeapHead(handle)->free_list) {
const uintptr_t absolute_block_start = reinterpret_cast<uintptr_t>(GetMemoryBlockStart(&it));
const uintptr_t absolute_block_start = reinterpret_cast<uintptr_t>(GetMemoryBlockStart(std::addressof(it)));
const uintptr_t block_start = util::AlignUp(absolute_block_start, alignment);
const uintptr_t block_end = reinterpret_cast<uintptr_t>(GetMemoryBlockEnd(&it));
const uintptr_t block_end = reinterpret_cast<uintptr_t>(GetMemoryBlockEnd(std::addressof(it)));
if (block_start < block_end) {
const size_t block_size = GetPointerDifference(block_start, block_end);
@@ -620,7 +620,7 @@ namespace ams::lmem::impl {
AMS_ASSERT(IsValidHeapHandle(handle));
for (auto &it : GetExpHeapHead(handle)->used_list) {
(*visitor)(GetMemoryBlockStart(&it), handle, user_data);
(*visitor)(GetMemoryBlockStart(std::addressof(it)), handle, user_data);
}
}

View File

@@ -27,11 +27,11 @@ namespace ams::lmem::impl {
}
constexpr inline UnitHeapHead *GetUnitHeapHead(HeapHead *heap_head) {
return &heap_head->impl_head.unit_heap_head;
return std::addressof(heap_head->impl_head.unit_heap_head);
}
constexpr inline const UnitHeapHead *GetUnitHeapHead(const HeapHead *heap_head) {
return &heap_head->impl_head.unit_heap_head;
return std::addressof(heap_head->impl_head.unit_heap_head);
}
inline UnitHead *PopUnit(UnitHeapList *list) {
@@ -190,7 +190,7 @@ namespace ams::lmem::impl {
/* Allocate a unit. */
UnitHeapHead *unit_heap = GetUnitHeapHead(handle);
UnitHead *unit = PopUnit(&unit_heap->free_list);
UnitHead *unit = PopUnit(std::addressof(unit_heap->free_list));
if (unit != nullptr) {
/* Fill memory with pattern for debug, if needed. */
FillAllocatedMemory(handle, unit, unit_heap->unit_size);
@@ -215,7 +215,7 @@ namespace ams::lmem::impl {
FillFreedMemory(handle, block, unit_heap->unit_size);
/* Push the unit onto the free list. */
PushUnit(&unit_heap->free_list, reinterpret_cast<UnitHead *>(block));
PushUnit(std::addressof(unit_heap->free_list), static_cast<UnitHead *>(block));
/* Note that we freed a unit. */
unit_heap->num_units--;

View File

@@ -21,19 +21,19 @@ namespace ams::lr {
Result AddOnContentLocationResolverImpl::ResolveAddOnContentPath(sf::Out<Path> out, ncm::DataId id) {
/* Find a storage that contains the given program id. */
ncm::StorageId storage_id = ncm::StorageId::None;
R_UNLESS(this->registered_storages.Find(&storage_id, id), lr::ResultAddOnContentNotFound());
R_UNLESS(this->registered_storages.Find(std::addressof(storage_id), id), lr::ResultAddOnContentNotFound());
/* Obtain a content meta database for the storage id. */
ncm::ContentMetaDatabase content_meta_database;
R_TRY(ncm::OpenContentMetaDatabase(&content_meta_database, storage_id));
R_TRY(ncm::OpenContentMetaDatabase(std::addressof(content_meta_database), storage_id));
/* Find the latest data content id for the given program id. */
ncm::ContentId data_content_id;
R_TRY(content_meta_database.GetLatestData(&data_content_id, id));
R_TRY(content_meta_database.GetLatestData(std::addressof(data_content_id), id));
/* Obtain a content storage for the storage id. */
ncm::ContentStorage content_storage;
R_TRY(ncm::OpenContentStorage(&content_storage, storage_id));
R_TRY(ncm::OpenContentStorage(std::addressof(content_storage), storage_id));
/* Get the path of the data content. */
static_assert(sizeof(lr::Path) == sizeof(ncm::Path));

View File

@@ -34,7 +34,7 @@ namespace ams::lr {
/* Find the latest program content for the program id. */
ncm::ContentId program_content_id;
R_TRY_CATCH(this->content_meta_database.GetLatestProgram(&program_content_id, id)) {
R_TRY_CATCH(this->content_meta_database.GetLatestProgram(std::addressof(program_content_id), id)) {
R_CONVERT(ncm::ResultContentMetaNotFound, lr::ResultProgramNotFound())
} R_END_TRY_CATCH;
@@ -62,7 +62,7 @@ namespace ams::lr {
Result ContentLocationResolverImpl::ResolveDataPath(sf::Out<Path> out, ncm::DataId id) {
/* Find the latest data content for the program id. */
ncm::ContentId data_content_id;
R_TRY(this->content_meta_database.GetLatestData(&data_content_id, id));
R_TRY(this->content_meta_database.GetLatestData(std::addressof(data_content_id), id));
/* Obtain the content path. */
this->GetContentStoragePath(out.GetPointer(), data_content_id);
@@ -109,8 +109,8 @@ namespace ams::lr {
/* Obtain content meta database and content storage objects for this resolver's storage. */
ncm::ContentMetaDatabase meta_db;
ncm::ContentStorage storage;
R_TRY(ncm::OpenContentMetaDatabase(&meta_db, this->storage_id));
R_TRY(ncm::OpenContentStorage(&storage, this->storage_id));
R_TRY(ncm::OpenContentMetaDatabase(std::addressof(meta_db), this->storage_id));
R_TRY(ncm::OpenContentStorage(std::addressof(storage), this->storage_id));
/* Store the acquired objects. */
this->content_meta_database = std::move(meta_db);

View File

@@ -84,13 +84,13 @@ namespace ams::lr {
}
}
void LocationRedirector::EraseRedirection(ncm::ProgramId program_id)
{
void LocationRedirector::EraseRedirection(ncm::ProgramId program_id) {
/* Remove any redirections with a matching program id. */
for (auto &redirection : this->redirection_list) {
if (redirection.GetProgramId() == program_id) {
this->redirection_list.erase(this->redirection_list.iterator_to(redirection));
delete &redirection;
for (auto it = this->redirection_list.begin(); it != this->redirection_list.end();) {
if (it->GetProgramId() == program_id) {
auto *redirection = std::addressof(*it);
this->redirection_list.erase(it);
delete redirection;
break;
}
}
@@ -100,9 +100,9 @@ namespace ams::lr {
/* Remove any redirections with matching flags. */
for (auto it = this->redirection_list.begin(); it != this->redirection_list.end();) {
if ((it->GetFlags() & flags) == flags) {
auto old = it;
auto *redirection = std::addressof(*it);
it = this->redirection_list.erase(it);
delete std::addressof(*old);
delete redirection;
} else {
it++;
}
@@ -118,9 +118,9 @@ namespace ams::lr {
}
/* Remove the redirection. */
auto old = it;
auto *redirection = std::addressof(*it);
it = this->redirection_list.erase(it);
delete std::addressof(*old);
delete redirection;
}
}

View File

@@ -24,7 +24,7 @@ namespace ams::lr {
public:
RemoteLocationResolverImpl(::LrLocationResolver &l) : srv(l) { /* ... */ }
~RemoteLocationResolverImpl() { ::serviceClose(&srv.s); }
~RemoteLocationResolverImpl() { ::serviceClose(std::addressof(srv.s)); }
public:
/* Actual commands. */
Result ResolveProgramPath(sf::Out<Path> out, ncm::ProgramId id) {

View File

@@ -25,7 +25,7 @@ namespace ams::lr {
public:
RemoteRegisteredLocationResolverImpl(::LrRegisteredLocationResolver &l) : srv(l) { /* ... */ }
~RemoteRegisteredLocationResolverImpl() { ::serviceClose(&srv.s); }
~RemoteRegisteredLocationResolverImpl() { ::serviceClose(std::addressof(srv.s)); }
public:
/* Actual commands. */
Result ResolveProgramPath(sf::Out<Path> out, ncm::ProgramId id) {

View File

@@ -251,7 +251,7 @@ namespace ams::ncm {
/* Obtain the content meta database root. */
ContentMetaDatabaseRoot *root;
R_TRY(this->GetContentMetaDatabaseRoot(&root, storage_id));
R_TRY(this->GetContentMetaDatabaseRoot(std::addressof(root), storage_id));
/* Print the savedata path. */
PathString savedata_db_path;
@@ -331,14 +331,14 @@ namespace ams::ncm {
}
/* First, setup the BuiltInSystem storage entry. */
R_TRY(this->InitializeContentStorageRoot(&this->content_storage_roots[this->num_content_storage_entries++], StorageId::BuiltInSystem, fs::ContentStorageId::System));
R_TRY(this->InitializeContentStorageRoot(std::addressof(this->content_storage_roots[this->num_content_storage_entries++]), StorageId::BuiltInSystem, fs::ContentStorageId::System));
if (R_FAILED(this->VerifyContentStorage(StorageId::BuiltInSystem))) {
R_TRY(this->CreateContentStorage(StorageId::BuiltInSystem));
}
R_TRY(this->ActivateContentStorage(StorageId::BuiltInSystem));
/* Next, the BuiltInSystem content meta entry. */
R_TRY(this->InitializeContentMetaDatabaseRoot(&this->content_meta_database_roots[this->num_content_meta_entries++], StorageId::BuiltInSystem, BuiltInSystemSystemSaveDataInfo, SystemMaxContentMetaCount, std::addressof(g_system_content_meta_memory_resource)));
R_TRY(this->InitializeContentMetaDatabaseRoot(std::addressof(this->content_meta_database_roots[this->num_content_meta_entries++]), StorageId::BuiltInSystem, BuiltInSystemSystemSaveDataInfo, SystemMaxContentMetaCount, std::addressof(g_system_content_meta_memory_resource)));
if (R_FAILED(this->VerifyContentMetaDatabase(StorageId::BuiltInSystem))) {
R_TRY(this->CreateContentMetaDatabase(StorageId::BuiltInSystem));
@@ -365,19 +365,19 @@ namespace ams::ncm {
R_TRY(this->ActivateContentMetaDatabase(StorageId::BuiltInSystem));
/* Now for BuiltInUser's content storage and content meta entries. */
R_TRY(this->InitializeContentStorageRoot(&this->content_storage_roots[this->num_content_storage_entries++], StorageId::BuiltInUser, fs::ContentStorageId::User));
R_TRY(this->InitializeContentMetaDatabaseRoot(&this->content_meta_database_roots[this->num_content_meta_entries++], StorageId::BuiltInUser, BuiltInUserSystemSaveDataInfo, UserMaxContentMetaCount, std::addressof(g_sd_and_user_content_meta_memory_resource)));
R_TRY(this->InitializeContentStorageRoot(std::addressof(this->content_storage_roots[this->num_content_storage_entries++]), StorageId::BuiltInUser, fs::ContentStorageId::User));
R_TRY(this->InitializeContentMetaDatabaseRoot(std::addressof(this->content_meta_database_roots[this->num_content_meta_entries++]), StorageId::BuiltInUser, BuiltInUserSystemSaveDataInfo, UserMaxContentMetaCount, std::addressof(g_sd_and_user_content_meta_memory_resource)));
/* Beyond this point, N uses hardcoded indices. */
/* Next SdCard's content storage and content meta entries. */
R_TRY(this->InitializeContentStorageRoot(&this->content_storage_roots[2], StorageId::SdCard, fs::ContentStorageId::SdCard));
R_TRY(this->InitializeContentMetaDatabaseRoot(&this->content_meta_database_roots[2], StorageId::SdCard, SdCardSystemSaveDataInfo, SdCardMaxContentMetaCount, std::addressof(g_sd_and_user_content_meta_memory_resource)));
R_TRY(this->InitializeContentStorageRoot(std::addressof(this->content_storage_roots[2]), StorageId::SdCard, fs::ContentStorageId::SdCard));
R_TRY(this->InitializeContentMetaDatabaseRoot(std::addressof(this->content_meta_database_roots[2]), StorageId::SdCard, SdCardSystemSaveDataInfo, SdCardMaxContentMetaCount, std::addressof(g_sd_and_user_content_meta_memory_resource)));
/* GameCard's content storage and content meta entries. */
/* N doesn't set a content storage id for game cards, so we'll just use 0 (System). */
R_TRY(this->InitializeGameCardContentStorageRoot(&this->content_storage_roots[3]));
R_TRY(this->InitializeGameCardContentMetaDatabaseRoot(&this->content_meta_database_roots[3], GameCardMaxContentMetaCount, std::addressof(g_gamecard_content_meta_memory_resource)));
R_TRY(this->InitializeGameCardContentStorageRoot(std::addressof(this->content_storage_roots[3])));
R_TRY(this->InitializeGameCardContentMetaDatabaseRoot(std::addressof(this->content_meta_database_roots[3]), GameCardMaxContentMetaCount, std::addressof(g_gamecard_content_meta_memory_resource)));
this->initialized = true;
return ResultSuccess();
@@ -408,7 +408,7 @@ namespace ams::ncm {
/* Obtain the content meta database root. */
ContentMetaDatabaseRoot *root;
R_TRY(this->GetContentMetaDatabaseRoot(&root, storage_id));
R_TRY(this->GetContentMetaDatabaseRoot(std::addressof(root), storage_id));
/* Mount (and optionally create) save data for the root. */
R_TRY(this->EnsureAndMountSystemSaveData(root->mount_name, root->info));
@@ -449,7 +449,7 @@ namespace ams::ncm {
/* Obtain the content meta database root. */
ContentMetaDatabaseRoot *root;
R_TRY(this->GetContentMetaDatabaseRoot(&root, storage_id));
R_TRY(this->GetContentMetaDatabaseRoot(std::addressof(root), storage_id));
/* Mount save data for non-existing content meta databases. */
const bool mount = !root->content_meta_database;
@@ -460,7 +460,7 @@ namespace ams::ncm {
/* Ensure the root path exists. */
bool has_dir = false;
R_TRY(fs::HasDirectory(&has_dir, root->path));
R_TRY(fs::HasDirectory(std::addressof(has_dir), root->path));
R_UNLESS(has_dir, ncm::ResultInvalidContentMetaDatabase());
return ResultSuccess();
@@ -492,7 +492,7 @@ namespace ams::ncm {
/* Obtain the content meta database root. */
ContentMetaDatabaseRoot *root;
R_TRY(this->GetContentMetaDatabaseRoot(&root, storage_id));
R_TRY(this->GetContentMetaDatabaseRoot(std::addressof(root), storage_id));
if (hos::GetVersion() >= hos::Version_2_0_0) {
/* Obtain the content meta database if already active. */
@@ -524,7 +524,7 @@ namespace ams::ncm {
/* Obtain the content meta database root. */
ContentMetaDatabaseRoot *root;
R_TRY(this->GetContentMetaDatabaseRoot(&root, storage_id));
R_TRY(this->GetContentMetaDatabaseRoot(std::addressof(root), storage_id));
/* Delete save data for the content meta database root. */
return fs::DeleteSaveData(root->info.space_id, root->info.id);
@@ -614,7 +614,7 @@ namespace ams::ncm {
/* Obtain the content meta database root. */
ContentMetaDatabaseRoot *root;
R_TRY(this->GetContentMetaDatabaseRoot(&root, storage_id));
R_TRY(this->GetContentMetaDatabaseRoot(std::addressof(root), storage_id));
/* Already activated. */
R_SUCCEED_IF(root->content_meta_database != nullptr);
@@ -652,7 +652,7 @@ namespace ams::ncm {
/* Obtain the content meta database root. */
ContentMetaDatabaseRoot *root;
R_TRY(this->GetContentMetaDatabaseRoot(&root, storage_id));
R_TRY(this->GetContentMetaDatabaseRoot(std::addressof(root), storage_id));
/* Disable the content meta database, if present. */
if (root->content_meta_database != nullptr) {

View File

@@ -88,7 +88,7 @@ namespace ams::ncm {
/* Call the process function. */
bool should_continue = true;
bool should_retry_dir_read = false;
R_TRY(f(&should_continue, &should_retry_dir_read, current_path, entry));
R_TRY(f(std::addressof(should_continue), std::addressof(should_retry_dir_read), current_path, entry));
/* If the provided function wishes to terminate immediately, we should respect it. */
if (!should_continue) {
@@ -368,7 +368,7 @@ namespace ams::ncm {
MakeContentPath(std::addressof(path), content_id, this->make_content_path_func, this->root_path);
/* Open the content file and store to the cache. */
R_TRY_CATCH(fs::OpenFile(&this->cached_file_handle, path, fs::OpenMode_Read)) {
R_TRY_CATCH(fs::OpenFile(std::addressof(this->cached_file_handle), path, fs::OpenMode_Read)) {
R_CONVERT(ams::fs::ResultPathNotFound, ncm::ResultContentNotFound())
} R_END_TRY_CATCH;
@@ -416,7 +416,7 @@ namespace ams::ncm {
/* Check if placeholder file exists. */
bool has = false;
R_TRY(fs::HasFile(&has, placeholder_path));
R_TRY(fs::HasFile(std::addressof(has), placeholder_path));
out.SetValue(has);
return ResultSuccess();
}
@@ -464,7 +464,7 @@ namespace ams::ncm {
/* Check if the content file exists. */
bool has = false;
R_TRY(fs::HasFile(&has, content_path));
R_TRY(fs::HasFile(std::addressof(has), content_path));
out.SetValue(has);
return ResultSuccess();
}
@@ -714,7 +714,7 @@ namespace ams::ncm {
Result ContentStorageImpl::GetRightsIdFromPlaceHolderIdDeprecated(sf::Out<ams::fs::RightsId> out_rights_id, PlaceHolderId placeholder_id) {
/* Obtain the regular rights id for the placeholder id. */
ncm::RightsId rights_id;
R_TRY(this->GetRightsIdFromPlaceHolderId(&rights_id, placeholder_id));
R_TRY(this->GetRightsIdFromPlaceHolderId(std::addressof(rights_id), placeholder_id));
/* Output the fs rights id. */
out_rights_id.SetValue(rights_id.id);
@@ -735,7 +735,7 @@ namespace ams::ncm {
Result ContentStorageImpl::GetRightsIdFromContentIdDeprecated(sf::Out<ams::fs::RightsId> out_rights_id, ContentId content_id) {
/* Obtain the regular rights id for the content id. */
ncm::RightsId rights_id;
R_TRY(this->GetRightsIdFromContentId(&rights_id, content_id));
R_TRY(this->GetRightsIdFromContentId(std::addressof(rights_id), content_id));
/* Output the fs rights id. */
out_rights_id.SetValue(rights_id.id);
@@ -893,7 +893,7 @@ namespace ams::ncm {
/* Get the rights id. */
ncm::RightsId rights_id;
R_TRY(GetRightsId(&rights_id, common_path));
R_TRY(GetRightsId(std::addressof(rights_id), common_path));
this->rights_id_cache->Store(cache_content_id, rights_id);
/* Set output. */

View File

@@ -137,7 +137,7 @@ namespace ams::ncm {
Result HostContentStorageImpl::GetRightsIdFromContentIdDeprecated(sf::Out<ams::fs::RightsId> out_rights_id, ContentId content_id) {
/* Obtain the regular rights id for the content id. */
ncm::RightsId rights_id;
R_TRY(this->GetRightsIdFromContentId(&rights_id, content_id));
R_TRY(this->GetRightsIdFromContentId(std::addressof(rights_id), content_id));
/* Output the fs rights id. */
out_rights_id.SetValue(rights_id.id);

View File

@@ -206,7 +206,7 @@ namespace ams::ncm {
/* Open the relevant content storage. */
ContentStorage content_storage;
R_TRY(ncm::OpenContentStorage(&content_storage, storage_id));
R_TRY(ncm::OpenContentStorage(std::addressof(content_storage), storage_id));
/* Iterate over content infos. */
for (size_t i = 0; i < reader.GetContentCount(); i++) {
@@ -464,7 +464,7 @@ namespace ams::ncm {
/* Open the content storage for this meta. */
ContentStorage content_storage;
R_TRY(OpenContentStorage(&content_storage, storage_id));
R_TRY(OpenContentStorage(std::addressof(content_storage), storage_id));
/* Open the content meta database for this meta. */
ContentMetaDatabase meta_db;
@@ -546,7 +546,7 @@ namespace ams::ncm {
/* Open the content storage for the content info. */
ContentStorage content_storage;
R_TRY(OpenContentStorage(&content_storage, content_info->storage_id));
R_TRY(OpenContentStorage(std::addressof(content_storage), content_info->storage_id));
/* Write data to the placeholder. */
R_TRY(content_storage.WritePlaceHolder(content_info->placeholder_id, content_info->written, data, data_size));
@@ -658,7 +658,7 @@ namespace ams::ncm {
/* Open the relevant content storage. */
ContentStorage content_storage;
R_TRY(ncm::OpenContentStorage(&content_storage, storage_id));
R_TRY(ncm::OpenContentStorage(std::addressof(content_storage), storage_id));
/* Update the storage id in the header. */
auto writer = content_meta.GetWriter();
@@ -670,7 +670,7 @@ namespace ams::ncm {
/* Check if we have the content already exists. */
bool has_content;
R_TRY(content_storage.Has(&has_content, content_info->GetId()));
R_TRY(content_storage.Has(std::addressof(has_content), content_info->GetId()));
if (has_content) {
/* Add the size of installed content infos to the total size. */
@@ -739,7 +739,7 @@ namespace ams::ncm {
Result InstallTaskBase::PrepareContentMeta(const InstallContentMetaInfo &meta_info, util::optional<ContentMetaKey> expected_key, util::optional<u32> source_version) {
/* Open the BuiltInSystem content storage. */
ContentStorage content_storage;
R_TRY(OpenContentStorage(&content_storage, StorageId::BuiltInSystem));
R_TRY(OpenContentStorage(std::addressof(content_storage), StorageId::BuiltInSystem));
/* Write content meta to a placeholder. */
InstallContentInfo content_info;
@@ -1104,7 +1104,7 @@ namespace ams::ncm {
/* Open the content storage. */
ContentStorage content_storage;
R_TRY(ncm::OpenContentStorage(&content_storage, storage_id));
R_TRY(ncm::OpenContentStorage(std::addressof(content_storage), storage_id));
/* Iterate over content meta. */
for (s32 i = 0; i < count; i++) {
@@ -1162,7 +1162,7 @@ namespace ams::ncm {
/* Open the BuiltInSystem content storage. */
ContentStorage content_storage;
R_TRY(ncm::OpenContentStorage(&content_storage, StorageId::BuiltInSystem));
R_TRY(ncm::OpenContentStorage(std::addressof(content_storage), StorageId::BuiltInSystem));
/* Write content meta to a placeholder. */
InstallContentInfo content_info;
@@ -1375,7 +1375,7 @@ namespace ams::ncm {
/* Open the relevant content storage. */
ContentStorage content_storage;
R_TRY(ncm::OpenContentStorage(&content_storage, content_info->storage_id));
R_TRY(ncm::OpenContentStorage(std::addressof(content_storage), content_info->storage_id));
/* Get the rights id. */
RightsId rights_id;

View File

@@ -137,7 +137,7 @@ namespace ams::ncm {
/* Attempt to find a cache entry with the same placeholder id. */
for (size_t i = 0; i < MaxCacheEntries; i++) {
if (placeholder_id == this->caches[i].id) {
return &this->caches[i];
return std::addressof(this->caches[i]);
}
}
return nullptr;

View File

@@ -224,7 +224,7 @@ namespace ams::ncm {
Result ReadOnlyContentStorageImpl::GetRightsIdFromContentIdDeprecated(sf::Out<ams::fs::RightsId> out_rights_id, ContentId content_id) {
/* Obtain the regular rights id for the content id. */
ncm::RightsId rights_id;
R_TRY(this->GetRightsIdFromContentId(&rights_id, content_id));
R_TRY(this->GetRightsIdFromContentId(std::addressof(rights_id), content_id));
/* Output the fs rights id. */
out_rights_id.SetValue(rights_id.id);
@@ -240,7 +240,7 @@ namespace ams::ncm {
/* Get the rights id. */
ncm::RightsId rights_id;
R_TRY(GetRightsId(&rights_id, path));
R_TRY(GetRightsId(std::addressof(rights_id), path));
out_rights_id.SetValue(rights_id);
return ResultSuccess();

View File

@@ -70,7 +70,7 @@ namespace ams::os::impl {
this->current_time = GetCurrentTick().ToTimeSpan();
TimeSpan min_timeout = 0;
MultiWaitHolderBase *min_timeout_object = this->RecalculateNextTimeout(&min_timeout, end_time);
MultiWaitHolderBase *min_timeout_object = this->RecalculateNextTimeout(std::addressof(min_timeout), end_time);
s32 index = WaitInvalid;
Result wait_result = ResultSuccess();
@@ -141,11 +141,10 @@ namespace ams::os::impl {
for (MultiWaitHolderBase &holder_base : this->multi_wait_list) {
if (auto handle = holder_base.GetHandle(); handle != os::InvalidNativeHandle) {
AMS_ASSERT(count < num);
AMS_UNUSED(num);
AMS_ABORT_UNLESS(count < num);
out_handles[count] = handle;
out_objects[count] = &holder_base;
out_objects[count] = std::addressof(holder_base);
count++;
}
}
@@ -160,7 +159,7 @@ namespace ams::os::impl {
TriBool is_signaled = holder_base.LinkToObjectList();
if (signaled_holder == nullptr && is_signaled == TriBool::True) {
signaled_holder = &holder_base;
signaled_holder = std::addressof(holder_base);
}
}
@@ -179,7 +178,7 @@ namespace ams::os::impl {
for (MultiWaitHolderBase &holder_base : this->multi_wait_list) {
if (const TimeSpan cur_time = holder_base.GetAbsoluteWakeupTime(); cur_time < min_time) {
min_timeout_holder = &holder_base;
min_timeout_holder = std::addressof(holder_base);
min_time = cur_time;
}
}

View File

@@ -27,7 +27,7 @@ namespace ams::os::impl {
public:
void SignalAllThreads() {
for (MultiWaitHolderBase &holder_base : this->object_list) {
holder_base.GetMultiWait()->SignalAndWakeupThread(&holder_base);
holder_base.GetMultiWait()->SignalAndWakeupThread(std::addressof(holder_base));
}
}

View File

@@ -20,7 +20,7 @@
namespace ams::os::impl {
#define ATOMIC_COMPARE_EXCHANGE_LOCK_COUNT(dst_ref, expected_ref, desired_ref, success, fail) \
(__atomic_compare_exchange(reinterpret_cast<u64 *>(&dst_ref), reinterpret_cast<u64 *>(&expected_ref), reinterpret_cast<u64 *>(&desired_ref), true, success, fail))
(__atomic_compare_exchange(reinterpret_cast<u64 *>(std::addressof(dst_ref)), reinterpret_cast<u64 *>(std::addressof(expected_ref)), reinterpret_cast<u64 *>(std::addressof(desired_ref)), true, success, fail))
void ReaderWriterLockHorizonImpl::AcquireReadLockWriteLocked(os::ReaderWriterLockType *rw_lock) {

View File

@@ -102,7 +102,7 @@ namespace ams::os {
AMS_ASSERT(!holder_base->IsLinked());
impl.LinkMultiWaitHolder(*holder_base);
holder_base->SetMultiWait(&impl);
holder_base->SetMultiWait(std::addressof(impl));
}
void UnlinkMultiWaitHolder(MultiWaitHolderType *holder) {

View File

@@ -30,7 +30,7 @@ namespace ams::os {
const T EffectiveMax = (std::numeric_limits<T>::max() / max) * max;
T cur_rnd;
while (true) {
os::GenerateRandomBytes(&cur_rnd, sizeof(T));
os::GenerateRandomBytes(std::addressof(cur_rnd), sizeof(T));
if (cur_rnd < EffectiveMax) {
return cur_rnd % max;
}
@@ -43,7 +43,7 @@ namespace ams::os {
std::scoped_lock lk(g_random_mutex);
if (AMS_UNLIKELY(!g_initialized_random)) {
impl::InitializeRandomImpl(&g_random);
impl::InitializeRandomImpl(std::addressof(g_random));
g_initialized_random = true;
}

View File

@@ -66,11 +66,11 @@ namespace ams::patcher {
bool MatchesModuleId(const char *name, size_t name_len, size_t extension_len, const ro::ModuleId *module_id) {
/* Get module id. */
ro::ModuleId module_id_from_name;
if (!ParseModuleIdFromPath(&module_id_from_name, name, name_len, extension_len)) {
if (!ParseModuleIdFromPath(std::addressof(module_id_from_name), name, name_len, extension_len)) {
return false;
}
return std::memcmp(&module_id_from_name, module_id, sizeof(*module_id)) == 0;
return std::memcmp(std::addressof(module_id_from_name), module_id, sizeof(*module_id)) == 0;
}
bool IsIpsFileForModule(const char *name, const ro::ModuleId *module_id) {

View File

@@ -21,7 +21,7 @@ namespace ams::pm::bm {
/* Both functions should be weakly linked, so that they can be overridden by ams::boot2 as needed. */
BootMode WEAK_SYMBOL GetBootMode() {
PmBootMode boot_mode = PmBootMode_Normal;
R_ABORT_UNLESS(pmbmGetBootMode(&boot_mode));
R_ABORT_UNLESS(pmbmGetBootMode(std::addressof(boot_mode)));
return static_cast<BootMode>(boot_mode);
}

View File

@@ -34,7 +34,7 @@ namespace ams::pm::dmnt {
Result HookToCreateApplicationProcess(os::NativeHandle *out_handle) {
Event evt;
R_TRY(pmdmntHookToCreateApplicationProcess(&evt));
R_TRY(pmdmntHookToCreateApplicationProcess(std::addressof(evt)));
*out_handle = evt.revent;
return ResultSuccess();
}

View File

@@ -36,7 +36,7 @@ namespace ams::pm::info {
bool HasLaunchedBootProgram(ncm::ProgramId program_id) {
bool has_launched = false;
R_ABORT_UNLESS(HasLaunchedBootProgram(&has_launched, program_id));
R_ABORT_UNLESS(HasLaunchedBootProgram(std::addressof(has_launched), program_id));
return has_launched;
}
@@ -44,7 +44,7 @@ namespace ams::pm::info {
Result IsHblProcessId(bool *out, os::ProcessId process_id) {
ncm::ProgramLocation loc;
cfg::OverrideStatus override_status;
R_TRY(GetProcessInfo(&loc, &override_status, process_id));
R_TRY(GetProcessInfo(std::addressof(loc), std::addressof(override_status), process_id));
*out = override_status.IsHbl();
return ResultSuccess();
@@ -52,7 +52,7 @@ namespace ams::pm::info {
Result IsHblProgramId(bool *out, ncm::ProgramId program_id) {
os::ProcessId process_id;
R_TRY(GetProcessId(&process_id, program_id));
R_TRY(GetProcessId(std::addressof(process_id), program_id));
return IsHblProcessId(out, process_id);
}

View File

@@ -21,7 +21,7 @@ namespace ams::pm::info {
/* Information API. */
Result WEAK_SYMBOL HasLaunchedBootProgram(bool *out, ncm::ProgramId program_id) {
bool has_launched = false;
R_TRY(pminfoAtmosphereHasLaunchedBootProgram(&has_launched, static_cast<u64>(program_id)));
R_TRY(pminfoAtmosphereHasLaunchedBootProgram(std::addressof(has_launched), static_cast<u64>(program_id)));
*out = has_launched;
return ResultSuccess();
}

View File

@@ -21,7 +21,7 @@ namespace ams::pm::shell {
Result WEAK_SYMBOL LaunchProgram(os::ProcessId *out, const ncm::ProgramLocation &loc, u32 launch_flags) {
static_assert(sizeof(ncm::ProgramLocation) == sizeof(NcmProgramLocation));
static_assert(alignof(ncm::ProgramLocation) == alignof(NcmProgramLocation));
return pmshellLaunchProgram(launch_flags, reinterpret_cast<const NcmProgramLocation *>(&loc), reinterpret_cast<u64 *>(out));
return pmshellLaunchProgram(launch_flags, reinterpret_cast<const NcmProgramLocation *>(std::addressof(loc)), reinterpret_cast<u64 *>(out));
}
Result TerminateProcess(os::ProcessId process_id) {

View File

@@ -19,7 +19,7 @@ namespace ams::sf::cmif {
ServerDomainManager::Domain::~Domain() {
while (!this->entries.empty()) {
Entry *entry = &this->entries.front();
Entry *entry = std::addressof(this->entries.front());
{
std::scoped_lock lk(this->manager->entry_owner_lock);
AMS_ABORT_UNLESS(entry->owner == this);
@@ -127,7 +127,7 @@ namespace ams::sf::cmif {
return nullptr;
}
Entry *e = &this->free_list.front();
Entry *e = std::addressof(this->free_list.front());
this->free_list.pop_front();
return e;
}

View File

@@ -43,9 +43,9 @@ namespace ams::sf::cmif {
std::memcpy(in_object_ids, reinterpret_cast<DomainObjectId *>(in_message_raw_data.GetAddress() + in_message_raw_data.GetSize()), sizeof(DomainObjectId) * in_header->num_in_objects);
DomainServiceObjectProcessor domain_processor(domain, in_object_ids, in_header->num_in_objects);
if (ctx.processor == nullptr) {
ctx.processor = &domain_processor;
ctx.processor = std::addressof(domain_processor);
} else {
ctx.processor->SetImplementationProcessor(&domain_processor);
ctx.processor->SetImplementationProcessor(std::addressof(domain_processor));
}
ctx.srv_obj = target_object.GetServiceObjectUnsafe();
return target_object.ProcessMessage(ctx, in_message_raw_data);
@@ -82,9 +82,9 @@ namespace ams::sf::cmif {
std::memcpy(in_object_ids, reinterpret_cast<DomainObjectId *>(in_message_raw_data.GetAddress() + in_message_raw_data.GetSize()), sizeof(DomainObjectId) * in_header->num_in_objects);
DomainServiceObjectProcessor domain_processor(domain, in_object_ids, in_header->num_in_objects);
if (ctx.processor == nullptr) {
ctx.processor = &domain_processor;
ctx.processor = std::addressof(domain_processor);
} else {
ctx.processor->SetImplementationProcessor(&domain_processor);
ctx.processor->SetImplementationProcessor(std::addressof(domain_processor));
}
ctx.srv_obj = target_object.GetServiceObjectUnsafe();
return target_object.ProcessMessage(ctx, in_message_raw_data);

View File

@@ -79,7 +79,7 @@ namespace ams::sf::hipc {
/* The object ID reservation cannot fail here, as that would cause desynchronization from target domain. */
object_id = cmif::DomainObjectId{session->forward_service->object_id};
domain->ReserveSpecificIds(&object_id, 1);
domain->ReserveSpecificIds(std::addressof(object_id), 1);
/* Register the object. */
domain->RegisterObject(object_id, std::move(session->srv_obj_holder));
@@ -91,7 +91,7 @@ namespace ams::sf::hipc {
SharedPointer<cmif::DomainServiceObject> cmif_domain(domain, false);
/* Reserve a new object in the domain. */
R_TRY(domain->ReserveIds(&object_id, 1));
R_TRY(domain->ReserveIds(std::addressof(object_id), 1));
/* Register the object. */
domain->RegisterObject(object_id, std::move(session->srv_obj_holder));
@@ -136,7 +136,7 @@ namespace ams::sf::hipc {
} else {
/* Copy from the target domain. */
os::NativeHandle new_forward_target;
R_TRY(cmifCopyFromCurrentDomain(this->session->forward_service->session, object_id.value, &new_forward_target));
R_TRY(cmifCopyFromCurrentDomain(this->session->forward_service->session, object_id.value, std::addressof(new_forward_target)));
/* Create new session handles. */
os::NativeHandle server_handle, client_handle;

View File

@@ -21,7 +21,7 @@ namespace ams::sf::hipc {
Result ServerManagerBase::InstallMitmServerImpl(os::NativeHandle *out_port_handle, sm::ServiceName service_name, ServerManagerBase::MitmQueryFunction query_func) {
/* Install the Mitm. */
os::NativeHandle query_handle;
R_TRY(sm::mitm::InstallMitm(out_port_handle, &query_handle, service_name));
R_TRY(sm::mitm::InstallMitm(out_port_handle, std::addressof(query_handle), service_name));
/* Register the query handle. */
impl::RegisterMitmQueryHandle(query_handle, query_func);
@@ -57,9 +57,9 @@ namespace ams::sf::hipc {
while (true) {
this->LinkDeferred();
auto selected = os::WaitAny(std::addressof(this->multi_wait));
if (selected == &this->request_stop_event_holder) {
if (selected == std::addressof(this->request_stop_event_holder)) {
return nullptr;
} else if (selected == &this->notify_event_holder) {
} else if (selected == std::addressof(this->notify_event_holder)) {
this->notify_event.Clear();
} else {
os::UnlinkMultiWaitHolder(selected);

View File

@@ -102,7 +102,7 @@ namespace ams::sf::hipc {
Result ServerSessionManager::AcceptSessionImpl(ServerSession *session_memory, os::NativeHandle port_handle, cmif::ServiceObjectHolder &&obj) {
/* Create session handle. */
os::NativeHandle session_handle;
R_TRY(svc::AcceptSession(&session_handle, port_handle));
R_TRY(svc::AcceptSession(std::addressof(session_handle), port_handle));
auto session_guard = SCOPE_GUARD { os::CloseNativeHandle(session_handle); };
@@ -133,7 +133,7 @@ namespace ams::sf::hipc {
Result ServerSessionManager::AcceptMitmSessionImpl(ServerSession *session_memory, os::NativeHandle mitm_port_handle, cmif::ServiceObjectHolder &&obj, std::shared_ptr<::Service> &&fsrv) {
/* Create session handle. */
os::NativeHandle mitm_session_handle;
R_TRY(svc::AcceptSession(&mitm_session_handle, mitm_port_handle));
R_TRY(svc::AcceptSession(std::addressof(mitm_session_handle), mitm_port_handle));
auto session_guard = SCOPE_GUARD { os::CloseNativeHandle(mitm_session_handle); };
@@ -147,25 +147,25 @@ namespace ams::sf::hipc {
Result ServerSessionManager::RegisterSession(os::NativeHandle session_handle, cmif::ServiceObjectHolder &&obj) {
/* We don't actually care about what happens to the session. It'll get linked. */
ServerSession *session_ptr = nullptr;
return this->RegisterSession(&session_ptr, session_handle, std::forward<cmif::ServiceObjectHolder>(obj));
return this->RegisterSession(std::addressof(session_ptr), session_handle, std::forward<cmif::ServiceObjectHolder>(obj));
}
Result ServerSessionManager::AcceptSession(os::NativeHandle port_handle, cmif::ServiceObjectHolder &&obj) {
/* We don't actually care about what happens to the session. It'll get linked. */
ServerSession *session_ptr = nullptr;
return this->AcceptSession(&session_ptr, port_handle, std::forward<cmif::ServiceObjectHolder>(obj));
return this->AcceptSession(std::addressof(session_ptr), port_handle, std::forward<cmif::ServiceObjectHolder>(obj));
}
Result ServerSessionManager::RegisterMitmSession(os::NativeHandle mitm_session_handle, cmif::ServiceObjectHolder &&obj, std::shared_ptr<::Service> &&fsrv) {
/* We don't actually care about what happens to the session. It'll get linked. */
ServerSession *session_ptr = nullptr;
return this->RegisterMitmSession(&session_ptr, mitm_session_handle, std::forward<cmif::ServiceObjectHolder>(obj), std::forward<std::shared_ptr<::Service>>(fsrv));
return this->RegisterMitmSession(std::addressof(session_ptr), mitm_session_handle, std::forward<cmif::ServiceObjectHolder>(obj), std::forward<std::shared_ptr<::Service>>(fsrv));
}
Result ServerSessionManager::AcceptMitmSession(os::NativeHandle mitm_port_handle, cmif::ServiceObjectHolder &&obj, std::shared_ptr<::Service> &&fsrv) {
/* We don't actually care about what happens to the session. It'll get linked. */
ServerSession *session_ptr = nullptr;
return this->AcceptMitmSession(&session_ptr, mitm_port_handle, std::forward<cmif::ServiceObjectHolder>(obj), std::forward<std::shared_ptr<::Service>>(fsrv));
return this->AcceptMitmSession(std::addressof(session_ptr), mitm_port_handle, std::forward<cmif::ServiceObjectHolder>(obj), std::forward<std::shared_ptr<::Service>>(fsrv));
}
Result ServerSessionManager::ReceiveRequestImpl(ServerSession *session, const cmif::PointerAndSize &message) {
@@ -184,7 +184,7 @@ namespace ams::sf::hipc {
);
}
hipc::ReceiveResult recv_result;
R_TRY(hipc::Receive(&recv_result, session->session_handle, message));
R_TRY(hipc::Receive(std::addressof(recv_result), session->session_handle, message));
switch (recv_result) {
case hipc::ReceiveResult::Success:
session->is_closed = false;
@@ -203,7 +203,7 @@ namespace ams::sf::hipc {
NX_CONSTEXPR u32 GetCmifCommandType(const cmif::PointerAndSize &message) {
HipcHeader hdr = {};
__builtin_memcpy(&hdr, message.GetPointer(), sizeof(hdr));
__builtin_memcpy(std::addressof(hdr), message.GetPointer(), sizeof(hdr));
return hdr.type;
}
@@ -289,7 +289,7 @@ namespace ams::sf::hipc {
.manager = this,
.session = session,
.processor = nullptr, /* Filled in by template implementations. */
.handles_to_close = &handles_to_close,
.handles_to_close = std::addressof(handles_to_close),
.pointer_buffer = session->pointer_buffer,
.in_message_buffer = in_message,
.out_message_buffer = out_message,

View File

@@ -22,7 +22,7 @@ namespace ams::sm::manager {
/* Manager API. */
Result RegisterProcess(os::ProcessId process_id, ncm::ProgramId program_id, cfg::OverrideStatus status, const void *acid, size_t acid_size, const void *aci, size_t aci_size) {
static_assert(sizeof(status) == sizeof(CfgOverrideStatus), "CfgOverrideStatus definition");
return smManagerAtmosphereRegisterProcess(static_cast<u64>(process_id), static_cast<u64>(program_id), reinterpret_cast<const CfgOverrideStatus *>(&status), acid, acid_size, aci, aci_size);
return smManagerAtmosphereRegisterProcess(static_cast<u64>(process_id), static_cast<u64>(program_id), reinterpret_cast<const CfgOverrideStatus *>(std::addressof(status)), acid, acid_size, aci, aci_size);
}
Result UnregisterProcess(os::ProcessId process_id) {

View File

@@ -40,19 +40,17 @@ namespace ams::sm::impl {
TipcService srv;
{
std::scoped_lock lk(GetPerThreadSessionMutex());
R_ABORT_UNLESS(smAtmosphereOpenSession(&srv));
R_ABORT_UNLESS(smAtmosphereOpenSession(std::addressof(srv)));
}
{
ON_SCOPE_EXIT { smAtmosphereCloseSession(&srv); };
return f(&srv);
ON_SCOPE_EXIT { smAtmosphereCloseSession(std::addressof(srv)); };
return f(std::addressof(srv));
}
}
NX_CONSTEXPR SmServiceName ConvertName(sm::ServiceName name) {
constexpr ALWAYS_INLINE SmServiceName ConvertName(sm::ServiceName name) {
static_assert(sizeof(SmServiceName) == sizeof(sm::ServiceName));
SmServiceName ret = {};
__builtin_memcpy(&ret, &name, sizeof(sm::ServiceName));
return ret;
return std::bit_cast<SmServiceName>(name);
}
}

View File

@@ -173,13 +173,13 @@ namespace ams::spl::smc {
svc::SecureMonitorArguments args;
args.r[0] = static_cast<u64>(FunctionId::ReencryptDeviceUniqueData);
args.r[1] = reinterpret_cast<u64>(&access_key_dec);
args.r[2] = reinterpret_cast<u64>(&access_key_enc);
args.r[1] = reinterpret_cast<u64>(std::addressof(access_key_dec));
args.r[2] = reinterpret_cast<u64>(std::addressof(access_key_enc));
args.r[3] = option;
args.r[4] = reinterpret_cast<u64>(data);
args.r[5] = size;
args.r[6] = reinterpret_cast<u64>(&source_dec);
args.r[7] = reinterpret_cast<u64>(&source_enc);
args.r[6] = reinterpret_cast<u64>(std::addressof(source_dec));
args.r[7] = reinterpret_cast<u64>(std::addressof(source_enc));
svc::CallSecureMonitor(std::addressof(args));
return static_cast<Result>(args.r[0]);

View File

@@ -112,7 +112,7 @@ namespace ams::updater {
Result VerifyBootImagesAndRepairIfNeeded(bool *out_repaired, BootModeType mode, void *work_buffer, size_t work_buffer_size, BootImageUpdateType boot_image_update_type) {
/* Get system data id for boot images (819/81A/81B/81C). */
ncm::SystemDataId bip_data_id = {};
R_TRY(GetBootImagePackageId(&bip_data_id, mode, work_buffer, work_buffer_size));
R_TRY(GetBootImagePackageId(std::addressof(bip_data_id), mode, work_buffer, work_buffer_size));
/* Verify the boot images in NAND. */
R_TRY_CATCH(VerifyBootImages(bip_data_id, mode, work_buffer, work_buffer_size, boot_image_update_type)) {
@@ -174,7 +174,7 @@ namespace ams::updater {
R_TRY(ValidateBctFileHash(boot0_accessor, Boot0Partition::BctNormalSub, nand_hash, work_buffer, work_buffer_size, boot_image_update_type));
/* Compare Package1 Normal/Sub hashes. */
R_TRY(GetFileHash(&size, file_hash, GetPackage1Path(boot_image_update_type), work_buffer, work_buffer_size));
R_TRY(GetFileHash(std::addressof(size), file_hash, GetPackage1Path(boot_image_update_type), work_buffer, work_buffer_size));
R_TRY(boot0_accessor.GetHash(nand_hash, size, work_buffer, work_buffer_size, Boot0Partition::Package1NormalMain));
R_TRY(CompareHash(file_hash, nand_hash, sizeof(file_hash)));
@@ -183,7 +183,7 @@ namespace ams::updater {
R_TRY(CompareHash(file_hash, nand_hash, sizeof(file_hash)));
/* Compare Package2 Normal/Sub hashes. */
R_TRY(GetFileHash(&size, file_hash, GetPackage2Path(boot_image_update_type), work_buffer, work_buffer_size));
R_TRY(GetFileHash(std::addressof(size), file_hash, GetPackage2Path(boot_image_update_type), work_buffer, work_buffer_size));
R_TRY(GetPackage2Hash(nand_hash, size, work_buffer, work_buffer_size, Package2Type::NormalMain));
R_TRY(CompareHash(file_hash, nand_hash, sizeof(file_hash)));
@@ -236,7 +236,7 @@ namespace ams::updater {
R_TRY(ValidateBctFileHash(boot0_accessor, Boot0Partition::BctSafeSub, nand_hash, work_buffer, work_buffer_size, boot_image_update_type));
/* Compare Package1 Normal/Sub hashes. */
R_TRY(GetFileHash(&size, file_hash, GetPackage1Path(boot_image_update_type), work_buffer, work_buffer_size));
R_TRY(GetFileHash(std::addressof(size), file_hash, GetPackage1Path(boot_image_update_type), work_buffer, work_buffer_size));
R_TRY(boot1_accessor.GetHash(nand_hash, size, work_buffer, work_buffer_size, Boot1Partition::Package1SafeMain));
R_TRY(CompareHash(file_hash, nand_hash, sizeof(file_hash)));
@@ -245,7 +245,7 @@ namespace ams::updater {
R_TRY(CompareHash(file_hash, nand_hash, sizeof(file_hash)));
/* Compare Package2 Normal/Sub hashes. */
R_TRY(GetFileHash(&size, file_hash, GetPackage2Path(boot_image_update_type), work_buffer, work_buffer_size));
R_TRY(GetFileHash(std::addressof(size), file_hash, GetPackage2Path(boot_image_update_type), work_buffer, work_buffer_size));
R_TRY(GetPackage2Hash(nand_hash, size, work_buffer, work_buffer_size, Package2Type::SafeMain));
R_TRY(CompareHash(file_hash, nand_hash, sizeof(file_hash)));
@@ -291,7 +291,7 @@ namespace ams::updater {
void *work = reinterpret_cast<void *>(reinterpret_cast<uintptr_t>(work_buffer) + BctSize);
size_t size;
R_TRY(ReadFile(&size, bct, BctSize, GetBctPath(boot_image_update_type)));
R_TRY(ReadFile(std::addressof(size), bct, BctSize, GetBctPath(boot_image_update_type)));
if (HasEks(boot_image_update_type)) {
R_TRY(boot0_accessor.UpdateEks(bct, work));
}
@@ -361,7 +361,7 @@ namespace ams::updater {
void *work = reinterpret_cast<void *>(reinterpret_cast<uintptr_t>(work_buffer) + BctSize);
size_t size;
R_TRY(ReadFile(&size, bct, BctSize, GetBctPath(boot_image_update_type)));
R_TRY(ReadFile(std::addressof(size), bct, BctSize, GetBctPath(boot_image_update_type)));
if (HasEks(boot_image_update_type)) {
R_TRY(boot0_accessor.UpdateEks(bct, work));
}
@@ -419,7 +419,7 @@ namespace ams::updater {
void *work = reinterpret_cast<void *>(reinterpret_cast<uintptr_t>(work_buffer) + BctSize);
size_t size;
R_TRY(ReadFile(&size, bct, BctSize, GetBctPath(boot_image_update_type)));
R_TRY(ReadFile(std::addressof(size), bct, BctSize, GetBctPath(boot_image_update_type)));
if (HasEks(boot_image_update_type)) {
R_TRY(accessor.UpdateEks(bct, work));
}
@@ -541,7 +541,7 @@ namespace ams::updater {
/* Get verification state from NAND. */
VerificationState verification_state;
R_TRY(GetVerificationState(&verification_state, work_buffer, work_buffer_size));
R_TRY(GetVerificationState(std::addressof(verification_state), work_buffer, work_buffer_size));
/* If we don't need to verify anything, we're done. */
if (!verification_state.needs_verify_normal && !verification_state.needs_verify_safe) {

View File

@@ -127,7 +127,7 @@ namespace ams::updater {
const OffsetSizeType *entry = nullptr;
for (size_t i = 0; i < Meta::NumEntries; i++) {
if (Meta::Entries[i].which == which) {
entry = &Meta::Entries[i];
entry = std::addressof(Meta::Entries[i]);
break;
}
}

View File

@@ -115,12 +115,12 @@ namespace ams::util::ini {
int ParseFile(fs::FileHandle file, void *user_ctx, Handler h) {
FileContext ctx(file);
return ini_parse_stream(ini_reader_file_handle, &ctx, h, user_ctx);
return ini_parse_stream(ini_reader_file_handle, std::addressof(ctx), h, user_ctx);
}
int ParseFile(fs::fsa::IFile *file, void *user_ctx, Handler h) {
IFileContext ctx(file);
return ini_parse_stream(ini_reader_ifile, &ctx, h, user_ctx);
return ini_parse_stream(ini_reader_ifile, std::addressof(ctx), h, user_ctx);
}
}