Minor updates for warnings from cppcheck.

This commit is contained in:
Stephen Anthony 2022-03-18 14:58:39 -02:30
parent 6d07ba4072
commit fee159ea81
38 changed files with 74 additions and 72 deletions

View File

@ -36,7 +36,7 @@ class DevSettingsHandler
numSets
};
DevSettingsHandler(OSystem& osystem);
explicit DevSettingsHandler(OSystem& osystem);
void loadSettings(SettingsSet set);
void saveSettings(SettingsSet set);

View File

@ -28,7 +28,7 @@
template<class T>
class KeyValueRepositoryFile : public KeyValueRepository {
public:
KeyValueRepositoryFile(const FilesystemNode& node);
explicit KeyValueRepositoryFile(const FilesystemNode& node);
std::map<string, Variant> load() override;

View File

@ -29,7 +29,7 @@ class KeyValueRepositoryJsonFile : public KeyValueRepositoryFile<KeyValueReposit
using KeyValueRepositoryFile<KeyValueRepositoryJsonFile>::load;
using KeyValueRepositoryFile<KeyValueRepositoryJsonFile>::save;
KeyValueRepositoryJsonFile(const FilesystemNode& node);
explicit KeyValueRepositoryJsonFile(const FilesystemNode& node);
static std::map<string, Variant> load(istream& in);

View File

@ -29,7 +29,7 @@ class KeyValueRepositoryPropertyFile : public KeyValueRepositoryFile<KeyValueRep
using KeyValueRepositoryFile<KeyValueRepositoryPropertyFile>::load;
using KeyValueRepositoryFile<KeyValueRepositoryPropertyFile>::save;
KeyValueRepositoryPropertyFile(const FilesystemNode& node);
explicit KeyValueRepositoryPropertyFile(const FilesystemNode& node);
static std::map<string, Variant> load(istream& in);

View File

@ -32,7 +32,7 @@ QisBlitter::~QisBlitter()
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool QisBlitter::isSupported(FBBackendSDL2& fb)
bool QisBlitter::isSupported(const FBBackendSDL2& fb)
{
if (!fb.isInitialized()) throw runtime_error("framebuffer not initialized");

View File

@ -29,7 +29,7 @@ class QisBlitter : public Blitter {
explicit QisBlitter(FBBackendSDL2& fb);
static bool isSupported(FBBackendSDL2& fb);
static bool isSupported(const FBBackendSDL2& fb);
~QisBlitter() override;

View File

@ -763,7 +763,7 @@ void Debugger::setStartState()
lockSystem();
// Save initial state and add it to the rewind list (except when in currently rewinding)
RewindManager& r = myOSystem.state().rewindManager();
const RewindManager& r = myOSystem.state().rewindManager();
// avoid invalidating future states when entering the debugger e.g. during rewind
if(r.atLast() && (myOSystem.eventHandler().state() != EventHandlerState::TIMEMACHINE
|| myOSystem.state().mode() == StateManager::Mode::Off))

View File

@ -41,7 +41,7 @@ class RiotState : public DebuggerState
uInt8 TIM1T{0}, TIM8T{0}, TIM64T{0}, T1024T{0}, INTIM{0}, TIMINT{0};
Int32 TIMCLKS{0}, INTIMCLKS{0}, TIMDIV{0};
uInt16 timReadCycles;
uInt16 timReadCycles{0};
// These are actually from the TIA, but are I/O related
uInt8 INPT0{0}, INPT1{0}, INPT2{0}, INPT3{0}, INPT4{0}, INPT5{0};

View File

@ -38,7 +38,7 @@ void AtariVoxWidget::eraseCurrent()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool AtariVoxWidget::isPageUsed(uInt32 page)
{
AtariVox& avox = static_cast<AtariVox&>(controller());
const AtariVox& avox = static_cast<AtariVox&>(controller());
return avox.isPageUsed(page);
}

View File

@ -97,9 +97,9 @@ void AudioWidget::loadConfig()
{
IntArray alist;
IntArray vlist;
BoolArray blist, changed, grNew, grOld;
BoolArray changed;
Debugger& dbg = instance().debugger();
const Debugger& dbg = instance().debugger();
TIADebug& tia = dbg.tiaDebug();
const TiaState& state = static_cast<const TiaState&>(tia.getState());
const TiaState& oldstate = static_cast<const TiaState&>(tia.getOldState());

View File

@ -82,8 +82,7 @@ CartridgeARWidget::CartridgeARWidget(
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeARWidget::loadConfig()
{
Debugger& dbg = instance().debugger();
CartDebug& cart = dbg.cartDebug();
CartDebug& cart = instance().debugger().cartDebug();
const CartState& state = static_cast<const CartState&>(cart.getState());
const CartState& oldstate = static_cast<const CartState&>(cart.getOldState());

View File

@ -287,6 +287,6 @@ uInt8 CartridgeCMWidget::internalRamGetValue(int addr)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string CartridgeCMWidget::internalRamLabel(int addr)
{
CartDebug& dbg = instance().debugger().cartDebug();
const CartDebug& dbg = instance().debugger().cartDebug();
return dbg.getLabel(addr + 0xF800, false);
}

View File

@ -157,6 +157,6 @@ uInt8 CartridgeCTYWidget::internalRamGetValue(int addr)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string CartridgeCTYWidget::internalRamLabel(int addr)
{
CartDebug& dbg = instance().debugger().cartDebug();
const CartDebug& dbg = instance().debugger().cartDebug();
return dbg.getLabel(addr + 0xF040, false);
}

View File

@ -455,6 +455,6 @@ uInt8 CartridgeEnhancedWidget::internalRamGetValue(int addr)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string CartridgeEnhancedWidget::internalRamLabel(int addr)
{
CartDebug& dbg = instance().debugger().cartDebug();
const CartDebug& dbg = instance().debugger().cartDebug();
return dbg.getLabel(addr + ADDR_BASE + myCart.myReadOffset, false, -1, true);
}

View File

@ -296,8 +296,8 @@ void CpuWidget::loadConfig()
// We push the enumerated items as addresses, and deal with the real
// address in the callback (handleCommand)
Debugger& dbg = instance().debugger();
CartDebug& cart = dbg.cartDebug();
const Debugger& dbg = instance().debugger();
const CartDebug& cart = dbg.cartDebug();
CpuDebug& cpu = dbg.cpuDebug();
const CpuState& state = static_cast<const CpuState&>(cpu.getState());
const CpuState& oldstate = static_cast<const CpuState&>(cpu.getOldState());

View File

@ -79,7 +79,6 @@ DataGridWidget::DataGridWidget(GuiObject* boss, const GUI::Font& font,
}
// Add filtering
EditableWidget::TextFilter f;
switch(base)
{
case Common::Base::Fmt::_16:

View File

@ -293,8 +293,7 @@ void RiotWidget::loadConfig()
// We push the enumerated items as addresses, and deal with the real
// address in the callback (handleCommand)
Debugger& dbg = instance().debugger();
RiotDebug& riot = dbg.riotDebug();
RiotDebug& riot = instance().debugger().riotDebug();
const RiotState& state = static_cast<const RiotState&>(riot.getState());
const RiotState& oldstate = static_cast<const RiotState&>(riot.getOldState());

View File

@ -60,7 +60,7 @@ RomWidget::RomWidget(GuiObject* boss, const GUI::Font& lfont, const GUI::Font& n
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void RomWidget::loadConfig()
{
Debugger& dbg = instance().debugger();
const Debugger& dbg = instance().debugger();
CartDebug& cart = dbg.cartDebug();
const CartState& state = static_cast<const CartState&>(cart.getState());
const CartState& oldstate = static_cast<const CartState&>(cart.getOldState());

View File

@ -37,7 +37,7 @@ void SaveKeyWidget::eraseCurrent()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool SaveKeyWidget::isPageUsed(uInt32 page)
{
SaveKey& skey = static_cast<SaveKey&>(controller());
const SaveKey& skey = static_cast<SaveKey&>(controller());
return skey.isPageUsed(page);
}

View File

@ -156,7 +156,7 @@ void TiaInfoWidget::handleCommand(CommandSender* sender, int cmd, int data, int
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TiaInfoWidget::loadConfig()
{
Debugger& dbg = instance().debugger();
const Debugger& dbg = instance().debugger();
TIADebug& tia = dbg.tiaDebug();
const TiaState& oldTia = static_cast<const TiaState&>(tia.getOldState());
RiotDebug& riot = dbg.riotDebug();

View File

@ -674,8 +674,7 @@ TiaWidget::TiaWidget(GuiObject* boss, const GUI::Font& lfont,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TiaWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
{
Debugger& dbg = instance().debugger();
TIADebug& tia = dbg.tiaDebug();
TIADebug& tia = instance().debugger().tiaDebug();
switch(cmd)
{
@ -974,10 +973,9 @@ void TiaWidget::loadConfig()
{
IntArray alist;
IntArray vlist;
BoolArray blist, changed, grNew, grOld;
BoolArray changed;
Debugger& dbg = instance().debugger();
TIADebug& tia = dbg.tiaDebug();
TIADebug& tia = instance().debugger().tiaDebug();
const TiaState& state = static_cast<const TiaState&>(tia.getState());
const TiaState& oldstate = static_cast<const TiaState&>(tia.getOldState());

View File

@ -410,7 +410,7 @@ class Cartridge : public Device
uInt16 myRamWriteAccess{0};
// Total size of ROM access area (might include RAM too)
uInt32 myAccessSize;
uInt32 myAccessSize{0};
// Callback to output messages
messageCallback myMsgCallback{nullptr};

View File

@ -76,7 +76,7 @@ CartridgeBUS::CartridgeBUS(const ByteBuffer& image, size_t size,
Thumbulator::ConfigureFor::BUS,
this);
setInitialState();
this->setInitialState();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -111,7 +111,7 @@ CartridgeCDF::CartridgeCDF(const ByteBuffer& image, size_t size,
thumulatorConfiguration(myCDFSubtype),
this);
setInitialState();
this->setInitialState();
myPlusROM = make_unique<PlusROM>(mySettings, *this);
@ -786,10 +786,9 @@ void CartridgeCDF::setupVersion()
myFastFetcherOffset = 0;
myWaveformBase = 0x01b0;
uInt32 cdfjValue;
for (int i=0; i<2048; i += 4)
{
cdfjValue = getUInt32(myImage.get(), i);
uInt32 cdfjValue = getUInt32(myImage.get(), i);
if (cdfjValue == 0x135200A2)
myLDXenabled = true;
if (cdfjValue == 0x135200A0)

View File

@ -102,7 +102,7 @@ inline void CartridgeDPC::updateMusicModeDataFetchers()
uInt32 wholeClocks = uInt32(clocks);
myFractionalClocks = clocks - double(wholeClocks);
if(wholeClocks <= 0)
if(wholeClocks == 0)
return;
// Let's update counters and flags of the music mode data fetchers

View File

@ -78,7 +78,7 @@ CartridgeDPCPlus::CartridgeDPCPlus(const ByteBuffer& image, size_t size,
myDriverMD5 == "8dd73b44fd11c488326ce507cbeb19d1" )
myFractionalLowMask = 0x0F0000;
setInitialState();
this->setInitialState();
myPlusROM = make_unique<PlusROM>(mySettings, *this);

View File

@ -1367,7 +1367,7 @@ void MovieCart::runStateMachine()
if(myLines == 22)
myStream.blankPartialLines(true);
}
}
}
if(myLines >= 1)
{
@ -1571,13 +1571,11 @@ CartridgeMVC::CartridgeMVC(const string& path, size_t size,
const string& md5, const Settings& settings,
size_t bsSize)
: Cartridge(settings, md5),
myImage{make_unique<uInt8[]>(bsSize)}, // not used
mySize{bsSize},
myMovie{make_unique<MovieCart>()},
myPath{path}
{
myMovie = make_unique<MovieCart>();
// not used
myImage = make_unique<uInt8[]>(mySize);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -34,7 +34,8 @@
class ControllerLowLevel
{
public:
ControllerLowLevel(Controller& controller) : myController(controller) { }
explicit ControllerLowLevel(Controller& controller)
: myController(controller) { }
virtual ~ControllerLowLevel() = default;
inline bool setPin(Controller::DigitalPin pin, bool value) {

View File

@ -28,7 +28,7 @@
class GlobalKeyHandler
{
public:
GlobalKeyHandler(OSystem& osystem);
explicit GlobalKeyHandler(OSystem& osystem);
public:
enum class Setting

View File

@ -48,14 +48,14 @@ class PlusROMRequest {
public:
struct Destination {
Destination(string _host, string _path) : host(_host), path(_path) {}
Destination(string _host, string _path) : host{_host}, path{_path} {}
string host;
string path;
};
struct PlusStoreId {
PlusStoreId(string _nick, string _id) : nick(_nick), id(_id) {}
PlusStoreId(string _nick, string _id) : nick{_nick}, id{_id} {}
string nick;
string id;
@ -70,10 +70,11 @@ class PlusROMRequest {
public:
PlusROMRequest(Destination destination, PlusStoreId id, const uInt8* request, uInt8 requestSize)
: myDestination(destination), myId(id), myRequestSize(requestSize)
PlusROMRequest(Destination destination, PlusStoreId id, const uInt8* request,
uInt8 requestSize)
: myState{State::created}, myDestination{destination},
myId{id}, myRequestSize{requestSize}
{
myState = State::created;
memcpy(myRequest.data(), request, myRequestSize);
}
@ -152,7 +153,7 @@ class PlusROMRequest {
myState = State::done;
}
State getState() {
State getState() const {
return myState;
}
@ -177,13 +178,13 @@ class PlusROMRequest {
#endif
private:
std::atomic<State> myState;
std::atomic<State> myState{State::failed};
Destination myDestination;
PlusStoreId myId;
std::array<uInt8, 256> myRequest;
uInt8 myRequestSize;
uInt8 myRequestSize{0};
string myResponse;
@ -196,8 +197,8 @@ class PlusROMRequest {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PlusROM::PlusROM(const Settings& settings, const Cartridge& cart)
: mySettings(settings),
myCart(cart)
: mySettings{settings},
myCart{cart}
{
}
@ -419,9 +420,10 @@ void PlusROM::send()
// We push to the back in order to avoid reverse_iterator in receive()
myPendingRequests.push_back(request);
// The lambda will retain a copy of the shared_ptr that is alive as long as the
// thread is running. Thus, the request can only be destructed once the thread has
// finished, and we can safely evict it from the deque at any time.
// The lambda will retain a copy of the shared_ptr that is alive as long
// as the thread is running. Thus, the request can only be destructed once
// the thread has finished, and we can safely evict it from the deque at
// any time.
std::thread thread([=]() {
request->execute();
switch(request->getState())

View File

@ -64,7 +64,8 @@ uInt8 AnalogReadout::inpt(uInt64 timestamp)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void AnalogReadout::update(Connection connection, uInt64 timestamp, ConsoleTiming consoleTiming)
void AnalogReadout::update(Connection connection, uInt64 timestamp,
ConsoleTiming consoleTiming)
{
if (consoleTiming != myConsoleTiming) {
setConsoleTiming(consoleTiming);
@ -165,21 +166,25 @@ bool AnalogReadout::load(Serializer& in)
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
AnalogReadout::Connection AnalogReadout::connectToGround(uInt32 resistance)
{
return Connection{ConnectionType::ground, resistance};
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
AnalogReadout::Connection AnalogReadout::connectToVcc(uInt32 resistance)
{
return Connection{ConnectionType::vcc, resistance};
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
AnalogReadout::Connection AnalogReadout::disconnect()
{
return Connection{ConnectionType::disconnected, 0};
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool AnalogReadout::Connection::save(Serializer& out) const
{
try
@ -196,7 +201,8 @@ bool AnalogReadout::Connection::save(Serializer& out) const
return true;
}
bool AnalogReadout::Connection::load(Serializer& in)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool AnalogReadout::Connection::load(const Serializer& in)
{
try
{
@ -212,7 +218,9 @@ bool AnalogReadout::Connection::load(Serializer& in)
return true;
}
bool operator==(const AnalogReadout::Connection& c1, const AnalogReadout::Connection& c2)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool operator==(const AnalogReadout::Connection& c1,
const AnalogReadout::Connection& c2)
{
if (c1.type == AnalogReadout::ConnectionType::disconnected)
return c2.type == AnalogReadout::ConnectionType::disconnected;
@ -220,7 +228,9 @@ bool operator==(const AnalogReadout::Connection& c1, const AnalogReadout::Connec
return c1.type == c2.type && c1.resistance == c2.resistance;
}
bool operator!=(const AnalogReadout::Connection& c1, const AnalogReadout::Connection& c2)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool operator!=(const AnalogReadout::Connection& c1,
const AnalogReadout::Connection& c2)
{
return !(c1 == c2);
}

View File

@ -35,7 +35,7 @@ class AnalogReadout : public Serializable
uInt32 resistance;
bool save(Serializer& out) const;
bool load(Serializer& in);
bool load(const Serializer& in);
friend bool operator==(const AnalogReadout::Connection& c1, const AnalogReadout::Connection& c2);
};

View File

@ -917,7 +917,7 @@ bool TIA::saveDisplay(Serializer& out) const
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool TIA::loadDisplay(Serializer& in)
bool TIA::loadDisplay(const Serializer& in)
{
try
{

View File

@ -208,7 +208,7 @@ class TIA : public Device
and eliminate having to save approx. 50K to normal state files.
*/
bool saveDisplay(Serializer& out) const;
bool loadDisplay(Serializer& in);
bool loadDisplay(const Serializer& in);
/**
This method should be called at an interval corresponding to the

View File

@ -13,9 +13,6 @@
//
// See the file "License.txt" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
//============================================================================
#ifndef ICON_HXX
@ -31,15 +28,15 @@ struct IconDesc
int height{0};
explicit IconDesc(int _width, int _height)
: width{_width}, height{_height} {}
: width{_width}, height{_height} { }
};
class Icon
{
public:
explicit Icon(IconDesc desc, uIntArray bitmap)
Icon(IconDesc desc, const uIntArray& bitmap)
: myIconDesc{desc}, myBitmap{bitmap} { }
Icon(int width, int height, uIntArray bitmap)
Icon(int width, int height, const uIntArray& bitmap)
: Icon(IconDesc(width, height), bitmap) { }
const IconDesc& desc() const { return myIconDesc; }

View File

@ -308,7 +308,7 @@ void MinUICommandDialog::updateTVFormat()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void MinUICommandDialog::updateWinds()
{
RewindManager& r = instance().state().rewindManager();
const RewindManager& r = instance().state().rewindManager();
myRewindButton->setEnabled(!r.atFirst());
myUnwindButton->setEnabled(!r.atLast());

View File

@ -484,7 +484,7 @@ void TimeMachineDialog::handleCommand(CommandSender* sender, int cmd,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TimeMachineDialog::initBar()
{
RewindManager& r = instance().state().rewindManager();
const RewindManager& r = instance().state().rewindManager();
IntArray cycles = r.cyclesList();
// Set range and intervals for timeline

View File

@ -147,7 +147,7 @@ void StellaLIBRETRO::runFrame()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void StellaLIBRETRO::updateInput()
{
Console& console = myOSystem->console();
const Console& console = myOSystem->console();
console.leftController().update();
console.rightController().update();