ams: use util::SNPrintf over std:: (size/linker improvements)

This commit is contained in:
Michael Scire
2021-01-12 02:59:41 -08:00
parent 9cfd259c5c
commit 094cede39e
41 changed files with 103 additions and 103 deletions

View File

@@ -303,7 +303,7 @@ namespace ams::creport {
char file_path[fs::EntryNameLengthMax + 1];
/* Save crash report. */
std::snprintf(file_path, sizeof(file_path), "sdmc:/atmosphere/crash_reports/%011lu_%016lx.log", timestamp, this->process_info.program_id);
util::SNPrintf(file_path, sizeof(file_path), "sdmc:/atmosphere/crash_reports/%011lu_%016lx.log", timestamp, this->process_info.program_id);
{
ScopedFile file(file_path);
if (file.IsOpen()) {
@@ -312,7 +312,7 @@ namespace ams::creport {
}
/* Dump threads. */
std::snprintf(file_path, sizeof(file_path), "sdmc:/atmosphere/crash_reports/dumps/%011lu_%016lx_thread_info.bin", timestamp, this->process_info.program_id);
util::SNPrintf(file_path, sizeof(file_path), "sdmc:/atmosphere/crash_reports/dumps/%011lu_%016lx_thread_info.bin", timestamp, this->process_info.program_id);
{
ScopedFile file(file_path);
if (file.IsOpen()) {
@@ -341,7 +341,7 @@ namespace ams::creport {
if (capssc_holder) {
u64 jpeg_size;
if (R_SUCCEEDED(capsrv::CaptureJpegScreenshot(std::addressof(jpeg_size), this->heap_storage, sizeof(this->heap_storage), vi::LayerStack_ApplicationForDebug, TimeSpan::FromSeconds(10)))) {
std::snprintf(file_path, sizeof(file_path), "sdmc:/atmosphere/crash_reports/%011lu_%016lx.jpg", timestamp, this->process_info.program_id);
util::SNPrintf(file_path, sizeof(file_path), "sdmc:/atmosphere/crash_reports/%011lu_%016lx.jpg", timestamp, this->process_info.program_id);
ScopedFile file(file_path);
if (file.IsOpen()) {
file.Write(this->heap_storage, jpeg_size);

View File

@@ -107,7 +107,7 @@ namespace ams::creport {
GetModuleBuildId(module.build_id, module.end_address);
/* Some homebrew won't have a name. Add a fake one for readability. */
if (std::strcmp(module.name, "") == 0) {
std::snprintf(module.name, sizeof(module.name), "[%02x%02x%02x%02x]", module.build_id[0], module.build_id[1], module.build_id[2], module.build_id[3]);
util::SNPrintf(module.name, sizeof(module.name), "[%02x%02x%02x%02x]", module.build_id[0], module.build_id[1], module.build_id[2], module.build_id[3]);
}
}
@@ -249,13 +249,13 @@ namespace ams::creport {
const char *ModuleList::GetFormattedAddressString(uintptr_t address) {
/* Print default formatted string. */
std::snprintf(this->address_str_buf, sizeof(this->address_str_buf), "%016lx", address);
util::SNPrintf(this->address_str_buf, sizeof(this->address_str_buf), "%016lx", address);
/* See if the address is inside a module, for pretty-printing. */
for (size_t i = 0; i < this->num_modules; i++) {
const auto& module = this->modules[i];
if (module.start_address <= address && address < module.end_address) {
std::snprintf(this->address_str_buf, sizeof(this->address_str_buf), "%016lx (%s + 0x%lx)", address, module.name, address - module.start_address);
util::SNPrintf(this->address_str_buf, sizeof(this->address_str_buf), "%016lx (%s + 0x%lx)", address, module.name, address - module.start_address);
break;
}
}

View File

@@ -40,7 +40,7 @@ namespace ams::creport {
{
std::va_list vl;
va_start(vl, fmt);
std::vsnprintf(g_format_buffer, sizeof(g_format_buffer), fmt, vl);
util::VSNPrintf(g_format_buffer, sizeof(g_format_buffer), fmt, vl);
va_end(vl);
}
@@ -70,7 +70,7 @@ namespace ams::creport {
{
char hex[MaximumLineLength * 2 + 2] = {};
for (size_t i = 0; i < cur_size; i++) {
std::snprintf(hex + i * 2, 3, "%02X", data_u8[data_ofs++]);
util::SNPrintf(hex + i * 2, 3, "%02X", data_u8[data_ofs++]);
}
hex[cur_size * 2 + 0] = '\n';
hex[cur_size * 2 + 1] = '\x00';