mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-28 16:00:58 +00:00
Merge pull request #7358 from unknownbrackets/warnings
A few more static analysis warnings
This commit is contained in:
commit
5c80731637
@ -33,7 +33,12 @@ PBPReader::PBPReader(const char *filename) : header_(), isELF_(false) {
|
||||
fseek(file_, 0, SEEK_END);
|
||||
fileSize_ = ftell(file_);
|
||||
fseek(file_, 0, SEEK_SET);
|
||||
fread((char *)&header_, 1, sizeof(header_), file_);
|
||||
if (fread((char *)&header_, 1, sizeof(header_), file_) != sizeof(header_)) {
|
||||
ERROR_LOG(LOADER, "PBP is too small to be valid: %s", filename);
|
||||
fclose(file_);
|
||||
file_ = nullptr;
|
||||
return;
|
||||
}
|
||||
if (memcmp(header_.magic, "\0PBP", 4) != 0) {
|
||||
if (memcmp(header_.magic, "\nFLE", 4) != 0) {
|
||||
DEBUG_LOG(LOADER, "%s: File actually an ELF, not a PBP", filename);
|
||||
@ -42,7 +47,7 @@ PBPReader::PBPReader(const char *filename) : header_(), isELF_(false) {
|
||||
ERROR_LOG(LOADER, "Magic number in %s indicated no PBP: %s", filename, header_.magic);
|
||||
}
|
||||
fclose(file_);
|
||||
file_ = 0;
|
||||
file_ = nullptr;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -50,17 +55,54 @@ PBPReader::PBPReader(const char *filename) : header_(), isELF_(false) {
|
||||
}
|
||||
|
||||
u8 *PBPReader::GetSubFile(PBPSubFile file, size_t *outSize) {
|
||||
*outSize = GetSubFileSize(file);
|
||||
u8 *buffer = new u8[*outSize];
|
||||
fseek(file_, header_.offsets[(int)file], SEEK_SET);
|
||||
fread(buffer, 1, *outSize, file_);
|
||||
return buffer;
|
||||
if (!file_) {
|
||||
*outSize = 0;
|
||||
return new u8[0];
|
||||
}
|
||||
|
||||
const size_t expected = GetSubFileSize(file);
|
||||
const u32 off = header_.offsets[(int)file];
|
||||
|
||||
*outSize = expected;
|
||||
if (fseek(file_, off, SEEK_SET) != 0) {
|
||||
ERROR_LOG(LOADER, "PBP file offset invalid: %d", off);
|
||||
*outSize = 0;
|
||||
return new u8[0];
|
||||
} else {
|
||||
u8 *buffer = new u8[expected];
|
||||
size_t bytes = fread(buffer, 1, expected, file_);
|
||||
if (bytes != expected) {
|
||||
ERROR_LOG(LOADER, "PBP file read truncated: %d -> %d", (int)expected, (int)bytes);
|
||||
if (bytes < expected) {
|
||||
*outSize = bytes;
|
||||
}
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
|
||||
void PBPReader::GetSubFileAsString(PBPSubFile file, std::string *out) {
|
||||
out->resize(GetSubFileSize(file));
|
||||
fseek(file_, header_.offsets[(int)file], SEEK_SET);
|
||||
fread((void *)out->data(), 1, out->size(), file_);
|
||||
if (!file_) {
|
||||
out->clear();
|
||||
return;
|
||||
}
|
||||
|
||||
const size_t expected = GetSubFileSize(file);
|
||||
const u32 off = header_.offsets[(int)file];
|
||||
|
||||
out->resize(expected);
|
||||
if (fseek(file_, off, SEEK_SET) != 0) {
|
||||
ERROR_LOG(LOADER, "PBP file offset invalid: %d", off);
|
||||
out->clear();
|
||||
} else {
|
||||
size_t bytes = fread((void *)out->data(), 1, expected, file_);
|
||||
if (bytes != expected) {
|
||||
ERROR_LOG(LOADER, "PBP file read truncated: %d -> %d", (int)expected, (int)bytes);
|
||||
if (bytes < expected) {
|
||||
out->resize(bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PBPReader::~PBPReader() {
|
||||
|
@ -131,6 +131,9 @@ int GetFuncIndex(int moduleIndex, u32 nib)
|
||||
u32 GetNibByName(const char *moduleName, const char *function)
|
||||
{
|
||||
int moduleIndex = GetModuleIndex(moduleName);
|
||||
if (moduleIndex == -1)
|
||||
return -1;
|
||||
|
||||
const HLEModule &module = moduleDB[moduleIndex];
|
||||
for (int i = 0; i < module.numFunctions; i++)
|
||||
{
|
||||
|
@ -162,7 +162,7 @@ namespace MIPSComp
|
||||
u32 value = gpr.GetImm(rs);
|
||||
int x = 31;
|
||||
int count = 0;
|
||||
while (!(value & (1 << x)) && x >= 0) {
|
||||
while (x >= 0 && !(value & (1 << x))) {
|
||||
count++;
|
||||
x--;
|
||||
}
|
||||
@ -177,7 +177,7 @@ namespace MIPSComp
|
||||
u32 value = gpr.GetImm(rs);
|
||||
int x = 31;
|
||||
int count = 0;
|
||||
while ((value & (1 << x)) && x >= 0) {
|
||||
while (x >= 0 && (value & (1 << x)))
|
||||
count++;
|
||||
x--;
|
||||
}
|
||||
|
@ -286,7 +286,7 @@ namespace MIPSInt
|
||||
_dbg_assert_msg_(CPU, 0, "Misaligned sv.q");
|
||||
}
|
||||
#ifndef COMMON_BIG_ENDIAN
|
||||
ReadVector((float*)Memory::GetPointer(addr), V_Quad, vt);
|
||||
ReadVector(reinterpret_cast<float *>(Memory::GetPointer(addr)), V_Quad, vt);
|
||||
#else
|
||||
float svqd[4];
|
||||
ReadVector(svqd, V_Quad, vt);
|
||||
@ -650,8 +650,8 @@ namespace MIPSInt
|
||||
}
|
||||
}
|
||||
}
|
||||
ApplyPrefixD((float*)d, sz, true);
|
||||
WriteVector((float*)d, sz, vd);
|
||||
ApplyPrefixD(reinterpret_cast<float *>(d), sz, true);
|
||||
WriteVector(reinterpret_cast<float *>(d), sz, vd);
|
||||
PC += 4;
|
||||
EatPrefixes();
|
||||
}
|
||||
@ -665,8 +665,8 @@ namespace MIPSInt
|
||||
int imm = (op >> 16) & 0x1f;
|
||||
float mult = 1.0f/(float)(1UL << imm);
|
||||
VectorSize sz = GetVecSize(op);
|
||||
ReadVector((float*)&s[0], sz, vs);
|
||||
ApplySwizzleS((float*)&s[0], sz); //TODO: and the mask to kill everything but swizzle
|
||||
ReadVector(reinterpret_cast<float *>(s), sz, vs);
|
||||
ApplySwizzleS(reinterpret_cast<float *>(s), sz); //TODO: and the mask to kill everything but swizzle
|
||||
for (int i = 0; i < GetNumVectorElements(sz); i++)
|
||||
{
|
||||
d[i] = (float)s[i] * mult;
|
||||
@ -684,8 +684,8 @@ namespace MIPSInt
|
||||
int vd = _VD;
|
||||
int vs = _VS;
|
||||
VectorSize sz = GetVecSize(op);
|
||||
ReadVector((float*)&s[0], sz, vs);
|
||||
ApplySwizzleS((float*)&s[0], sz);
|
||||
ReadVector(reinterpret_cast<float *>(s), sz, vs);
|
||||
ApplySwizzleS(reinterpret_cast<float *>(s), sz);
|
||||
|
||||
VectorSize outsize = V_Pair;
|
||||
switch (sz) {
|
||||
@ -703,6 +703,7 @@ namespace MIPSInt
|
||||
break;
|
||||
default:
|
||||
_dbg_assert_msg_(CPU, 0, "Trying to interpret Int_Vh2f instruction that can't be interpreted");
|
||||
memset(d, 0, sizeof(d));
|
||||
break;
|
||||
}
|
||||
ApplyPrefixD(d, outsize);
|
||||
@ -736,8 +737,8 @@ namespace MIPSInt
|
||||
_dbg_assert_msg_(CPU, 0, "Trying to interpret Int_Vf2h instruction that can't be interpreted");
|
||||
break;
|
||||
}
|
||||
ApplyPrefixD((float*)&d[0], outsize);
|
||||
WriteVector((float*)&d[0], outsize, vd);
|
||||
ApplyPrefixD(reinterpret_cast<float *>(d), outsize);
|
||||
WriteVector(reinterpret_cast<float *>(d), outsize, vd);
|
||||
PC += 4;
|
||||
EatPrefixes();
|
||||
}
|
||||
@ -750,7 +751,7 @@ namespace MIPSInt
|
||||
int vs = _VS;
|
||||
VectorSize sz = GetVecSize(op);
|
||||
VectorSize oz = sz;
|
||||
ReadVector((float*)s, sz, vs);
|
||||
ReadVector(reinterpret_cast<float *>(s), sz, vs);
|
||||
// ForbidVPFXS
|
||||
|
||||
switch ((op >> 16) & 3) {
|
||||
@ -830,8 +831,8 @@ namespace MIPSInt
|
||||
break;
|
||||
}
|
||||
|
||||
ApplyPrefixD((float*)d,oz, true); // Only write mask
|
||||
WriteVector((float*)d,oz,vd);
|
||||
ApplyPrefixD(reinterpret_cast<float *>(d),oz, true); // Only write mask
|
||||
WriteVector(reinterpret_cast<float *>(d),oz,vd);
|
||||
PC += 4;
|
||||
EatPrefixes();
|
||||
}
|
||||
@ -844,8 +845,8 @@ namespace MIPSInt
|
||||
int vs = _VS;
|
||||
VectorSize sz = GetVecSize(op);
|
||||
VectorSize oz;
|
||||
ReadVector((float*)s, sz, vs);
|
||||
ApplySwizzleS((float*)s, sz); //TODO: and the mask to kill everything but swizzle
|
||||
ReadVector(reinterpret_cast<float *>(s), sz, vs);
|
||||
ApplySwizzleS(reinterpret_cast<float *>(s), sz); //TODO: and the mask to kill everything but swizzle
|
||||
switch ((op >> 16)&3)
|
||||
{
|
||||
case 0: //vi2uc
|
||||
@ -917,8 +918,8 @@ namespace MIPSInt
|
||||
oz = V_Single;
|
||||
break;
|
||||
}
|
||||
ApplyPrefixD((float*)d,oz);
|
||||
WriteVector((float*)d,oz,vd);
|
||||
ApplyPrefixD(reinterpret_cast<float *>(d),oz);
|
||||
WriteVector(reinterpret_cast<float *>(d),oz,vd);
|
||||
PC += 4;
|
||||
EatPrefixes();
|
||||
}
|
||||
@ -929,7 +930,7 @@ namespace MIPSInt
|
||||
int vs = _VS;
|
||||
u32 s[4];
|
||||
VectorSize sz = V_Quad;
|
||||
ReadVector((float *)s, sz, vs);
|
||||
ReadVector(reinterpret_cast<float *>(s), sz, vs);
|
||||
u16 colors[4];
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
@ -1370,6 +1371,7 @@ namespace MIPSInt
|
||||
{
|
||||
Reporting::ReportMessage("Trying to interpret instruction that can't be interpreted (BADVTFM)");
|
||||
_dbg_assert_msg_(CPU,0,"Trying to interpret instruction that can't be interpreted (BADVTFM)");
|
||||
memset(d, 0, sizeof(d));
|
||||
}
|
||||
WriteVector(d, sz, vd);
|
||||
PC += 4;
|
||||
|
@ -962,7 +962,6 @@ void MIPSDisAsm(MIPSOpcode op, u32 pc, char *out, bool tabsToSpaces) {
|
||||
}
|
||||
} else {
|
||||
strcpy(out, "no instruction :(");
|
||||
MIPSGetInstruction(op);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -210,7 +210,7 @@ namespace MIPSComp
|
||||
u32 value = gpr.GetImm(rs);
|
||||
int x = 31;
|
||||
int count = 0;
|
||||
while (!(value & (1 << x)) && x >= 0)
|
||||
while (x >= 0 && !(value & (1 << x)))
|
||||
{
|
||||
count++;
|
||||
x--;
|
||||
@ -241,7 +241,7 @@ namespace MIPSComp
|
||||
u32 value = gpr.GetImm(rs);
|
||||
int x = 31;
|
||||
int count = 0;
|
||||
while ((value & (1 << x)) && x >= 0)
|
||||
while (x >= 0 && (value & (1 << x)))
|
||||
{
|
||||
count++;
|
||||
x--;
|
||||
|
@ -611,7 +611,7 @@ void FramebufferManagerCommon::FindTransferFramebuffers(VirtualFramebuffer *&dst
|
||||
}
|
||||
if (match) {
|
||||
srcYOffset = yOffset;
|
||||
srcXOffset = (byteOffset / bpp) % srcStride;
|
||||
srcXOffset = srcStride == 0 ? 0 : (byteOffset / bpp) % srcStride;
|
||||
srcBuffer = vfb;
|
||||
}
|
||||
}
|
||||
|
@ -588,7 +588,7 @@ namespace DX9 {
|
||||
}
|
||||
|
||||
FBO *FramebufferManagerDX9::GetTempFBO(u16 w, u16 h, FBOColorDepth depth) {
|
||||
u64 key = ((u64)depth << 32) | (w << 16) | h;
|
||||
u64 key = ((u64)depth << 32) | ((u32)w << 16) | h;
|
||||
auto it = tempFBOs_.find(key);
|
||||
if (it != tempFBOs_.end()) {
|
||||
it->second.last_frame_used = gpuStats.numFlips;
|
||||
|
@ -362,7 +362,7 @@ bool TextureCacheDX9::AttachFramebuffer(TexCacheEntry *entry, u32 address, Virtu
|
||||
const u32 bitOffset = (texaddr - addr) * 8;
|
||||
const u32 pixelOffset = bitOffset / std::max(1U, (u32)textureBitsPerPixel[entry->format]);
|
||||
fbInfo.yOffset = pixelOffset / entry->bufw;
|
||||
fbInfo.xOffset = pixelOffset % entry->bufw;
|
||||
fbInfo.xOffset = entry->bufw == 0 ? 0 : pixelOffset % entry->bufw;
|
||||
|
||||
if (framebuffer->fb_stride != entry->bufw) {
|
||||
if (noOffset) {
|
||||
|
@ -902,7 +902,7 @@ void FramebufferManager::BlitFramebufferDepth(VirtualFramebuffer *src, VirtualFr
|
||||
}
|
||||
|
||||
FBO *FramebufferManager::GetTempFBO(u16 w, u16 h, FBOColorDepth depth) {
|
||||
u64 key = ((u64)depth << 32) | (w << 16) | h;
|
||||
u64 key = ((u64)depth << 32) | ((u32)w << 16) | h;
|
||||
auto it = tempFBOs_.find(key);
|
||||
if (it != tempFBOs_.end()) {
|
||||
it->second.last_frame_used = gpuStats.numFlips;
|
||||
|
@ -357,7 +357,7 @@ bool TextureCache::AttachFramebuffer(TexCacheEntry *entry, u32 address, VirtualF
|
||||
const u32 bitOffset = (texaddr - addr) * 8;
|
||||
const u32 pixelOffset = bitOffset / std::max(1U, (u32)textureBitsPerPixel[entry->format]);
|
||||
fbInfo.yOffset = pixelOffset / entry->bufw;
|
||||
fbInfo.xOffset = pixelOffset % entry->bufw;
|
||||
fbInfo.xOffset = entry->bufw == 0 ? 0 : pixelOffset % entry->bufw;
|
||||
|
||||
if (framebuffer->fb_stride != entry->bufw) {
|
||||
if (noOffset) {
|
||||
|
@ -320,6 +320,8 @@ void CtrlBreakpointList::reloadBreakpoints()
|
||||
{
|
||||
bool isMemory;
|
||||
int index = getBreakpointIndex(i, isMemory);
|
||||
if (index < 0)
|
||||
continue;
|
||||
|
||||
if (isMemory)
|
||||
SetCheckState(i,(displayedMemChecks_[index].result & MEMCHECK_BREAK) != 0);
|
||||
|
@ -30,6 +30,7 @@ LRESULT CALLBACK AddressEditProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM
|
||||
SendMessage(AddressEditParentHwnd,WM_DEB_GOTOADDRESSEDIT,0,0);
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case WM_KEYUP:
|
||||
if( wParam == VK_RETURN ) return 0;
|
||||
break;
|
||||
|
@ -1260,7 +1260,7 @@ namespace MainWindow
|
||||
|
||||
case ID_FILE_SAVESTATE_NEXT_SLOT_HC:
|
||||
{
|
||||
if (KeyMap::g_controllerMap[VIRTKEY_NEXT_SLOT].begin() == KeyMap::g_controllerMap[VIRTKEY_NEXT_SLOT].end())
|
||||
if (KeyMap::g_controllerMap[VIRTKEY_NEXT_SLOT].empty())
|
||||
{
|
||||
SaveState::NextSlot();
|
||||
}
|
||||
@ -1282,7 +1282,7 @@ namespace MainWindow
|
||||
|
||||
case ID_FILE_QUICKLOADSTATE_HC:
|
||||
{
|
||||
if (KeyMap::g_controllerMap[VIRTKEY_LOAD_STATE].begin() == KeyMap::g_controllerMap[VIRTKEY_LOAD_STATE].end())
|
||||
if (KeyMap::g_controllerMap[VIRTKEY_LOAD_STATE].empty())
|
||||
{
|
||||
SetCursor(LoadCursor(0, IDC_WAIT));
|
||||
SaveState::LoadSlot(g_Config.iCurrentStateSlot, SaveStateActionFinished);
|
||||
@ -1298,7 +1298,7 @@ namespace MainWindow
|
||||
|
||||
case ID_FILE_QUICKSAVESTATE_HC:
|
||||
{
|
||||
if (KeyMap::g_controllerMap[VIRTKEY_SAVE_STATE].begin() == KeyMap::g_controllerMap[VIRTKEY_SAVE_STATE].end())
|
||||
if (KeyMap::g_controllerMap[VIRTKEY_SAVE_STATE].empty())
|
||||
{
|
||||
SetCursor(LoadCursor(0, IDC_WAIT));
|
||||
SaveState::SaveSlot(g_Config.iCurrentStateSlot, SaveStateActionFinished);
|
||||
|
@ -1293,7 +1293,9 @@ lPling:
|
||||
op = num(op, rot);
|
||||
}
|
||||
else {
|
||||
imm8 = (imm8>>rot) | (imm8<<(32-rot));
|
||||
if (rot != 0) {
|
||||
imm8 = (imm8>>rot) | (imm8<<(32-rot));
|
||||
}
|
||||
if (c=='*') {
|
||||
*op++='#';
|
||||
if (imm8>256 && ((imm8&(imm8-1))==0)) {
|
||||
|
Loading…
Reference in New Issue
Block a user