Fix some unlikely uninitialized values.

This commit is contained in:
Unknown W. Brackets 2015-01-17 18:36:41 -08:00
parent de8ffc18b3
commit fa84bb6948
2 changed files with 35 additions and 42 deletions

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

View file

@ -45,6 +45,7 @@ class CtrlRegisterList
bool *changedCat0Regs;
bool ctrlDown;
u32 getSelectedRegValue(char *out, size_t size);
void copyRegisterValue();
void editRegisterValue();
public: