Fix some compiler warnings with VS

Minor refactoring on Windows SEH code.
This commit is contained in:
amai2012 2015-06-28 19:20:16 +02:00
parent 0b225fa02f
commit 5814c3b84c
4 changed files with 14 additions and 15 deletions

View File

@ -508,7 +508,7 @@ static bool loadDbgHelp()
{
hLibDbgHelp = ::LoadLibraryW(L"Dbghelp.dll");
if (!hLibDbgHelp)
return true;
return false;
pStackWalk64 = (fpStackWalk64) ::GetProcAddress(hLibDbgHelp, "StackWalk64");
pSymGetModuleBase64 = (fpSymGetModuleBase64) ::GetProcAddress(hLibDbgHelp, "SymGetModuleBase64");
pSymGetSymFromAddr64 = (fpSymGetSymFromAddr64) ::GetProcAddress(hLibDbgHelp, "SymGetSymFromAddr64");
@ -583,7 +583,7 @@ static void PrintCallstack(FILE* f, PEXCEPTION_POINTERS ex)
"%lu. 0x%08I64X in ",
frame, (ULONG64)stack.AddrPC.Offset);
fputs((const char *)undname, f);
fputs("\n", f);
fputc('\n', f);
if (0==stack.AddrReturn.Offset || beyond_main>2) // StackWalk64() sometimes doesn't reach any end...
break;
}
@ -595,20 +595,21 @@ static void PrintCallstack(FILE* f, PEXCEPTION_POINTERS ex)
static void writeMemoryErrorDetails(FILE* f, PEXCEPTION_POINTERS ex, const char* description)
{
fputs(description, f);
fprintf(f, " (instruction: 0x%p) ", ex->ExceptionRecord->ExceptionAddress);
// Using %p for ULONG_PTR later on, so it must have size identical to size of pointer
// This is not the universally portable solution but good enough for Win32/64
C_ASSERT(sizeof(void*) == sizeof(ex->ExceptionRecord->ExceptionInformation[1]));
switch (ex->ExceptionRecord->ExceptionInformation[0]) {
case 0:
fprintf(f, " reading from 0x%p",
fprintf(f, "reading from 0x%p",
ex->ExceptionRecord->ExceptionInformation[1]);
break;
case 1:
fprintf(f, " writing at 0x%p",
fprintf(f, "writing to 0x%p",
ex->ExceptionRecord->ExceptionInformation[1]);
break;
case 8:
fprintf(f, " data execution prevention at 0x%p",
fprintf(f, "data execution prevention at 0x%p",
ex->ExceptionRecord->ExceptionInformation[1]);
break;
default:
@ -695,7 +696,7 @@ static int filterException(int code, PEXCEPTION_POINTERS ex)
code);
break;
}
fputs("\n", f);
fputc('\n', f);
PrintCallstack(f, ex);
fflush(f);
return EXCEPTION_EXECUTE_HANDLER;

View File

@ -1801,6 +1801,7 @@ Check::FileInfo* CheckBufferOverrun::getFileInfo(const Tokenizer *tokenizer, con
void CheckBufferOverrun::analyseWholeProgram(const std::list<Check::FileInfo*> &fileInfo, const Settings& settings, ErrorLogger &errorLogger)
{
(void)settings;
// Merge all fileInfo
MyFileInfo all;
for (std::list<Check::FileInfo*>::const_iterator it = fileInfo.begin(); it != fileInfo.end(); ++it) {

View File

@ -552,14 +552,11 @@ static bool checkFloatRelation(const std::string &op, const double value1, const
template<class T>
T getvalue3(const T value1, const T value2)
{
if (std::numeric_limits<T>::is_integer) {
const T min = std::min(value1, value2);
if (min== std::numeric_limits<T>::max())
return min;
else
return min+1; // see #5895
}
return (value1 + value2) / (T)2;
const T min = std::min(value1, value2);
if (min== std::numeric_limits<T>::max())
return min;
else
return min+1; // see #5895
}
template<>

View File

@ -159,7 +159,7 @@ bool ErrorLogger::ErrorMessage::deserialize(const std::string &data)
_id = results[0];
_severity = Severity::fromString(results[1]);
_cwe = MathLib::toULongNumber(results[2]);
_cwe = (unsigned)MathLib::toULongNumber(results[2]);
_shortMessage = results[3];
_verboseMessage = results[4];