From 09cc7e2ddfa40190172eb38d4448c35f5e761cdb Mon Sep 17 00:00:00 2001 From: Matthew Parlane Date: Fri, 7 Feb 2014 01:10:04 +1300 Subject: Give StringFromFormat a printf format attribute. It gives StringFromFormat printf style arguments that should be type-checked against a format string. --- Source/Core/Common/StringUtil.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'Source/Core/Common') diff --git a/Source/Core/Common/StringUtil.h b/Source/Core/Common/StringUtil.h index 46ed382724..7846cbee3d 100644 --- a/Source/Core/Common/StringUtil.h +++ b/Source/Core/Common/StringUtil.h @@ -14,7 +14,14 @@ #include "Common.h" -std::string StringFromFormat(const char* format, ...); +std::string StringFromFormat(const char* format, ...) +#if !defined _WIN32 +// On compilers that support function attributes, this gives StringFromFormat +// the same errors and warnings that printf would give. + __attribute__ ((__format__(printf, 1, 2))) +#endif +; + // Cheap! bool CharArrayFromFormatV(char* out, int outsize, const char* format, va_list args); -- cgit v1.2.3 From 70d2592ffbbb2252d5ac998ce4d3200175a5951c Mon Sep 17 00:00:00 2001 From: Matthew Parlane Date: Fri, 7 Feb 2014 01:38:08 +1300 Subject: Fix warnings found by StringFromFormat having printf style checking. --- Source/Core/Common/Timer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Source/Core/Common') diff --git a/Source/Core/Common/Timer.cpp b/Source/Core/Common/Timer.cpp index b7ae848970..267755fb17 100644 --- a/Source/Core/Common/Timer.cpp +++ b/Source/Core/Common/Timer.cpp @@ -113,7 +113,7 @@ std::string Timer::GetTimeElapsedFormatted() const // Hours u32 Hours = Minutes / 60; - std::string TmpStr = StringFromFormat("%02i:%02i:%02i:%03i", + std::string TmpStr = StringFromFormat("%02i:%02i:%02i:%03lu", Hours, Minutes % 60, Seconds % 60, Milliseconds % 1000); return TmpStr; } -- cgit v1.2.3