Merge pull request #41 from Parlane/printf_warnings

Give StringFromFormat a printf format attribute.
This commit is contained in:
Pierre Bourdon 2014-02-07 00:18:12 +01:00
commit 4c6d4cc270
5 changed files with 12 additions and 5 deletions

View File

@ -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);

View File

@ -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;
}

View File

@ -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;

View File

@ -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:

View File

@ -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);