From 585899dba39fdad6dd5875a96007d5b4f1bb41f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Wed, 25 Nov 2020 18:59:47 +0100 Subject: Turn format string issues into compile-time errors If the compiler can detect an issue with a format string at compile time, then we should take advantage of that and turn the issue into a hard compile-time error as such problems almost always lead to UB. This helps with catching logging or assertion messages that have been converted over to fmt but are still using the old, non-fmt variants of the logging macros. This commit also fixes all incorrect usages that I could find. --- Source/UnitTests/Core/PowerPC/Jit64Common/ConvertDoubleToSingle.cpp | 3 ++- Source/UnitTests/Core/PowerPC/Jit64Common/Frsqrte.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'Source/UnitTests/Core') diff --git a/Source/UnitTests/Core/PowerPC/Jit64Common/ConvertDoubleToSingle.cpp b/Source/UnitTests/Core/PowerPC/Jit64Common/ConvertDoubleToSingle.cpp index 41ca31b273..aa4324968d 100644 --- a/Source/UnitTests/Core/PowerPC/Jit64Common/ConvertDoubleToSingle.cpp +++ b/Source/UnitTests/Core/PowerPC/Jit64Common/ConvertDoubleToSingle.cpp @@ -14,6 +14,7 @@ #include "Core/PowerPC/Jit64Common/Jit64AsmCommon.h" #include "Core/PowerPC/Jit64Common/Jit64PowerPCState.h" +#include #include namespace @@ -109,7 +110,7 @@ TEST(Jit64, ConvertDoubleToSingle) const u32 expected = ConvertToSingle(input); const u32 actual = routines.wrapped_cdts(input); - printf("%016llx -> %08x == %08x\n", input, actual, expected); + fmt::print("{:016x} -> {:08x} == {:08x}\n", input, actual, expected); EXPECT_EQ(expected, actual); } diff --git a/Source/UnitTests/Core/PowerPC/Jit64Common/Frsqrte.cpp b/Source/UnitTests/Core/PowerPC/Jit64Common/Frsqrte.cpp index 18e0ee8044..4dff5ff723 100644 --- a/Source/UnitTests/Core/PowerPC/Jit64Common/Frsqrte.cpp +++ b/Source/UnitTests/Core/PowerPC/Jit64Common/Frsqrte.cpp @@ -14,6 +14,7 @@ #include "Core/PowerPC/Jit64Common/Jit64AsmCommon.h" #include "Core/PowerPC/Jit64Common/Jit64PowerPCState.h" +#include #include namespace @@ -98,7 +99,7 @@ TEST(Jit64, Frsqrte) u64 actual = routines.wrapped_frsqrte(ivalue, fpscr); - printf("%016llx -> %016llx == %016llx\n", ivalue, actual, expected); + fmt::print("{:016x} -> {:016x} == {:016x}\n", ivalue, actual, expected); EXPECT_EQ(expected, actual); } -- cgit v1.2.3