Merge pull request #221 from unknownbrackets/warnings

Misc. warnings
This commit is contained in:
Henrik Rydgård 2012-12-22 00:12:27 -08:00
commit b437ea8e9a
24 changed files with 134 additions and 117 deletions

33
.gitignore vendored
View File

@ -1,37 +1,46 @@
# For MSVC
*.lastcodeanalysissucceeded
*.pdb
*.ilk
*.obj
*.pch
Logs
*.log
*.dll
*.rar
*.exe
*.ini
*.map
*.lib
*.user
*.sdf
*.ncb
Debug
DebugFast
Release
*.opensdf
*.suo
*.aps
*.exp
Debug
DebugFast
Release
Windows/x64
Windows/ipch
# For ppsspp.ini, etc.
*.ini
Logs
Memstick
bin
gen
libs
obj
*.exp
build*/
.pspsh.hist
GameLogNotes.txt
Windows/x64
Windows/ipch
Memstick
android/ui_atlas.zim
__testoutput.txt
__testerror.txt
__testfinish.txt
GameLogNotes.txt
android/ui_atlas.zim
ppge_atlas.zim.png
local.properties
build*/

View File

@ -318,9 +318,7 @@ void ConsoleListener::Log(LogTypes::LOG_LEVELS Level, const char *Text)
Text += 10;
}
SetConsoleTextAttribute(hConsole, Color);
size_t len = strlen(Text);
if (Text[len-1] == '\n' && Text[len-1] == '\r')
len--;
size_t len = strlen(Text);
WriteConsole(hConsole, Text, (DWORD)len, &cCharsWritten, NULL);
#else
char ColorAttr[16] = "";

View File

@ -283,7 +283,7 @@ static bool Memory_TryBase(u8 *base, const MemoryView *views, int num_views, u32
int i;
for (i = 0; i < num_views; i++)
{
const MemoryView &view = views[i];
const MemoryView &view = views[i];
SKIP(flags, view.flags);
if (view.flags & MV_MIRROR_PREVIOUS) {
position = last_position;

View File

@ -40,7 +40,7 @@ void MemCheck::Action(u32 iValue, u32 addr, bool write, int size, u32 pc)
if (bLog)
{
char temp[256];
printf(temp,"CHK %08x %s%i at %08x (%s), PC=%08x (%s)",iValue,write?"Write":"Read",size*8,addr,symbolMap.GetDescription(addr),pc,symbolMap.GetDescription(pc));
sprintf(temp,"CHK %08x %s%i at %08x (%s), PC=%08x (%s)",iValue,write?"Write":"Read",size*8,addr,symbolMap.GetDescription(addr),pc,symbolMap.GetDescription(pc));
ERROR_LOG(MEMMAP,"%s",temp);
}
if (bBreak)

View File

@ -144,10 +144,9 @@ bool SymbolMap::LoadSymbolMap(const char *filename)
{
char line[512],temp[256];
fgets(line,511,f);
if (strlen(line)<4)
if (strlen(line) < 4 || sscanf(line, "%s", temp) != 1)
continue;
sscanf(line,"%s",temp);
if (strcmp(temp,"UNUSED")==0) continue;
if (strcmp(temp,".text")==0) {started=true;continue;};
if (strcmp(temp,".init")==0) {started=true;continue;};
@ -233,7 +232,7 @@ int SymbolMap::GetSymbolNum(unsigned int address, SymbolType symmask)
}
char temp[256];
char descriptionTemp[256];
char *SymbolMap::GetDescription(unsigned int address)
{
@ -244,8 +243,8 @@ char *SymbolMap::GetDescription(unsigned int address)
return entries[fun].name;
else
{
sprintf(temp, "(%08x)", address);
return temp;
sprintf(descriptionTemp, "(%08x)", address);
return descriptionTemp;
}
//}
//else
@ -438,11 +437,12 @@ void SymbolMap::UseFuncSignaturesFile(const char *filename, u32 maxAddress)
//#1: Read the signature file and put them in a fast data structure
FILE *f = fopen(filename, "r");
int count;
fscanf(f,"%08x\n",&count);
u32 inst,size,hash;
if (fscanf(f, "%08x\n", &count) != 1)
count = 0;
char name[256];
for (int a=0; a<count; a++)
{
u32 inst, size, hash;
if (fscanf(f,"%08x\t%08x\t%08x\t%s\n",&inst,&size,&hash,name)!=EOF)
sigs[numSigs++]=Sig(inst,size,hash,name);
else

View File

@ -413,7 +413,7 @@ u32 SavedataParam::SetPspParam(SceUtilitySavedataParam *param)
memcpy(saveDataList[realCount].saveDetail,savedetail.c_str(),savedetail.size());
saveDataList[realCount].saveDetail[savedetail.size()] = 0;
}
delete sfoParam;
delete [] sfoParam;
}
DEBUG_LOG(HLE,"%s Exist",fileDataPath.c_str());
@ -504,7 +504,7 @@ u32 SavedataParam::SetPspParam(SceUtilitySavedataParam *param)
memcpy(saveDataList[0].saveDetail,savedetail.c_str(),savedetail.size());
saveDataList[0].saveDetail[savedetail.size()] = 0;
}
delete sfoParam;
delete [] sfoParam;
}
DEBUG_LOG(HLE,"%s Exist",fileDataPath.c_str());

View File

@ -183,11 +183,11 @@ size_t DirectoryFileSystem::ReadFile(u32 handle, u8 *pointer, s64 size)
EntryMap::iterator iter = entries.find(handle);
if (iter != entries.end())
{
size_t bytesRead;
size_t bytesRead;
#ifdef _WIN32
::ReadFile(iter->second.hFile, (LPVOID)pointer, (DWORD)size, (LPDWORD)&bytesRead, 0);
#else
bytesRead = fread(pointer, 1, size, iter->second.hFile);
bytesRead = fread(pointer, 1, size, iter->second.hFile);
#endif
return bytesRead;
}

View File

@ -16,7 +16,7 @@
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#include "Globals.h"
#include "Log.h"
#include "Common.h"
#include "ISOFileSystem.h"
#include <cstring>
#include <cstdio>
@ -29,11 +29,13 @@ static bool parseLBN(std::string filename, u32 *sectorStart, u32 *readSize)
{
if (filename.substr(0, 8) != "/sce_lbn")
return false;
std::string yo = filename;
std::string prev = filename;
filename.erase(0, 10);
sscanf(filename.c_str(), "%08x", sectorStart);
if (sscanf(filename.c_str(), "%08x", sectorStart) != 1)
WARN_LOG(FILESYS, "Invalid LBN reference: %s", prev.c_str());
filename.erase(0, filename.find("_size") + 7);
sscanf(filename.c_str(), "%08x", readSize);
if (sscanf(filename.c_str(), "%08x", readSize) != 1)
WARN_LOG(FILESYS, "Incomplete LBN reference: %s", prev.c_str());
return true;
}
@ -393,6 +395,8 @@ size_t ISOFileSystem::ReadFile(u32 handle, u8 *pointer, s64 size)
}
else
{
_dbg_assert_msg_(HLE, e.file != 0, "Expecting non-raw fd to have a tree entry.");
//clamp read length
if ((s64)e.seekPos > e.file->size - (s64)size)
{

View File

@ -211,7 +211,7 @@ void hleCheckCurrentCallbacks()
void hleReSchedule(const char *reason)
{
_dbg_assert_msg_(HLE, reason != 0, "hleReSchedule: Expecting a valid reason.");
_dbg_assert_msg_(HLE, strlen(reason) < 256, "hleReSchedule: Not too long reason.");
_dbg_assert_msg_(HLE, reason != 0 && strlen(reason) < 256, "hleReSchedule: Not too long reason.");
hleAfterSyscall |= HLE_AFTER_RESCHED;

View File

@ -298,8 +298,13 @@ u32 sceDisplaySetFramebuf()
if (sync == PSP_DISPLAY_SETBUF_IMMEDIATE)
{
// Write immediately to the current framebuffer parameters
framebuf = fbstate;
gpu->SetDisplayFramebuffer(framebuf.topaddr, framebuf.pspFramebufLinesize, framebuf.pspFramebufFormat);
if (topaddr != 0)
{
framebuf = fbstate;
gpu->SetDisplayFramebuffer(framebuf.topaddr, framebuf.pspFramebufLinesize, framebuf.pspFramebufFormat);
}
else
WARN_LOG(HLE, "%s: PSP_DISPLAY_SETBUF_IMMEDIATE without topaddr?", __FUNCTION__);
}
else if (topaddr != 0)
{

View File

@ -235,32 +235,32 @@ int sceFontGetFontInfo(u32 fontHandle, u32 fontInfoPtr)
memset (&fi, 0, sizeof(fi));
if (Memory::IsValidAddress(fontInfoPtr))
{
fi.BPP =4;
fi.BPP = 4;
fi.charMapLength = 255;
// fi.fontStyle =1;
fi.maxGlyphAdvanceXF = 2.0;
fi.maxGlyphAdvanceXI =2;
fi.maxGlyphAdvanceXI = 2;
fi.maxGlyphAdvanceYF = 2.0;
fi.maxGlyphAdvanceYI = 32 << 6;
fi.maxGlyphAscenderF =32 << 6;
fi.maxGlyphAscenderF = 32 << 6;
fi.maxGlyphAscenderI = 32 << 6;
fi.maxGlyphBaseYF= 0.0;
fi.maxGlyphBaseYI=0.0;
fi.maxGlyphDescenderF =0;
fi.maxGlyphDescenderI =0;
fi.maxGlyphBaseYF = 0.0;
fi.maxGlyphBaseYI = 0;
fi.maxGlyphDescenderF = 0;
fi.maxGlyphDescenderI = 0;
fi.maxGlyphHeight = 32;
fi.maxGlyphHeightF= 32;
fi.maxGlyphHeightF = 32;
fi.maxGlyphHeightI = 32;
fi.maxGlyphLeftXF= 0;
fi.maxGlyphLeftXF = 0;
fi.maxGlyphLeftXI = 0;
fi.maxGlyphTopYF =0;
fi.maxGlyphTopYF = 0;
fi.maxGlyphTopYI = 0;
fi.maxGlyphWidth =32;
fi.maxGlyphWidth = 32;
fi.maxGlyphWidthF = 32;
fi.maxGlyphWidthI= 32;
fi.maxGlyphWidthI = 32;
fi.minGlyphCenterXF = 16;
fi.minGlyphCenterXI= 16;
fi.shadowMapLength=0;
fi.minGlyphCenterXI = 16;
fi.shadowMapLength = 0;
Memory::WriteStruct(fontInfoPtr, &fi);
}

View File

@ -192,7 +192,6 @@ void __IoInit() {
}
void __IoShutdown() {
}
u32 sceIoAssign(const char *aliasname, const char *physname, const char *devname, u32 flag) {

View File

@ -270,12 +270,12 @@ void KernelObjectPool::List()
if (pool[i])
{
pool[i]->GetQuickInfo(buffer,256);
INFO_LOG(HLE, "KO %i: %s \"%s\": %s", i + handleOffset, pool[i]->GetTypeName(), pool[i]->GetName(), buffer);
}
else
{
strcpy(buffer,"WTF? Zero Pointer");
}
INFO_LOG(HLE, "KO %i: %s \"%s\": %s", i + handleOffset, pool[i]->GetTypeName(), pool[i]->GetName(), buffer);
}
}
}

View File

@ -448,13 +448,13 @@ bool __KernelLoadPBP(const char *filename, std::string *error_string)
in.seekg(offsets[5]);
//in.read((char*)&id,4);
{
u8 *temp = new u8[1024*1024*8];
in.read((char*)temp, 1024*1024*8);
Module *module = __KernelLoadELFFromPtr(temp, PSP_GetDefaultLoadAddress(), error_string);
u8 *elftemp = new u8[1024*1024*8];
in.read((char*)elftemp, 1024*1024*8);
Module *module = __KernelLoadELFFromPtr(elftemp, PSP_GetDefaultLoadAddress(), error_string);
if (!module)
return false;
mipsr4k.pc = module->nm.entry_addr;
delete [] temp;
delete [] elftemp;
}
in.close();
return true;
@ -612,7 +612,7 @@ u32 sceKernelLoadModule(const char *name, u32 flags)
// TODO: Use position to decide whether to load high or low
if (PARAM(2))
{
SceKernelLMOption *lmoption = (SceKernelLMOption *)Memory::GetPointer(PARAM(2));
lmoption = (SceKernelLMOption *)Memory::GetPointer(PARAM(2));
}

View File

@ -98,7 +98,7 @@ struct MsgPipe : public KernelObject
if (sendWaitingThreads.empty())
return;
MsgPipeWaitingThread *thread = &sendWaitingThreads.front();
if (nmp.freeSize >= thread->bufSize)
if ((u32) nmp.freeSize >= thread->bufSize)
{
// Put all the data to the buffer
memcpy(buffer + (nmp.bufSize - nmp.freeSize), Memory::GetPointer(thread->bufAddr), thread->bufSize);
@ -126,7 +126,7 @@ struct MsgPipe : public KernelObject
if (receiveWaitingThreads.empty())
return;
MsgPipeWaitingThread *thread = &receiveWaitingThreads.front();
if (nmp.bufSize - nmp.freeSize >= thread->bufSize)
if ((u32) nmp.bufSize - (u32) nmp.freeSize >= thread->bufSize)
{
// Get the needed data from the buffer
Memory::Memcpy(thread->bufAddr, buffer, thread->bufSize);
@ -271,7 +271,7 @@ void __KernelSendMsgPipe(MsgPipe *m, u32 sendBufAddr, u32 sendSize, int waitMode
}
else
{
if (sendSize <= m->nmp.freeSize)
if (sendSize <= (u32) m->nmp.freeSize)
{
memcpy(m->buffer + (m->nmp.bufSize - m->nmp.freeSize), Memory::GetPointer(sendBufAddr), sendSize);
m->nmp.freeSize -= sendSize;
@ -445,7 +445,7 @@ void __KernelReceiveMsgPipe(MsgPipe *m, u32 receiveBufAddr, u32 receiveSize, int
else
{
// Enough data in the buffer: copy just the needed amount of data
if (receiveSize <= m->nmp.bufSize - m->nmp.freeSize)
if (receiveSize <= (u32) m->nmp.bufSize - (u32) m->nmp.freeSize)
{
Memory::Memcpy(receiveBufAddr, m->buffer, receiveSize);
m->nmp.freeSize += receiveSize;

View File

@ -845,7 +845,7 @@ void __KernelReSchedule(bool doCallbacks, const char *reason)
thread->isProcessingCallbacks = doCallbacks;
}
__KernelReSchedule(reason);
if (doCallbacks && thread == currentThread) {
if (doCallbacks && thread != NULL && thread == currentThread) {
if (thread->isRunning()) {
thread->isProcessingCallbacks = false;
}
@ -1833,8 +1833,12 @@ void __KernelCallAddress(Thread *thread, u32 entryPoint, Action *afterAction, bo
}
if (!called) {
DEBUG_LOG(HLE, "Making mipscall pending on thread");
thread->pendingMipsCalls.push_back(callId);
if (thread) {
DEBUG_LOG(HLE, "Making mipscall pending on thread");
thread->pendingMipsCalls.push_back(callId);
} else {
WARN_LOG(HLE, "Ignoring mispcall on NULL/deleted thread");
}
}
}

View File

@ -459,7 +459,7 @@ int sceRtcGetTime_t(u32 datePtr, u32 timePtr)
ScePspDateTime pt;
Memory::ReadStruct(datePtr, &pt);
pt.year-=1969;
u64 result = __RtcPspTimeToTicks(pt)/1000000ULL;
u32 result = (u32) (__RtcPspTimeToTicks(pt)/1000000ULL);
Memory::Write_U32(result, timePtr);
}
else

View File

@ -215,7 +215,7 @@ void SasInstance::Mix(u32 outAddr) {
// Figure out number of samples to read.
int curSample = voice.samplePos / PSP_SAS_PITCH_BASE;
int lastSample = (voice.samplePos + grainSize * voice.pitch) / PSP_SAS_PITCH_BASE;
u32 numSamples = lastSample - curSample;
int numSamples = lastSample - curSample;
if (numSamples > grainSize * 4) {
ERROR_LOG(SAS, "numSamples too large, clamping: %i vs %i", numSamples, grainSize * 4);
numSamples = grainSize * 4;

View File

@ -301,13 +301,13 @@ namespace MIPSAnalyst
{
if (addr >= furthestBranch)
{
u32 target = GetSureBranchTarget(addr);
if (target != INVALIDTARGET && target < addr)
u32 sureTarget = GetSureBranchTarget(addr);
if (sureTarget != INVALIDTARGET && sureTarget < addr)
{
end = true;
}
target = GetJumpTarget(addr);
if (target != INVALIDTARGET && target < addr && ((op&0xFC000000)==0x08000000))
sureTarget = GetJumpTarget(addr);
if (sureTarget != INVALIDTARGET && sureTarget < addr && ((op&0xFC000000)==0x08000000))
{
end = true;
}

View File

@ -1495,10 +1495,8 @@ namespace MIPSInt
ApplySwizzleT(t, sz);
int n = GetNumVectorElements(sz);
for (int i = 0; i < n ; i++) {
int a=s[i] - t[i];
if (a > 0) d[i]=1;
else if (a < 0) d[i]=-1;
else d[i]=0;
float a = s[i] - t[i];
d[i] = (float) ((0.0 < a) - (a < 0.0));
}
ApplyPrefixD(d, sz);
WriteVector(d, sz, vd);

View File

@ -587,7 +587,7 @@ void GLES_GPU::ExecuteOp(u32 op, u32 diff)
case GE_CMD_CALL:
{
u32 retval = dcontext.pc + 4;
if (stackptr == ARRAY_SIZE(stack)) {
if (stackptr == ARRAY_SIZE(stack) - 1) {
ERROR_LOG(G3D, "CALL: Stack full!");
} else {
stack[stackptr++] = retval;

View File

@ -234,7 +234,7 @@ void VertexDecoder::Step_Color5551Morph() const
col[0] += w * (cdata & 0x1f) / 31.f;
col[1] += w * ((cdata>>5) & 0x1f) / 31.f;
col[2] += w * ((cdata>>10) & 0x1f) / 31.f;
col[3] += w * (cdata>>15) ? 1.0f : 0.0f;
col[3] += w * ((cdata>>15) ? 1.0f : 0.0f);
}
u8 *c = decoded_ + decFmt.c0off;
for (int i = 0; i < 4; i++) {

View File

@ -29,7 +29,8 @@ DWORD TheThread(LPVOID x);
void EmuThread_Start(const char *filename)
{
// _dbg_clear_();
_tcscpy(fileToStart, filename);
_tcsncpy(fileToStart, filename, sizeof(fileToStart) - 1);
fileToStart[sizeof(fileToStart) - 1] = 0;
unsigned int i;
emuThread = (HANDLE)_beginthreadex(0,0,(unsigned int (__stdcall *)(void *))TheThread,(LPVOID)0,0,&i);

View File

@ -37,7 +37,7 @@
#endif
BOOL g_bFullScreen = FALSE;
RECT rc = {0};
RECT g_normalRC = {0};
namespace MainWindow
{
@ -114,13 +114,13 @@ namespace MainWindow
void SetZoom(float zoom) {
if (zoom < 5)
g_Config.iWindowZoom = zoom;
g_Config.iWindowZoom = (int) zoom;
RECT rc, rcOuter;
GetWindowRectAtZoom(zoom, rc, rcOuter);
GetWindowRectAtZoom((int) zoom, rc, rcOuter);
MoveWindow(hwndMain, rcOuter.left, rcOuter.top, rcOuter.right - rcOuter.left, rcOuter.bottom - rcOuter.top, TRUE);
MoveWindow(hwndDisplay, 0, 0, rc.right - rc.left, rc.bottom - rc.top, TRUE);
PSP_CoreParameter().pixelWidth = 480 * zoom;
PSP_CoreParameter().pixelHeight = 272 * zoom;
PSP_CoreParameter().pixelWidth = (int) (480 * zoom);
PSP_CoreParameter().pixelHeight = (int) (272 * zoom);
GL_Resized();
}
@ -705,51 +705,50 @@ namespace MainWindow
}
void _ViewNormal(HWND hWnd)
{
// put caption and border styles back
DWORD dwOldStyle = ::GetWindowLong(hWnd, GWL_STYLE);
DWORD dwNewStyle = dwOldStyle | WS_CAPTION | WS_THICKFRAME;
::SetWindowLong(hWnd, GWL_STYLE, dwNewStyle);
// put caption and border styles back
DWORD dwOldStyle = ::GetWindowLong(hWnd, GWL_STYLE);
DWORD dwNewStyle = dwOldStyle | WS_CAPTION | WS_THICKFRAME;
::SetWindowLong(hWnd, GWL_STYLE, dwNewStyle);
// put back the menu bar
::SetMenu(hWnd, menu);
// put back the menu bar
::SetMenu(hWnd, menu);
// resize to normal view
// NOTE: use SWP_FRAMECHANGED to force redraw non-client
const int x = rc.left;
const int y = rc.top;
const int cx = rc.right - rc.left;
const int cy = rc.bottom - rc.top;
::SetWindowPos(hWnd, HWND_NOTOPMOST, x, y, cx, cy, SWP_FRAMECHANGED);
// resize to normal view
// NOTE: use SWP_FRAMECHANGED to force redraw non-client
const int x = g_normalRC.left;
const int y = g_normalRC.top;
const int cx = g_normalRC.right - g_normalRC.left;
const int cy = g_normalRC.bottom - g_normalRC.top;
::SetWindowPos(hWnd, HWND_NOTOPMOST, x, y, cx, cy, SWP_FRAMECHANGED);
// reset full screen indicator
g_bFullScreen = FALSE;
// reset full screen indicator
g_bFullScreen = FALSE;
}
void _ViewFullScreen(HWND hWnd)
{
// keep in mind normal window rectangle
::GetWindowRect(hWnd, &rc);
void _ViewFullScreen(HWND hWnd)
{
// keep in mind normal window rectangle
::GetWindowRect(hWnd, &g_normalRC);
// remove caption and border styles
DWORD dwOldStyle = ::GetWindowLong(hWnd, GWL_STYLE);
DWORD dwNewStyle = dwOldStyle & ~(WS_CAPTION | WS_THICKFRAME);
::SetWindowLong(hWnd, GWL_STYLE, dwNewStyle);
// remove caption and border styles
DWORD dwOldStyle = ::GetWindowLong(hWnd, GWL_STYLE);
DWORD dwNewStyle = dwOldStyle & ~(WS_CAPTION | WS_THICKFRAME);
::SetWindowLong(hWnd, GWL_STYLE, dwNewStyle);
// remove the menu bar
::SetMenu(hWnd, NULL);
// remove the menu bar
::SetMenu(hWnd, NULL);
// resize to full screen view
// NOTE: use SWP_FRAMECHANGED to force redraw non-client
const int x = 0;
const int y = 0;
const int cx = ::GetSystemMetrics(SM_CXSCREEN);
const int cy = ::GetSystemMetrics(SM_CYSCREEN);
::SetWindowPos(hWnd, HWND_TOPMOST, x, y, cx, cy, SWP_FRAMECHANGED);
// set full screen indicator
g_bFullScreen = TRUE;
}
// resize to full screen view
// NOTE: use SWP_FRAMECHANGED to force redraw non-client
const int x = 0;
const int y = 0;
const int cx = ::GetSystemMetrics(SM_CXSCREEN);
const int cy = ::GetSystemMetrics(SM_CYSCREEN);
::SetWindowPos(hWnd, HWND_TOPMOST, x, y, cx, cy, SWP_FRAMECHANGED);
// set full screen indicator
g_bFullScreen = TRUE;
}
void SetPlaying(const char *text)
{