summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorPierre Bourdon <delroth@gmail.com>2014-02-07 00:18:12 +0100
committerPierre Bourdon <delroth@gmail.com>2014-02-07 00:18:12 +0100
commit4c6d4cc27092ffbdd7be3483b83e355fbc115f4e (patch)
tree8b2af8ad3894ec5f751ab2c2c0b5563e9fa6d149 /Source
parent8ad6f154a4fe64564d18598bb5fab70cc89d70c4 (diff)
parent70d2592ffbbb2252d5ac998ce4d3200175a5951c (diff)
Merge pull request #41 from Parlane/printf_warnings
Give StringFromFormat a printf format attribute.
Diffstat (limited to 'Source')
-rw-r--r--Source/Core/Common/StringUtil.h9
-rw-r--r--Source/Core/Common/Timer.cpp2
-rw-r--r--Source/Core/Core/CoreTiming.cpp2
-rw-r--r--Source/Core/Core/HLE/HLE_OS.cpp2
-rw-r--r--Source/Core/Core/PowerPC/PPCTables.cpp2
5 files changed, 12 insertions, 5 deletions
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);
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;
}
diff --git a/Source/Core/Core/CoreTiming.cpp b/Source/Core/Core/CoreTiming.cpp
index 5461692a22..ace2c9759c 100644
--- a/Source/Core/Core/CoreTiming.cpp
+++ b/Source/Core/Core/CoreTiming.cpp
@@ -469,7 +469,7 @@ std::string GetScheduledEventsSummary()
if (!name)
name = "[unknown]";
- text += StringFromFormat("%s : %i %08x%08x\n", name, ptr->time, ptr->userdata >> 32, ptr->userdata);
+ text += StringFromFormat("%s : %li %08lx%08lx\n", name, ptr->time, ptr->userdata >> 32, ptr->userdata);
ptr = ptr->next;
}
return text;
diff --git a/Source/Core/Core/HLE/HLE_OS.cpp b/Source/Core/Core/HLE/HLE_OS.cpp
index ed80a68154..ed02672110 100644
--- a/Source/Core/Core/HLE/HLE_OS.cpp
+++ b/Source/Core/Core/HLE/HLE_OS.cpp
@@ -155,7 +155,7 @@ void GetStringVA(std::string& _rOutBuffer, u32 strReg)
case 'p':
// Override, so 64bit dolphin prints 32bit pointers, since the ppc is 32bit :)
- _rOutBuffer += StringFromFormat("%x", Parameter);
+ _rOutBuffer += StringFromFormat("%x", (u32)Parameter);
break;
default:
diff --git a/Source/Core/Core/PowerPC/PPCTables.cpp b/Source/Core/Core/PowerPC/PPCTables.cpp
index 758fbae6c9..ce7d299f92 100644
--- a/Source/Core/Core/PowerPC/PPCTables.cpp
+++ b/Source/Core/Core/PowerPC/PPCTables.cpp
@@ -231,7 +231,7 @@ void LogCompiledInstructions()
}
#ifdef OPLOG
- f.Open(StringFromFormat("%s" OP_TO_LOG "_at.txt", File::GetUserPath(D_LOGS_IDX).c_str(), time), "w");
+ f.Open(StringFromFormat("%s" OP_TO_LOG "_at%i.txt", File::GetUserPath(D_LOGS_IDX).c_str(), time), "w");
for (auto& rsplocation : rsplocations)
{
fprintf(f.GetHandle(), OP_TO_LOG ": %08x\n", rsplocation);