Merge pull request #7341 from unknownbrackets/warnings

Fix some static analysis warnings
This commit is contained in:
Henrik Rydgård committed 2015-01-18 19:47:38 +01:00
commit c72bd355dc
29 files changed
+102 -92

No files matched your search

+3 -1
View File
@@ -844,7 +844,9 @@ const char *InstNames[] = { "AND",
"ORR",
"MOV",
"BIC",
"MVN"
"MVN",
"MOVW",
"MOVT",
};
void ARMXEmitter::AND (ARMReg Rd, ARMReg Rn, Operand2 Rm) { WriteInstruction(0, Rd, Rn, Rm); }
+1
View File
@@ -212,6 +212,7 @@ CChunkFileReader::Error CChunkFileReader::LoadFile(const std::string& _rFilename
if (!pFile.ReadBytes(buffer, sz))
{
ERROR_LOG(COMMON, "ChunkReader: Error reading file");
delete [] buffer;
return ERROR_BAD_FILE;
}
+1
View File
@@ -390,6 +390,7 @@ void SetDefaultKeyMap(DefaultMaps dmap, bool replace) {
case DEFAULT_MAPPING_BLACKBERRY_QWERTY:
SetDefaultKeyMap(DEVICE_ID_KEYBOARD, defaultBlackberryQWERTYKeyMap, ARRAY_SIZE(defaultBlackberryQWERTYKeyMap), replace);
replace = false;
// Intentional fallthrough.
case DEFAULT_MAPPING_PAD:
SetDefaultKeyMap(DEVICE_ID_PAD_0, defaultPadMap, ARRAY_SIZE(defaultPadMap), replace);
break;
+1
View File
@@ -639,6 +639,7 @@ void DisassemblyFunction::load()
dataSize = 16;
break;
default:
delete macro;
return;
}
+2 -1
View File
@@ -426,6 +426,7 @@ void SymbolMap::AddModule(const char *name, u32 address, u32 size) {
ModuleEntry mod;
strncpy(mod.name, name, ARRAY_SIZE(mod.name));
mod.name[ARRAY_SIZE(mod.name) - 1] = '\0';
mod.start = address;
mod.size = size;
mod.index = (int)modules.size() + 1;
@@ -788,7 +789,7 @@ void SymbolMap::SetLabelName(const char* name, u32 address) {
auto symbolKey = std::make_pair(labelInfo->second.module, labelInfo->second.addr);
auto label = labels.find(symbolKey);
if (label != labels.end()) {
strcpy(label->second.name,name);
strncpy(label->second.name, name, 128);
label->second.name[127] = 0;
// Refresh the active item if it exists.
+1 -1
View File
@@ -1500,7 +1500,7 @@ u32 sceKernelReferThreadStatus(u32 threadID, u32 statusPtr)
t->nt.nativeSize = THREADINFO_SIZE_AFTER_260;
if (wantedSize != 0)
Memory::Memcpy(statusPtr, &t->nt, wantedSize);
Memory::Memcpy(statusPtr, &t->nt, std::min(wantedSize, (u32)sizeof(t->nt)));
// TODO: What is this value? Basic tests show 0...
if (wantedSize > sizeof(t->nt))
Memory::Memset(statusPtr + sizeof(t->nt), 0, wantedSize - sizeof(t->nt));
+3 -1
View File
@@ -572,7 +572,7 @@ int ArmRegCacheFPU::GetMipsRegOffset(MIPSReg r) {
return 0; // or what?
}
if (r < 32 || r > 32 + 128) {
if (r < 32 || r >= 32 + 128) {
return (32 + r) << 2;
} else {
// r is between 32 and 128 + 32
@@ -916,6 +916,8 @@ ARMReg ArmRegCacheFPU::QMapReg(int vreg, VectorSize sz, int flags) {
// Find where we want to map it, obeying the constraints we gave.
int quad = QGetFreeQuad(start, count, "mapping");
if (quad < 0)
return INVALID_REG;
// If parts of our register are elsewhere, and we are dirty, we need to flush them
// before we reload in a new location.
+5 -1
View File
@@ -242,9 +242,13 @@ bool FPURegCache::TryMapRegsVS(const u8 *v, VectorSize vsz, int flags) {
// Single is easy, just map normally but track as a SIMD reg.
// This way V/VS can warn about improper usage properly.
MapRegV(v[0], flags);
X64Reg vx = VX(v[0]);
if (vx == INVALID_REG)
return false;
vregs[v[0]].lane = 1;
if ((flags & MAP_DIRTY) != 0)
xregs[VSX(v)].dirty = true;
xregs[vx].dirty = true;
if ((flags & MAP_NOLOCK) == 0)
SpillLockV(v, vsz);
Invariant();
+10 -10
View File
@@ -164,19 +164,19 @@ void __PPGeInit()
NOTICE_LOG(SCEGE, "Not initializing PPGe - GPU is NullGpu");
return;
}
u8 *imageData;
int width;
int height;
u8 *imageData[12];
int width[12];
int height[12];
int flags;
if (!LoadZIM("ppge_atlas.zim", &width, &height, &flags, &imageData)) {
if (!LoadZIM("ppge_atlas.zim", width, height, &flags, imageData)) {
PanicAlert("Failed to load ppge_atlas.zim.\n\nPlace it in the directory \"assets\" under your PPSSPP directory.");
ERROR_LOG(SCEGE, "PPGe init failed - no atlas texture. PPGe stuff will not be drawn.");
return;
}
u32 atlasSize = height * width / 2; // it's a 4-bit paletted texture in ram
atlasWidth = width;
atlasHeight = height;
u32 atlasSize = height[0] * width[0] / 2; // it's a 4-bit paletted texture in ram
atlasWidth = width[0];
atlasHeight = height[0];
dlPtr = __PPGeDoAlloc(dlSize, false, "PPGe Display List");
dataPtr = __PPGeDoAlloc(dataSize, false, "PPGe Vertex Data");
__PPGeSetupListArgs();
@@ -189,11 +189,11 @@ void __PPGeInit()
palette[i] = (val << 12) | 0xFFF;
}
const u32_le *imagePtr = (u32_le *)imageData;
const u32_le *imagePtr = (u32_le *)imageData[0];
u8 *ramPtr = (u8 *)Memory::GetPointer(atlasPtr);
// Palettize to 4-bit, the easy way.
for (int i = 0; i < width * height / 2; i++) {
for (int i = 0; i < width[0] * height[0] / 2; i++) {
// Each pixel is 16 bits, so this loads two pixels.
u32 c = imagePtr[i];
// It's white anyway, so we only look at one channel of each pixel.
@@ -203,7 +203,7 @@ void __PPGeInit()
ramPtr[i] = cval;
}
free(imageData);
free(imageData[0]);
DEBUG_LOG(SCEGE, "PPGe drawing library initialized. DL: %08x Data: %08x Atlas: %08x (%i) Args: %08x",
dlPtr, dataPtr, atlasPtr, atlasSize, listArgs.ptr);
+2 -2
View File
@@ -40,13 +40,13 @@ void IndexGenerator::Reset() {
}
bool IndexGenerator::PrimCompatible(int prim1, int prim2) {
if (prim1 == -1)
if (prim1 == GE_PRIM_INVALID || prim2 == GE_PRIM_KEEP_PREVIOUS)
return true;
return indexedPrimitiveType[prim1] == indexedPrimitiveType[prim2];
}
bool IndexGenerator::PrimCompatible(int prim) const {
if (prim_ == GE_PRIM_INVALID)
if (prim_ == GE_PRIM_INVALID || prim == GE_PRIM_KEEP_PREVIOUS)
return true;
return indexedPrimitiveType[prim] == prim_;
}
+1
View File
@@ -876,6 +876,7 @@ namespace DX9 {
textureCache_->ForgetLastTexture();
nvfb->fbo = fbo_create(nvfb->width, nvfb->height, 1, true, (FBOColorDepth)nvfb->colorDepth);
if (!(nvfb->fbo)) {
delete nvfb;
ERROR_LOG(SCEGE, "Error creating FBO! %i x %i", nvfb->renderWidth, nvfb->renderHeight);
return;
}
+1 -1
View File
@@ -60,7 +60,7 @@ public:
// Called by the window system if the window size changed. This will be reflected in PSPCoreParam.pixel*.
virtual void Resized();
virtual void ClearShaderCache();
virtual bool DecodeTexture(u8* dest, GPUgstate state) {
virtual bool DecodeTexture(u8 *dest, const GPUgstate &state) {
return textureCache_.DecodeTexture(dest, state);
}
virtual bool FramebufferDirty();
+1 -1
View File
@@ -1738,7 +1738,7 @@ void TextureCacheDX9::LoadTextureLevel(TexCacheEntry &entry, int level, int maxL
entry.texture->UnlockRect(level);
}
bool TextureCacheDX9::DecodeTexture(u8* output, GPUgstate state)
bool TextureCacheDX9::DecodeTexture(u8 *output, const GPUgstate &state)
{
OutputDebugStringA("TextureCache::DecodeTexture : FixMe\r\n");
return true;
+1 -1
View File
@@ -78,7 +78,7 @@ public:
}
// Only used by Qt UI?
bool DecodeTexture(u8 *output, GPUgstate state);
bool DecodeTexture(u8 *output, const GPUgstate &state);
void ForgetLastTexture();
+1
View File
@@ -1195,6 +1195,7 @@ void FramebufferManager::ReadFramebufferToMemory(VirtualFramebuffer *vfb, bool s
textureCache_->ForgetLastTexture();
nvfb->fbo = fbo_create(nvfb->width, nvfb->height, 1, false, (FBOColorDepth)nvfb->colorDepth);
if (!(nvfb->fbo)) {
delete nvfb;
ERROR_LOG(SCEGE, "Error creating FBO! %i x %i", nvfb->renderWidth, nvfb->renderHeight);
return;
}
+1 -1
View File
@@ -62,7 +62,7 @@ public:
virtual void Resized();
virtual void ClearShaderCache();
virtual void CleanupBeforeUI();
virtual bool DecodeTexture(u8* dest, GPUgstate state) {
virtual bool DecodeTexture(u8 *dest, const GPUgstate &state) {
return textureCache_.DecodeTexture(dest, state);
}
virtual bool FramebufferDirty();
+1 -1
View File
@@ -2037,7 +2037,7 @@ void TextureCache::LoadTextureLevel(TexCacheEntry &entry, int level, bool replac
}
// Only used by Qt UI?
bool TextureCache::DecodeTexture(u8* output, GPUgstate state) {
bool TextureCache::DecodeTexture(u8* output, const GPUgstate &state) {
GPUgstate oldState = gstate;
gstate = state;
+1 -1
View File
@@ -95,7 +95,7 @@ public:
u32 AllocTextureName();
// Only used by Qt UI?
bool DecodeTexture(u8 *output, GPUgstate state);
bool DecodeTexture(u8 *output, const GPUgstate &state);
// Wow this is starting to grow big. Soon need to start looking at resizing it.
// Must stay a POD.
+1 -1
View File
@@ -111,7 +111,7 @@ public:
const std::list<int>& GetDisplayLists() {
return dlQueue;
}
virtual bool DecodeTexture(u8* dest, GPUgstate state) {
virtual bool DecodeTexture(u8* dest, const GPUgstate &state) {
return false;
}
std::vector<FramebufferInfo> GetFramebufferList() {
+1 -1
View File
@@ -284,6 +284,6 @@ public:
virtual void DumpNextFrame() = 0;
virtual void GetReportingInfo(std::string &primaryInfo, std::string &fullInfo) = 0;
virtual const std::list<int>& GetDisplayLists() = 0;
virtual bool DecodeTexture(u8* dest, GPUgstate state) = 0;
virtual bool DecodeTexture(u8* dest, const GPUgstate &state) = 0;
virtual std::vector<FramebufferInfo> GetFramebufferList() = 0;
};
+2 -2
View File
@@ -64,11 +64,11 @@ public:
virtual void Draw(UIContext &dc);
UI::EventReturn OnClicked(UI::EventParams &e) {
bool temp = false;
if (toggle_) {
*toggle_ = !(*toggle_);
temp = *toggle_;
}
bool temp;
temp = *toggle_;
if (temp) {
activatedCheat = text_;
processFileOn(activatedCheat);
+2
View File
@@ -82,12 +82,14 @@ bool D3D9_Init(HWND wnd, bool windowed, std::string *error_message) {
HRESULT result = g_pfnCreate9ex(D3D_SDK_VERSION, &d3dEx);
d3d = d3dEx;
if (FAILED(result)) {
FreeLibrary(hD3D9);
*error_message = "D3D9Ex available but context creation failed";
return false;
}
} else {
d3d = Direct3DCreate9(D3D_SDK_VERSION);
if (!d3d) {
FreeLibrary(hD3D9);
*error_message = "Failed to create D3D9 context";
return false;
}
+34 -42
View File
@@ -291,6 +291,9 @@ void CtrlRegisterList::onPaint(WPARAM wParam, LPARAM lParam)
value = cpu->GetLo();
len = sprintf(temp,"lo");
break;
default:
temp[0] = '\0';
break;
}
SetTextColor(hdc,0x600000);
@@ -366,22 +369,18 @@ void CtrlRegisterList::redraw()
UpdateWindow(wnd);
}
void CtrlRegisterList::copyRegisterValue()
u32 CtrlRegisterList::getSelectedRegValue(char *out, size_t size)
{
if (!Core_IsStepping())
{
MessageBox(wnd,L"Can't copy register values while the core is running.",L"Error",MB_OK);
return;
}
int cat = category;
int reg = selection;
u32 val;
if (selection >= cpu->GetNumRegsInCategory(cat))
if (selection >= cpu->GetNumRegsInCategory(category))
{
if (cat != 0 || selection >= REGISTERS_END)
return;
if (category != 0 || selection >= REGISTERS_END)
{
*out = '\0';
return -1;
}
switch (selection)
{
@@ -394,14 +393,29 @@ void CtrlRegisterList::copyRegisterValue()
case REGISTER_LO:
val = cpu->GetLo();
break;
default:
*out = '\0';
return -1;
}
} else {
val = cpu->GetRegValue(cat,reg);
}
else
val = cpu->GetRegValue(category, reg);
snprintf(out, size, "%08X", val);
return val;
}
void CtrlRegisterList::copyRegisterValue()
{
if (!Core_IsStepping())
{
MessageBox(wnd,L"Can't copy register values while the core is running.",L"Error",MB_OK);
return;
}
char temp[24];
sprintf(temp,"%08X",val);
W32Util::CopyTextToClipboard(wnd,temp);
getSelectedRegValue(temp, 24);
W32Util::CopyTextToClipboard(wnd, temp);
}
void CtrlRegisterList::editRegisterValue()
@@ -412,33 +426,9 @@ void CtrlRegisterList::editRegisterValue()
return;
}
int cat = category;
char temp[24];
u32 val = getSelectedRegValue(temp, 24);
int reg = selection;
u32 val;
if (selection >= cpu->GetNumRegsInCategory(cat))
{
if (cat != 0 || selection >= REGISTERS_END)
return;
switch (selection)
{
case REGISTER_PC:
val = cpu->GetPC();
break;
case REGISTER_HI:
val = cpu->GetHi();
break;
case REGISTER_LO:
val = cpu->GetLo();
break;
}
} else {
val = cpu->GetRegValue(cat,reg);
}
char temp[256];
sprintf(temp,"0x%08X",val);
std::string value = temp;
if (InputBox_GetString(GetModuleHandle(NULL),wnd,L"Set new value",value,value)) {
@@ -457,7 +447,7 @@ void CtrlRegisterList::editRegisterValue()
cpu->SetLo(val);
break;
default:
cpu->SetRegValue(cat,reg,val);
cpu->SetRegValue(category, reg, val);
break;
}
redraw();
@@ -531,6 +521,8 @@ void CtrlRegisterList::onMouseUp(WPARAM wParam, LPARAM lParam, int button)
case REGISTER_LO:
val = cpu->GetLo();
break;
default:
return;
}
}
else
+1
View File
@@ -45,6 +45,7 @@ class CtrlRegisterList
bool *changedCat0Regs;
bool ctrlDown;
u32 getSelectedRegValue(char *out, size_t size);
void copyRegisterValue();
void editRegisterValue();
public:
+1 -1
View File
@@ -316,7 +316,7 @@ void CDisasm::stepOut()
auto threads = GetThreadsInfo();
u32 entry, stackTop;
u32 entry = cpu->GetPC(), stackTop = 0;
for (size_t i = 0; i < threads.size(); i++)
{
if (threads[i].isCurrent)
+2 -2
View File
@@ -55,9 +55,9 @@ namespace W32Util
}
float f = (float)size + ((float)frac / 1024.0f);
if (s==0)
sprintf(out,"%d B",size);
sprintf(out, "%d B", (int)size);
else
sprintf(out,"%3.1f %s",f,sizes[s]);
sprintf(out, "%3.1f %s", f, sizes[s]);
}
BOOL CopyTextToClipboard(HWND hwnd, const char *text) {
+2 -2
View File
@@ -125,13 +125,13 @@ namespace W32Util
}
AsyncBrowseDialog::AsyncBrowseDialog(HWND parent, UINT completeMsg, std::wstring title)
: type_(DIR), parent_(parent), completeMsg_(completeMsg), title_(title), complete_(false) {
: type_(DIR), parent_(parent), completeMsg_(completeMsg), title_(title), complete_(false), result_(false) {
thread_ = new std::thread(std::bind(&AsyncBrowseDialog::Execute, this));
thread_->detach();
}
AsyncBrowseDialog::AsyncBrowseDialog(Type type, HWND parent, UINT completeMsg, std::wstring title, std::wstring initialFolder, std::wstring filter, std::wstring extension)
: type_(type), parent_(parent), completeMsg_(completeMsg), title_(title), initialFolder_(initialFolder), filter_(filter), extension_(extension), complete_(false) {
: type_(type), parent_(parent), completeMsg_(completeMsg), title_(title), initialFolder_(initialFolder), filter_(filter), extension_(extension), complete_(false), result_(false) {
thread_ = new std::thread(std::bind(&AsyncBrowseDialog::Execute, this));
thread_->detach();
}
+1
View File
@@ -1130,6 +1130,7 @@ namespace MainWindow
break;
}
}
break;
case WM_TIMER:
// Hack: Take the opportunity to also show/hide the mouse cursor in fullscreen mode.
+18 -18
View File
@@ -185,6 +185,7 @@ std::string GetVideoCardDriverVersion() {
hr = pIWbemLocator->ConnectServer(bstrServer, NULL, NULL, 0L, 0L, NULL, NULL, &pIWbemServices);
if (FAILED(hr)) {
pIWbemLocator->Release();
SysFreeString(bstrServer);
CoUninitialize();
return retvalue;
}
@@ -287,25 +288,24 @@ void System_SendMessage(const char *command, const char *parameter) {
}
}
void EnableCrashingOnCrashes() {
typedef BOOL (WINAPI *tGetPolicy)(LPDWORD lpFlags);
typedef BOOL (WINAPI *tSetPolicy)(DWORD dwFlags);
const DWORD EXCEPTION_SWALLOWING = 0x1;
void EnableCrashingOnCrashes() {
typedef BOOL (WINAPI *tGetPolicy)(LPDWORD lpFlags);
typedef BOOL (WINAPI *tSetPolicy)(DWORD dwFlags);
const DWORD EXCEPTION_SWALLOWING = 0x1;
HMODULE kernel32 = LoadLibrary(L"kernel32.dll");
tGetPolicy pGetPolicy = (tGetPolicy)GetProcAddress(kernel32,
"GetProcessUserModeExceptionPolicy");
tSetPolicy pSetPolicy = (tSetPolicy)GetProcAddress(kernel32,
"SetProcessUserModeExceptionPolicy");
if (pGetPolicy && pSetPolicy)
{
DWORD dwFlags;
if (pGetPolicy(&dwFlags))
{
// Turn off the filter
pSetPolicy(dwFlags & ~EXCEPTION_SWALLOWING);
}
}
HMODULE kernel32 = LoadLibrary(L"kernel32.dll");
tGetPolicy pGetPolicy = (tGetPolicy)GetProcAddress(kernel32,
"GetProcessUserModeExceptionPolicy");
tSetPolicy pSetPolicy = (tSetPolicy)GetProcAddress(kernel32,
"SetProcessUserModeExceptionPolicy");
if (pGetPolicy && pSetPolicy) {
DWORD dwFlags;
if (pGetPolicy(&dwFlags)) {
// Turn off the filter.
pSetPolicy(dwFlags & ~EXCEPTION_SWALLOWING);
}
}
FreeLibrary(kernel32);
}
bool System_InputBoxGetString(const char *title, const char *defaultValue, char *outValue, size_t outLength)