Fix some warnings generated by cppcheck (a C++ linter).

This commit is contained in:
Stephen Anthony 2018-08-27 11:09:03 -02:30
parent 409fa49aae
commit 8c7488914d
26 changed files with 63 additions and 58 deletions

View File

@ -27,7 +27,8 @@ AudioQueue::AudioQueue(uInt32 fragmentSize, uInt32 capacity, bool isStereo)
myFragmentQueue(capacity),
myAllFragments(capacity + 2),
mySize(0),
myNextFragment(0)
myNextFragment(0),
myIgnoreOverflows(true)
{
const uInt8 sampleSize = myIsStereo ? 2 : 1;

View File

@ -185,7 +185,11 @@ class AtariNTSC
float fringing;
float kernel [rescale_out * kernel_size * 2];
init_t() : contrast(0.0), brightness(0.0), artifacts(0.0), fringing(0.0) { }
init_t() : contrast(0.0), brightness(0.0), artifacts(0.0), fringing(0.0) {
std::fill(to_rgb, to_rgb + burst_count * 6, 0.0);
std::fill(to_float, to_float + gamma_size, 0.0);
std::fill(kernel, kernel + rescale_out * kernel_size * 2, 0.0);
}
};
init_t myImpl;

View File

@ -460,7 +460,7 @@ bool CartDebug::addDirective(CartDebug::DisasmType type,
i->end = tag.start - 1;
// Insert new endpoint
i++;
++i;
list.insert(i, tag2);
break; // no need to go further; this is the insertion point
}
@ -1179,10 +1179,10 @@ string CartDebug::saveDisassembly()
out << "\n";
out << ALIGN(16) << ourZPMnemonic[addr - 0x80] << "= $"
<< Base::HEX2 << right << (addr)
<< (stackUsed|codeUsed ? "; (" : "")
<< ((stackUsed|codeUsed) ? "; (" : "")
<< (codeUsed ? "c" : "")
<< (stackUsed ? "s" : "")
<< (stackUsed | codeUsed ? ")" : "")
<< ((stackUsed | codeUsed) ? ")" : "")
<< "\n";
addLine = false;
} else if (ramUsed|codeUsed|stackUsed) {

View File

@ -33,6 +33,8 @@ class CpuState : public DebuggerState
int PC, SP, PS, A, X, Y;
int srcS, srcA, srcX, srcY;
BoolArray PSbits;
CpuState() : PC(0), SP(0), PS(0), A(0), X(0), Y(0), srcS(0), srcA(0), srcX(0), srcY(0) { }
};
class CpuDebug : public DebuggerSystem

View File

@ -293,10 +293,10 @@ string RiotDebug::dirP0String()
{
uInt8 reg = swcha();
ostringstream buf;
buf << (reg & 0x80 ? "" : "right ")
<< (reg & 0x40 ? "" : "left ")
<< (reg & 0x20 ? "" : "left ")
<< (reg & 0x10 ? "" : "left ")
buf << ((reg & 0x80) ? "" : "right ")
<< ((reg & 0x40) ? "" : "left ")
<< ((reg & 0x20) ? "" : "left ")
<< ((reg & 0x10) ? "" : "left ")
<< ((reg & 0xf0) == 0xf0 ? "(no directions) " : "");
return buf.str();
}
@ -306,10 +306,10 @@ string RiotDebug::dirP1String()
{
uInt8 reg = swcha();
ostringstream buf;
buf << (reg & 0x08 ? "" : "right ")
<< (reg & 0x04 ? "" : "left ")
<< (reg & 0x02 ? "" : "left ")
<< (reg & 0x01 ? "" : "left ")
buf << ((reg & 0x08) ? "" : "right ")
<< ((reg & 0x04) ? "" : "left ")
<< ((reg & 0x02) ? "" : "left ")
<< ((reg & 0x01) ? "" : "left ")
<< ((reg & 0x0f) == 0x0f ? "(no directions) " : "");
return buf.str();
}
@ -336,8 +336,8 @@ string RiotDebug::tvTypeString()
string RiotDebug::switchesString()
{
ostringstream buf;
buf << (swchb() & 0x2 ? "-" : "+") << "select "
<< (swchb() & 0x1 ? "-" : "+") << "reset";
buf << ((swchb() & 0x2) ? "-" : "+") << "select "
<< ((swchb() & 0x1) ? "-" : "+") << "reset";
return buf.str();
}

View File

@ -41,6 +41,14 @@ class RiotState : public DebuggerState
// These are actually from the TIA, but are I/O related
uInt8 INPT0, INPT1, INPT2, INPT3, INPT4, INPT5;
bool INPTLatch, INPTDump;
RiotState()
: SWCHA_R(0), SWCHA_W(0), SWACNT(0), SWCHB_R(0), SWCHB_W(0), SWBCNT(0),
TIM1T(0), TIM8T(0), TIM64T(0), T1024T(0), INTIM(0), TIMINT(0),
TIMCLKS(0), INTIMCLKS(0), TIMDIV(0),
INPT0(0), INPT1(0), INPT2(0), INPT3(0), INPT4(0), INPT5(0),
INPTLatch(false), INPTDump(false)
{ }
};
class RiotDebug : public DebuggerSystem

View File

@ -196,8 +196,8 @@ void CartridgeCMWidget::loadConfig()
myAudOut->setState(swcha & 0x40);
// RAM state (several bits from SWCHA)
const string& ram = swcha & 0x10 ? " Inactive" :
swcha & 0x20 ? " Read-only" : " Write-only";
const string& ram = (swcha & 0x10) ? " Inactive" :
(swcha & 0x20) ? " Read-only" : " Write-only";
myRAM->setText(ram, (swcha & 0x30) != (myOldState.swcha & 0x30));
CartDebugWidget::loadConfig();
@ -224,8 +224,8 @@ string CartridgeCMWidget::bankState()
ostringstream& buf = buffer();
buf << "Bank = " << std::dec << myCart.getBank()
<< ", RAM is" << (myCart.mySWCHA & 0x10 ? " Inactive" :
myCart.mySWCHA & 0x20 ? " Read-only" : " Write-only");
<< ", RAM is" << ((myCart.mySWCHA & 0x10) ? " Inactive" :
(myCart.mySWCHA & 0x20) ? " Read-only" : " Write-only");
return buf.str();
}

View File

@ -255,7 +255,7 @@ void CartridgeDASHWidget::updateUIState()
else
{
int bankno = segment & myCart.BIT_BANK_MASK;
const string& banktype = segment & myCart.BITMASK_ROMRAM ? "RAM" : "ROM";
const string& banktype = (segment & myCart.BITMASK_ROMRAM) ? "RAM" : "ROM";
myBankNumber[i]->setSelected(bankno);
myBankType[i]->setSelected(banktype);

View File

@ -80,7 +80,6 @@ CartRamWidget::CartRamWidget(
ypos += myDesc->getHeight() + myFontHeight / 2;
// Add RAM widget
xpos = x + _font.getStringWidth("xxxx");
myRam = new InternalRamWidget(boss, lfont, nfont, 2, ypos, w, h-ypos, cartDebug);
addToFocusList(myRam->getFocusList());
}

View File

@ -25,6 +25,7 @@ FlashWidget::FlashWidget(GuiObject* boss, const GUI::Font& font,
: ControllerWidget(boss, font, x, y, controller),
myEEPROMEraseCurrent(nullptr)
{
std::fill(myPage, myPage + MAX_PAGES, nullptr);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -80,11 +80,10 @@ RomListWidget::RomListWidget(GuiObject* boss, const GUI::Font& lfont,
_rows = h / _fontHeight;
// Create a CheckboxWidget for each row in the list
CheckboxWidget* t = nullptr;
for(int i = 0; i < _rows; ++i)
{
t = new CheckboxWidget(boss, lfont, _x + 2, ypos, "",
CheckboxWidget::kCheckActionCmd);
CheckboxWidget* t = new CheckboxWidget(boss, lfont, _x + 2, ypos, "",
CheckboxWidget::kCheckActionCmd);
t->setTarget(this);
t->setID(i);
t->setFill(CheckboxWidget::Circle);

View File

@ -242,7 +242,7 @@ uInt8 CartridgeDPC::peek(uInt16 address)
}
// Clock the selected data fetcher's counter if needed
if((index < 5) || ((index >= 5) && (!myMusicMode[index - 5])))
if(index < 5 || !myMusicMode[index - 5])
{
myCounters[index] = (myCounters[index] - 1) & 0x07ff;
}

View File

@ -216,7 +216,7 @@ class Controller : public Serializable
*/
virtual string about(bool swappedPorts) const
{
return name() + " in " + ((myJack == Left) ^ swappedPorts ?
return name() + " in " + (((myJack == Left) ^ swappedPorts) ?
"left port" : "right port");
}

View File

@ -27,7 +27,8 @@ class DispatchResult
public:
DispatchResult() : myStatus(Status::invalid) {}
DispatchResult()
: myStatus(Status::invalid), myCycles(0), myAddress(0), myWasReadTrap(false) { }
Status getStatus() const { return myStatus; }

View File

@ -88,6 +88,8 @@ MT24LC256::MT24LC256(const string& filename, const System& system)
// Then initialize the I2C state
jpee_init();
systemReset();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -149,7 +151,7 @@ void MT24LC256::update()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void MT24LC256::systemReset()
{
memset(myPageHit, false, sizeof(myPageHit));
std::fill(myPageHit, myPageHit + PAGE_NUM, false);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -63,7 +63,7 @@ void AudioChannel::phase0()
default:
myNoiseFeedback =
((myNoiseCounter & 0x04 ? 1 : 0) ^ (myNoiseCounter & 0x01)) ||
(((myNoiseCounter & 0x04) ? 1 : 0) ^ (myNoiseCounter & 0x01)) ||
myNoiseCounter == 0;
break;
@ -82,13 +82,12 @@ void AudioChannel::phase0()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8 AudioChannel::phase1()
{
bool pulseFeedback = false;
if (myClockEnable) {
bool pulseFeedback = false;
switch (myAudc >> 2) {
case 0x00:
pulseFeedback =
((myPulseCounter & 0x02 ? 1 : 0) ^ (myPulseCounter & 0x01)) &&
(((myPulseCounter & 0x02) ? 1 : 0) ^ (myPulseCounter & 0x01)) &&
(myPulseCounter != 0x0a) &&
(myAudc & 0x03);

View File

@ -58,7 +58,6 @@ AudioDialog::AudioDialog(OSystem& osystem, DialogContainer& parent,
xpos = HBORDER; ypos = VBORDER + _th;
// Enable sound
xpos = HBORDER;
mySoundEnableCheckbox = new CheckboxWidget(this, font, xpos, ypos,
"Enable sound", kSoundEnableChanged);
wid.push_back(mySoundEnableCheckbox);

View File

@ -33,11 +33,10 @@ CheckListWidget::CheckListWidget(GuiObject* boss, const GUI::Font& font,
_rows = h / _fontHeight;
// Create a CheckboxWidget for each row in the list
CheckboxWidget* t = nullptr;
for(int i = 0; i < _rows; ++i)
{
t = new CheckboxWidget(boss, font, _x + 2, ypos, "",
CheckboxWidget::kCheckActionCmd);
CheckboxWidget* t = new CheckboxWidget(boss, font, _x + 2, ypos, "",
CheckboxWidget::kCheckActionCmd);
t->setTextColor(kTextColor);
t->setTarget(this);
t->setID(i);

View File

@ -131,7 +131,6 @@ void DeveloperDialog::addEmulationTab(const GUI::Font& font)
ypos += lineHeight + VGAP;
// Randomize CPU
lwidth = font.getStringWidth("Randomize CPU ");
myRandomizeCPULabel = new StaticTextWidget(myTab, font, HBORDER + INDENT * 2, ypos + 1, "Randomize CPU ");
wid.push_back(myRandomizeCPULabel);
@ -184,7 +183,6 @@ void DeveloperDialog::addVideoTab(const GUI::Font& font)
int tabID = myTab->addTab("Video");
wid.clear();
ypos = VBORDER;
// settings set
mySettingsGroup1 = new RadioButtonGroup();

View File

@ -614,14 +614,11 @@ void GameInfoDialog::updateControllerStates()
const string& contrP0 = myP0Controller->getSelectedTag().toString();
const string& contrP1 = myP1Controller->getSelectedTag().toString();
bool enableEEEraseButton = false;
bool enableSwapPaddles = false;
bool enableSwapPorts = false;
// Compumate bankswitching scheme doesn't allow to select controllers
bool enableSelectControl = myType->getSelectedTag() != "CM";
enableSwapPorts = enableSelectControl;
enableSwapPaddles = BSPF::startsWithIgnoreCase(contrP0, "PADDLES") ||
bool enableSwapPaddles = BSPF::startsWithIgnoreCase(contrP0, "PADDLES") ||
BSPF::startsWithIgnoreCase(contrP1, "PADDLES");
if(instance().hasConsole())
@ -630,10 +627,10 @@ void GameInfoDialog::updateControllerStates()
const Controller& rport = instance().console().rightController();
// we only enable the button if we have a valid previous and new controller.
enableEEEraseButton = ((lport.type() == Controller::SaveKey && contrP0 == "SAVEKEY")
|| (lport.type() == Controller::AtariVox && contrP0 == "ATARIVOX")
|| (rport.type() == Controller::SaveKey && contrP1 == "SAVEKEY")
|| (rport.type() == Controller::AtariVox && contrP1 == "ATARIVOX"));
enableEEEraseButton = ((lport.type() == Controller::SaveKey && contrP0 == "SAVEKEY") ||
(rport.type() == Controller::SaveKey && contrP1 == "SAVEKEY") ||
(lport.type() == Controller::AtariVox && contrP0 == "ATARIVOX") ||
(rport.type() == Controller::AtariVox && contrP1 == "ATARIVOX"));
}
myP0Label->setEnabled(enableSelectControl);
@ -641,7 +638,7 @@ void GameInfoDialog::updateControllerStates()
myP0Controller->setEnabled(enableSelectControl);
myP1Controller->setEnabled(enableSelectControl);
mySwapPorts->setEnabled(enableSwapPorts);
mySwapPorts->setEnabled(enableSelectControl);
mySwapPaddles->setEnabled(enableSwapPaddles);
myEraseEEPROMLabel->setEnabled(enableEEEraseButton);

View File

@ -141,7 +141,6 @@ void InputDialog::addDevicePortTab(const GUI::Font& font)
#endif
lwidth = font.getStringWidth("Digital paddle sensitivity ");
pwidth = font.getMaxCharWidth() * 8;
// Add joystick deadzone setting
ypos += lineHeight + VGAP*3;

View File

@ -134,11 +134,12 @@ void RomAuditDialog::auditRoms()
int renamed = 0, notfound = 0;
for(uInt32 idx = 0; idx < files.size(); idx++)
{
bool renameSucceeded = false;
string extension;
if(files[idx].isFile() &&
LauncherFilterDialog::isValidRomName(files[idx], extension))
{
bool renameSucceeded = false;
// Calculate the MD5 so we can get the rest of the info
// from the PropertiesSet (stella.pro)
const string& md5 = MD5::hash(files[idx]);

View File

@ -59,7 +59,6 @@ SnapshotDialog::SnapshotDialog(OSystem& osystem, DialogContainer& parent,
// Snapshot naming
xpos = HBORDER; ypos += buttonHeight + V_GAP * 4;
fwidth = font.getStringWidth("10 seconds");
// Snapshot interval (continuous mode)
mySnapInterval = new SliderWidget(this, font, xpos, ypos,
@ -106,7 +105,7 @@ SnapshotDialog::~SnapshotDialog()
void SnapshotDialog::loadConfig()
{
const Settings& settings = instance().settings();
mySnapSavePath->setText(settings.getString("snapsavedir"));
mySnapSavePath->setText(settings.getString("snapsavedir"));
mySnapInterval->setValue(instance().settings().getInt("ssinterval"));
mySnapName->setState(instance().settings().getString("snapname") == "rom");
mySnapSingle->setState(settings.getBool("sssingle"));
@ -116,7 +115,7 @@ void SnapshotDialog::loadConfig()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SnapshotDialog::saveConfig()
{
instance().settings().setValue("snapsavedir", mySnapSavePath->getText());
instance().settings().setValue("snapsavedir", mySnapSavePath->getText());
instance().settings().setValue("ssinterval", mySnapInterval->getValue());
instance().settings().setValue("snapname", mySnapName->getState() ? "rom" : "int");
instance().settings().setValue("sssingle", mySnapSingle->getState());
@ -130,7 +129,7 @@ void SnapshotDialog::saveConfig()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SnapshotDialog::setDefaults()
{
mySnapSavePath->setText(instance().defaultSaveDir());
mySnapSavePath->setText(instance().defaultSaveDir());
mySnapInterval->setValue(2);
mySnapName->setState(false);
mySnapSingle->setState(false);

View File

@ -51,7 +51,7 @@ UIDialog::UIDialog(OSystem& osystem, DialogContainer& parent,
const int HBORDER = 10;
const int INDENT = 16;
int xpos, ypos, tabID;
int lwidth, pwidth = font.getStringWidth("Standard");
int lwidth, pwidth;
WidgetArray wid;
VariantList items;
const GUI::Size& ds = instance().frameBuffer().desktopSize();
@ -61,7 +61,6 @@ UIDialog::UIDialog(OSystem& osystem, DialogContainer& parent,
_h = (10+1) * (lineHeight + 4) + VBORDER + _th;
// The tab widget
xpos = HBORDER; ypos = VBORDER;
myTab = new TabWidget(this, font, 2, 4 + _th, _w - 2*2, _h - _th - buttonHeight - 20);
addTabWidget(myTab);

View File

@ -244,7 +244,6 @@ VideoDialog::VideoDialog(OSystem& osystem, DialogContainer& parent,
// Custom adjustables (using macro voodoo)
xpos += INDENT - 2; ypos += 0;
pwidth = lwidth;
lwidth = font.getStringWidth("Saturation ");
#define CREATE_CUSTOM_SLIDERS(obj, desc) \
@ -271,7 +270,6 @@ VideoDialog::VideoDialog(OSystem& osystem, DialogContainer& parent,
ypos = VBORDER;
lwidth = font.getStringWidth("Intensity ");
pwidth = font.getMaxCharWidth() * 6;
// TV Phosphor effect
myTVPhosphor = new CheckboxWidget(myTab, font, xpos, ypos + 1, "Phosphor for all ROMs");

View File

@ -131,7 +131,7 @@ void FilesystemNodeWINDOWS::addFile(AbstractFSList& list, ListMode mode,
if(!strncmp(asciiName, ".", 1) || !strncmp(asciiName, "..", 2))
return;
isDirectory = (find_data->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ? true : false);
isDirectory = ((find_data->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? true : false);
isFile = !isDirectory;//(find_data->dwFileAttributes & FILE_ATTRIBUTE_NORMAL ? true : false);
if((isFile && mode == FilesystemNode::kListDirectoriesOnly) ||