uart.mitm: Abort on memalloc failure and adjust stack size.

This commit is contained in:
yellows8
2021-02-18 19:25:59 -05:00
parent 4cb8034ac8
commit 8a9ddc30e0
2 changed files with 15 additions and 22 deletions

View File

@@ -67,28 +67,22 @@ namespace ams::mitm::uart {
/* Initialize the Send cache-buffer. */
this->m_send_cache_buffer = static_cast<u8 *>(std::malloc(this->CacheBufferSize));
if (this->m_send_cache_buffer != nullptr) {
std::memset(this->m_send_cache_buffer, 0, this->CacheBufferSize);
}
AMS_ABORT_UNLESS(this->m_send_cache_buffer != nullptr);
std::memset(this->m_send_cache_buffer, 0, this->CacheBufferSize);
this->m_send_cache_pos = 0;
/* Initialize the Receive cache-buffer. */
this->m_receive_cache_buffer = static_cast<u8 *>(std::malloc(this->CacheBufferSize));
if (this->m_receive_cache_buffer != nullptr) {
std::memset(this->m_receive_cache_buffer, 0, this->CacheBufferSize);
}
AMS_ABORT_UNLESS(this->m_receive_cache_buffer != nullptr);
std::memset(this->m_receive_cache_buffer, 0, this->CacheBufferSize);
this->m_receive_cache_pos = 0;
this->m_datalog_ready = false;
/* When the above is successful, initialize the datalog. */
if (this->m_send_cache_buffer != nullptr && this->m_receive_cache_buffer != nullptr) {
std::snprintf(tmp_path, sizeof(tmp_path), "%s/%s", this->m_base_path, "btsnoop_hci.log");
ams::mitm::fs::CreateAtmosphereSdFile(tmp_path, 0, 0);
rc = ams::mitm::fs::OpenAtmosphereSdFile(&this->m_datalog_file, tmp_path, FsOpenMode_Read | FsOpenMode_Write | FsOpenMode_Append);
/* Set datalog_ready to whether initialization was successful. */
this->m_datalog_ready = R_SUCCEEDED(rc);
}
/* Initialize the datalog. */
std::snprintf(tmp_path, sizeof(tmp_path), "%s/%s", this->m_base_path, "btsnoop_hci.log");
ams::mitm::fs::CreateAtmosphereSdFile(tmp_path, 0, 0);
rc = ams::mitm::fs::OpenAtmosphereSdFile(&this->m_datalog_file, tmp_path, FsOpenMode_Read | FsOpenMode_Write | FsOpenMode_Append);
/* Set datalog_ready to whether initialization was successful. */
this->m_datalog_ready = R_SUCCEEDED(rc);
if (this->m_datalog_ready) {
std::shared_ptr<UartLogger> logger = mitm::uart::g_logger;