mirror of
https://github.com/libretro/ppsspp.git
synced 2024-11-25 09:09:49 +00:00
Fixed various potential bugs and compiler warnings
This commit is contained in:
parent
03eacd1af3
commit
b780e39397
@ -261,7 +261,7 @@ public:
|
||||
case MODE_READ: x = (wchar_t*)*ptr; break;
|
||||
case MODE_WRITE: memcpy(*ptr, x.c_str(), stringLen); break;
|
||||
case MODE_MEASURE: break;
|
||||
case MODE_VERIFY: _dbg_assert_msg_(COMMON, x == (wchar_t*)*ptr, "Savestate verification failure: \"%s\" != \"%s\" (at %p).\n", x.c_str(), (wchar_t*)*ptr, ptr); break;
|
||||
case MODE_VERIFY: _dbg_assert_msg_(COMMON, x == (wchar_t*)*ptr, "Savestate verification failure: \"%ls\" != \"%ls\" (at %p).\n", x.c_str(), (wchar_t*)*ptr, ptr); break;
|
||||
}
|
||||
(*ptr) += stringLen;
|
||||
}
|
||||
|
@ -143,7 +143,8 @@ void* AllocateAlignedMemory(size_t size,size_t alignment)
|
||||
// On Symbian, we will want to create an RChunk.
|
||||
ptr = malloc(size);
|
||||
#else
|
||||
posix_memalign(&ptr, alignment, size);
|
||||
if(posix_memalign(&ptr, alignment, size) != 0)
|
||||
ptr = NULL;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -55,25 +55,30 @@ std::string StringFromFormat(const char* format, ...)
|
||||
{
|
||||
va_list args;
|
||||
char *buf = NULL;
|
||||
std::string temp = "";
|
||||
#ifdef _WIN32
|
||||
int required = 0;
|
||||
|
||||
va_start(args, format);
|
||||
required = _vscprintf(format, args);
|
||||
buf = new char[required + 1];
|
||||
vsnprintf(buf, required, format, args);
|
||||
if(vsnprintf(buf, required, format, args) < 0)
|
||||
buf[0] = '\0';
|
||||
va_end(args);
|
||||
|
||||
buf[required] = '\0';
|
||||
std::string temp = buf;
|
||||
temp = buf;
|
||||
delete[] buf;
|
||||
#else
|
||||
va_start(args, format);
|
||||
vasprintf(&buf, format, args);
|
||||
if(vasprintf(&buf, format, args) < 0)
|
||||
buf = NULL;
|
||||
va_end(args);
|
||||
|
||||
std::string temp = buf;
|
||||
free(buf);
|
||||
if(buf != NULL) {
|
||||
temp = buf;
|
||||
free(buf);
|
||||
}
|
||||
#endif
|
||||
return temp;
|
||||
}
|
||||
|
@ -143,7 +143,10 @@ bool SymbolMap::LoadSymbolMap(const char *filename)
|
||||
while (!feof(f))
|
||||
{
|
||||
char line[512],temp[256];
|
||||
fgets(line,511,f);
|
||||
char *p = fgets(line,512,f);
|
||||
if(p == NULL)
|
||||
break;
|
||||
|
||||
if (strlen(line) < 4 || sscanf(line, "%s", temp) != 1)
|
||||
continue;
|
||||
|
||||
|
@ -123,7 +123,7 @@ void PSPOskDialog::RenderKeyboard()
|
||||
else
|
||||
temp[0] = '_';
|
||||
|
||||
PPGeDrawText(temp, previewLeftSide + (i * 16.0f), 40.0f, NULL, 0.5f, color);
|
||||
PPGeDrawText(temp, previewLeftSide + (i * 16.0f), 40.0f, 0, 0.5f, color);
|
||||
}
|
||||
for (int row = 0; row < NUMKEYROWS; ++row)
|
||||
{
|
||||
@ -134,10 +134,10 @@ void PSPOskDialog::RenderKeyboard()
|
||||
color = 0xFF7f7f7f;
|
||||
|
||||
temp[0] = oskKeys[row][col];
|
||||
PPGeDrawText(temp, keyboardLeftSide + (25.0f * col), 70.0f + (25.0f * row), NULL, 0.6f, color);
|
||||
PPGeDrawText(temp, keyboardLeftSide + (25.0f * col), 70.0f + (25.0f * row), 0, 0.6f, color);
|
||||
|
||||
if (selectedRow == row && col == selectedExtra)
|
||||
PPGeDrawText("_", keyboardLeftSide + (25.0f * col), 70.0f + (25.0f * row), NULL, 0.6f, 0xFFFFFFFF);
|
||||
PPGeDrawText("_", keyboardLeftSide + (25.0f * col), 70.0f + (25.0f * row), 0, 0.6f, 0xFFFFFFFF);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,9 @@ FileBlockDevice::~FileBlockDevice()
|
||||
bool FileBlockDevice::ReadBlock(int blockNumber, u8 *outPtr)
|
||||
{
|
||||
fseek(f, blockNumber * GetBlockSize(), SEEK_SET);
|
||||
fread(outPtr, 2048, 1, f);
|
||||
if(fread(outPtr, 1, 2048, f) != 2048)
|
||||
DEBUG_LOG(LOADER, "Could not read 2048 bytes from block");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -80,10 +82,10 @@ CISOFileBlockDevice::CISOFileBlockDevice(std::string _filename)
|
||||
|
||||
f = fopen(_filename.c_str(), "rb");
|
||||
CISO_H hdr;
|
||||
fread(&hdr, 1, sizeof(CISO_H), f);
|
||||
if (memcmp(hdr.magic, "CISO", 4) != 0)
|
||||
size_t readSize = fread(&hdr, sizeof(CISO_H), 1, f);
|
||||
if (readSize != 1 || memcmp(hdr.magic, "CISO", 4) != 0)
|
||||
{
|
||||
//ARGH!
|
||||
WARN_LOG(LOADER, "Invalid CSO!");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -109,7 +111,8 @@ CISOFileBlockDevice::CISOFileBlockDevice(std::string _filename)
|
||||
int indexSize = numBlocks + 1;
|
||||
|
||||
index = new u32[indexSize];
|
||||
fread(index, 4, indexSize, f);
|
||||
if(fread(index, sizeof(u32), indexSize, f) != indexSize)
|
||||
memset(index, 0, indexSize * sizeof(u32));
|
||||
}
|
||||
|
||||
CISOFileBlockDevice::~CISOFileBlockDevice()
|
||||
@ -134,12 +137,12 @@ bool CISOFileBlockDevice::ReadBlock(int blockNumber, u8 *outPtr)
|
||||
u32 compressedReadSize = idx2 - idx;
|
||||
|
||||
fseek(f, compressedReadPos, SEEK_SET);
|
||||
fread(inbuffer, compressedReadSize, 1, f);
|
||||
size_t readSize = fread(inbuffer, 1, compressedReadSize, f);
|
||||
|
||||
if (plain)
|
||||
{
|
||||
memset(outPtr, 0, 2048);
|
||||
memcpy(outPtr, inbuffer, compressedReadSize);
|
||||
memcpy(outPtr, inbuffer, readSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -152,7 +155,7 @@ bool CISOFileBlockDevice::ReadBlock(int blockNumber, u8 *outPtr)
|
||||
ERROR_LOG(LOADER, "deflateInit ERROR : %s\n", (z.msg) ? z.msg : "???");
|
||||
return 1;
|
||||
}
|
||||
z.avail_in = compressedReadSize;
|
||||
z.avail_in = readSize;
|
||||
z.next_out = outPtr;
|
||||
z.avail_out = blockSize;
|
||||
z.next_in = inbuffer;
|
||||
|
@ -313,7 +313,7 @@ u32 scePsmfGetNumberOfStreams(u32 psmfStruct)
|
||||
ERROR_LOG(HLE, "scePsmfGetNumberOfStreams - invalid psmf");
|
||||
return ERROR_PSMF_NOT_FOUND;
|
||||
}
|
||||
INFO_LOG(HLE, "%i=scePsmfGetNumberOfStreams(%08x)", psmf->getNumStreams(), psmf);
|
||||
INFO_LOG(HLE, "%i=scePsmfGetNumberOfStreams(%p)", psmf->getNumStreams(), psmf);
|
||||
return psmf->getNumStreams();
|
||||
}
|
||||
|
||||
|
@ -38,8 +38,12 @@ EmuFileType Identify_File(const char *filename)
|
||||
return FILETYPE_ERROR;
|
||||
}
|
||||
u32 id;
|
||||
fread(&id,4,1,f);
|
||||
size_t readSize = fread(&id,4,1,f);
|
||||
fclose(f);
|
||||
|
||||
if(readSize != 1)
|
||||
return FILETYPE_ERROR;
|
||||
|
||||
if (id == 'FLE\x7F')
|
||||
{
|
||||
if (strstr(filename,".plf") || strstr(filename,"BOOT.BIN") || strstr(filename,".elf") || strstr(filename,".prx") )
|
||||
|
@ -351,7 +351,8 @@ namespace MIPSAnalyst
|
||||
{
|
||||
FILE *file = fopen(filename,"wb");
|
||||
u32 num = 0;
|
||||
fwrite(&num,4,1,file); //fill in later
|
||||
if(fwrite(&num,4,1,file) != 1) //fill in later
|
||||
WARN_LOG(CPU, "Could not store hash map %s", filename);
|
||||
|
||||
for (vector<Function>::iterator iter = functions.begin(); iter!=functions.end(); iter++)
|
||||
{
|
||||
@ -363,12 +364,16 @@ namespace MIPSAnalyst
|
||||
strcpy(temp.name, f.name);
|
||||
temp.hash=f.hash;
|
||||
temp.size=f.size;
|
||||
fwrite((char*)&temp,sizeof(temp),1,file);
|
||||
if(fwrite((char*)&temp,sizeof(temp),1,file) != 1) {
|
||||
WARN_LOG(CPU, "Could not store hash map %s", filename);
|
||||
break;
|
||||
}
|
||||
num++;
|
||||
}
|
||||
}
|
||||
fseek(file,0,SEEK_SET);
|
||||
fwrite(&num,4,1,file); //fill in later
|
||||
if(fwrite(&num,4,1,file) != 1) //fill in later
|
||||
WARN_LOG(CPU, "Could not store hash map %s", filename);
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
@ -380,25 +385,26 @@ namespace MIPSAnalyst
|
||||
|
||||
FILE *file = fopen(filename, "rb");
|
||||
int num;
|
||||
fread(&num,4,1,file);
|
||||
for (int i=0; i<num; i++)
|
||||
{
|
||||
HashMapFunc temp;
|
||||
fread(&temp,sizeof(temp),1,file);
|
||||
map<u32,Function*>::iterator iter = hashToFunction.find(temp.hash);
|
||||
if (iter != hashToFunction.end())
|
||||
if(fread(&num,4,1,file) == 1) {
|
||||
for (int i=0; i<num; i++)
|
||||
{
|
||||
//yay, found a function!
|
||||
Function &f = *(iter->second);
|
||||
if (f.size==temp.size)
|
||||
{
|
||||
strcpy(f.name, temp.name);
|
||||
f.hash=temp.hash;
|
||||
f.size=temp.size;
|
||||
HashMapFunc temp;
|
||||
if(fread(&temp,sizeof(temp),1,file) == 1) {
|
||||
map<u32,Function*>::iterator iter = hashToFunction.find(temp.hash);
|
||||
if (iter != hashToFunction.end())
|
||||
{
|
||||
//yay, found a function!
|
||||
Function &f = *(iter->second);
|
||||
if (f.size==temp.size)
|
||||
{
|
||||
strcpy(f.name, temp.name);
|
||||
f.hash=temp.hash;
|
||||
f.size=temp.size;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fclose(file);
|
||||
}
|
||||
void CompileLeafs()
|
||||
|
@ -925,7 +925,7 @@ void MIPSInterpret(u32 op) //only for those rare ones
|
||||
// Try to disassemble it
|
||||
char disasm[256];
|
||||
MIPSDisAsm(op, currentMIPS->pc, disasm);
|
||||
_dbg_assert_msg_(CPU, 0, disasm);
|
||||
_dbg_assert_msg_(CPU, 0, "%s", disasm);
|
||||
currentMIPS->pc += 4;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user