From 111da6db0631e4c4a9100b92698c6110b96b6e00 Mon Sep 17 00:00:00 2001 From: Daniel Lim Wee Soong Date: Sun, 25 Mar 2018 18:35:50 +0800 Subject: [PATCH 1/7] common: Migrate logging macros Follow-up of #3533 Replace logging to use NGLOG instead of LOG This is significantly larger than the previous ones. --- src/common/assert.h | 6 +-- src/common/chunk_file.h | 14 +++--- src/common/file_util.cpp | 94 +++++++++++++++++------------------ src/common/logging/filter.cpp | 8 +-- src/common/memory_util.cpp | 16 +++--- src/common/param_package.cpp | 12 ++--- src/common/string_util.cpp | 10 ++-- 7 files changed, 79 insertions(+), 81 deletions(-) diff --git a/src/common/assert.h b/src/common/assert.h index 5c479f501..9718b0222 100644 --- a/src/common/assert.h +++ b/src/common/assert.h @@ -30,14 +30,14 @@ __declspec(noinline, noreturn) #define ASSERT(_a_) \ do \ if (!(_a_)) { \ - assert_noinline_call([] { LOG_CRITICAL(Debug, "Assertion Failed!"); }); \ + assert_noinline_call([] { NGLOG_CRITICAL(Debug, "Assertion Failed!"); }); \ } \ while (0) #define ASSERT_MSG(_a_, ...) \ do \ if (!(_a_)) { \ - assert_noinline_call([&] { LOG_CRITICAL(Debug, "Assertion Failed!\n" __VA_ARGS__); }); \ + assert_noinline_call([&] { NGLOG_CRITICAL(Debug, "Assertion Failed!" __VA_ARGS__); }); \ } \ while (0) @@ -52,5 +52,5 @@ __declspec(noinline, noreturn) #define DEBUG_ASSERT_MSG(_a_, _desc_, ...) #endif -#define UNIMPLEMENTED() LOG_CRITICAL(Debug, "Unimplemented code!") +#define UNIMPLEMENTED() NGLOG_CRITICAL(Debug, "Unimplemented code!") #define UNIMPLEMENTED_MSG(_a_, ...) ASSERT_MSG(false, _a_, __VA_ARGS__) diff --git a/src/common/chunk_file.h b/src/common/chunk_file.h index 972ef9039..eaa8d81ed 100644 --- a/src/common/chunk_file.h +++ b/src/common/chunk_file.h @@ -159,8 +159,8 @@ public: Do(foundVersion); if (error == ERROR_FAILURE || foundVersion < minVer || foundVersion > ver) { - LOG_ERROR(Common, "Savestate failure: wrong version %d found for %s", foundVersion, - title); + NGLOG_ERROR(Common, "Savestate failure: wrong version {} found for {}", foundVersion, + title); SetError(ERROR_FAILURE); return PointerWrapSection(*this, -1, title); } @@ -466,7 +466,7 @@ public: } break; default: - LOG_ERROR(Common, "Savestate error: invalid mode %d.", mode); + NGLOG_ERROR(Common, "Savestate error: invalid mode {}.", mode); } } @@ -607,10 +607,10 @@ public: u32 cookie = arbitraryNumber; Do(cookie); if (mode == PointerWrap::MODE_READ && cookie != arbitraryNumber) { - LOG_ERROR(Common, - "After \"%s\", found %d (0x%X) instead of save marker %d (0x%X). " - "Aborting savestate load...", - prevName, cookie, cookie, arbitraryNumber, arbitraryNumber); + NGLOG_ERROR(Common, + "After \"{}\", found {} ({:#X}) instead of save marker {} ({:#X}). " + "Aborting savestate load...", + prevName, cookie, cookie, arbitraryNumber, arbitraryNumber); SetError(ERROR_FAILURE); } } diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp index 4e1d702f7..5879ebe3b 100644 --- a/src/common/file_util.cpp +++ b/src/common/file_util.cpp @@ -118,7 +118,7 @@ bool IsDirectory(const std::string& filename) { #endif if (result < 0) { - LOG_DEBUG(Common_Filesystem, "stat failed on %s: %s", filename.c_str(), GetLastErrorMsg()); + NGLOG_DEBUG(Common_Filesystem, "stat failed on {}: {}", filename, GetLastErrorMsg()); return false; } @@ -128,31 +128,29 @@ bool IsDirectory(const std::string& filename) { // Deletes a given filename, return true on success // Doesn't supports deleting a directory bool Delete(const std::string& filename) { - LOG_TRACE(Common_Filesystem, "file %s", filename.c_str()); + NGLOG_TRACE(Common_Filesystem, "file {}", filename); // Return true because we care about the file no // being there, not the actual delete. if (!Exists(filename)) { - LOG_DEBUG(Common_Filesystem, "%s does not exist", filename.c_str()); + NGLOG_DEBUG(Common_Filesystem, "{} does not exist", filename); return true; } // We can't delete a directory if (IsDirectory(filename)) { - LOG_ERROR(Common_Filesystem, "Failed: %s is a directory", filename.c_str()); + NGLOG_ERROR(Common_Filesystem, "Failed: {} is a directory", filename); return false; } #ifdef _WIN32 if (!DeleteFileW(Common::UTF8ToUTF16W(filename).c_str())) { - LOG_ERROR(Common_Filesystem, "DeleteFile failed on %s: %s", filename.c_str(), - GetLastErrorMsg()); + NGLOG_ERROR(Common_Filesystem, "DeleteFile failed on {}: {}", filename, GetLastErrorMsg()); return false; } #else if (unlink(filename.c_str()) == -1) { - LOG_ERROR(Common_Filesystem, "unlink failed on %s: %s", filename.c_str(), - GetLastErrorMsg()); + NGLOG_ERROR(Common_Filesystem, "unlink failed on {}: {}", filename, GetLastErrorMsg()); return false; } #endif @@ -162,16 +160,16 @@ bool Delete(const std::string& filename) { // Returns true if successful, or path already exists. bool CreateDir(const std::string& path) { - LOG_TRACE(Common_Filesystem, "directory %s", path.c_str()); + NGLOG_TRACE(Common_Filesystem, "directory {}", path); #ifdef _WIN32 if (::CreateDirectoryW(Common::UTF8ToUTF16W(path).c_str(), nullptr)) return true; DWORD error = GetLastError(); if (error == ERROR_ALREADY_EXISTS) { - LOG_DEBUG(Common_Filesystem, "CreateDirectory failed on %s: already exists", path.c_str()); + NGLOG_DEBUG(Common_Filesystem, "CreateDirectory failed on {}: already exists", path); return true; } - LOG_ERROR(Common_Filesystem, "CreateDirectory failed on %s: %i", path.c_str(), error); + NGLOG_ERROR(Common_Filesystem, "CreateDirectory failed on {}: {}", path, error); return false; #else if (mkdir(path.c_str(), 0755) == 0) @@ -180,11 +178,11 @@ bool CreateDir(const std::string& path) { int err = errno; if (err == EEXIST) { - LOG_DEBUG(Common_Filesystem, "mkdir failed on %s: already exists", path.c_str()); + NGLOG_DEBUG(Common_Filesystem, "mkdir failed on {}: already exists", path); return true; } - LOG_ERROR(Common_Filesystem, "mkdir failed on %s: %s", path.c_str(), strerror(err)); + NGLOG_ERROR(Common_Filesystem, "mkdir failed on {}: {}", path, strerror(err)); return false; #endif } @@ -192,10 +190,10 @@ bool CreateDir(const std::string& path) { // Creates the full path of fullPath returns true on success bool CreateFullPath(const std::string& fullPath) { int panicCounter = 100; - LOG_TRACE(Common_Filesystem, "path %s", fullPath.c_str()); + NGLOG_TRACE(Common_Filesystem, "path {}", fullPath); if (FileUtil::Exists(fullPath)) { - LOG_DEBUG(Common_Filesystem, "path exists %s", fullPath.c_str()); + NGLOG_DEBUG(Common_Filesystem, "path exists {}", fullPath); return true; } @@ -211,14 +209,14 @@ bool CreateFullPath(const std::string& fullPath) { // Include the '/' so the first call is CreateDir("/") rather than CreateDir("") std::string const subPath(fullPath.substr(0, position + 1)); if (!FileUtil::IsDirectory(subPath) && !FileUtil::CreateDir(subPath)) { - LOG_ERROR(Common, "CreateFullPath: directory creation failed"); + NGLOG_ERROR(Common, "CreateFullPath: directory creation failed"); return false; } // A safety check panicCounter--; if (panicCounter <= 0) { - LOG_ERROR(Common, "CreateFullPath: directory structure is too deep"); + NGLOG_ERROR(Common, "CreateFullPath: directory structure is too deep"); return false; } position++; @@ -227,11 +225,11 @@ bool CreateFullPath(const std::string& fullPath) { // Deletes a directory filename, returns true on success bool DeleteDir(const std::string& filename) { - LOG_TRACE(Common_Filesystem, "directory %s", filename.c_str()); + NGLOG_TRACE(Common_Filesystem, "directory {}", filename); // check if a directory if (!FileUtil::IsDirectory(filename)) { - LOG_ERROR(Common_Filesystem, "Not a directory %s", filename.c_str()); + NGLOG_ERROR(Common_Filesystem, "Not a directory {}", filename); return false; } @@ -242,14 +240,14 @@ bool DeleteDir(const std::string& filename) { if (rmdir(filename.c_str()) == 0) return true; #endif - LOG_ERROR(Common_Filesystem, "failed %s: %s", filename.c_str(), GetLastErrorMsg()); + NGLOG_ERROR(Common_Filesystem, "failed {}: {}", filename, GetLastErrorMsg()); return false; } // renames file srcFilename to destFilename, returns true on success bool Rename(const std::string& srcFilename, const std::string& destFilename) { - LOG_TRACE(Common_Filesystem, "%s --> %s", srcFilename.c_str(), destFilename.c_str()); + NGLOG_TRACE(Common_Filesystem, "{} --> {}", srcFilename, destFilename); #ifdef _WIN32 if (_wrename(Common::UTF8ToUTF16W(srcFilename).c_str(), Common::UTF8ToUTF16W(destFilename).c_str()) == 0) @@ -258,21 +256,21 @@ bool Rename(const std::string& srcFilename, const std::string& destFilename) { if (rename(srcFilename.c_str(), destFilename.c_str()) == 0) return true; #endif - LOG_ERROR(Common_Filesystem, "failed %s --> %s: %s", srcFilename.c_str(), destFilename.c_str(), - GetLastErrorMsg()); + NGLOG_ERROR(Common_Filesystem, "failed {} --> {}: {}", srcFilename, destFilename, + GetLastErrorMsg()); return false; } // copies file srcFilename to destFilename, returns true on success bool Copy(const std::string& srcFilename, const std::string& destFilename) { - LOG_TRACE(Common_Filesystem, "%s --> %s", srcFilename.c_str(), destFilename.c_str()); + NGLOG_TRACE(Common_Filesystem, "{} --> {}", srcFilename, destFilename); #ifdef _WIN32 if (CopyFileW(Common::UTF8ToUTF16W(srcFilename).c_str(), Common::UTF8ToUTF16W(destFilename).c_str(), FALSE)) return true; - LOG_ERROR(Common_Filesystem, "failed %s --> %s: %s", srcFilename.c_str(), destFilename.c_str(), - GetLastErrorMsg()); + NGLOG_ERROR(Common_Filesystem, "failed {} --> {}: {}", srcFilename, destFilename, + GetLastErrorMsg()); return false; #else @@ -284,8 +282,8 @@ bool Copy(const std::string& srcFilename, const std::string& destFilename) { // Open input file FILE* input = fopen(srcFilename.c_str(), "rb"); if (!input) { - LOG_ERROR(Common_Filesystem, "opening input failed %s --> %s: %s", srcFilename.c_str(), - destFilename.c_str(), GetLastErrorMsg()); + NGLOG_ERROR(Common_Filesystem, "opening input failed {} --> {}: {}", srcFilename, + destFilename, GetLastErrorMsg()); return false; } @@ -293,8 +291,8 @@ bool Copy(const std::string& srcFilename, const std::string& destFilename) { FILE* output = fopen(destFilename.c_str(), "wb"); if (!output) { fclose(input); - LOG_ERROR(Common_Filesystem, "opening output failed %s --> %s: %s", srcFilename.c_str(), - destFilename.c_str(), GetLastErrorMsg()); + NGLOG_ERROR(Common_Filesystem, "opening output failed {} --> {}: {}", srcFilename, + destFilename, GetLastErrorMsg()); return false; } @@ -304,8 +302,8 @@ bool Copy(const std::string& srcFilename, const std::string& destFilename) { size_t rnum = fread(buffer, sizeof(char), BSIZE, input); if (rnum != BSIZE) { if (ferror(input) != 0) { - LOG_ERROR(Common_Filesystem, "failed reading from source, %s --> %s: %s", - srcFilename.c_str(), destFilename.c_str(), GetLastErrorMsg()); + NGLOG_ERROR(Common_Filesystem, "failed reading from source, {} --> {}: {}", + srcFilename, destFilename, GetLastErrorMsg()); goto bail; } } @@ -313,8 +311,8 @@ bool Copy(const std::string& srcFilename, const std::string& destFilename) { // write output size_t wnum = fwrite(buffer, sizeof(char), rnum, output); if (wnum != rnum) { - LOG_ERROR(Common_Filesystem, "failed writing to output, %s --> %s: %s", - srcFilename.c_str(), destFilename.c_str(), GetLastErrorMsg()); + NGLOG_ERROR(Common_Filesystem, "failed writing to output, {} --> {}: {}", srcFilename, + destFilename, GetLastErrorMsg()); goto bail; } } @@ -334,12 +332,12 @@ bail: // Returns the size of filename (64bit) u64 GetSize(const std::string& filename) { if (!Exists(filename)) { - LOG_ERROR(Common_Filesystem, "failed %s: No such file", filename.c_str()); + NGLOG_ERROR(Common_Filesystem, "failed {}: No such file", filename); return 0; } if (IsDirectory(filename)) { - LOG_ERROR(Common_Filesystem, "failed %s: is a directory", filename.c_str()); + NGLOG_ERROR(Common_Filesystem, "failed {}: is a directory", filename); return 0; } @@ -350,11 +348,11 @@ u64 GetSize(const std::string& filename) { if (stat(filename.c_str(), &buf) == 0) #endif { - LOG_TRACE(Common_Filesystem, "%s: %lld", filename.c_str(), (long long)buf.st_size); + NGLOG_TRACE(Common_Filesystem, "{}: {}", filename, (long long)buf.st_size); return buf.st_size; } - LOG_ERROR(Common_Filesystem, "Stat failed %s: %s", filename.c_str(), GetLastErrorMsg()); + NGLOG_ERROR(Common_Filesystem, "Stat failed {}: {}", filename, GetLastErrorMsg()); return 0; } @@ -362,7 +360,7 @@ u64 GetSize(const std::string& filename) { u64 GetSize(const int fd) { struct stat buf; if (fstat(fd, &buf) != 0) { - LOG_ERROR(Common_Filesystem, "GetSize: stat failed %i: %s", fd, GetLastErrorMsg()); + NGLOG_ERROR(Common_Filesystem, "GetSize: stat failed {}: {}", fd, GetLastErrorMsg()); return 0; } return buf.st_size; @@ -373,12 +371,12 @@ u64 GetSize(FILE* f) { // can't use off_t here because it can be 32-bit u64 pos = ftello(f); if (fseeko(f, 0, SEEK_END) != 0) { - LOG_ERROR(Common_Filesystem, "GetSize: seek failed %p: %s", f, GetLastErrorMsg()); + NGLOG_ERROR(Common_Filesystem, "GetSize: seek failed {}: {}", f, GetLastErrorMsg()); return 0; } u64 size = ftello(f); if ((size != pos) && (fseeko(f, pos, SEEK_SET) != 0)) { - LOG_ERROR(Common_Filesystem, "GetSize: seek failed %p: %s", f, GetLastErrorMsg()); + NGLOG_ERROR(Common_Filesystem, "GetSize: seek failed {}: {}", f, GetLastErrorMsg()); return 0; } return size; @@ -386,10 +384,10 @@ u64 GetSize(FILE* f) { // creates an empty file filename, returns true on success bool CreateEmptyFile(const std::string& filename) { - LOG_TRACE(Common_Filesystem, "%s", filename.c_str()); + NGLOG_TRACE(Common_Filesystem, "{}", filename); if (!FileUtil::IOFile(filename, "wb")) { - LOG_ERROR(Common_Filesystem, "failed %s: %s", filename.c_str(), GetLastErrorMsg()); + NGLOG_ERROR(Common_Filesystem, "failed {}: {}", filename, GetLastErrorMsg()); return false; } @@ -398,7 +396,7 @@ bool CreateEmptyFile(const std::string& filename) { bool ForeachDirectoryEntry(unsigned* num_entries_out, const std::string& directory, DirectoryEntryCallable callback) { - LOG_TRACE(Common_Filesystem, "directory %s", directory.c_str()); + NGLOG_TRACE(Common_Filesystem, "directory {}", directory); // How many files + directories we found unsigned found_entries = 0; @@ -556,7 +554,7 @@ std::string GetCurrentDir() { char* dir; if (!(dir = getcwd(nullptr, 0))) { #endif - LOG_ERROR(Common_Filesystem, "GetCurrentDirectory failed: %s", GetLastErrorMsg()); + NGLOG_ERROR(Common_Filesystem, "GetCurrentDirectory failed: {}", GetLastErrorMsg()); return nullptr; } #ifdef _WIN32 @@ -676,7 +674,7 @@ std::string GetSysDirectory() { #endif sysDir += DIR_SEP; - LOG_DEBUG(Common_Filesystem, "Setting to %s:", sysDir.c_str()); + NGLOG_DEBUG(Common_Filesystem, "Setting to {}:", sysDir); return sysDir; } @@ -692,7 +690,7 @@ const std::string& GetUserPath(const unsigned int DirIDX, const std::string& new if (!FileUtil::IsDirectory(paths[D_USER_IDX])) { paths[D_USER_IDX] = AppDataRoamingDirectory() + DIR_SEP EMU_DATA_DIR DIR_SEP; } else { - LOG_INFO(Common_Filesystem, "Using the local user directory"); + NGLOG_INFO(Common_Filesystem, "Using the local user directory"); } paths[D_CONFIG_IDX] = paths[D_USER_IDX] + CONFIG_DIR DIR_SEP; @@ -719,7 +717,7 @@ const std::string& GetUserPath(const unsigned int DirIDX, const std::string& new if (!newPath.empty()) { if (!FileUtil::IsDirectory(newPath)) { - LOG_ERROR(Common_Filesystem, "Invalid path specified %s", newPath.c_str()); + NGLOG_ERROR(Common_Filesystem, "Invalid path specified {}", newPath); return paths[DirIDX]; } else { paths[DirIDX] = newPath; diff --git a/src/common/logging/filter.cpp b/src/common/logging/filter.cpp index 733247b51..1ab6c2ee3 100644 --- a/src/common/logging/filter.cpp +++ b/src/common/logging/filter.cpp @@ -65,14 +65,14 @@ bool Filter::ParseFilterRule(const std::string::const_iterator begin, const std::string::const_iterator end) { auto level_separator = std::find(begin, end, ':'); if (level_separator == end) { - LOG_ERROR(Log, "Invalid log filter. Must specify a log level after `:`: %s", - std::string(begin, end).c_str()); + NGLOG_ERROR(Log, "Invalid log filter. Must specify a log level after `:`: {}", + std::string(begin, end)); return false; } const Level level = GetLevelByName(level_separator + 1, end); if (level == Level::Count) { - LOG_ERROR(Log, "Unknown log level in filter: %s", std::string(begin, end).c_str()); + NGLOG_ERROR(Log, "Unknown log level in filter: {}", std::string(begin, end)); return false; } @@ -83,7 +83,7 @@ bool Filter::ParseFilterRule(const std::string::const_iterator begin, const Class log_class = GetClassByName(begin, level_separator); if (log_class == Class::Count) { - LOG_ERROR(Log, "Unknown log class in filter: %s", std::string(begin, end).c_str()); + NGLOG_ERROR(Log, "Unknown log class in filter: {}", std::string(begin, end)); return false; } diff --git a/src/common/memory_util.cpp b/src/common/memory_util.cpp index 759ad02ca..79b7215d3 100644 --- a/src/common/memory_util.cpp +++ b/src/common/memory_util.cpp @@ -55,7 +55,7 @@ void* AllocateExecutableMemory(size_t size, bool low) { if (ptr == MAP_FAILED) { ptr = nullptr; #endif - LOG_ERROR(Common_Memory, "Failed to allocate executable memory"); + NGLOG_ERROR(Common_Memory, "Failed to allocate executable memory"); } #if !defined(_WIN32) && defined(ARCHITECTURE_X64) && !defined(MAP_32BIT) else { @@ -68,7 +68,7 @@ void* AllocateExecutableMemory(size_t size, bool low) { #if EMU_ARCH_BITS == 64 if ((u64)ptr >= 0x80000000 && low == true) - LOG_ERROR(Common_Memory, "Executable memory ended up above 2GB!"); + NGLOG_ERROR(Common_Memory, "Executable memory ended up above 2GB!"); #endif return ptr; @@ -85,7 +85,7 @@ void* AllocateMemoryPages(size_t size) { #endif if (ptr == nullptr) - LOG_ERROR(Common_Memory, "Failed to allocate raw memory"); + NGLOG_ERROR(Common_Memory, "Failed to allocate raw memory"); return ptr; } @@ -99,12 +99,12 @@ void* AllocateAlignedMemory(size_t size, size_t alignment) { ptr = memalign(alignment, size); #else if (posix_memalign(&ptr, alignment, size) != 0) - LOG_ERROR(Common_Memory, "Failed to allocate aligned memory"); + NGLOG_ERROR(Common_Memory, "Failed to allocate aligned memory"); #endif #endif if (ptr == nullptr) - LOG_ERROR(Common_Memory, "Failed to allocate aligned memory"); + NGLOG_ERROR(Common_Memory, "Failed to allocate aligned memory"); return ptr; } @@ -113,7 +113,7 @@ void FreeMemoryPages(void* ptr, size_t size) { if (ptr) { #ifdef _WIN32 if (!VirtualFree(ptr, 0, MEM_RELEASE)) - LOG_ERROR(Common_Memory, "FreeMemoryPages failed!\n%s", GetLastErrorMsg()); + NGLOG_ERROR(Common_Memory, "FreeMemoryPages failed!\n{}", GetLastErrorMsg()); #else munmap(ptr, size); #endif @@ -134,7 +134,7 @@ void WriteProtectMemory(void* ptr, size_t size, bool allowExecute) { #ifdef _WIN32 DWORD oldValue; if (!VirtualProtect(ptr, size, allowExecute ? PAGE_EXECUTE_READ : PAGE_READONLY, &oldValue)) - LOG_ERROR(Common_Memory, "WriteProtectMemory failed!\n%s", GetLastErrorMsg()); + NGLOG_ERROR(Common_Memory, "WriteProtectMemory failed!\n{}", GetLastErrorMsg()); #else mprotect(ptr, size, allowExecute ? (PROT_READ | PROT_EXEC) : PROT_READ); #endif @@ -145,7 +145,7 @@ void UnWriteProtectMemory(void* ptr, size_t size, bool allowExecute) { DWORD oldValue; if (!VirtualProtect(ptr, size, allowExecute ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE, &oldValue)) - LOG_ERROR(Common_Memory, "UnWriteProtectMemory failed!\n%s", GetLastErrorMsg()); + NGLOG_ERROR(Common_Memory, "UnWriteProtectMemory failed!\n{}", GetLastErrorMsg()); #else mprotect(ptr, size, allowExecute ? (PROT_READ | PROT_WRITE | PROT_EXEC) : PROT_WRITE | PROT_READ); diff --git a/src/common/param_package.cpp b/src/common/param_package.cpp index 3a6ef8c27..10b16f124 100644 --- a/src/common/param_package.cpp +++ b/src/common/param_package.cpp @@ -25,7 +25,7 @@ ParamPackage::ParamPackage(const std::string& serialized) { std::vector key_value; Common::SplitString(pair, KEY_VALUE_SEPARATOR, key_value); if (key_value.size() != 2) { - LOG_ERROR(Common, "invalid key pair %s", pair.c_str()); + NGLOG_ERROR(Common, "invalid key pair {}", pair); continue; } @@ -64,7 +64,7 @@ std::string ParamPackage::Serialize() const { std::string ParamPackage::Get(const std::string& key, const std::string& default_value) const { auto pair = data.find(key); if (pair == data.end()) { - LOG_DEBUG(Common, "key %s not found", key.c_str()); + NGLOG_DEBUG(Common, "key {} not found", key); return default_value; } @@ -74,14 +74,14 @@ std::string ParamPackage::Get(const std::string& key, const std::string& default int ParamPackage::Get(const std::string& key, int default_value) const { auto pair = data.find(key); if (pair == data.end()) { - LOG_DEBUG(Common, "key %s not found", key.c_str()); + NGLOG_DEBUG(Common, "key {} not found", key); return default_value; } try { return std::stoi(pair->second); } catch (const std::logic_error&) { - LOG_ERROR(Common, "failed to convert %s to int", pair->second.c_str()); + NGLOG_ERROR(Common, "failed to convert {} to int", pair->second); return default_value; } } @@ -89,14 +89,14 @@ int ParamPackage::Get(const std::string& key, int default_value) const { float ParamPackage::Get(const std::string& key, float default_value) const { auto pair = data.find(key); if (pair == data.end()) { - LOG_DEBUG(Common, "key %s not found", key.c_str()); + NGLOG_DEBUG(Common, "key {} not found", key); return default_value; } try { return std::stof(pair->second); } catch (const std::logic_error&) { - LOG_ERROR(Common, "failed to convert %s to float", pair->second.c_str()); + NGLOG_ERROR(Common, "failed to convert {} to float", pair->second); return default_value; } } diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp index 124a8937f..96c52e3ba 100644 --- a/src/common/string_util.cpp +++ b/src/common/string_util.cpp @@ -107,7 +107,7 @@ std::string StringFromFormat(const char* format, ...) { #else va_start(args, format); if (vasprintf(&buf, format, args) < 0) - LOG_ERROR(Common, "Unable to allocate memory for string"); + NGLOG_ERROR(Common, "Unable to allocate memory for string"); va_end(args); std::string temp = buf; @@ -347,7 +347,7 @@ static std::string CodeToUTF8(const char* fromcode, const std::basic_string& iconv_t const conv_desc = iconv_open("UTF-8", fromcode); if ((iconv_t)(-1) == conv_desc) { - LOG_ERROR(Common, "Iconv initialization failure [%s]: %s", fromcode, strerror(errno)); + NGLOG_ERROR(Common, "Iconv initialization failure [{}]: {}", fromcode, strerror(errno)); iconv_close(conv_desc); return {}; } @@ -376,7 +376,7 @@ static std::string CodeToUTF8(const char* fromcode, const std::basic_string& ++src_buffer; } } else { - LOG_ERROR(Common, "iconv failure [%s]: %s", fromcode, strerror(errno)); + NGLOG_ERROR(Common, "iconv failure [{}]: {}", fromcode, strerror(errno)); break; } } @@ -395,7 +395,7 @@ std::u16string UTF8ToUTF16(const std::string& input) { iconv_t const conv_desc = iconv_open("UTF-16LE", "UTF-8"); if ((iconv_t)(-1) == conv_desc) { - LOG_ERROR(Common, "Iconv initialization failure [UTF-8]: %s", strerror(errno)); + NGLOG_ERROR(Common, "Iconv initialization failure [UTF-8]: {}", strerror(errno)); iconv_close(conv_desc); return {}; } @@ -424,7 +424,7 @@ std::u16string UTF8ToUTF16(const std::string& input) { ++src_buffer; } } else { - LOG_ERROR(Common, "iconv failure [UTF-8]: %s", strerror(errno)); + NGLOG_ERROR(Common, "iconv failure [UTF-8]: {}", strerror(errno)); break; } } From 59b8a1dbc20e277042205f1b8c8bc26146a37ec6 Mon Sep 17 00:00:00 2001 From: Daniel Lim Wee Soong Date: Tue, 27 Mar 2018 10:01:10 +0800 Subject: [PATCH 2/7] assert: Undo removal of newline for string with __VA_ARGS__ --- src/common/assert.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/common/assert.h b/src/common/assert.h index 9718b0222..cf8109af8 100644 --- a/src/common/assert.h +++ b/src/common/assert.h @@ -37,7 +37,8 @@ __declspec(noinline, noreturn) #define ASSERT_MSG(_a_, ...) \ do \ if (!(_a_)) { \ - assert_noinline_call([&] { NGLOG_CRITICAL(Debug, "Assertion Failed!" __VA_ARGS__); }); \ + assert_noinline_call( \ + [&] { NGLOG_CRITICAL(Debug, "Assertion Failed!\n" __VA_ARGS__); }); \ } \ while (0) From 968569aa618b64af002196f0d2f2f9a2ecf142ff Mon Sep 17 00:00:00 2001 From: Daniel Lim Wee Soong Date: Tue, 27 Mar 2018 23:28:42 +0800 Subject: [PATCH 3/7] Replace format specifiers for all usages of ASSERT_MSG --- src/audio_core/hle/mixers.cpp | 2 +- .../debugger/graphics/graphics_surface.cpp | 2 +- src/common/chunk_file.h | 12 +++++------ src/common/file_util.cpp | 6 +++--- src/core/core_timing.cpp | 4 ++-- src/core/hle/applets/applet.cpp | 2 +- src/core/hle/ipc_helpers.h | 2 +- src/core/hle/kernel/hle_ipc.cpp | 4 ++-- src/core/hle/kernel/ipc.cpp | 2 +- src/core/hle/kernel/svc.cpp | 4 ++-- src/core/hle/kernel/thread.cpp | 4 ++-- src/core/hle/kernel/vm_manager.cpp | 8 ++++---- src/core/hle/service/apt/applet_manager.cpp | 2 +- src/core/hle/service/apt/apt.cpp | 4 ++-- src/core/hle/service/dsp_dsp.cpp | 18 ++++++++--------- src/core/hle/service/sm/srv.cpp | 2 +- src/core/memory.cpp | 20 +++++++++---------- src/video_core/regs_framebuffer.h | 4 ++-- .../renderer_opengl/gl_rasterizer.cpp | 2 +- src/video_core/shader/shader.cpp | 2 +- 20 files changed, 53 insertions(+), 53 deletions(-) diff --git a/src/audio_core/hle/mixers.cpp b/src/audio_core/hle/mixers.cpp index 533df2be2..727d64fde 100644 --- a/src/audio_core/hle/mixers.cpp +++ b/src/audio_core/hle/mixers.cpp @@ -132,7 +132,7 @@ void Mixers::DownmixAndMixIntoCurrentFrame(float gain, const QuadFrame32& sample return; } - UNREACHABLE_MSG("Invalid output_format %zu", static_cast(state.output_format)); + UNREACHABLE_MSG("Invalid output_format {}", static_cast(state.output_format)); } void Mixers::AuxReturn(const IntermediateMixSamples& read_samples) { diff --git a/src/citra_qt/debugger/graphics/graphics_surface.cpp b/src/citra_qt/debugger/graphics/graphics_surface.cpp index 20fd1944d..0ac746906 100644 --- a/src/citra_qt/debugger/graphics/graphics_surface.cpp +++ b/src/citra_qt/debugger/graphics/graphics_surface.cpp @@ -708,7 +708,7 @@ unsigned int GraphicsSurfaceWidget::NibblesPerPixel(GraphicsSurfaceWidget::Forma default: UNREACHABLE_MSG("GraphicsSurfaceWidget::BytesPerPixel: this should not be reached as this " "function should be given a format which is in " - "GraphicsSurfaceWidget::Format. Instead got %i", + "GraphicsSurfaceWidget::Format. Instead got {}", static_cast(format)); return 0; } diff --git a/src/common/chunk_file.h b/src/common/chunk_file.h index eaa8d81ed..277dfb697 100644 --- a/src/common/chunk_file.h +++ b/src/common/chunk_file.h @@ -198,7 +198,7 @@ public: for (int i = 0; i < size; i++) { DEBUG_ASSERT_MSG( ((u8*)data)[i] == (*ptr)[i], - "Savestate verification failure: %d (0x%X) (at %p) != %d (0x%X) (at %p).\n", + "Savestate verification failure: {} ({:#X}) (at {}) != {} ({:#X}) (at {}).\n", ((u8*)data)[i], ((u8*)data)[i], &((u8*)data)[i], (*ptr)[i], (*ptr)[i], &(*ptr)[i]); } @@ -224,7 +224,7 @@ public: for (int i = 0; i < size; i++) { DEBUG_ASSERT_MSG( ((u8*)data)[i] == (*ptr)[i], - "Savestate verification failure: %d (0x%X) (at %p) != %d (0x%X) (at %p).\n", + "Savestate verification failure: {} ({#:X}) (at {}) != {} ({:#X}) (at {}).\n", ((u8*)data)[i], ((u8*)data)[i], &((u8*)data)[i], (*ptr)[i], (*ptr)[i], &(*ptr)[i]); } @@ -486,8 +486,8 @@ public: break; case MODE_VERIFY: DEBUG_ASSERT_MSG((x == (char*)*ptr), - "Savestate verification failure: \"%s\" != \"%s\" (at %p).\n", - x.c_str(), (char*)*ptr, ptr); + "Savestate verification failure: \"{}\" != \"{}\" (at {}).\n", x, + (char*)*ptr, ptr); break; } (*ptr) += stringLen; @@ -508,8 +508,8 @@ public: break; case MODE_VERIFY: DEBUG_ASSERT_MSG((x == (wchar_t*)*ptr), - "Savestate verification failure: \"%ls\" != \"%ls\" (at %p).\n", - x.c_str(), (wchar_t*)*ptr, ptr); + "Savestate verification failure: \"{}\" != \"{}\" (at {}).\n", x, + (wchar_t*)*ptr, ptr); break; } (*ptr) += stringLen; diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp index 5879ebe3b..554a0ee95 100644 --- a/src/common/file_util.cpp +++ b/src/common/file_util.cpp @@ -651,12 +651,12 @@ static const std::string GetUserDirectory(const std::string& envvar) { else if (envvar == "XDG_CACHE_HOME") subdirectory = DIR_SEP ".cache"; else - ASSERT_MSG(false, "Unknown XDG variable %s.", envvar.c_str()); + ASSERT_MSG(false, "Unknown XDG variable {}.", envvar); user_dir = GetHomeDirectory() + subdirectory; } - ASSERT_MSG(!user_dir.empty(), "User directory %s musn’t be empty.", envvar.c_str()); - ASSERT_MSG(user_dir[0] == '/', "User directory %s must be absolute.", envvar.c_str()); + ASSERT_MSG(!user_dir.empty(), "User directory {} musn’t be empty.", envvar); + ASSERT_MSG(user_dir[0] == '/', "User directory {} must be absolute.", envvar); return user_dir; } diff --git a/src/core/core_timing.cpp b/src/core/core_timing.cpp index f62cac155..62c439739 100644 --- a/src/core/core_timing.cpp +++ b/src/core/core_timing.cpp @@ -74,9 +74,9 @@ EventType* RegisterEvent(const std::string& name, TimedCallback callback) { // check for existing type with same name. // we want event type names to remain unique so that we can use them for serialization. ASSERT_MSG(event_types.find(name) == event_types.end(), - "CoreTiming Event \"%s\" is already registered. Events should only be registered " + "CoreTiming Event \"{}\" is already registered. Events should only be registered " "during Init to avoid breaking save states.", - name.c_str()); + name); auto info = event_types.emplace(name, EventType{callback, nullptr}); EventType* event_type = &info.first->second; diff --git a/src/core/hle/applets/applet.cpp b/src/core/hle/applets/applet.cpp index 3e115f113..d644a43d3 100644 --- a/src/core/hle/applets/applet.cpp +++ b/src/core/hle/applets/applet.cpp @@ -82,7 +82,7 @@ std::shared_ptr Applet::Get(Service::APT::AppletId id) { static void AppletUpdateEvent(u64 applet_id, int cycles_late) { Service::APT::AppletId id = static_cast(applet_id); std::shared_ptr applet = Applet::Get(id); - ASSERT_MSG(applet != nullptr, "Applet doesn't exist! applet_id=%08X", static_cast(id)); + ASSERT_MSG(applet != nullptr, "Applet doesn't exist! applet_id={:#X}", static_cast(id)); applet->Update(); diff --git a/src/core/hle/ipc_helpers.h b/src/core/hle/ipc_helpers.h index dc6c7bf7d..bbe97b7f9 100644 --- a/src/core/hle/ipc_helpers.h +++ b/src/core/hle/ipc_helpers.h @@ -32,7 +32,7 @@ public: } void ValidateHeader() { - DEBUG_ASSERT_MSG(index == TotalSize(), "Operations do not match the header (cmd 0x%x)", + DEBUG_ASSERT_MSG(index == TotalSize(), "Operations do not match the header (cmd {:#x})", header.raw); } diff --git a/src/core/hle/kernel/hle_ipc.cpp b/src/core/hle/kernel/hle_ipc.cpp index 8240324bd..5f5885ad1 100644 --- a/src/core/hle/kernel/hle_ipc.cpp +++ b/src/core/hle/kernel/hle_ipc.cpp @@ -154,7 +154,7 @@ ResultCode HLERequestContext::PopulateFromIncomingCommandBuffer(const u32_le* sr break; } default: - UNIMPLEMENTED_MSG("Unsupported handle translation: 0x%08X", descriptor); + UNIMPLEMENTED_MSG("Unsupported handle translation: {:#X}", descriptor); } } @@ -218,7 +218,7 @@ ResultCode HLERequestContext::WriteToOutgoingCommandBuffer(u32_le* dst_cmdbuf, P break; } default: - UNIMPLEMENTED_MSG("Unsupported handle translation: 0x%08X", descriptor); + UNIMPLEMENTED_MSG("Unsupported handle translation: {:#X}", descriptor); } } diff --git a/src/core/hle/kernel/ipc.cpp b/src/core/hle/kernel/ipc.cpp index 0907b105c..fe3943c66 100644 --- a/src/core/hle/kernel/ipc.cpp +++ b/src/core/hle/kernel/ipc.cpp @@ -199,7 +199,7 @@ ResultCode TranslateCommandBuffer(SharedPtr src_thread, SharedPtr process = thread->owner_process; - ASSERT_MSG(process != nullptr, "Invalid parent process for thread=0x%08X", thread_handle); + ASSERT_MSG(process != nullptr, "Invalid parent process for thread={:#X}", thread_handle); *process_id = process->process_id; return RESULT_SUCCESS; diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index b86ca6cf8..674eb5b42 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp @@ -242,11 +242,11 @@ void Thread::ResumeFromWait() { return; case THREADSTATUS_RUNNING: - DEBUG_ASSERT_MSG(false, "Thread with object id %u has already resumed.", GetObjectId()); + DEBUG_ASSERT_MSG(false, "Thread with object id {} has already resumed.", GetObjectId()); return; case THREADSTATUS_DEAD: // This should never happen, as threads must complete before being stopped. - DEBUG_ASSERT_MSG(false, "Thread with object id %u cannot be resumed because it's DEAD.", + DEBUG_ASSERT_MSG(false, "Thread with object id {} cannot be resumed because it's DEAD.", GetObjectId()); return; } diff --git a/src/core/hle/kernel/vm_manager.cpp b/src/core/hle/kernel/vm_manager.cpp index c886d4f61..a3c62b174 100644 --- a/src/core/hle/kernel/vm_manager.cpp +++ b/src/core/hle/kernel/vm_manager.cpp @@ -276,8 +276,8 @@ VMManager::VMAIter VMManager::StripIterConstness(const VMAHandle& iter) { } ResultVal VMManager::CarveVMA(VAddr base, u32 size) { - ASSERT_MSG((size & Memory::PAGE_MASK) == 0, "non-page aligned size: 0x%8X", size); - ASSERT_MSG((base & Memory::PAGE_MASK) == 0, "non-page aligned base: 0x%08X", base); + ASSERT_MSG((size & Memory::PAGE_MASK) == 0, "non-page aligned size: {:#8X}", size); + ASSERT_MSG((base & Memory::PAGE_MASK) == 0, "non-page aligned base: {:#010X}", base); VMAIter vma_handle = StripIterConstness(FindVMA(base)); if (vma_handle == vma_map.end()) { @@ -312,8 +312,8 @@ ResultVal VMManager::CarveVMA(VAddr base, u32 size) { } ResultVal VMManager::CarveVMARange(VAddr target, u32 size) { - ASSERT_MSG((size & Memory::PAGE_MASK) == 0, "non-page aligned size: 0x%8X", size); - ASSERT_MSG((target & Memory::PAGE_MASK) == 0, "non-page aligned base: 0x%08X", target); + ASSERT_MSG((size & Memory::PAGE_MASK) == 0, "non-page aligned size: {:#8X}", size); + ASSERT_MSG((target & Memory::PAGE_MASK) == 0, "non-page aligned base: {:#010X}", target); VAddr target_end = target + size; ASSERT(target_end >= target); diff --git a/src/core/hle/service/apt/applet_manager.cpp b/src/core/hle/service/apt/applet_manager.cpp index fafd73bb4..c31b49d8b 100644 --- a/src/core/hle/service/apt/applet_manager.cpp +++ b/src/core/hle/service/apt/applet_manager.cpp @@ -77,7 +77,7 @@ static u64 GetTitleIdForApplet(AppletId id) { return data.applet_ids[0] == id || data.applet_ids[1] == id; }); - ASSERT_MSG(itr != applet_titleids.end(), "Unknown applet id 0x%03X", static_cast(id)); + ASSERT_MSG(itr != applet_titleids.end(), "Unknown applet id 0x{:#05X}", static_cast(id)); return itr->title_ids[CFG::GetCurrentModule()->GetRegionValue()]; } diff --git a/src/core/hle/service/apt/apt.cpp b/src/core/hle/service/apt/apt.cpp index 28f358b4b..a7a7513c0 100644 --- a/src/core/hle/service/apt/apt.cpp +++ b/src/core/hle/service/apt/apt.cpp @@ -653,7 +653,7 @@ void Module::Interface::Wrap(Kernel::HLERequestContext& ctx) { // Note: real 3DS still returns SUCCESS when the sizes don't match. It seems that it doesn't // check the buffer size and writes data with potential overflow. ASSERT_MSG(output_size == input_size + HW::AES::CCM_MAC_SIZE, - "input_size (%d) doesn't match to output_size (%d)", input_size, output_size); + "input_size ({}) doesn't match to output_size ({})", input_size, output_size); LOG_DEBUG(Service_APT, "called, output_size=%u, input_size=%u, nonce_offset=%u, nonce_size=%u", output_size, input_size, nonce_offset, nonce_size); @@ -698,7 +698,7 @@ void Module::Interface::Unwrap(Kernel::HLERequestContext& ctx) { // Note: real 3DS still returns SUCCESS when the sizes don't match. It seems that it doesn't // check the buffer size and writes data with potential overflow. ASSERT_MSG(output_size == input_size - HW::AES::CCM_MAC_SIZE, - "input_size (%d) doesn't match to output_size (%d)", input_size, output_size); + "input_size ({}) doesn't match to output_size ({})", input_size, output_size); LOG_DEBUG(Service_APT, "called, output_size=%u, input_size=%u, nonce_offset=%u, nonce_size=%u", output_size, input_size, nonce_offset, nonce_size); diff --git a/src/core/hle/service/dsp_dsp.cpp b/src/core/hle/service/dsp_dsp.cpp index d5ea97986..bab845ce4 100644 --- a/src/core/hle/service/dsp_dsp.cpp +++ b/src/core/hle/service/dsp_dsp.cpp @@ -51,7 +51,7 @@ public: } } - UNREACHABLE_MSG("Invalid interrupt type = %zu", static_cast(type)); + UNREACHABLE_MSG("Invalid interrupt type = {}", static_cast(type)); } bool HasTooManyEventsRegistered() const { @@ -219,7 +219,7 @@ static void RegisterInterruptEvents(Service::Interface* self) { u32 event_handle = cmd_buff[4]; ASSERT_MSG(type_index < NUM_INTERRUPT_TYPE && pipe_index < AudioCore::num_dsp_pipe, - "Invalid type or pipe: type = %u, pipe = %u", type_index, pipe_index); + "Invalid type or pipe: type = {}, pipe = {}", type_index, pipe_index); InterruptType type = static_cast(cmd_buff[1]); DspPipe pipe = static_cast(cmd_buff[2]); @@ -305,7 +305,7 @@ static void WriteProcessPipe(Service::Interface* self) { } ASSERT_MSG(Memory::IsValidVirtualAddress(buffer), - "Invalid Buffer: pipe=%u, size=0x%X, buffer=0x%08X", pipe_index, size, buffer); + "Invalid Buffer: pipe={}, size={:#X}, buffer={:#010X}", pipe_index, size, buffer); std::vector message(size); for (u32 i = 0; i < size; i++) { @@ -363,8 +363,8 @@ static void ReadPipeIfPossible(Service::Interface* self) { AudioCore::DspPipe pipe = static_cast(pipe_index); ASSERT_MSG(Memory::IsValidVirtualAddress(addr), - "Invalid addr: pipe=0x%08X, unknown=0x%08X, size=0x%X, buffer=0x%08X", pipe_index, - unknown, size, addr); + "Invalid addr: pipe={:#010X}, unknown={:#010X}, size={:#X}, buffer={:#010X}", + pipe_index, unknown, size, addr); cmd_buff[0] = IPC::MakeHeader(0x10, 1, 2); cmd_buff[1] = RESULT_SUCCESS.raw; // No error @@ -407,8 +407,8 @@ static void ReadPipe(Service::Interface* self) { AudioCore::DspPipe pipe = static_cast(pipe_index); ASSERT_MSG(Memory::IsValidVirtualAddress(addr), - "Invalid addr: pipe=0x%08X, unknown=0x%08X, size=0x%X, buffer=0x%08X", pipe_index, - unknown, size, addr); + "Invalid addr: pipe={:#010X}, unknown={:#010X}, size={:#X}, buffer={:#010X}", + pipe_index, unknown, size, addr); if (Core::DSP().GetPipeReadableSize(pipe) >= size) { std::vector response = Core::DSP().PipeRead(pipe, size); @@ -508,7 +508,7 @@ static void RecvData(Service::Interface* self) { u32 register_number = cmd_buff[1]; - ASSERT_MSG(register_number == 0, "Unknown register_number %u", register_number); + ASSERT_MSG(register_number == 0, "Unknown register_number {}", register_number); // Application reads this after requesting DSP shutdown, to verify the DSP has indeed shutdown // or slept. @@ -547,7 +547,7 @@ static void RecvDataIsReady(Service::Interface* self) { u32 register_number = cmd_buff[1]; - ASSERT_MSG(register_number == 0, "Unknown register_number %u", register_number); + ASSERT_MSG(register_number == 0, "Unknown register_number {}", register_number); cmd_buff[0] = IPC::MakeHeader(0x2, 2, 0); cmd_buff[1] = RESULT_SUCCESS.raw; diff --git a/src/core/hle/service/sm/srv.cpp b/src/core/hle/service/sm/srv.cpp index b669aa8a9..4a440c55e 100644 --- a/src/core/hle/service/sm/srv.cpp +++ b/src/core/hle/service/sm/srv.cpp @@ -118,7 +118,7 @@ void SRV::GetServiceHandle(Kernel::HLERequestContext& ctx) { } else if (session.Code() == Kernel::ERR_MAX_CONNECTIONS_REACHED && wait_until_available) { LOG_WARNING(Service_SRV, "called service=%s -> ERR_MAX_CONNECTIONS_REACHED", name.c_str()); // TODO(Subv): Put the caller guest thread to sleep until this port becomes available again. - UNIMPLEMENTED_MSG("Unimplemented wait until port %s is available.", name.c_str()); + UNIMPLEMENTED_MSG("Unimplemented wait until port {} is available.", name); } else { LOG_ERROR(Service_SRV, "called service=%s -> error 0x%08X", name.c_str(), session.Code().raw); diff --git a/src/core/memory.cpp b/src/core/memory.cpp index ca917307a..64e6fbb93 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp @@ -46,7 +46,7 @@ static void MapPages(PageTable& page_table, u32 base, u32 size, u8* memory, Page u32 end = base + size; while (base != end) { - ASSERT_MSG(base < PAGE_TABLE_NUM_ENTRIES, "out of range mapping at %08X", base); + ASSERT_MSG(base < PAGE_TABLE_NUM_ENTRIES, "out of range mapping at {:#010X}", base); page_table.attributes[base] = type; page_table.pointers[base] = memory; @@ -58,22 +58,22 @@ static void MapPages(PageTable& page_table, u32 base, u32 size, u8* memory, Page } void MapMemoryRegion(PageTable& page_table, VAddr base, u32 size, u8* target) { - ASSERT_MSG((size & PAGE_MASK) == 0, "non-page aligned size: %08X", size); - ASSERT_MSG((base & PAGE_MASK) == 0, "non-page aligned base: %08X", base); + ASSERT_MSG((size & PAGE_MASK) == 0, "non-page aligned size: {:#010X}", size); + ASSERT_MSG((base & PAGE_MASK) == 0, "non-page aligned base: {:#010X}", base); MapPages(page_table, base / PAGE_SIZE, size / PAGE_SIZE, target, PageType::Memory); } void MapIoRegion(PageTable& page_table, VAddr base, u32 size, MMIORegionPointer mmio_handler) { - ASSERT_MSG((size & PAGE_MASK) == 0, "non-page aligned size: %08X", size); - ASSERT_MSG((base & PAGE_MASK) == 0, "non-page aligned base: %08X", base); + ASSERT_MSG((size & PAGE_MASK) == 0, "non-page aligned size: {:#010X}", size); + ASSERT_MSG((base & PAGE_MASK) == 0, "non-page aligned base: {:#010X}", base); MapPages(page_table, base / PAGE_SIZE, size / PAGE_SIZE, nullptr, PageType::Special); page_table.special_regions.emplace_back(SpecialRegion{base, size, mmio_handler}); } void UnmapRegion(PageTable& page_table, VAddr base, u32 size) { - ASSERT_MSG((size & PAGE_MASK) == 0, "non-page aligned size: %08X", size); - ASSERT_MSG((base & PAGE_MASK) == 0, "non-page aligned base: %08X", base); + ASSERT_MSG((size & PAGE_MASK) == 0, "non-page aligned size: {:#010X}", size); + ASSERT_MSG((base & PAGE_MASK) == 0, "non-page aligned base: {:#010X}", base); MapPages(page_table, base / PAGE_SIZE, size / PAGE_SIZE, nullptr, PageType::Unmapped); } @@ -123,7 +123,7 @@ static MMIORegionPointer GetMMIOHandler(const PageTable& page_table, VAddr vaddr return region.handler; } } - ASSERT_MSG(false, "Mapped IO page without a handler @ %08X", vaddr); + ASSERT_MSG(false, "Mapped IO page without a handler @ {:08X}", vaddr); return nullptr; // Should never happen } @@ -154,7 +154,7 @@ T Read(const VAddr vaddr) { LOG_ERROR(HW_Memory, "unmapped Read%lu @ 0x%08X", sizeof(T) * 8, vaddr); return 0; case PageType::Memory: - ASSERT_MSG(false, "Mapped memory page without a pointer @ %08X", vaddr); + ASSERT_MSG(false, "Mapped memory page without a pointer @ {:08X}", vaddr); break; case PageType::RasterizerCachedMemory: { RasterizerFlushVirtualRegion(vaddr, sizeof(T), FlushMode::Flush); @@ -192,7 +192,7 @@ void Write(const VAddr vaddr, const T data) { vaddr); return; case PageType::Memory: - ASSERT_MSG(false, "Mapped memory page without a pointer @ %08X", vaddr); + ASSERT_MSG(false, "Mapped memory page without a pointer @ {:08X}", vaddr); break; case PageType::RasterizerCachedMemory: { RasterizerFlushVirtualRegion(vaddr, sizeof(T), FlushMode::Invalidate); diff --git a/src/video_core/regs_framebuffer.h b/src/video_core/regs_framebuffer.h index 8020faee8..cfddd629c 100644 --- a/src/video_core/regs_framebuffer.h +++ b/src/video_core/regs_framebuffer.h @@ -258,7 +258,7 @@ struct FramebufferRegs { return 4; } - ASSERT_MSG(false, "Unknown depth format %u", static_cast(format)); + ASSERT_MSG(false, "Unknown depth format {}", static_cast(format)); } // Returns the number of bits per depth component of the specified depth format @@ -271,7 +271,7 @@ struct FramebufferRegs { return 24; } - ASSERT_MSG(false, "Unknown depth format %u", static_cast(format)); + ASSERT_MSG(false, "Unknown depth format {}", static_cast(format)); } INSERT_PADDING_WORDS(0x20); diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index 612540d25..521e07641 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp @@ -1281,7 +1281,7 @@ void RasterizerOpenGL::SetShader() { glGetActiveUniformBlockiv(current_shader->shader.handle, block_index, GL_UNIFORM_BLOCK_DATA_SIZE, &block_size); ASSERT_MSG(block_size == sizeof(UniformData), - "Uniform block size did not match! Got %d, expected %zu", + "Uniform block size did not match! Got {}, expected {}", static_cast(block_size), sizeof(UniformData)); glUniformBlockBinding(current_shader->shader.handle, block_index, 0); diff --git a/src/video_core/shader/shader.cpp b/src/video_core/shader/shader.cpp index 443923eae..54331b453 100644 --- a/src/video_core/shader/shader.cpp +++ b/src/video_core/shader/shader.cpp @@ -30,7 +30,7 @@ void OutputVertex::ValidateSemantics(const RasterizerRegs& regs) { for (size_t comp = 0; comp < 4; ++comp) { u32 semantic = (output_register_map >> (8 * comp)) & 0x1F; ASSERT_MSG(semantic < 24 || semantic == RasterizerRegs::VSOutputAttributes::INVALID, - "Invalid/unknown semantic id: %" PRIu32, semantic); + "Invalid/unknown semantic id: {}", semantic); } } } From 0f4c9c9f47228fa85bdf3821b171f31aa9a84027 Mon Sep 17 00:00:00 2001 From: Daniel Lim Wee Soong Date: Tue, 27 Mar 2018 23:31:08 +0800 Subject: [PATCH 4/7] file_util: Remove long long casting on buf.st_size in NGLOG statement --- src/common/file_util.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp index 554a0ee95..23828fbe2 100644 --- a/src/common/file_util.cpp +++ b/src/common/file_util.cpp @@ -348,7 +348,7 @@ u64 GetSize(const std::string& filename) { if (stat(filename.c_str(), &buf) == 0) #endif { - NGLOG_TRACE(Common_Filesystem, "{}: {}", filename, (long long)buf.st_size); + NGLOG_TRACE(Common_Filesystem, "{}: {}", filename, buf.st_size); return buf.st_size; } From 20776b37be6ba25d29f68f5318719148d3c6cb8b Mon Sep 17 00:00:00 2001 From: Daniel Lim Wee Soong Date: Tue, 27 Mar 2018 23:37:36 +0800 Subject: [PATCH 5/7] Fix wrongly converted specifiers Sorry that was a lot in one go so some of them had some mistakes --- src/core/hle/applets/applet.cpp | 2 +- src/core/hle/kernel/hle_ipc.cpp | 4 ++-- src/core/hle/kernel/ipc.cpp | 2 +- src/core/hle/kernel/svc.cpp | 2 +- src/core/memory.cpp | 14 +++++++------- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/core/hle/applets/applet.cpp b/src/core/hle/applets/applet.cpp index d644a43d3..81227df76 100644 --- a/src/core/hle/applets/applet.cpp +++ b/src/core/hle/applets/applet.cpp @@ -82,7 +82,7 @@ std::shared_ptr Applet::Get(Service::APT::AppletId id) { static void AppletUpdateEvent(u64 applet_id, int cycles_late) { Service::APT::AppletId id = static_cast(applet_id); std::shared_ptr applet = Applet::Get(id); - ASSERT_MSG(applet != nullptr, "Applet doesn't exist! applet_id={:#X}", static_cast(id)); + ASSERT_MSG(applet != nullptr, "Applet doesn't exist! applet_id={:#08X}", static_cast(id)); applet->Update(); diff --git a/src/core/hle/kernel/hle_ipc.cpp b/src/core/hle/kernel/hle_ipc.cpp index 5f5885ad1..6c087dd86 100644 --- a/src/core/hle/kernel/hle_ipc.cpp +++ b/src/core/hle/kernel/hle_ipc.cpp @@ -154,7 +154,7 @@ ResultCode HLERequestContext::PopulateFromIncomingCommandBuffer(const u32_le* sr break; } default: - UNIMPLEMENTED_MSG("Unsupported handle translation: {:#X}", descriptor); + UNIMPLEMENTED_MSG("Unsupported handle translation: {:#010X}", descriptor); } } @@ -218,7 +218,7 @@ ResultCode HLERequestContext::WriteToOutgoingCommandBuffer(u32_le* dst_cmdbuf, P break; } default: - UNIMPLEMENTED_MSG("Unsupported handle translation: {:#X}", descriptor); + UNIMPLEMENTED_MSG("Unsupported handle translation: {:#010X}", descriptor); } } diff --git a/src/core/hle/kernel/ipc.cpp b/src/core/hle/kernel/ipc.cpp index fe3943c66..b390b7fbc 100644 --- a/src/core/hle/kernel/ipc.cpp +++ b/src/core/hle/kernel/ipc.cpp @@ -199,7 +199,7 @@ ResultCode TranslateCommandBuffer(SharedPtr src_thread, SharedPtr process = thread->owner_process; - ASSERT_MSG(process != nullptr, "Invalid parent process for thread={:#X}", thread_handle); + ASSERT_MSG(process != nullptr, "Invalid parent process for thread={:#010X}", thread_handle); *process_id = process->process_id; return RESULT_SUCCESS; diff --git a/src/core/memory.cpp b/src/core/memory.cpp index 64e6fbb93..06cd2231d 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp @@ -46,7 +46,7 @@ static void MapPages(PageTable& page_table, u32 base, u32 size, u8* memory, Page u32 end = base + size; while (base != end) { - ASSERT_MSG(base < PAGE_TABLE_NUM_ENTRIES, "out of range mapping at {:#010X}", base); + ASSERT_MSG(base < PAGE_TABLE_NUM_ENTRIES, "out of range mapping at {:08X}", base); page_table.attributes[base] = type; page_table.pointers[base] = memory; @@ -58,22 +58,22 @@ static void MapPages(PageTable& page_table, u32 base, u32 size, u8* memory, Page } void MapMemoryRegion(PageTable& page_table, VAddr base, u32 size, u8* target) { - ASSERT_MSG((size & PAGE_MASK) == 0, "non-page aligned size: {:#010X}", size); - ASSERT_MSG((base & PAGE_MASK) == 0, "non-page aligned base: {:#010X}", base); + ASSERT_MSG((size & PAGE_MASK) == 0, "non-page aligned size: {:08X}", size); + ASSERT_MSG((base & PAGE_MASK) == 0, "non-page aligned base: {:08X}", base); MapPages(page_table, base / PAGE_SIZE, size / PAGE_SIZE, target, PageType::Memory); } void MapIoRegion(PageTable& page_table, VAddr base, u32 size, MMIORegionPointer mmio_handler) { - ASSERT_MSG((size & PAGE_MASK) == 0, "non-page aligned size: {:#010X}", size); - ASSERT_MSG((base & PAGE_MASK) == 0, "non-page aligned base: {:#010X}", base); + ASSERT_MSG((size & PAGE_MASK) == 0, "non-page aligned size: {:08X}", size); + ASSERT_MSG((base & PAGE_MASK) == 0, "non-page aligned base: {:08X}", base); MapPages(page_table, base / PAGE_SIZE, size / PAGE_SIZE, nullptr, PageType::Special); page_table.special_regions.emplace_back(SpecialRegion{base, size, mmio_handler}); } void UnmapRegion(PageTable& page_table, VAddr base, u32 size) { - ASSERT_MSG((size & PAGE_MASK) == 0, "non-page aligned size: {:#010X}", size); - ASSERT_MSG((base & PAGE_MASK) == 0, "non-page aligned base: {:#010X}", base); + ASSERT_MSG((size & PAGE_MASK) == 0, "non-page aligned size: {:08X}", size); + ASSERT_MSG((base & PAGE_MASK) == 0, "non-page aligned base: {:08X}", base); MapPages(page_table, base / PAGE_SIZE, size / PAGE_SIZE, nullptr, PageType::Unmapped); } From 730f8a410365d3ed27a00ae7d102c36546b53d2a Mon Sep 17 00:00:00 2001 From: Daniel Lim Wee Soong Date: Wed, 28 Mar 2018 22:28:55 +0800 Subject: [PATCH 6/7] Fix formatting mistakes --- src/core/hle/applets/applet.cpp | 2 +- src/core/hle/kernel/vm_manager.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/hle/applets/applet.cpp b/src/core/hle/applets/applet.cpp index 81227df76..dc0c00d58 100644 --- a/src/core/hle/applets/applet.cpp +++ b/src/core/hle/applets/applet.cpp @@ -82,7 +82,7 @@ std::shared_ptr Applet::Get(Service::APT::AppletId id) { static void AppletUpdateEvent(u64 applet_id, int cycles_late) { Service::APT::AppletId id = static_cast(applet_id); std::shared_ptr applet = Applet::Get(id); - ASSERT_MSG(applet != nullptr, "Applet doesn't exist! applet_id={:#08X}", static_cast(id)); + ASSERT_MSG(applet != nullptr, "Applet doesn't exist! applet_id={:08X}", static_cast(id)); applet->Update(); diff --git a/src/core/hle/kernel/vm_manager.cpp b/src/core/hle/kernel/vm_manager.cpp index a3c62b174..37ecb239d 100644 --- a/src/core/hle/kernel/vm_manager.cpp +++ b/src/core/hle/kernel/vm_manager.cpp @@ -276,7 +276,7 @@ VMManager::VMAIter VMManager::StripIterConstness(const VMAHandle& iter) { } ResultVal VMManager::CarveVMA(VAddr base, u32 size) { - ASSERT_MSG((size & Memory::PAGE_MASK) == 0, "non-page aligned size: {:#8X}", size); + ASSERT_MSG((size & Memory::PAGE_MASK) == 0, "non-page aligned size: {:#10X}", size); ASSERT_MSG((base & Memory::PAGE_MASK) == 0, "non-page aligned base: {:#010X}", base); VMAIter vma_handle = StripIterConstness(FindVMA(base)); @@ -312,7 +312,7 @@ ResultVal VMManager::CarveVMA(VAddr base, u32 size) { } ResultVal VMManager::CarveVMARange(VAddr target, u32 size) { - ASSERT_MSG((size & Memory::PAGE_MASK) == 0, "non-page aligned size: {:#8X}", size); + ASSERT_MSG((size & Memory::PAGE_MASK) == 0, "non-page aligned size: {:#10X}", size); ASSERT_MSG((target & Memory::PAGE_MASK) == 0, "non-page aligned base: {:#010X}", target); VAddr target_end = target + size; From 98760336beb6712c07d9e67378f4fa17c1043381 Mon Sep 17 00:00:00 2001 From: Daniel Lim Wee Soong Date: Wed, 28 Mar 2018 22:40:16 +0800 Subject: [PATCH 7/7] video_core/shader/shader: Remove include cinttypes --- src/video_core/shader/shader.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/video_core/shader/shader.cpp b/src/video_core/shader/shader.cpp index 54331b453..f978390d7 100644 --- a/src/video_core/shader/shader.cpp +++ b/src/video_core/shader/shader.cpp @@ -2,7 +2,6 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#include #include #include #include "common/bit_set.h"