diff --git a/stratosphere/creport/source/creport_crash_report.cpp b/stratosphere/creport/source/creport_crash_report.cpp index ec5b4727e..a35c5cf3d 100644 --- a/stratosphere/creport/source/creport_crash_report.cpp +++ b/stratosphere/creport/source/creport_crash_report.cpp @@ -301,7 +301,7 @@ namespace ams::creport { } void CrashReport::SaveToFile(ScopedFile &file) { - file.WriteFormat("Atmosphère Crash Report (v1.5):\n"); + file.WriteFormat(u8"Atmosphère Crash Report (v1.5):\n"); file.WriteFormat("Result: 0x%X (2%03d-%04d)\n\n", this->result.GetValue(), this->result.GetModule(), this->result.GetDescription()); /* Process Info. */ @@ -360,7 +360,7 @@ namespace ams::creport { this->module_list.SaveToFile(file); /* Thread Info. */ - file.WriteFormat("\nThread Report:\n"); + file.WriteFormat("Thread Report:\n"); this->thread_list.SaveToFile(file); } diff --git a/stratosphere/creport/source/creport_modules.cpp b/stratosphere/creport/source/creport_modules.cpp index 87393ed9c..5370aa453 100644 --- a/stratosphere/creport/source/creport_modules.cpp +++ b/stratosphere/creport/source/creport_modules.cpp @@ -53,7 +53,7 @@ namespace ams::creport { if (std::strcmp(this->modules[i].name, "") != 0) { file.WriteFormat(" Name: %s\n", module.name); } - file.DumpMemory(" Build Id: ", module.build_id, sizeof(module.build_id)); + file.DumpMemory(" Build Id: ", &module.build_id[0], sizeof(module.build_id)); } } diff --git a/stratosphere/creport/source/creport_scoped_file.cpp b/stratosphere/creport/source/creport_scoped_file.cpp index 2d433abca..0ee09604f 100644 --- a/stratosphere/creport/source/creport_scoped_file.cpp +++ b/stratosphere/creport/source/creport_scoped_file.cpp @@ -27,6 +27,10 @@ namespace ams::creport { } + void ScopedFile::WriteString(const char *str) { + this->Write(str, std::strlen(str)); + } + void ScopedFile::WriteFormat(const char *fmt, ...) { /* Acquire exclusive access to the format buffer. */ std::scoped_lock lk(g_format_lock); @@ -40,13 +44,13 @@ namespace ams::creport { } /* Write data. */ - this->Write(g_format_buffer, std::strlen(g_format_buffer)); + this->WriteString(g_format_buffer); } void ScopedFile::DumpMemory(const char *prefix, const void *data, size_t size) { const u8 *data_u8 = reinterpret_cast(data); const int prefix_len = std::strlen(prefix); - size_t offset = 0; + size_t data_ofs = 0; size_t remaining = size; bool first = true; @@ -63,14 +67,14 @@ namespace ams::creport { /* Dump up to 0x20 of hex memory. */ { - char hex[MaximumLineLength * 2 + 2]; + char hex[MaximumLineLength * 2 + 2] = {}; for (size_t i = 0; i < cur_size; i++) { - std::snprintf(hex + i * 2, 3, "%02X", data_u8[offset++]); + std::snprintf(hex + i * 2, 3, "%02X", data_u8[data_ofs++]); } hex[cur_size * 2 + 0] = '\n'; hex[cur_size * 2 + 1] = '\x00'; - this->Write(hex, std::strlen(hex)); + this->WriteString(hex); } /* Continue. */ @@ -85,7 +89,7 @@ namespace ams::creport { } /* Advance, if we write successfully. */ - if (R_SUCCEEDED(fs::WriteFile(this->file, this->offset, g_format_buffer, size, fs::WriteOption::Flush))) { + if (R_SUCCEEDED(fs::WriteFile(this->file, this->offset, data, size, fs::WriteOption::Flush))) { this->offset += size; } } diff --git a/stratosphere/creport/source/creport_scoped_file.hpp b/stratosphere/creport/source/creport_scoped_file.hpp index 151458884..e82956f87 100644 --- a/stratosphere/creport/source/creport_scoped_file.hpp +++ b/stratosphere/creport/source/creport_scoped_file.hpp @@ -42,6 +42,7 @@ namespace ams::creport { return this->opened; } + void WriteString(const char *str); void WriteFormat(const char *fmt, ...) __attribute__((format(printf, 2, 3))); void DumpMemory(const char *prefix, const void *data, size_t size);