mirror of https://github.com/stella-emu/stella.git
Some fixes for warnings from cppcheck.
This commit is contained in:
parent
e5af3b20d3
commit
7676e9b4c8
|
@ -101,18 +101,19 @@ class SoundNull : public Sound
|
||||||
*/
|
*/
|
||||||
void adjustVolume(int direction = 1) override { }
|
void adjustVolume(int direction = 1) override { }
|
||||||
|
|
||||||
/**
|
|
||||||
Sets the audio device.
|
|
||||||
|
|
||||||
@param device The number of the device to select (0 = default).
|
|
||||||
*/
|
|
||||||
void setDevice(uInt32 device) override { }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This method is called to provide information about the sound device.
|
This method is called to provide information about the sound device.
|
||||||
*/
|
*/
|
||||||
string about() const override { return "Sound disabled"; }
|
string about() const override { return "Sound disabled"; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/**
|
||||||
|
This method is called to query the audio devices.
|
||||||
|
|
||||||
|
@param devices List of device names
|
||||||
|
*/
|
||||||
|
void queryHardware(VariantList& devices) override { }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Following constructors and assignment operators not supported
|
// Following constructors and assignment operators not supported
|
||||||
SoundNull() = delete;
|
SoundNull() = delete;
|
||||||
|
|
|
@ -44,9 +44,8 @@ void ZipHandler::open(const string& filename)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Allocate memory for the ZipFile structure
|
// Allocate memory for the ZipFile structure
|
||||||
ptr = make_unique<ZipFile>(filename);
|
try { ptr = make_unique<ZipFile>(filename); }
|
||||||
if(ptr == nullptr)
|
catch(...) { throw runtime_error(errorMessage(ZipError::OUT_OF_MEMORY)); }
|
||||||
throw runtime_error(errorMessage(ZipError::OUT_OF_MEMORY));
|
|
||||||
|
|
||||||
// Open the file and initialize it
|
// Open the file and initialize it
|
||||||
if(!ptr->open())
|
if(!ptr->open())
|
||||||
|
@ -109,13 +108,11 @@ uInt64 ZipHandler::decompress(ByteBuffer& image)
|
||||||
{
|
{
|
||||||
if(myZip && myZip->myHeader.uncompressedLength > 0)
|
if(myZip && myZip->myHeader.uncompressedLength > 0)
|
||||||
{
|
{
|
||||||
const uInt64 length = myZip->myHeader.uncompressedLength;
|
|
||||||
image = make_unique<uInt8[]>(length);
|
|
||||||
if(image == nullptr)
|
|
||||||
throw runtime_error(errorMessage(ZipError::OUT_OF_MEMORY));
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
const uInt64 length = myZip->myHeader.uncompressedLength;
|
||||||
|
image = make_unique<uInt8[]>(length);
|
||||||
|
|
||||||
myZip->decompress(image, length);
|
myZip->decompress(image, length);
|
||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
|
@ -123,6 +120,10 @@ uInt64 ZipHandler::decompress(ByteBuffer& image)
|
||||||
{
|
{
|
||||||
throw runtime_error(errorMessage(err));
|
throw runtime_error(errorMessage(err));
|
||||||
}
|
}
|
||||||
|
catch(...)
|
||||||
|
{
|
||||||
|
throw runtime_error(errorMessage(ZipError::OUT_OF_MEMORY));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
throw runtime_error("Invalid ZIP archive");
|
throw runtime_error("Invalid ZIP archive");
|
||||||
|
@ -235,9 +236,8 @@ void ZipHandler::ZipFile::initialize()
|
||||||
throw runtime_error(errorMessage(ZipError::UNSUPPORTED));
|
throw runtime_error(errorMessage(ZipError::UNSUPPORTED));
|
||||||
|
|
||||||
// Allocate memory for the central directory
|
// Allocate memory for the central directory
|
||||||
myCd = make_unique<uInt8[]>(myEcd.cdSize + 1);
|
try { myCd = make_unique<uInt8[]>(myEcd.cdSize + 1); }
|
||||||
if(myCd == nullptr)
|
catch(...) { throw runtime_error(errorMessage(ZipError::OUT_OF_MEMORY)); }
|
||||||
throw runtime_error(errorMessage(ZipError::OUT_OF_MEMORY));
|
|
||||||
|
|
||||||
// Read the central directory
|
// Read the central directory
|
||||||
uInt64 read_length = 0;
|
uInt64 read_length = 0;
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
Some keys are used only by the main function; these are placed in localOpts.
|
Some keys are used only by the main function; these are placed in localOpts.
|
||||||
The rest are needed globally, and are placed in globalOpts.
|
The rest are needed globally, and are placed in globalOpts.
|
||||||
*/
|
*/
|
||||||
void parseCommandLine(int ac, char* av[],
|
void parseCommandLine(int ac, const char* const av[],
|
||||||
Settings::Options& globalOpts, Settings::Options& localOpts);
|
Settings::Options& globalOpts, Settings::Options& localOpts);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -84,7 +84,7 @@ void freeConsole();
|
||||||
|
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void parseCommandLine(int ac, char* av[],
|
void parseCommandLine(int ac, const char* const av[],
|
||||||
Settings::Options& globalOpts, Settings::Options& localOpts)
|
Settings::Options& globalOpts, Settings::Options& localOpts)
|
||||||
{
|
{
|
||||||
localOpts["ROMFILE"] = ""; // make sure we have an entry for this
|
localOpts["ROMFILE"] = ""; // make sure we have an entry for this
|
||||||
|
|
|
@ -84,20 +84,18 @@ class TimerMap
|
||||||
c_mirrors, c_anyBank);
|
c_mirrors, c_anyBank);
|
||||||
}
|
}
|
||||||
|
|
||||||
Timer(const TimerPoint& tp, bool c_mirrors = false, bool c_anyBank = false)
|
explicit Timer(const TimerPoint& tp, bool c_mirrors = false,
|
||||||
{
|
bool c_anyBank = false)
|
||||||
from = tp;
|
: from{tp}, mirrors{c_mirrors}, anyBank{c_anyBank}, isPartial{true} {}
|
||||||
mirrors = c_mirrors;
|
|
||||||
anyBank = c_anyBank;
|
|
||||||
isPartial = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Timer(uInt16 addr, uInt8 bank, bool c_mirrors = false, bool c_anyBank = false)
|
Timer(uInt16 addr, uInt8 bank, bool c_mirrors = false,
|
||||||
|
bool c_anyBank = false)
|
||||||
{
|
{
|
||||||
Timer(TimerPoint(addr, bank), c_mirrors, c_anyBank);
|
Timer(TimerPoint(addr, bank), c_mirrors, c_anyBank);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setTo(const TimerPoint& tp, bool c_mirrors = false, bool c_anyBank = false)
|
void setTo(const TimerPoint& tp, bool c_mirrors = false,
|
||||||
|
bool c_anyBank = false)
|
||||||
{
|
{
|
||||||
to = tp;
|
to = tp;
|
||||||
mirrors |= c_mirrors;
|
mirrors |= c_mirrors;
|
||||||
|
|
|
@ -1481,9 +1481,9 @@ bool MovieCart::save(Serializer& out) const
|
||||||
out.putByte(myDrawLevelBars);
|
out.putByte(myDrawLevelBars);
|
||||||
out.putByte(myDrawTimeCode);
|
out.putByte(myDrawTimeCode);
|
||||||
|
|
||||||
if(!myStream.save(out)) throw;
|
if(!myStream.save(out)) return false;
|
||||||
if(!myInputs.save(out)) throw;
|
if(!myInputs.save(out)) return false;
|
||||||
if(!myLastInputs.save(out)) throw;
|
if(!myLastInputs.save(out)) return false;
|
||||||
|
|
||||||
out.putByte(mySpeed);
|
out.putByte(mySpeed);
|
||||||
out.putByte(myJoyRepeat);
|
out.putByte(myJoyRepeat);
|
||||||
|
@ -1535,9 +1535,9 @@ bool MovieCart::load(Serializer& in)
|
||||||
myDrawLevelBars = in.getByte();
|
myDrawLevelBars = in.getByte();
|
||||||
myDrawTimeCode = in.getByte();
|
myDrawTimeCode = in.getByte();
|
||||||
|
|
||||||
if(!myStream.load(in)) throw;
|
if(!myStream.load(in)) return false;
|
||||||
if(!myInputs.load(in)) throw;
|
if(!myInputs.load(in)) return false;
|
||||||
if(!myLastInputs.load(in)) throw;
|
if(!myLastInputs.load(in)) return false;
|
||||||
|
|
||||||
mySpeed = in.getByte();
|
mySpeed = in.getByte();
|
||||||
myJoyRepeat = in.getByte();
|
myJoyRepeat = in.getByte();
|
||||||
|
@ -1621,29 +1621,11 @@ bool CartridgeMVC::poke(uInt16 address, uInt8 value)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
bool CartridgeMVC::save(Serializer& out) const
|
bool CartridgeMVC::save(Serializer& out) const
|
||||||
{
|
{
|
||||||
try
|
return myMovie->save(out);
|
||||||
{
|
|
||||||
if(!myMovie->save(out)) throw;
|
|
||||||
}
|
|
||||||
catch(...)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
bool CartridgeMVC::load(Serializer& in)
|
bool CartridgeMVC::load(Serializer& in)
|
||||||
{
|
{
|
||||||
try
|
return myMovie->load(in);
|
||||||
{
|
|
||||||
if(!myMovie->load(in)) throw;
|
|
||||||
}
|
|
||||||
catch(...)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -255,6 +255,7 @@ const char* KidVid::getFileName() const
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void KidVid::openSampleFiles()
|
void KidVid::openSampleFiles()
|
||||||
{
|
{
|
||||||
|
#ifdef SOUND_SUPPORT
|
||||||
static constexpr uInt32 firstSongPointer[6] = {
|
static constexpr uInt32 firstSongPointer[6] = {
|
||||||
44 + 38,
|
44 + 38,
|
||||||
0,
|
0,
|
||||||
|
@ -264,7 +265,6 @@ void KidVid::openSampleFiles()
|
||||||
44 + 38 + 42 + 62
|
44 + 38 + 42 + 62
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef SOUND_SUPPORT
|
|
||||||
if(!myFilesFound)
|
if(!myFilesFound)
|
||||||
{
|
{
|
||||||
int i = myGame == Game::Smurfs ? myTape - 1 : myTape + 2;
|
int i = myGame == Game::Smurfs ? myTape - 1 : myTape + 2;
|
||||||
|
@ -280,11 +280,11 @@ void KidVid::openSampleFiles()
|
||||||
<< "found file: " << "KVSHARED.WAV" << endl;
|
<< "found file: " << "KVSHARED.WAV" << endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
|
||||||
mySongLength = 0;
|
mySongLength = 0;
|
||||||
mySongPointer = firstSongPointer[i];
|
mySongPointer = firstSongPointer[i];
|
||||||
}
|
}
|
||||||
myTapeBusy = false;
|
myTapeBusy = false;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
Loading…
Reference in New Issue