Final batch of fixes from cppcheck.

git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@3024 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2014-10-27 14:41:46 +00:00
parent bb7f5e0c5c
commit 27e005d7a5
44 changed files with 101 additions and 97 deletions

View File

@ -47,10 +47,10 @@ CheatManager::~CheatManager()
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const Cheat* CheatManager::add(const string& name, const string& code,
bool enable, int idx)
Cheat* CheatManager::add(const string& name, const string& code,
bool enable, int idx)
{
Cheat* cheat = (Cheat*) createCheat(name, code);
Cheat* cheat = createCheat(name, code);
if(!cheat)
return NULL;
@ -139,7 +139,7 @@ void CheatManager::addOneShot(const string& name, const string& code)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const Cheat* CheatManager::createCheat(const string& name, const string& code)
Cheat* CheatManager::createCheat(const string& name, const string& code) const
{
if(!isValidCode(code))
return NULL;
@ -360,7 +360,7 @@ void CheatManager::clear()
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CheatManager::isValidCode(const string& code)
bool CheatManager::isValidCode(const string& code) const
{
for(unsigned int i = 0; i < code.size(); i++)
if(!isxdigit(code[i]))

View File

@ -55,8 +55,8 @@ class CheatManager
@return The cheat (if was created), else NULL.
*/
const Cheat* add(const string& name, const string& code,
bool enable = true, int idx = -1);
Cheat* add(const string& name, const string& code,
bool enable = true, int idx = -1);
/**
Remove the cheat at 'idx' from the cheat list(s).
@ -126,7 +126,7 @@ class CheatManager
/**
Checks if a code is valid.
*/
bool isValidCode(const string& code);
bool isValidCode(const string& code) const;
private:
/**
@ -137,7 +137,7 @@ class CheatManager
@return The cheat (if was created), else NULL.
*/
const Cheat* createCheat(const string& name, const string& code);
Cheat* createCheat(const string& name, const string& code) const;
/**
Parses a list of cheats and adds/enables each one.

View File

@ -24,22 +24,19 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FilesystemNodeZIP::FilesystemNodeZIP()
: _error(ZIPERR_NOT_A_FILE),
_numFiles(0)
{
// We need a name, else the node is invalid
_path = _shortPath = _virtualFile = "";
_error = ZIPERR_NOT_A_FILE;
_numFiles = 0;
AbstractFSNode* tmp = 0;
_realNode = Common::SharedPtr<AbstractFSNode>(tmp);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FilesystemNodeZIP::FilesystemNodeZIP(const string& p)
: _error(ZIPERR_NONE),
_numFiles(0)
{
_path = _shortPath = _virtualFile = "";
_error = ZIPERR_NOT_A_FILE;
// Extract ZIP file and virtual file (if specified)
size_t pos = BSPF_findIgnoreCase(p, ".zip");
if(pos == string::npos)

View File

@ -291,7 +291,7 @@ void FrameBufferSDL2::setWindowIcon()
uInt32 rgba[256], icon[32 * 32];
uInt8 mask[32][4];
sscanf(stella_icon[0], "%u %u %u %u", &w, &h, &ncols, &nbytes);
sscanf(stella_icon[0], "%2u %2u %2u %2u", &w, &h, &ncols, &nbytes);
if((w != 32) || (h != 32) || (ncols > 255) || (nbytes > 1))
{
myOSystem.logMessage("ERROR: Couldn't load the application icon.", 0);

View File

@ -194,7 +194,7 @@ class CartDebug : public DebuggerSystem
/**
Get the name/type of the cartridge.
*/
string getCartType() const;
string getCartType() const; // FIXME - dead code
/**
Add a label and associated address.

View File

@ -121,7 +121,7 @@ class Debugger : public DialogContainer
bool delFunction(const string& name);
const Expression* getFunction(const string& name) const;
const string& getFunctionDef(const string& name) const;
const string& getFunctionDef(const string& name) const; // FIXME - dead code
const FunctionDefMap getFunctionDefMap() const;
string builtinHelp() const;

View File

@ -56,7 +56,8 @@ using namespace Common;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
DebuggerParser::DebuggerParser(Debugger& d, Settings& s)
: debugger(d),
settings(s)
settings(s),
argCount(0)
{
}

View File

@ -45,7 +45,8 @@ class CartDebugWidget : public Widget, public CommandSender
myFontWidth(lfont.getMaxCharWidth()),
myFontHeight(lfont.getFontHeight()),
myLineHeight(lfont.getLineHeight()),
myButtonHeight(myLineHeight + 4) { }
myButtonHeight(myLineHeight + 4),
myDesc(NULL) { }
virtual ~CartDebugWidget() { };

View File

@ -647,10 +647,13 @@ void PromptWidget::addToHistory(const char *str)
_historySize++;
}
#if 0 // FIXME
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int PromptWidget::compareHistory(const char *histLine) {
int PromptWidget::compareHistory(const char *histLine)
{
return 1;
}
#endif
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PromptWidget::historyScroll(int direction)

View File

@ -119,7 +119,7 @@ class PromptWidget : public Widget, public CommandSender
bool _firstTime;
bool _exitedEarly;
int compareHistory(const char *histLine);
// int compareHistory(const char *histLine);
};
#endif

View File

@ -29,7 +29,8 @@ RomListSettings::RomListSettings(GuiObject* boss, const GUI::Font& font)
: Dialog(boss->instance(), boss->parent(), 0, 0, 16, 16),
CommandSender(boss),
_xorig(0),
_yorig(0)
_yorig(0),
_item(0)
{
const int buttonWidth = font.getStringWidth("RunTo PC @ current line") + 20,
buttonHeight = font.getLineHeight() + 4;

View File

@ -77,7 +77,7 @@ RomListWidget::RomListWidget(GuiObject* boss, const GUI::Font& lfont,
_rows = h / _fontHeight;
// Create a CheckboxWidget for each row in the list
CheckboxWidget* t;
CheckboxWidget* t = NULL;
for(int i = 0; i < _rows; ++i)
{
t = new CheckboxWidget(boss, lfont, _x + 2, ypos, "", kCheckActionCmd);

View File

@ -39,12 +39,11 @@ TiaInfoWidget::TiaInfoWidget(GuiObject* boss, const GUI::Font& lfont,
x += 5;
const int lineHeight = lfont.getLineHeight();
int xpos = x, ypos = y;
int xpos = x, ypos = y + 10;
int lwidth = lfont.getStringWidth(longstr ? "Frame Cycle:" : "F. Cycle:");
int fwidth = 5 * lfont.getMaxCharWidth() + 4;
// Add frame info
xpos = x; ypos = y + 10;
new StaticTextWidget(boss, lfont, xpos, ypos, lwidth, lineHeight,
longstr ? "Frame Count:" : "Frame:",
kTextAlignLeft);

View File

@ -39,7 +39,9 @@ TiaOutputWidget::TiaOutputWidget(GuiObject* boss, const GUI::Font& font,
: Widget(boss, font, x, y, w, h),
CommandSender(boss),
myMenu(NULL),
myZoom(NULL)
myZoom(NULL),
myClickX(0),
myClickY(0)
{
// Create context menu for commands
VariantList l;

View File

@ -29,7 +29,8 @@ TogglePixelWidget::TogglePixelWidget(GuiObject* boss, const GUI::Font& font,
int x, int y, int cols, int rows)
: ToggleWidget(boss, font, x, y, cols, rows),
_pixelColor(0),
_backgroundColor(kDlgColor)
_backgroundColor(kDlgColor),
_swapBits(false)
{
_rowHeight = _colWidth = font.getLineHeight();

View File

@ -30,6 +30,8 @@ ToggleWidget::ToggleWidget(GuiObject* boss, const GUI::Font& font,
_cols(cols),
_currentRow(0),
_currentCol(0),
_rowHeight(0),
_colWidth(0),
_selectedItem(0),
_editable(true)
{

View File

@ -61,8 +61,8 @@ class ToggleWidget : public Widget, public CommandSender
int _cols;
int _currentRow;
int _currentCol;
int _rowHeight;
int _colWidth;
int _rowHeight; // explicitly set in child classes
int _colWidth; // explicitly set in child classes
int _selectedItem;
bool _editable;

View File

@ -63,8 +63,8 @@ class CompuMate
/**
Return the left and right CompuMate controllers
*/
Controller* leftController() { return myLeftController; }
Controller* rightController() { return myRightController; }
Controller* leftController() const { return myLeftController; }
Controller* rightController() const { return myRightController; }
/**
In normal key-handling mode, the update handler receives key events

View File

@ -1147,20 +1147,3 @@ uInt32 Console::ourUserPALPalette[256] = { 0 }; // filled from external file
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 Console::ourUserSECAMPalette[256] = { 0 }; // filled from external file
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Console::Console(const Console& console)
: myOSystem(console.myOSystem),
myCart(console.myCart),
myEvent(console.myEvent)
{
assert(false);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Console& Console::operator = (const Console&)
{
assert(false);
return *this;
}

View File

@ -69,13 +69,6 @@ class Console : public Serializable
@param props The properties for the cartridge
*/
Console(OSystem& osystem, Cartridge& cart, const Properties& props);
/**
Create a new console object by copying another one
@param console The object to copy
*/
Console(const Console& console);
/**
Destructor
@ -188,15 +181,6 @@ class Console : public Serializable
*/
void stateChanged(EventHandler::State state);
public:
/**
Overloaded assignment operator
@param console The console object to set myself equal to
@return Myself after assignment has taken place
*/
Console& operator = (const Console& console);
public:
/**
Toggle between NTSC/PAL/SECAM (and variants) display format.
@ -338,6 +322,10 @@ class Console : public Serializable
void toggleTIABit(TIABit bit, const string& bitname, bool show = true) const;
void toggleTIACollision(TIABit bit, const string& bitname, bool show = true) const;
// Copy constructor and assignment operator not supported
Console(const Console&);
Console& operator = (const Console&);
private:
// Reference to the osystem object
OSystem& myOSystem;

View File

@ -26,6 +26,8 @@
Driving::Driving(Jack jack, const Event& event, const System& system)
: Controller(jack, event, system, Controller::Driving),
myCounter(0),
myGrayIndex(0),
myLastYaxis(0),
myControlID(-1),
myControlIDX(-1),
myControlIDY(-1)

View File

@ -62,6 +62,7 @@ EventHandler::EventHandler(OSystem& osystem)
myState(S_NONE),
myAllowAllDirectionsFlag(false),
myFryingFlag(false),
myUseCtrlKeyFlag(true),
mySkipMouseMotion(true),
myJoyHandler(NULL)
{
@ -1971,7 +1972,7 @@ void EventHandler::setEventState(State state)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 EventHandler::resetEventsCallback(uInt32 interval, void* param)
{
((EventHandler*)param)->myEvent.clear();
(static_cast<EventHandler*>(param))->myEvent.clear();
return 0;
}

View File

@ -479,6 +479,10 @@ class EventHandler
void removeJoystick(int index);
private:
// Copy constructor and assignment operator not supported
EventHandler(const EventHandler&);
EventHandler& operator = (const EventHandler&);
enum {
kComboSize = 16,
kEventsPerCombo = 8,

View File

@ -247,7 +247,7 @@ class FilesystemNode
*/
string getNameWithExt(const string& ext) const;
string getPathWithExt(const string& ext) const;
string getShortPathWithExt(const string& ext) const;
string getShortPathWithExt(const string& ext) const; // FIXME - dead code
private:
Common::SharedPtr<AbstractFSNode> _realNode;

View File

@ -30,7 +30,9 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
M6532::M6532(const Console& console, const Settings& settings)
: myConsole(console),
mySettings(settings)
mySettings(settings),
myTimerFlagValid(false),
myEdgeDetectPositive(false)
{
}

View File

@ -58,7 +58,19 @@ MT24LC256::MT24LC256(const string& filename, const System& system)
myCyclesWhenSCLSet(0),
myDataFile(filename),
myDataFileExists(false),
myDataChanged(false)
myDataChanged(false),
jpee_mdat(0),
jpee_sdat(0),
jpee_mclk(0),
jpee_sizemask(0),
jpee_pagemask(0),
jpee_smallmode(0),
jpee_logmode(0),
jpee_pptr(0),
jpee_state(0),
jpee_nb(0),
jpee_address(0),
jpee_ad_known(0)
{
// Load the data from an external file (if it exists)
ifstream in;
@ -211,8 +223,6 @@ void MT24LC256::jpee_data_start()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void MT24LC256::jpee_data_stop()
{
int i;
if (jpee_state == 1 && jpee_nb != 1)
{
JPEE_LOG0("I2C_WARNING ABANDON_WRITE");
@ -233,7 +243,7 @@ void MT24LC256::jpee_data_stop()
jpee_pptr = 4+jpee_pagemask-(jpee_address & jpee_pagemask);
JPEE_LOG1("I2C_WARNING PAGECROSSING!(Truncate to %d bytes)",jpee_pptr-3);
}
for (i=3; i<jpee_pptr; i++)
for (int i=3; i<jpee_pptr; i++)
{
myDataChanged = true;
myData[(jpee_address++) & jpee_sizemask] = jpee_packet[i];

View File

@ -586,7 +586,7 @@ Console* OSystem::openConsole(const FilesystemNode& romfile, string& md5,
// For initial creation of the Cart, we're only concerned with the BS type
Properties props;
myPropSet->getMD5(md5, props);
string s = "";
string s;
CMDLINE_PROPS_UPDATE("bs", Cartridge_Type);
CMDLINE_PROPS_UPDATE("type", Cartridge_Type);

View File

@ -31,6 +31,7 @@ System::System(const OSystem& osystem)
: myOSystem(osystem),
myNumberOfDevices(0),
myM6502(0),
myM6532(0),
myTIA(0),
myCycles(0),
myDataBusState(0),
@ -97,7 +98,7 @@ void System::reset(bool autodetect)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void System::attach(Device* device)
{
assert(myNumberOfDevices < 100);
assert(myNumberOfDevices < 5);
// Add device to my collection of devices
myDevices[myNumberOfDevices++] = device;
@ -123,14 +124,14 @@ void System::attach(M6532* m6532)
myM6532 = m6532;
// Attach it as a normal device
attach((Device*) m6532);
attach(static_cast<Device*>(m6532));
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void System::attach(TIA* tia)
{
myTIA = tia;
attach((Device*) tia);
attach(static_cast<Device*>(tia));
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -411,7 +411,7 @@ class System : public Serializable
bool* myPageIsDirtyTable;
// Array of all the devices attached to the system
Device* myDevices[100];
Device* myDevices[5];
// Number of devices attached to the system
uInt32 myNumberOfDevices;

View File

@ -38,7 +38,8 @@ TIASurface::TIASurface(OSystem& system)
myFilterType(kNormal),
myUsePhosphor(false),
myPhosphorBlend(77),
myScanlinesEnabled(false)
myScanlinesEnabled(false),
myPalette(NULL)
{
// Load NTSC filter settings
myNTSCFilter.loadConfig(myOSystem.settings());

View File

@ -162,6 +162,7 @@ uInt32 Thumbulator::fetch16 ( uInt32 addr )
return fatalError("fetch16", addr, "abort");
}
#if 0 // Currently not used anywhere in this class
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 Thumbulator::fetch32 ( uInt32 addr )
{
@ -187,6 +188,7 @@ uInt32 Thumbulator::fetch32 ( uInt32 addr )
}
return fatalError("fetch32", addr, "abort");
}
#endif
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Thumbulator::write16 ( uInt32 addr, uInt32 data )

View File

@ -93,7 +93,7 @@ class Thumbulator
uInt32 read_register ( uInt32 reg );
uInt32 write_register ( uInt32 reg, uInt32 data );
uInt32 fetch16 ( uInt32 addr );
uInt32 fetch32 ( uInt32 addr );
//uInt32 fetch32 ( uInt32 addr );
uInt32 read16 ( uInt32 addr );
uInt32 read32 ( uInt32 );
void write16 ( uInt32 addr, uInt32 data );

View File

@ -40,7 +40,9 @@
BrowserDialog::BrowserDialog(GuiObject* boss, const GUI::Font& font,
int max_w, int max_h)
: Dialog(boss->instance(), boss->parent(), 0, 0, 0, 0),
CommandSender(boss)
CommandSender(boss),
_cmd(0),
_mode(FileSave)
{
// Set real dimensions
_w = max_w;

View File

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

View File

@ -29,7 +29,6 @@
EditTextWidget::EditTextWidget(GuiObject* boss, const GUI::Font& font,
int x, int y, int w, int h, const string& text)
: EditableWidget(boss, font, x, y, w, h + 2, text),
_editable(true),
_changed(false)
{
_flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS;

View File

@ -47,7 +47,6 @@ class EditTextWidget : public EditableWidget
protected:
string _backupString;
int _editable;
bool _changed;
};

View File

@ -63,17 +63,17 @@ FBInitStatus Launcher::initializeVideo()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const string& Launcher::selectedRomMD5()
{
return ((LauncherDialog*)myBaseDialog)->selectedRomMD5();
return (static_cast<LauncherDialog*>(myBaseDialog))->selectedRomMD5();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const FilesystemNode& Launcher::currentNode() const
{
return ((LauncherDialog*)myBaseDialog)->currentNode();
return (static_cast<LauncherDialog*>(myBaseDialog))->currentNode();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Launcher::reload()
{
((LauncherDialog*)myBaseDialog)->reload();
(static_cast<LauncherDialog*>(myBaseDialog))->reload();
}

View File

@ -69,7 +69,7 @@ LauncherDialog::LauncherDialog(OSystem& osystem, DialogContainer& parent,
fontHeight = font.getFontHeight(),
bwidth = (_w - 2 * 10 - 8 * (4 - 1)) / 4,
bheight = font.getLineHeight() + 4;
int xpos = 0, ypos = 0, lwidth = 0, lwidth2 = 0, fwidth = 0;
int xpos = 0, ypos = 0, lwidth = 0, lwidth2 = 0;
WidgetArray wid;
// Show game name
@ -88,7 +88,7 @@ LauncherDialog::LauncherDialog(OSystem& osystem, DialogContainer& parent,
// It has to fit between both labels
if(w >= 640)
{
fwidth = BSPF_min(15 * fontWidth, xpos - 20 - lwidth);
int fwidth = BSPF_min(15 * fontWidth, xpos - 20 - lwidth);
xpos -= fwidth + 5;
myPattern = new EditTextWidget(this, font, xpos, ypos,
fwidth, fontHeight, "");

View File

@ -33,7 +33,8 @@ ProgressDialog::ProgressDialog(GuiObject* boss, const GUI::Font& font,
mySlider(NULL),
myStart(0),
myFinish(0),
myStep(0)
myStep(0),
myCurrentStep(0)
{
const int fontWidth = font.getMaxCharWidth(),
fontHeight = font.getFontHeight(),

View File

@ -30,12 +30,11 @@ RomInfoWidget::RomInfoWidget(GuiObject* boss, const GUI::Font& font,
: Widget(boss, font, x, y, w, h),
mySurface(NULL),
mySurfaceIsValid(false),
myHaveProperties(false)
myHaveProperties(false),
myAvail(w > 400 ? GUI::Size(640, 512) : GUI::Size(320, 256))
{
_flags = WIDGET_ENABLED;
_bgcolor = _bgcolorhi = kWidColor;
myAvail = w > 400 ? GUI::Size(640, 512) : GUI::Size(320, 256);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -51,9 +51,6 @@ class RomInfoWidget : public Widget
// Surface pointer holding the PNG image
FBSurface* mySurface;
// How much space available for the PNG image
GUI::Size myAvail;
// Whether the surface should be redrawn by drawWidget()
bool mySurfaceIsValid;
@ -68,6 +65,9 @@ class RomInfoWidget : public Widget
// Indicates if an error occurred in creating/displaying the surface
string mySurfaceErrorMsg;
// How much space available for the PNG image
GUI::Size myAvail;
};
#endif

View File

@ -106,6 +106,7 @@ void TabWidget::setActiveTab(int tabID, bool show)
sendCommand(kTabChangedCmd, _activeTab, _id);
}
#if 0 // FIXME
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TabWidget::disableTab(int tabID)
{
@ -114,6 +115,7 @@ void TabWidget::disableTab(int tabID)
_tabs[tabID].enabled = false;
// TODO - also disable all widgets belonging to this tab
}
#endif
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TabWidget::updateActiveTab()

View File

@ -45,7 +45,7 @@ class TabWidget : public Widget, public CommandSender
//void removeTab(int tabID);
// Setting the active tab:
void setActiveTab(int tabID, bool show = false);
void disableTab(int tabID);
// void disableTab(int tabID);
void activateTabs();
void cycleTab(int direction);
// setActiveTab changes the value of _firstWidget. This means Widgets added afterwards

View File

@ -300,6 +300,7 @@ StaticTextWidget::StaticTextWidget(GuiObject *boss, const GUI::Font& font,
_textcolorhi = kTextColor;
_label = text;
_editable = false;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -