strat: use m_ for member variables

This commit is contained in:
Michael Scire
2021-10-10 00:14:06 -07:00
parent ce28591ab2
commit a595c232b9
425 changed files with 8531 additions and 8484 deletions

View File

@@ -79,7 +79,7 @@ namespace ams::mitm::sysupdater {
Result SystemUpdateApplyManager::ApplyPackageTask(ncm::PackageSystemDowngradeTask *task) {
/* Lock the apply mutex. */
std::scoped_lock lk(this->apply_mutex);
std::scoped_lock lk(m_apply_mutex);
/* NOTE: Here, Nintendo creates a system report for the update. */

View File

@@ -20,9 +20,9 @@ namespace ams::mitm::sysupdater {
class SystemUpdateApplyManager {
private:
os::SdkMutex apply_mutex;
os::SdkMutex m_apply_mutex;
public:
constexpr SystemUpdateApplyManager() : apply_mutex() { /* ... */ }
constexpr SystemUpdateApplyManager() : m_apply_mutex() { /* ... */ }
Result ApplyPackageTask(ncm::PackageSystemDowngradeTask *task);
};

View File

@@ -29,10 +29,10 @@ namespace ams::mitm::sysupdater {
}
AsyncPrepareSdCardUpdateImpl::~AsyncPrepareSdCardUpdateImpl() {
if (this->thread_info) {
os::WaitThread(this->thread_info->thread);
os::DestroyThread(this->thread_info->thread);
GetAsyncThreadAllocator()->Free(*this->thread_info);
if (m_thread_info) {
os::WaitThread(m_thread_info->thread);
os::DestroyThread(m_thread_info->thread);
GetAsyncThreadAllocator()->Free(*m_thread_info);
}
}
@@ -46,16 +46,16 @@ namespace ams::mitm::sysupdater {
/* Ensure that we clean up appropriately. */
ON_SCOPE_EXIT {
if (!this->thread_info) {
if (!m_thread_info) {
GetAsyncThreadAllocator()->Free(info);
}
};
/* Create a thread for the task. */
R_TRY(os::CreateThread(info.thread, [](void *arg) {
auto *_this = reinterpret_cast<AsyncPrepareSdCardUpdateImpl *>(arg);
_this->result = _this->Execute();
_this->event.Signal();
auto *async = reinterpret_cast<AsyncPrepareSdCardUpdateImpl *>(arg);
async->m_result = async->Execute();
async->m_event.Signal();
}, this, info.stack, info.stack_size, info.priority));
/* Set the thread name. */
@@ -65,16 +65,16 @@ namespace ams::mitm::sysupdater {
os::StartThread(info.thread);
/* Set our thread info. */
this->thread_info = info;
m_thread_info = info;
return ResultSuccess();
}
Result AsyncPrepareSdCardUpdateImpl::Execute() {
return this->task->PrepareAndExecute();
return m_task->PrepareAndExecute();
}
void AsyncPrepareSdCardUpdateImpl::CancelImpl() {
this->task->Cancel();
m_task->Cancel();
}
}

View File

@@ -21,16 +21,16 @@ namespace ams::mitm::sysupdater {
class ErrorContextHolder {
private:
err::ErrorContext error_context;
err::ErrorContext m_error_context;
public:
constexpr ErrorContextHolder() : error_context{} { /* ... */ }
constexpr ErrorContextHolder() : m_error_context{} { /* ... */ }
virtual ~ErrorContextHolder() { /* ... */ }
template<typename T>
Result SaveErrorContextIfFailed(T &async, Result result) {
if (R_FAILED(result)) {
async.GetErrorContext(std::addressof(this->error_context));
async.GetErrorContext(std::addressof(m_error_context));
return result;
}
@@ -46,7 +46,7 @@ namespace ams::mitm::sysupdater {
template<typename T>
Result SaveInternalTaskErrorContextIfFailed(T &async, Result result) {
if (R_FAILED(result)) {
async.CreateErrorContext(std::addressof(this->error_context));
async.CreateErrorContext(std::addressof(m_error_context));
return result;
}
@@ -54,7 +54,7 @@ namespace ams::mitm::sysupdater {
}
const err::ErrorContext &GetErrorContextImpl() {
return this->error_context;
return m_error_context;
}
};
@@ -93,15 +93,15 @@ namespace ams::mitm::sysupdater {
/* We don't implement the RequestServer::ManagedStop details, as we don't implement stoppable request list. */
class AsyncPrepareSdCardUpdateImpl : public AsyncResultBase, private ErrorContextHolder {
private:
Result result;
os::SystemEvent event;
util::optional<ThreadInfo> thread_info;
ncm::InstallTaskBase *task;
Result m_result;
os::SystemEvent m_event;
util::optional<ThreadInfo> m_thread_info;
ncm::InstallTaskBase *m_task;
public:
AsyncPrepareSdCardUpdateImpl(ncm::InstallTaskBase *task) : result(ResultSuccess()), event(os::EventClearMode_ManualClear, true), thread_info(), task(task) { /* ... */ }
AsyncPrepareSdCardUpdateImpl(ncm::InstallTaskBase *task) : m_result(ResultSuccess()), m_event(os::EventClearMode_ManualClear, true), m_thread_info(), m_task(task) { /* ... */ }
virtual ~AsyncPrepareSdCardUpdateImpl();
os::SystemEvent &GetEvent() { return this->event; }
os::SystemEvent &GetEvent() { return m_event; }
virtual Result GetErrorContext(sf::Out<err::ErrorContext> out) override {
*out = ErrorContextHolder::GetErrorContextImpl();
@@ -113,7 +113,7 @@ namespace ams::mitm::sysupdater {
Result Execute();
virtual void CancelImpl() override;
virtual Result GetImpl() override { return this->result; }
virtual Result GetImpl() override { return m_result; }
};
}

View File

@@ -211,16 +211,16 @@ namespace ams::mitm::sysupdater {
}
bool PathView::HasPrefix(util::string_view prefix) const {
return this->path.compare(0, prefix.length(), prefix) == 0;
return m_path.compare(0, prefix.length(), prefix) == 0;
}
bool PathView::HasSuffix(util::string_view suffix) const {
return this->path.compare(this->path.length() - suffix.length(), suffix.length(), suffix) == 0;
return m_path.compare(m_path.length() - suffix.length(), suffix.length(), suffix) == 0;
}
util::string_view PathView::GetFileName() const {
auto pos = this->path.find_last_of("/");
return pos != util::string_view::npos ? this->path.substr(pos + 1) : this->path;
auto pos = m_path.find_last_of("/");
return pos != util::string_view::npos ? m_path.substr(pos + 1) : m_path;
}
Result MountSdCardContentMeta(const char *mount_name, const char *path) {

View File

@@ -20,9 +20,9 @@ namespace ams::mitm::sysupdater {
class PathView {
private:
util::string_view path;
util::string_view m_path;
public:
PathView(util::string_view p) : path(p) { /* ...*/ }
PathView(util::string_view p) : m_path(p) { /* ...*/ }
bool HasPrefix(util::string_view prefix) const;
bool HasSuffix(util::string_view suffix) const;
util::string_view GetFileName() const;

View File

@@ -420,18 +420,18 @@ namespace ams::mitm::sysupdater {
Result SystemUpdateService::RequestPrepareUpdate(sf::OutCopyHandle out_event_handle, sf::Out<sf::SharedPointer<ns::impl::IAsyncResult>> out_async) {
/* Ensure the update is setup but not prepared. */
R_UNLESS(this->setup_update, ns::ResultCardUpdateNotSetup());
R_UNLESS(!this->requested_update, ns::ResultPrepareCardUpdateAlreadyRequested());
R_UNLESS(m_setup_update, ns::ResultCardUpdateNotSetup());
R_UNLESS(!m_requested_update, ns::ResultPrepareCardUpdateAlreadyRequested());
/* Create the async result. */
auto async_result = sf::CreateSharedObjectEmplaced<ns::impl::IAsyncResult, AsyncPrepareSdCardUpdateImpl>(std::addressof(*this->update_task));
auto async_result = sf::CreateSharedObjectEmplaced<ns::impl::IAsyncResult, AsyncPrepareSdCardUpdateImpl>(std::addressof(*m_update_task));
R_UNLESS(async_result != nullptr, ns::ResultOutOfMaxRunningTask());
/* Run the task. */
R_TRY(async_result.GetImpl().Run());
/* We prepared the task! */
this->requested_update = true;
m_requested_update = true;
out_event_handle.SetValue(async_result.GetImpl().GetEvent().GetReadableHandle(), false);
*out_async = std::move(async_result);
@@ -440,38 +440,38 @@ namespace ams::mitm::sysupdater {
Result SystemUpdateService::GetPrepareUpdateProgress(sf::Out<SystemUpdateProgress> out) {
/* Ensure the update is setup. */
R_UNLESS(this->setup_update, ns::ResultCardUpdateNotSetup());
R_UNLESS(m_setup_update, ns::ResultCardUpdateNotSetup());
/* Get the progress. */
auto install_progress = this->update_task->GetProgress();
auto install_progress = m_update_task->GetProgress();
out.SetValue({ .current_size = install_progress.installed_size, .total_size = install_progress.total_size });
return ResultSuccess();
}
Result SystemUpdateService::HasPreparedUpdate(sf::Out<bool> out) {
/* Ensure the update is setup. */
R_UNLESS(this->setup_update, ns::ResultCardUpdateNotSetup());
R_UNLESS(m_setup_update, ns::ResultCardUpdateNotSetup());
out.SetValue(this->update_task->GetProgress().state == ncm::InstallProgressState::Downloaded);
out.SetValue(m_update_task->GetProgress().state == ncm::InstallProgressState::Downloaded);
return ResultSuccess();
}
Result SystemUpdateService::ApplyPreparedUpdate() {
/* Ensure the update is setup. */
R_UNLESS(this->setup_update, ns::ResultCardUpdateNotSetup());
R_UNLESS(m_setup_update, ns::ResultCardUpdateNotSetup());
/* Ensure the update is prepared. */
R_UNLESS(this->update_task->GetProgress().state == ncm::InstallProgressState::Downloaded, ns::ResultCardUpdateNotPrepared());
R_UNLESS(m_update_task->GetProgress().state == ncm::InstallProgressState::Downloaded, ns::ResultCardUpdateNotPrepared());
/* Apply the task. */
R_TRY(this->apply_manager.ApplyPackageTask(std::addressof(*this->update_task)));
R_TRY(m_apply_manager.ApplyPackageTask(std::addressof(*m_update_task)));
return ResultSuccess();
}
Result SystemUpdateService::SetupUpdateImpl(sf::NativeHandle &&transfer_memory, u64 transfer_memory_size, const ncm::Path &path, bool exfat, ncm::FirmwareVariationId firmware_variation_id) {
/* Ensure we don't already have an update set up. */
R_UNLESS(!this->setup_update, ns::ResultCardUpdateAlreadySetup());
R_UNLESS(!m_setup_update, ns::ResultCardUpdateAlreadySetup());
/* Destroy any existing update tasks. */
nim::SystemUpdateTaskId id;
@@ -484,21 +484,21 @@ namespace ams::mitm::sysupdater {
R_TRY(InitializeUpdateTask(std::move(transfer_memory), transfer_memory_size, path, exfat, firmware_variation_id));
/* The update is now set up. */
this->setup_update = true;
m_setup_update = true;
return ResultSuccess();
}
Result SystemUpdateService::InitializeUpdateTask(sf::NativeHandle &&transfer_memory, u64 transfer_memory_size, const ncm::Path &path, bool exfat, ncm::FirmwareVariationId firmware_variation_id) {
/* Map the transfer memory. */
const size_t tmem_buffer_size = static_cast<size_t>(transfer_memory_size);
this->update_transfer_memory.emplace(tmem_buffer_size, transfer_memory.GetOsHandle(), transfer_memory.IsManaged());
m_update_transfer_memory.emplace(tmem_buffer_size, transfer_memory.GetOsHandle(), transfer_memory.IsManaged());
transfer_memory.Detach();
void *tmem_buffer;
R_TRY(this->update_transfer_memory->Map(std::addressof(tmem_buffer), os::MemoryPermission_None));
R_TRY(m_update_transfer_memory->Map(std::addressof(tmem_buffer), os::MemoryPermission_None));
auto tmem_guard = SCOPE_GUARD {
this->update_transfer_memory->Unmap();
this->update_transfer_memory = util::nullopt;
m_update_transfer_memory->Unmap();
m_update_transfer_memory = util::nullopt;
};
/* Adjust the package root. */
@@ -510,8 +510,8 @@ namespace ams::mitm::sysupdater {
const char *context_path = "@Sdcard:/atmosphere/update/cup.ctx";
/* Create and initialize the update task. */
this->update_task.emplace();
R_TRY(this->update_task->Initialize(package_root.str, context_path, tmem_buffer, tmem_buffer_size, exfat, firmware_variation_id));
m_update_task.emplace();
R_TRY(m_update_task->Initialize(package_root.str, context_path, tmem_buffer, tmem_buffer_size, exfat, firmware_variation_id));
/* We successfully setup the update. */
tmem_guard.Cancel();

View File

@@ -56,13 +56,13 @@ namespace ams::mitm::sysupdater {
class SystemUpdateService {
private:
SystemUpdateApplyManager apply_manager;
util::optional<ncm::PackageSystemDowngradeTask> update_task;
util::optional<os::TransferMemory> update_transfer_memory;
bool setup_update;
bool requested_update;
SystemUpdateApplyManager m_apply_manager;
util::optional<ncm::PackageSystemDowngradeTask> m_update_task;
util::optional<os::TransferMemory> m_update_transfer_memory;
bool m_setup_update;
bool m_requested_update;
public:
constexpr SystemUpdateService() : apply_manager(), update_task(), update_transfer_memory(), setup_update(false), requested_update(false) { /* ... */ }
constexpr SystemUpdateService() : m_apply_manager(), m_update_task(), m_update_transfer_memory(), m_setup_update(false), m_requested_update(false) { /* ... */ }
private:
Result SetupUpdateImpl(sf::NativeHandle &&transfer_memory, u64 transfer_memory_size, const ncm::Path &path, bool exfat, ncm::FirmwareVariationId firmware_variation_id);
Result InitializeUpdateTask(sf::NativeHandle &&transfer_memory, u64 transfer_memory_size, const ncm::Path &path, bool exfat, ncm::FirmwareVariationId firmware_variation_id);

View File

@@ -19,18 +19,18 @@
namespace ams::mitm::sysupdater {
Result ThreadAllocator::Allocate(ThreadInfo *out) {
std::scoped_lock lk(this->mutex);
std::scoped_lock lk(m_mutex);
for (int i = 0; i < this->thread_count; ++i) {
for (int i = 0; i < m_thread_count; ++i) {
const u64 mask = (static_cast<u64>(1) << i);
if ((this->bitmap & mask) == 0) {
if ((m_bitmap & mask) == 0) {
*out = {
.thread = this->thread_list + i,
.priority = this->thread_priority,
.stack = this->stack_heap + (this->stack_size * i),
.stack_size = this->stack_size,
.thread = m_thread_list + i,
.priority = m_thread_priority,
.stack = m_stack_heap + (m_stack_size * i),
.stack_size = m_stack_size,
};
this->bitmap |= mask;
m_bitmap |= mask;
return ResultSuccess();
}
}
@@ -39,12 +39,12 @@ namespace ams::mitm::sysupdater {
}
void ThreadAllocator::Free(const ThreadInfo &info) {
std::scoped_lock lk(this->mutex);
std::scoped_lock lk(m_mutex);
for (int i = 0; i < this->thread_count; ++i) {
if (info.thread == std::addressof(this->thread_list[i])) {
for (int i = 0; i < m_thread_count; ++i) {
if (info.thread == std::addressof(m_thread_list[i])) {
const u64 mask = (static_cast<u64>(1) << i);
this->bitmap &= ~mask;
m_bitmap &= ~mask;
return;
}
}

View File

@@ -28,20 +28,20 @@ namespace ams::mitm::sysupdater {
/* NOTE: Nintendo uses a util::BitArray, but this seems excessive. */
class ThreadAllocator {
private:
os::ThreadType *thread_list;
const int thread_priority;
const int thread_count;
u8 *stack_heap;
const size_t stack_heap_size;
const size_t stack_size;
u64 bitmap;
os::SdkMutex mutex;
os::ThreadType *m_thread_list;
const int m_thread_priority;
const int m_thread_count;
u8 *m_stack_heap;
const size_t m_stack_heap_size;
const size_t m_stack_size;
u64 m_bitmap;
os::SdkMutex m_mutex;
public:
constexpr ThreadAllocator(os::ThreadType *thread_list, int count, int priority, u8 *stack_heap, size_t stack_heap_size, size_t stack_size)
: thread_list(thread_list), thread_priority(priority), thread_count(count), stack_heap(stack_heap), stack_heap_size(stack_heap_size), stack_size(stack_size), bitmap()
: m_thread_list(thread_list), m_thread_priority(priority), m_thread_count(count), m_stack_heap(stack_heap), m_stack_heap_size(stack_heap_size), m_stack_size(stack_size), m_bitmap()
{
AMS_ASSERT(count <= static_cast<int>(stack_heap_size / stack_size));
AMS_ASSERT(count <= static_cast<int>(BITSIZEOF(this->bitmap)));
AMS_ASSERT(count <= static_cast<int>(BITSIZEOF(m_bitmap)));
}
Result Allocate(ThreadInfo *out);