Fixes for various issues reported by Coverity.

This commit is contained in:
Stephen Anthony 2018-03-24 16:58:08 -02:30
parent 524cec907a
commit 698beaec8b
26 changed files with 84 additions and 36 deletions

View File

@ -177,7 +177,7 @@ class RewindManager
// We do nothing on object instantiation or copy
// The goal of LinkedObjectPool is to not do any allocations at all
RewindState() { }
RewindState() : cycles(0) { }
RewindState(const RewindState&) { }
// Output object info; used for debugging only

View File

@ -131,9 +131,13 @@ int main(int argc, char* argv[])
if(theOSystem->settings().getBool("takesnapshot"))
{
try {
theOSystem->logMessage("Taking snapshots with 'takesnapshot' ...", 2);
for(int i = 0; i < 30; ++i) theOSystem->frameBuffer().update();
theOSystem->png().takeSnapshot();
} catch(const runtime_error& e) {
cout << e.what() << endl;
}
return Cleanup();
}

View File

@ -184,6 +184,8 @@ class AtariNTSC
float artifacts;
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 myImpl;

View File

@ -58,6 +58,7 @@ using std::right;
DebuggerParser::DebuggerParser(Debugger& d, Settings& s)
: debugger(d),
settings(s),
myCommand(0),
argCount(0),
execDepth(0),
execPrefix("")
@ -1459,13 +1460,10 @@ void DebuggerParser::executeListfunctions()
void DebuggerParser::executeListsavestateifs()
{
ostringstream buf;
int count = 0;
StringList conds = debugger.m6502().getCondSaveStateNames();
if(conds.size() > 0)
{
if(count)
commandResult << endl;
commandResult << "savestateif:" << endl;
for(uInt32 i = 0; i < conds.size(); i++)
{

View File

@ -26,8 +26,11 @@ CartridgeMNetworkWidget::CartridgeMNetworkWidget(
int x, int y, int w, int h,
CartridgeMNetwork& cart)
: CartDebugWidget(boss, lfont, nfont, x, y, w, h),
myCart(cart)
{}
myCart(cart),
myLower2K(nullptr),
myUpper256B(nullptr)
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeMNetworkWidget::initialize(GuiObject* boss, CartridgeMNetwork& cart, ostringstream& info)

View File

@ -34,11 +34,11 @@ class CartridgeMNetworkWidget : public CartDebugWidget
virtual ~CartridgeMNetworkWidget() = default;
protected:
PopUpWidget *myLower2K, *myUpper256B;
//CartridgeE7& myCart;
CartridgeMNetwork& myCart;
PopUpWidget *myLower2K, *myUpper256B;
struct CartState
{
ByteArray internalram;

View File

@ -22,7 +22,8 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FlashWidget::FlashWidget(GuiObject* boss, const GUI::Font& font,
int x, int y, Controller& controller)
: ControllerWidget(boss, font, x, y, controller)
: ControllerWidget(boss, font, x, y, controller),
myEEPROMEraseCurrent(nullptr)
{
}

View File

@ -34,7 +34,9 @@ PromptWidget::PromptWidget(GuiObject* boss, const GUI::Font& font,
int x, int y, int w, int h)
: Widget(boss, font, x, y, w - kScrollBarWidth, h),
CommandSender(boss),
_historySize(0),
_historyIndex(0),
_historyLine(0),
_makeDirty(false),
_firstTime(true),
_exitedEarly(false)

View File

@ -102,6 +102,11 @@ void CartridgeBUS::setInitialState()
// Assuming mode starts out with Fast Fetch off and 3-Voice music,
// need to confirm with Chris
myMode = 0xFF;
myBankOffset = myBusOverdriveAddress =
mySTYZeroPageAddress = myJMPoperandAddress = 0;
myFastJumpActive = 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -105,6 +105,7 @@ void CartridgeCDF::setInitialState()
// need to confirm with Chris
myMode = 0xFF;
myBankOffset = myLDAimmediateOperandAddress = myJMPoperandAddress = 0;
myFastJumpActive = 0;
}

View File

@ -273,8 +273,6 @@ class CartridgeCDF : public Cartridge
// *and* the next two bytes in ROM are 00 00
uInt16 myJMPoperandAddress;
TIA* myTIA;
uInt8 myFastJumpActive;
// version of CDF

View File

@ -23,7 +23,8 @@ CartridgeMNetwork::CartridgeMNetwork(const BytePtr& image, uInt32 size,
const Settings& settings)
: Cartridge(settings),
mySize(size),
myCurrentRAM(0)
myCurrentRAM(0),
myRAMSlice(0)
{
}

View File

@ -47,7 +47,9 @@ FrameBuffer::FrameBuffer(OSystem& osystem)
myInitializedCount(0),
myPausedCount(0),
myStatsEnabled(false),
myLastScanlines(0),
myLastFrameRate(60),
myGrabMouse(false),
myCurrentModeList(nullptr),
myTotalTime(0),
myTotalFrames(0)

View File

@ -505,7 +505,9 @@ class FrameBuffer
shared_ptr<FBSurface> surface;
bool enabled;
Message() : counter(0), x(0), y(0), w(0), h(0), color(0), enabled(false) { }
Message()
: counter(0), x(0), y(0), w(0), h(0), position(MessagePosition::BottomCenter),
color(0), enabled(false) { }
};
Message myMsg;
Message myStatsMsg;

View File

@ -20,6 +20,7 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Background::Background()
: myTIA(nullptr)
{
reset();
}

View File

@ -26,7 +26,8 @@ enum Count: Int8 {
Ball::Ball(uInt32 collisionMask)
: myCollisionMaskDisabled(collisionMask),
myCollisionMaskEnabled(0xFFFF),
myIsSuppressed(false)
myIsSuppressed(false),
myTIA(nullptr)
{
reset();
}

View File

@ -28,6 +28,8 @@ class DelayQueueMember : public Serializable {
struct Entry {
uInt8 address;
uInt8 value;
Entry() : address(0), value(0) { }
};
public:
@ -52,7 +54,6 @@ class DelayQueueMember : public Serializable {
uInt8 mySize;
private:
DelayQueueMember(const DelayQueueMember<capacity>&) = delete;
DelayQueueMember(DelayQueueMember<capacity>&&) = delete;
DelayQueueMember<capacity>& operator=(const DelayQueueMember<capacity>&) = delete;
@ -68,7 +69,8 @@ class DelayQueueMember : public Serializable {
template<unsigned capacity>
DelayQueueMember<capacity>::DelayQueueMember()
: mySize(0)
{}
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
template<unsigned capacity>

View File

@ -28,7 +28,8 @@ Missile::Missile(uInt32 collisionMask)
: myCollisionMaskDisabled(collisionMask),
myCollisionMaskEnabled(0xFFFF),
myIsSuppressed(false),
myDecodesOffset(0)
myDecodesOffset(0),
myTIA(nullptr)
{
reset();
}

View File

@ -28,7 +28,8 @@ Player::Player(uInt32 collisionMask)
: myCollisionMaskDisabled(collisionMask),
myCollisionMaskEnabled(0xFFFF),
myIsSuppressed(false),
myDecodesOffset(0)
myDecodesOffset(0),
myTIA(nullptr)
{
reset();
}

View File

@ -22,7 +22,8 @@
Playfield::Playfield(uInt32 collisionMask)
: myCollisionMaskDisabled(collisionMask),
myCollisionMaskEnabled(0xFFFF),
myIsSuppressed(false)
myIsSuppressed(false),
myTIA(nullptr)
{
reset();
}
@ -38,9 +39,11 @@ void Playfield::reset()
myPf1 = 0;
myPf2 = 0;
myX = 0;
myObjectColor = myDebugColor = 0;
myColorP0 = 0;
myColorP1 = 0;
myColorLeft = myColorRight = 0;
myColorP0 = myColorP1 = 0;
myColorMode = ColorMode::normal;
myDebugEnabled = false;

View File

@ -35,9 +35,21 @@ enum Metrics: uInt32 {
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FrameManager::FrameManager() :
FrameManager::FrameManager()
: myState(State::waitForVsyncStart),
myLineInState(0),
myVsyncLines(0),
myY(0), myLastY(0),
myVblankLines(0),
myKernelLines(0),
myOverscanLines(0),
myFrameLines(0),
myHeight(0),
myYStart(0)
myFixedHeight(0),
myYStart(0),
myJitterEnabled(false),
myStableFrameLines(-1),
myStableFrameHeightCountdown(0)
{
onLayoutChange();
}

View File

@ -25,9 +25,12 @@ enum Metrics: uInt32 {
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
JitterEmulation::JitterEmulation() :
JitterEmulation::JitterEmulation()
: myJitterFactor(0),
myYStart(0)
{}
{
reset();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void JitterEmulation::reset()

View File

@ -51,6 +51,7 @@ Dialog::Dialog(OSystem& instance, DialogContainer& parent, const GUI::Font& font
_mouseWidget(nullptr),
_focusedWidget(nullptr),
_dragWidget(nullptr),
_defaultWidget(nullptr),
_okWidget(nullptr),
_cancelWidget(nullptr),
_visible(false),

View File

@ -56,7 +56,7 @@ class RadioButtonWidget : public CheckboxWidget
class RadioButtonGroup
{
public:
RadioButtonGroup() = default;
RadioButtonGroup() : mySelected(0) { }
// add widget to group
void addWidget(RadioButtonWidget* widget);

View File

@ -39,7 +39,8 @@ Widget::Widget(GuiObject* boss, const GUI::Font& font,
_bgcolor(kWidColor),
_bgcolorhi(kWidColor),
_textcolor(kTextColor),
_textcolorhi(kTextColorHi)
_textcolorhi(kTextColorHi),
_shadowcolor(kShadowColor)
{
// Insert into the widget list of the boss
_next = _boss->_firstWidget;
@ -354,7 +355,10 @@ ButtonWidget::ButtonWidget(GuiObject* boss, const GUI::Font& font,
: StaticTextWidget(boss, font, x, y, w, h, label, TextAlign::Center),
CommandSender(boss),
_cmd(cmd),
_useBitmap(false)
_useBitmap(false),
_bitmap(nullptr),
_bmw(0),
_bmh(0)
{
_flags = WIDGET_ENABLED | WIDGET_CLEARBG;
_bgcolor = kBtnColor;