diff --git a/src/cheat/BankRomCheat.hxx b/src/cheat/BankRomCheat.hxx index 2f42c8882..28f23d985 100644 --- a/src/cheat/BankRomCheat.hxx +++ b/src/cheat/BankRomCheat.hxx @@ -31,7 +31,7 @@ class BankRomCheat : public Cheat void evaluate() override; private: - std::array savedRom; + std::array savedRom{}; uInt16 address{0}; uInt8 value{0}; uInt8 count{0}; diff --git a/src/cheat/CheatManager.cxx b/src/cheat/CheatManager.cxx index 698d8adf1..c36d9b8d6 100644 --- a/src/cheat/CheatManager.cxx +++ b/src/cheat/CheatManager.cxx @@ -135,7 +135,7 @@ shared_ptr CheatManager::createCheat(string_view name, string_view code) { case 4: return make_shared(myOSystem, name, code); case 6: return make_shared(myOSystem, name, code); - case 7: return make_shared(myOSystem, name, code); + case 7: [[fallthrough]]; case 8: return make_shared(myOSystem, name, code); default: return nullptr; } diff --git a/src/cheat/CheetahCheat.hxx b/src/cheat/CheetahCheat.hxx index 14823b48d..9a61be961 100644 --- a/src/cheat/CheetahCheat.hxx +++ b/src/cheat/CheetahCheat.hxx @@ -31,7 +31,7 @@ class CheetahCheat : public Cheat void evaluate() override; private: - std::array savedRom; + std::array savedRom{}; uInt16 address{0}; uInt8 value{0}; uInt8 count{0}; diff --git a/src/common/DevSettingsHandler.hxx b/src/common/DevSettingsHandler.hxx index b2c304d3d..a0f914e11 100644 --- a/src/common/DevSettingsHandler.hxx +++ b/src/common/DevSettingsHandler.hxx @@ -47,44 +47,44 @@ class DevSettingsHandler protected: OSystem& myOSystem; // Emulator sets - std::array myFrameStats; - std::array myDetectedInfo; - std::array myExternAccess; - std::array myConsole; - std::array myRandomBank; - std::array myRandomizeTIA; - std::array myRandomizeRAM; - std::array myRandomizeCPU; - std::array myColorLoss; - std::array myTVJitter; - std::array myTVJitterSense; - std::array myTVJitterRec; - std::array myDebugColors; - std::array myRandomHotspots; - std::array myUndrivenPins; + std::array myFrameStats{}; + std::array myDetectedInfo{}; + std::array myExternAccess{}; + std::array myConsole{}; + std::array myRandomBank{}; + std::array myRandomizeTIA{}; + std::array myRandomizeRAM{}; + std::array myRandomizeCPU{}; + std::array myColorLoss{}; + std::array myTVJitter{}; + std::array myTVJitterSense{}; + std::array myTVJitterRec{}; + std::array myDebugColors{}; + std::array myRandomHotspots{}; + std::array myUndrivenPins{}; #ifdef DEBUGGER_SUPPORT - std::array myRWPortBreak; - std::array myWRPortBreak; + std::array myRWPortBreak{}; + std::array myWRPortBreak{}; #endif - std::array myThumbException; - std::array myArmSpeed; + std::array myThumbException{}; + std::array myArmSpeed{}; // TIA sets - std::array myTIAType; - std::array myPlInvPhase; - std::array myMsInvPhase; - std::array myBlInvPhase; - std::array myPFBits; - std::array myPFColor; - std::array myPFScore; - std::array myBKColor; - std::array myPlSwap; - std::array myBlSwap; + std::array myTIAType{}; + std::array myPlInvPhase{}; + std::array myMsInvPhase{}; + std::array myBlInvPhase{}; + std::array myPFBits{}; + std::array myPFColor{}; + std::array myPFScore{}; + std::array myBKColor{}; + std::array myPlSwap{}; + std::array myBlSwap{}; // States sets - std::array myTimeMachine; - std::array myStateSize; - std::array myUncompressed; - std::array myStateInterval; - std::array myStateHorizon; + std::array myTimeMachine{}; + std::array myStateSize{}; + std::array myUncompressed{}; + std::array myStateInterval{}; + std::array myStateHorizon{}; private: void handleEnableDebugColors(bool enable); diff --git a/src/common/EventHandlerSDL2.cxx b/src/common/EventHandlerSDL2.cxx index 4f6f4e041..8c8a3712d 100644 --- a/src/common/EventHandlerSDL2.cxx +++ b/src/common/EventHandlerSDL2.cxx @@ -265,6 +265,7 @@ EventHandlerSDL2::JoystickSDL2::JoystickSDL2(int idx) { ASSERT_MAIN_THREAD; + // NOLINTNEXTLINE: we want to initialize here, not in the member list myStick = SDL_JoystickOpen(idx); if(myStick) { diff --git a/src/common/FSNodeFactory.hxx b/src/common/FSNodeFactory.hxx index 1c4d43540..2abe4e8f5 100644 --- a/src/common/FSNodeFactory.hxx +++ b/src/common/FSNodeFactory.hxx @@ -63,8 +63,9 @@ class FSNodeFactory #endif break; default: - return nullptr; + break; } + return nullptr; // satisfy compiler } private: diff --git a/src/common/HighScoresManager.hxx b/src/common/HighScoresManager.hxx index 9cda9e8c1..10896ba73 100644 --- a/src/common/HighScoresManager.hxx +++ b/src/common/HighScoresManager.hxx @@ -65,7 +65,7 @@ namespace HSM { bool specialZeroBased{false}; string notes; // Addresses - ScoreAddresses scoreAddr; + ScoreAddresses scoreAddr{}; uInt16 varsAddr{0}; uInt16 specialAddr{0}; }; diff --git a/src/common/SoundSDL2.hxx b/src/common/SoundSDL2.hxx index 1dbe582e5..f69307e6c 100644 --- a/src/common/SoundSDL2.hxx +++ b/src/common/SoundSDL2.hxx @@ -156,7 +156,7 @@ class SoundSDL2 : public Sound bool myIsInitializedFlag{false}; // Audio specification structure - SDL_AudioSpec myHardwareSpec; + SDL_AudioSpec myHardwareSpec{}; SDL_AudioDeviceID myDevice{0}; uInt32 myDeviceId{0}; @@ -196,9 +196,9 @@ class SoundSDL2 : public Sound double mySpeed{1.0}; unique_ptr myCvtBuffer; uInt32 myCvtBufferSize{0}; - SDL_AudioSpec mySpec; // audio output format - uInt8* myPos{nullptr}; // pointer to the audio buffer to be played - uInt32 myRemaining{0}; // remaining length of the sample we have to play + SDL_AudioSpec mySpec{}; // audio output format + uInt8* myPos{nullptr}; // pointer to the audio buffer to be played + uInt32 myRemaining{0}; // remaining length of the sample we have to play private: // Callback function invoked by the SDL Audio library when it needs data diff --git a/src/common/Stack.hxx b/src/common/Stack.hxx index dd34ec97c..56e842ab9 100644 --- a/src/common/Stack.hxx +++ b/src/common/Stack.hxx @@ -31,7 +31,7 @@ template class FixedStack { private: - std::array _stack; + std::array _stack{}; size_t _size{0}; public: diff --git a/src/common/StaggeredLogger.cxx b/src/common/StaggeredLogger.cxx index ddaade8e8..0e007eb9e 100644 --- a/src/common/StaggeredLogger.cxx +++ b/src/common/StaggeredLogger.cxx @@ -27,8 +27,7 @@ namespace { { const std::tm now = BSPF::localTime(); - std::array formattedTime; - formattedTime.fill(0); + std::array formattedTime{}; std::ignore = std::strftime(formattedTime.data(), 99, "%H:%M:%S", &now); return formattedTime.data(); diff --git a/src/common/StateManager.hxx b/src/common/StateManager.hxx index 5f2a32544..f18c0a4c1 100644 --- a/src/common/StateManager.hxx +++ b/src/common/StateManager.hxx @@ -18,7 +18,7 @@ #ifndef STATE_MANAGER_HXX #define STATE_MANAGER_HXX -#define STATE_HEADER "06070020state" +#define STATE_HEADER "06070030state" class OSystem; class RewindManager; diff --git a/src/common/bspf.hxx b/src/common/bspf.hxx index f8243fc5d..d61f8e497 100644 --- a/src/common/bspf.hxx +++ b/src/common/bspf.hxx @@ -424,7 +424,7 @@ namespace BSPF inline std::tm localTime() { const auto currtime = std::time(nullptr); - std::tm tm_snapshot; + std::tm tm_snapshot{}; #if (defined BSPF_WINDOWS || defined __WIN32__) && (!defined __GNUG__ || defined __MINGW32__) localtime_s(&tm_snapshot, &currtime); #else diff --git a/src/common/repository/KeyValueRepositoryPropertyFile.cxx b/src/common/repository/KeyValueRepositoryPropertyFile.cxx index d02a41091..667686c0d 100644 --- a/src/common/repository/KeyValueRepositoryPropertyFile.cxx +++ b/src/common/repository/KeyValueRepositoryPropertyFile.cxx @@ -31,9 +31,7 @@ namespace { string s; while(in.get(c)) { - if((c == '\\') && (in.peek() == '"')) - in.get(c); - else if((c == '\\') && (in.peek() == '\\')) + if(c == '\\' && (in.peek() == '"' || in.peek() == '\\')) in.get(c); else if(c == '"') break; diff --git a/src/common/tv_filters/AtariNTSC.cxx b/src/common/tv_filters/AtariNTSC.cxx index 16c48fe7b..4442247e2 100644 --- a/src/common/tv_filters/AtariNTSC.cxx +++ b/src/common/tv_filters/AtariNTSC.cxx @@ -106,7 +106,8 @@ void AtariNTSC::render(const uInt8* atari_in, uInt32 in_width, uInt32 in_height, // Spawn the threads... for(uInt32 i = 0; i < myWorkerThreads; ++i) { - myThreads[i] = std::thread([=, this] + myThreads[i] = std::thread([rgb_in, atari_in, in_width, in_height, + i, rgb_out, out_pitch, this] { rgb_in == nullptr ? renderThread(atari_in, in_width, in_height, myTotalThreads, diff --git a/src/common/tv_filters/AtariNTSC.hxx b/src/common/tv_filters/AtariNTSC.hxx index 08a272072..faf09ba31 100644 --- a/src/common/tv_filters/AtariNTSC.hxx +++ b/src/common/tv_filters/AtariNTSC.hxx @@ -154,8 +154,8 @@ class AtariNTSC luma_cutoff = 0.20F ; - std::array myRGBPalette; - BSPF::array2D myColorTable; + std::array myRGBPalette{}; + BSPF::array2D myColorTable{}; // Rendering threads unique_ptr myThreads; diff --git a/src/debugger/CartDebug.cxx b/src/debugger/CartDebug.cxx index 4d77aa42e..33a9fa777 100644 --- a/src/debugger/CartDebug.cxx +++ b/src/debugger/CartDebug.cxx @@ -779,9 +779,8 @@ int CartDebug::getAddress(const string& label) const { LabelToAddr::const_iterator iter; - if((iter = mySystemAddresses.find(label)) != mySystemAddresses.end()) - return iter->second; - else if((iter = myUserAddresses.find(label)) != myUserAddresses.end()) + if((iter = mySystemAddresses.find(label)) != mySystemAddresses.end() || + ((iter = myUserAddresses.find(label)) != myUserAddresses.end())) return iter->second; else return -1; @@ -1626,10 +1625,8 @@ void CartDebug::accessTypeAsString(ostream& buf, uInt16 addr) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Device::AccessType CartDebug::accessTypeAbsolute(Device::AccessFlags flags) { - if(flags & Device::CODE) + if(flags & Device::CODE || flags & Device::TCODE) // TODO: TCODE separate? return Device::CODE; - else if(flags & Device::TCODE) - return Device::CODE; // TODO - should this be separate?? else if(flags & Device::GFX) return Device::GFX; else if(flags & Device::PGFX) diff --git a/src/debugger/CartDebug.hxx b/src/debugger/CartDebug.hxx index 25341e7ab..a09a92290 100644 --- a/src/debugger/CartDebug.hxx +++ b/src/debugger/CartDebug.hxx @@ -294,14 +294,14 @@ class CartDebug : public DebuggerSystem }; // Address type information determined by Distella - AddrTypeArray myDisLabels, myDisDirectives; + AddrTypeArray myDisLabels{}, myDisDirectives{}; // Information on equates used in the disassembly struct ReservedEquates { - std::array TIARead{false}; - std::array TIAWrite{false}; - std::array IOReadWrite{false}; - std::array ZPRAM{false}; + std::array TIARead{}; + std::array TIAWrite{}; + std::array IOReadWrite{}; + std::array ZPRAM{}; AddrToLabel Label; bool breakFound{false}; }; diff --git a/src/debugger/DebuggerParser.cxx b/src/debugger/DebuggerParser.cxx index ef23ef06b..42ac0eafe 100644 --- a/src/debugger/DebuggerParser.cxx +++ b/src/debugger/DebuggerParser.cxx @@ -499,14 +499,14 @@ bool DebuggerParser::validateArgs(int cmd) case Parameters::ARG_LABEL: case Parameters::ARG_FILE: - break; // TODO: validate these (for now any string's allowed) + [[fallthrough]]; // FIXME: validate these (for now any string's allowed) case Parameters::ARG_MULTI_BYTE: case Parameters::ARG_MULTI_WORD: - break; // FIXME: validate these (for now, any number's allowed) + [[fallthrough]]; // FIXME: validate these (for now, any number's allowed) case Parameters::ARG_END_ARGS: - break; + [[fallthrough]]; default: break; // Not supposed to get here diff --git a/src/debugger/DiStella.cxx b/src/debugger/DiStella.cxx index e61415636..993bdd5fa 100644 --- a/src/debugger/DiStella.cxx +++ b/src/debugger/DiStella.cxx @@ -31,6 +31,7 @@ DiStella::DiStella(const CartDebug& dbg, CartDebug::DisassemblyList& list, myList{list}, mySettings{s}, myReserved{reserved}, + myOffset{info.offset}, myLabels{labels}, myDirectives{directives} { @@ -38,7 +39,6 @@ DiStella::DiStella(const CartDebug& dbg, CartDebug::DisassemblyList& list, const CartDebug::AddressList& debuggerAddresses = info.addressList; const uInt16 start = *debuggerAddresses.cbegin(); - myOffset = info.offset; if (start & 0x1000) { info.start = myAppData.start = 0x0000; info.end = myAppData.end = static_cast(info.size - 1); @@ -378,7 +378,7 @@ void DiStella::disasm(uInt32 distart, int pass) { d1 = Debugger::debugger().peek(myPC + myOffset); if(pass == 3) { - if (checkBits(myPC, Device::COL | Device::PCOL | Device::BCOL, + if (checkBits(myPC, Device::COL | Device::PCOL | Device::BCOL, /*Device::CODE |*/ Device::GFX | Device::PGFX)) nextLine << " #" << getColor(d1); else @@ -818,38 +818,21 @@ void DiStella::disasmFromAddress(uInt32 distart) mark(ad, Device::DATA); break; - case AddressingMode::ZERO_PAGE: - d1 = Debugger::debugger().peek(myPC + myOffset); ++myPC; - mark(d1, Device::REFERENCED); + case AddressingMode::ABSOLUTE_X: + case AddressingMode::ABSOLUTE_Y: + case AddressingMode::ABS_INDIRECT: + ad = Debugger::debugger().dpeek(myPC + myOffset); myPC += 2; + mark(ad, Device::REFERENCED); break; case AddressingMode::IMMEDIATE: - ++myPC; - break; - - case AddressingMode::ABSOLUTE_X: - ad = Debugger::debugger().dpeek(myPC + myOffset); myPC += 2; - mark(ad, Device::REFERENCED); - break; - - case AddressingMode::ABSOLUTE_Y: - ad = Debugger::debugger().dpeek(myPC + myOffset); myPC += 2; - mark(ad, Device::REFERENCED); - break; - case AddressingMode::INDIRECT_X: - ++myPC; - break; - case AddressingMode::INDIRECT_Y: ++myPC; break; + case AddressingMode::ZERO_PAGE: case AddressingMode::ZERO_PAGE_X: - d1 = Debugger::debugger().peek(myPC + myOffset); ++myPC; - mark(d1, Device::REFERENCED); - break; - case AddressingMode::ZERO_PAGE_Y: d1 = Debugger::debugger().peek(myPC + myOffset); ++myPC; mark(d1, Device::REFERENCED); @@ -869,11 +852,6 @@ void DiStella::disasmFromAddress(uInt32 distart) } break; - case AddressingMode::ABS_INDIRECT: - ad = Debugger::debugger().dpeek(myPC + myOffset); myPC += 2; - mark(ad, Device::REFERENCED); - break; - default: break; } // end switch diff --git a/src/debugger/TrapArray.hxx b/src/debugger/TrapArray.hxx index 74fba3b72..068abe52d 100644 --- a/src/debugger/TrapArray.hxx +++ b/src/debugger/TrapArray.hxx @@ -44,7 +44,7 @@ class TrapArray private: // The actual counts - std::array myCount; + std::array myCount{}; // Indicates whether we should treat this array as initialized bool myInitialized{false}; diff --git a/src/debugger/gui/CartELFWidget.cxx b/src/debugger/gui/CartELFWidget.cxx index ffa4bfe12..9c3b3b541 100644 --- a/src/debugger/gui/CartELFWidget.cxx +++ b/src/debugger/gui/CartELFWidget.cxx @@ -29,7 +29,7 @@ namespace { constexpr int SAVE_ARM_IMAGE_CMD = 'sarm'; -} +} // namespace // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CartridgeELFWidget::CartridgeELFWidget(GuiObject* boss, const GUI::Font& lfont, @@ -41,6 +41,7 @@ CartridgeELFWidget::CartridgeELFWidget(GuiObject* boss, const GUI::Font& lfont, initialize(); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void CartridgeELFWidget::initialize() { addBaseInformation(myCart.myImageSize, "AtariAge", "see log below", 1); @@ -60,7 +61,7 @@ void CartridgeELFWidget::initialize() const auto& logLines = parser.stringList(); const bool useScrollbar = logLines.size() > visibleLogLines; - auto logWidget = new StringListWidget( + auto* logWidget = new StringListWidget( _boss, _font, x, y, width, visibleLogLines * lineHeight, false, useScrollbar ); @@ -72,7 +73,7 @@ void CartridgeELFWidget::initialize() WidgetArray wid; - const auto saveImageButton = new ButtonWidget(_boss, _font, x, y, "Save ARM image", SAVE_ARM_IMAGE_CMD); + auto* saveImageButton = new ButtonWidget(_boss, _font, x, y, "Save ARM image", SAVE_ARM_IMAGE_CMD); saveImageButton->setTarget(this); wid.push_back(saveImageButton); @@ -80,6 +81,7 @@ void CartridgeELFWidget::initialize() addToFocusList(wid); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void CartridgeELFWidget::saveArmImage(const FSNode& node) { try { @@ -95,6 +97,7 @@ void CartridgeELFWidget::saveArmImage(const FSNode& node) } } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void CartridgeELFWidget::handleCommand(CommandSender* sender, int cmd, int data, int id) { if (cmd == SAVE_ARM_IMAGE_CMD) diff --git a/src/debugger/gui/PromptWidget.cxx b/src/debugger/gui/PromptWidget.cxx index 9af727251..7b6bb5214 100644 --- a/src/debugger/gui/PromptWidget.cxx +++ b/src/debugger/gui/PromptWidget.cxx @@ -40,7 +40,10 @@ PromptWidget::PromptWidget(GuiObject* boss, const GUI::Font& font, int x, int y, int w, int h) : Widget(boss, font, x, y, w - ScrollBarWidget::scrollBarWidth(font), h), - CommandSender(boss) + CommandSender(boss), + _kConsoleCharWidth{font.getMaxCharWidth()}, + _kConsoleCharHeight{font.getFontHeight()}, + _kConsoleLineHeight{_kConsoleCharHeight + 2} { _flags = Widget::FLAG_ENABLED | Widget::FLAG_CLEARBG | Widget::FLAG_RETAIN_FOCUS | Widget::FLAG_WANTS_TAB | Widget::FLAG_WANTS_RAWDATA; @@ -48,20 +51,16 @@ PromptWidget::PromptWidget(GuiObject* boss, const GUI::Font& font, _bgcolor = kWidColor; _bgcolorlo = kDlgColor; - _kConsoleCharWidth = font.getMaxCharWidth(); - _kConsoleCharHeight = font.getFontHeight(); - _kConsoleLineHeight = _kConsoleCharHeight + 2; - // Calculate depending values _lineWidth = (_w - ScrollBarWidget::scrollBarWidth(_font) - 2) / _kConsoleCharWidth; _linesPerPage = (_h - 2) / _kConsoleLineHeight; _linesInBuffer = kBufferSize / _lineWidth; // Add scrollbar + // NOLINTNEXTLINE: we want to initialize here, not in the member list _scrollBar = new ScrollBarWidget(boss, font, _x + _w, _y, ScrollBarWidget::scrollBarWidth(_font), _h); _scrollBar->setTarget(this); - _scrollStopLine = INT_MAX; clearScreen(); diff --git a/src/debugger/gui/PromptWidget.hxx b/src/debugger/gui/PromptWidget.hxx index fdb4eaaad..92be039e7 100644 --- a/src/debugger/gui/PromptWidget.hxx +++ b/src/debugger/gui/PromptWidget.hxx @@ -106,29 +106,29 @@ class PromptWidget : public Widget, public CommandSender kHistorySize = 1000 }; - int _buffer[kBufferSize]; // NOLINT (will be rewritten soon) - int _linesInBuffer; + int _buffer[kBufferSize]{}; // NOLINT (will be rewritten soon) + int _linesInBuffer{0}; - int _lineWidth; - int _linesPerPage; + int _lineWidth{0}; + int _linesPerPage{0}; - int _currentPos; - int _scrollLine; - int _firstLineInBuffer; - int _scrollStopLine; + int _currentPos{0}; + int _scrollLine{0}; + int _firstLineInBuffer{0}; + int _scrollStopLine{INT_MAX}; - int _promptStartPos; - int _promptEndPos; + int _promptStartPos{0}; + int _promptEndPos{0}; - ScrollBarWidget* _scrollBar; + ScrollBarWidget* _scrollBar{nullptr}; std::vector _history; int _historyIndex{0}; int _historyLine{0}; int _tabCount{-1}; - char _inputStr[kLineBufferSize]; + char _inputStr[kLineBufferSize]{}; - int _kConsoleCharWidth, _kConsoleCharHeight, _kConsoleLineHeight; + int _kConsoleCharWidth{0}, _kConsoleCharHeight{0}, _kConsoleLineHeight{0}; bool _inverse{false}; bool _firstTime{true}; diff --git a/src/debugger/gui/RomListSettings.cxx b/src/debugger/gui/RomListSettings.cxx index 1d35d0e3e..ef1d09910 100644 --- a/src/debugger/gui/RomListSettings.cxx +++ b/src/debugger/gui/RomListSettings.cxx @@ -157,15 +157,7 @@ void RomListSettings::handleCommand(CommandSender* sender, int cmd, int data, in { case RomListWidget::kSetPCCmd: case RomListWidget::kRuntoPCCmd: - { - sendCommand(cmd, _item, -1); - break; - } case RomListWidget::kSetTimerCmd: - { - sendCommand(cmd, _item, -1); - break; - } case RomListWidget::kDisassembleCmd: { sendCommand(cmd, _item, -1); diff --git a/src/debugger/gui/RomListWidget.cxx b/src/debugger/gui/RomListWidget.cxx index 7e881bbd4..26da5bd2d 100644 --- a/src/debugger/gui/RomListWidget.cxx +++ b/src/debugger/gui/RomListWidget.cxx @@ -33,7 +33,8 @@ RomListWidget::RomListWidget(GuiObject* boss, const GUI::Font& lfont, const GUI::Font& nfont, int x, int y, int w, int h) - : EditableWidget(boss, nfont, x, y, 16, 16) + : EditableWidget(boss, nfont, x, y, 16, 16), + _rows{h / _lineHeight} { _flags = Widget::FLAG_ENABLED | Widget::FLAG_CLEARBG | Widget::FLAG_RETAIN_FOCUS; _bgcolor = kWidColor; @@ -44,14 +45,12 @@ RomListWidget::RomListWidget(GuiObject* boss, const GUI::Font& lfont, _editMode = false; _dyText = -1; // fixes the vertical position of selected text - _cols = w / _fontWidth; - _rows = h / _lineHeight; - // Set real dimensions _w = w - ScrollBarWidget::scrollBarWidth(_font); _h = h + 2; // Create scrollbar and attach to the list + // NOLINTNEXTLINE: we want to initialize here, not in the member list myScrollBar = new ScrollBarWidget(boss, lfont, _x + _w, _y, ScrollBarWidget::scrollBarWidth(_font), _h); myScrollBar->setTarget(this); @@ -73,7 +72,7 @@ RomListWidget::RomListWidget(GuiObject* boss, const GUI::Font& lfont, // rowheight is determined by largest item on a line, // possibly meaning that number of rows will change _lineHeight = std::max(_lineHeight, CheckboxWidget::boxSize(_font)); - _rows = h / _lineHeight; + _rows = h / _lineHeight; // NOLINT: must be initialized after _lineHeight // Create a CheckboxWidget for each row in the list for(int i = 0; i < _rows; ++i) diff --git a/src/debugger/gui/RomListWidget.hxx b/src/debugger/gui/RomListWidget.hxx index 376d6dc79..85f8858e0 100644 --- a/src/debugger/gui/RomListWidget.hxx +++ b/src/debugger/gui/RomListWidget.hxx @@ -98,7 +98,6 @@ class RomListWidget : public EditableWidget int _labelWidth{0}; int _bytesWidth{0}; int _rows{0}; - int _cols{0}; int _currentPos{0}; // position of first line in visible window int _selectedItem{-1}; int _highlightedItem{-1}; diff --git a/src/debugger/gui/TiaOutputWidget.hxx b/src/debugger/gui/TiaOutputWidget.hxx index 4ab372e74..6cfbfe1c6 100644 --- a/src/debugger/gui/TiaOutputWidget.hxx +++ b/src/debugger/gui/TiaOutputWidget.hxx @@ -63,7 +63,7 @@ class TiaOutputWidget : public Widget, public CommandSender // Create this buffer once, instead of allocating it each time the // TIA image is redrawn - std::array myLineBuffer; + std::array myLineBuffer{}; private: void handleMouseDown(int x, int y, MouseButton b, int clickCount) override; diff --git a/src/debugger/gui/TiaZoomWidget.cxx b/src/debugger/gui/TiaZoomWidget.cxx index 4b11b5fc3..5ea8c150b 100644 --- a/src/debugger/gui/TiaZoomWidget.cxx +++ b/src/debugger/gui/TiaZoomWidget.cxx @@ -49,8 +49,8 @@ TiaZoomWidget::TiaZoomWidget(GuiObject* boss, const GUI::Font& font, addFocusWidget(this); // Initialize positions - myNumCols = (_w - 4) / myZoomLevel; - myNumRows = (_h - 4) / myZoomLevel; + myNumCols = (_w - 4) / myZoomLevel; // NOLINT: must initialize after _w + myNumRows = (_h - 4) / myZoomLevel; // NOLINT: must initialize after _h // Create context menu for zoom levels VariantList l; diff --git a/src/debugger/yacc/YaccParser.cxx b/src/debugger/yacc/YaccParser.cxx index eeb2e11c5..5f7fc11e8 100644 --- a/src/debugger/yacc/YaccParser.cxx +++ b/src/debugger/yacc/YaccParser.cxx @@ -20,6 +20,8 @@ #include "YaccParser.hxx" +// NOLINTBEGIN: this entire class is due to be rewritten + namespace YaccParser { #include @@ -409,3 +411,5 @@ int yylex() { } } // namespace YaccParser + +// NOLINTEND diff --git a/src/emucore/Cart.cxx b/src/emucore/Cart.cxx index 881dc6d27..86ef7b3de 100644 --- a/src/emucore/Cart.cxx +++ b/src/emucore/Cart.cxx @@ -191,13 +191,12 @@ uInt16 Cartridge::bankOrigin(uInt16 bank, uInt16 PC) const const uInt32 offset = bank * bankSize(); //uInt16 addrMask = (4_KB - 1) & ~(bankSize(bank) - 1); //int addrShift = 0; - std::array count; // up to 128 256 byte interval origins + std::array count{}; // up to 128 256 byte interval origins //if(addrMask) // addrShift = log(addrMask) / log(2); //addrMask; - count.fill(0); if(PC) count[PC >> 13]++; for(uInt16 addr = 0x0000; addr < bankSize(bank); ++addr) diff --git a/src/emucore/Cart.hxx b/src/emucore/Cart.hxx index ec9448354..4ef7ca8d3 100644 --- a/src/emucore/Cart.hxx +++ b/src/emucore/Cart.hxx @@ -452,7 +452,7 @@ class Cartridge : public Device messageCallback myMsgCallback{nullptr}; // Semi-random values to use when a read from write port occurs - std::array myRWPRandomValues; + std::array myRWPRandomValues{}; // If myRandomHotspots is true, peeks to hotspots return semi-random values. bool myRandomHotspots{false}; diff --git a/src/emucore/Cart4A50.hxx b/src/emucore/Cart4A50.hxx index 209308024..6ac155c37 100644 --- a/src/emucore/Cart4A50.hxx +++ b/src/emucore/Cart4A50.hxx @@ -217,7 +217,7 @@ class Cartridge4A50 : public Cartridge ByteBuffer myImage; // The 32K of RAM on the cartridge - std::array myRAM; + std::array myRAM{}; // (Actual) Size of the ROM image size_t mySize{0}; diff --git a/src/emucore/CartAR.cxx b/src/emucore/CartAR.cxx index 2f7e78c07..8fc152783 100644 --- a/src/emucore/CartAR.cxx +++ b/src/emucore/CartAR.cxx @@ -33,11 +33,11 @@ namespace { CartridgeAR::CartridgeAR(const ByteBuffer& image, size_t size, string_view md5, const Settings& settings) : Cartridge(settings, md5), - mySize{std::max(size, LOAD_SIZE)} + mySize{std::max(size, LOAD_SIZE)}, + myNumberOfLoadImages{static_cast(mySize / LOAD_SIZE)} { // Create a load image buffer and copy the given image myLoadImages = make_unique(mySize); - myNumberOfLoadImages = static_cast(mySize / LOAD_SIZE); std::copy_n(image.get(), size, myLoadImages.get()); // Add header if image doesn't include it diff --git a/src/emucore/CartAR.hxx b/src/emucore/CartAR.hxx index 1f8f81afb..97ea6bcc5 100644 --- a/src/emucore/CartAR.hxx +++ b/src/emucore/CartAR.hxx @@ -194,13 +194,13 @@ class CartridgeAR : public Cartridge private: // Indicates the offset within the image for the corresponding bank - std::array myImageOffset; + std::array myImageOffset{}; // The 6K of RAM and 2K of ROM contained in the Supercharger - std::array myImage; + std::array myImage{}; // The 256 byte header for the current 8448 byte load - std::array myHeader; + std::array myHeader{}; // Size of the ROM image size_t mySize{0}; diff --git a/src/emucore/CartBUS.hxx b/src/emucore/CartBUS.hxx index 27a51010a..3a58f6f6a 100644 --- a/src/emucore/CartBUS.hxx +++ b/src/emucore/CartBUS.hxx @@ -45,11 +45,11 @@ class CartridgeBUS : public CartridgeARM enum class BUSSubtype: uInt8 { BUS0, // very old demos when BUS was in flux, not supported in Stella BUS1, // draconian_20161102.bin - BUS2, // 128bus_20170120.bin, 128chronocolour_20170101.bin, parrot_20161231_NTSC.bin + BUS2, // 128bus_20170120.bin, 128chronocolour_20170101.bin, + // parrot_20161231_NTSC.bin BUS3 // rpg_20170616_NTSC.bin }; - public: /** Create a new cartridge using the specified image @@ -160,18 +160,18 @@ class CartridgeBUS : public CartridgeARM */ uInt8 internalRamGetValue(uInt16 addr) const override; - #ifdef DEBUGGER_SUPPORT /** Get debugger widget responsible for accessing the inner workings of the cart. */ CartDebugWidget* debugWidget(GuiObject* boss, const GUI::Font& lfont, - const GUI::Font& nfont, int x, int y, int w, int h) override; + const GUI::Font& nfont, int x, int y, + int w, int h) override; CartDebugWidget* infoWidget(GuiObject* boss, const GUI::Font& lfont, - const GUI::Font& nfont, int x, int y, int w, int h) override; - + const GUI::Font& nfont, int x, int y, + int w, int h) override; #endif public: @@ -249,7 +249,7 @@ class CartridgeBUS : public CartridgeARM // $0000 - 2K BUS driver // $0800 - 4K Display Data // $1800 - 2K C Variable & Stack - std::array myRAM; + std::array myRAM{}; // Indicates the offset into the ROM image (aligns to current bank) uInt16 myBankOffset{0}; @@ -283,13 +283,13 @@ class CartridgeBUS : public CartridgeARM uInt16 myWaveformBase{0}; // was WAVEFORM // The music mode counters - std::array myMusicCounters{0}; + std::array myMusicCounters{}; // The music frequency - std::array myMusicFrequencies{0}; + std::array myMusicFrequencies{}; // The music waveform sizes - std::array myMusicWaveformSize{0}; + std::array myMusicWaveformSize{}; // Fractional DPC music OSC clocks unused during the last update double myFractionalClocks{0.0}; diff --git a/src/emucore/CartCDF.cxx b/src/emucore/CartCDF.cxx index 458e2a0cd..cde2997e6 100644 --- a/src/emucore/CartCDF.cxx +++ b/src/emucore/CartCDF.cxx @@ -70,6 +70,7 @@ CartridgeCDF::CartridgeCDF(const ByteBuffer& image, size_t size, // Pointer to the program ROM // which starts after the 2K driver (and 2K C Code for CDF) + // NOLINTNEXTLINE: we want to initialize here, not in the member list myProgramImage = myImage.get() + (isCDFJplus() ? 2_KB : 4_KB); // Pointer to CDF driver in RAM diff --git a/src/emucore/CartCDF.hxx b/src/emucore/CartCDF.hxx index db4d272fb..2bf13c9e2 100644 --- a/src/emucore/CartCDF.hxx +++ b/src/emucore/CartCDF.hxx @@ -202,9 +202,11 @@ class CartridgeCDF : public CartridgeARM of the cart. */ CartDebugWidget* debugWidget(GuiObject* boss, const GUI::Font& lfont, - const GUI::Font& nfont, int x, int y, int w, int h) override; + const GUI::Font& nfont, int x, int y, + int w, int h) override; CartDebugWidget* infoWidget(GuiObject* boss, const GUI::Font& lfont, - const GUI::Font& nfont, int x, int y, int w, int h) override; + const GUI::Font& nfont, int x, int y, + int w, int h) override; #endif public: @@ -296,7 +298,7 @@ class CartridgeCDF : public CartridgeARM // For CDFJ+, used as: // $0000 - 2K Driver // $0800 - Display Data, C Variables & Stack - std::array myRAM; + std::array myRAM{}; // Indicates the offset into the ROM image (aligns to current bank) uInt16 myBankOffset{0}; diff --git a/src/emucore/CartCTY.cxx b/src/emucore/CartCTY.cxx index 1ec94a86c..5b026242f 100644 --- a/src/emucore/CartCTY.cxx +++ b/src/emucore/CartCTY.cxx @@ -515,7 +515,7 @@ void CartridgeCTY::loadScore(uInt8 index) const Serializer serializer(myEEPROMFile, Serializer::Mode::ReadOnly); if(serializer) { - std::array scoreRAM; + std::array scoreRAM{}; try { serializer.getByteArray(scoreRAM.data(), scoreRAM.size()); @@ -537,7 +537,7 @@ void CartridgeCTY::saveScore(uInt8 index) if(serializer) { // Load score RAM - std::array scoreRAM; + std::array scoreRAM{}; try { serializer.getByteArray(scoreRAM.data(), scoreRAM.size()); @@ -571,7 +571,7 @@ void CartridgeCTY::wipeAllScores() if(serializer) { // Erase score RAM - std::array scoreRAM = {}; + std::array scoreRAM{}; try { serializer.putByteArray(scoreRAM.data(), scoreRAM.size()); diff --git a/src/emucore/CartCTY.hxx b/src/emucore/CartCTY.hxx index e358680bc..074e024fe 100644 --- a/src/emucore/CartCTY.hxx +++ b/src/emucore/CartCTY.hxx @@ -274,10 +274,10 @@ class CartridgeCTY : public Cartridge ByteBuffer myImage; // The 28K ROM image of the music - std::array myTuneData; + std::array myTuneData{}; // The 64 bytes of RAM accessible at $1000 - $1080 - std::array myRAM; + std::array myRAM{}; // Console clock rate double myClockRate{1193191.66666667}; @@ -293,10 +293,10 @@ class CartridgeCTY : public Cartridge uInt16 myTunePosition{0}; // The music mode counters - std::array myMusicCounters{0}; + std::array myMusicCounters{}; // The music frequency - std::array myMusicFrequencies{0}; + std::array myMusicFrequencies{}; // Flags that last byte peeked was A9 (LDA #) bool myLDAimmediate{false}; diff --git a/src/emucore/CartDPCPlus.hxx b/src/emucore/CartDPCPlus.hxx index af9c1535b..6c68d6ac4 100644 --- a/src/emucore/CartDPCPlus.hxx +++ b/src/emucore/CartDPCPlus.hxx @@ -235,25 +235,25 @@ class CartridgeDPCPlus : public CartridgeARM // 3K DPC+ driver // 4K Display Data // 1K Frequency Data - std::array myDPCRAM; + std::array myDPCRAM{}; // Pointer to the 1K frequency table uInt8* myFrequencyImage{nullptr}; // The top registers for the data fetchers - std::array myTops; + std::array myTops{}; // The bottom registers for the data fetchers - std::array myBottoms; + std::array myBottoms{}; // The counter registers for the data fetchers - std::array myCounters; + std::array myCounters{}; // The counter registers for the fractional data fetchers - std::array myFractionalCounters; + std::array myFractionalCounters{}; // The fractional increments for the data fetchers - std::array myFractionalIncrements; + std::array myFractionalIncrements{}; // The Fast Fetcher Enabled flag bool myFastFetch{false}; @@ -262,19 +262,19 @@ class CartridgeDPCPlus : public CartridgeARM bool myLDAimmediate{false}; // Parameter for special functions - std::array myParameter; + std::array myParameter{}; // Parameter pointer for special functions uInt8 myParameterPointer{0}; // The music mode counters - std::array myMusicCounters; + std::array myMusicCounters{}; // The music frequency - std::array myMusicFrequencies; + std::array myMusicFrequencies{}; // The music waveforms - std::array myMusicWaveforms; + std::array myMusicWaveforms{}; // The random number generator register uInt32 myRandomNumber{1}; diff --git a/src/emucore/CartE7.hxx b/src/emucore/CartE7.hxx index a0fd35639..ba380c8cd 100644 --- a/src/emucore/CartE7.hxx +++ b/src/emucore/CartE7.hxx @@ -259,10 +259,10 @@ class CartridgeE7 : public Cartridge size_t mySize{0}; // The 2K of RAM - std::array myRAM; + std::array myRAM{}; // Indicates which bank is in the segment - std::array myCurrentBank; + std::array myCurrentBank{}; // Indicates which 256 byte bank of RAM is being used uInt16 myCurrentRAM{0}; diff --git a/src/emucore/CartELF.cxx b/src/emucore/CartELF.cxx index e94909a25..29dc642ac 100644 --- a/src/emucore/CartELF.cxx +++ b/src/emucore/CartELF.cxx @@ -411,7 +411,7 @@ std::pair, size_t> CartridgeELF::getArmImage() const memcpy(image.get() + ADDR_RODATA_BASE, mySectionRodata.get(), RODATA_SIZE); memcpy(image.get() + ADDR_TABLES_BASE, mySectionTables.get(), TABLES_SIZE); - return std::pair(std::move(image), imageSize); + return {std::move(image), imageSize}; } #endif @@ -718,6 +718,7 @@ void CartridgeELF::setupConfig() myConfigSystemType = determineSystemType(myProperties); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void CartridgeELF::resetWithConfig() { std::fill_n(myLastPeekResult.get(), 0x1000, 0); diff --git a/src/emucore/CartMVC.cxx b/src/emucore/CartMVC.cxx index 55c91bc2f..774c5838f 100755 --- a/src/emucore/CartMVC.cxx +++ b/src/emucore/CartMVC.cxx @@ -54,7 +54,7 @@ namespace { class StreamReader : public Serializable { public: - StreamReader() { myBuffer1.fill(0); myBuffer2.fill(0); } + StreamReader() = default; bool open(string_view path) { myFile = Serializer(path, Serializer::Mode::ReadOnly); @@ -250,8 +250,8 @@ class StreamReader : public Serializable uInt8* myColor{nullptr}; uInt8* myColorBK{nullptr}; - std::array myBuffer1; - std::array myBuffer2; + std::array myBuffer1{}; + std::array myBuffer2{}; uInt8 myVisibleLines{192}; uInt8 myVSyncLines{3}; @@ -785,7 +785,7 @@ static constexpr uInt8 levelBarsOddData[] = { class MovieCart : public Serializable { public: - MovieCart() { myROM.fill(0); } + MovieCart() = default; bool init(string_view path); bool process(uInt16 address); @@ -845,7 +845,7 @@ class MovieCart : public Serializable void updateTransport(); // data - std::array myROM; + std::array myROM{}; // title screen state int myTitleCycles{0}; diff --git a/src/emucore/CartMVC.hxx b/src/emucore/CartMVC.hxx index aa0ca62da..2c356655b 100755 --- a/src/emucore/CartMVC.hxx +++ b/src/emucore/CartMVC.hxx @@ -135,7 +135,7 @@ class CartridgeMVC : public Cartridge private: // Currently not used: // Pointer to a dynamically allocated ROM image of the cartridge - ByteBuffer myImage{nullptr}; + ByteBuffer myImage; size_t mySize{0}; unique_ptr myMovie; diff --git a/src/emucore/Console.cxx b/src/emucore/Console.cxx index e1e8d5bef..55dbc9c8c 100644 --- a/src/emucore/Console.cxx +++ b/src/emucore/Console.cxx @@ -116,9 +116,10 @@ Console::Console(OSystem& osystem, unique_ptr& cart, const Properties& props, AudioSettings& audioSettings) : myOSystem{osystem}, myEvent{osystem.eventHandler().event()}, + myAudioSettings{audioSettings}, myProperties{props}, myCart{std::move(cart)}, - myAudioSettings{audioSettings} + myDisplayFormat{myProperties.get(PropType::Display_Format)} { myEmulationTiming = make_shared(); myCart->setProperties(&myProperties); @@ -170,9 +171,6 @@ Console::Console(OSystem& osystem, unique_ptr& cart, myDevSettingsHandler = make_unique(myOSystem); // Auto-detect NTSC/PAL mode if it's requested - string autodetected; - myDisplayFormat = myProperties.get(PropType::Display_Format); - if (myDisplayFormat == "AUTO") myDisplayFormat = formatFromFilename(); @@ -184,6 +182,7 @@ Console::Console(OSystem& osystem, unique_ptr& cart, myOSystem.sound().pause(true); myOSystem.frameBuffer().clear(); + string autodetected; if(myDisplayFormat == "AUTO" || myOSystem.settings().getBool("rominfo")) { autodetectFrameLayout(); diff --git a/src/emucore/Console.hxx b/src/emucore/Console.hxx index b8e3186c1..510b6a167 100644 --- a/src/emucore/Console.hxx +++ b/src/emucore/Console.hxx @@ -444,6 +444,9 @@ class Console : public Serializable, public ConsoleIO // Reference to the event object to use const Event& myEvent; + // The audio settings + AudioSettings& myAudioSettings; + // Properties for the game Properties myProperties; @@ -501,9 +504,6 @@ class Console : public Serializable, public ConsoleIO // so we make it a shared pointer. shared_ptr myEmulationTiming; - // The audio settings - AudioSettings& myAudioSettings; - private: // Following constructors and assignment operators not supported Console() = delete; diff --git a/src/emucore/ControllerDetector.cxx b/src/emucore/ControllerDetector.cxx index dac9141a5..5b867baf5 100644 --- a/src/emucore/ControllerDetector.cxx +++ b/src/emucore/ControllerDetector.cxx @@ -90,7 +90,7 @@ Controller::Type ControllerDetector::autodetectPort( type = Controller::Type::Paddles; else if(isProbablyKidVid(image, size, port)) type = Controller::Type::KidVid; - else if (isQuadTari) // currently most likely assumption + else if(isQuadTari) // currently most likely assumption type = Controller::Type::Paddles; } // TODO: BOOSTERGRIP, DRIVING, COMPUMATE, MINDLINK, ATARIVOX @@ -102,7 +102,7 @@ Controller::Type ControllerDetector::autodetectPort( bool ControllerDetector::searchForBytes(const ByteBuffer& image, size_t imagesize, const uInt8* signature, uInt32 sigsize) { - if (imagesize >= sigsize) + if(imagesize >= sigsize) for(uInt32 i = 0; i < imagesize - sigsize; ++i) { uInt32 matches = 0; diff --git a/src/emucore/CortexM0.cxx b/src/emucore/CortexM0.cxx index 38e480423..36bd87da7 100644 --- a/src/emucore/CortexM0.cxx +++ b/src/emucore/CortexM0.cxx @@ -551,9 +551,8 @@ string CortexM0::describeError(err_t err) { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CortexM0::CortexM0() + : myPageMap{make_unique(PAGEMAP_SIZE)} { - myPageMap = make_unique(PAGEMAP_SIZE); - resetMappings(); reset(); } @@ -628,8 +627,7 @@ void CortexM0::MemoryRegion::loadDirtyBits(Serializer& in) bool CortexM0::save(Serializer& out) const { try { - for (size_t i = 0; i < 16; i++) - out.putInt(reg_norm[i]); + out.putIntArray(reg_norm.data(), reg_norm.size()); out.putInt(znFlags); out.putInt(cFlag); @@ -650,8 +648,7 @@ bool CortexM0::load(Serializer& in) try { reset(); - for (size_t i = 0; i < 16; i++) - reg_norm[i] = in.getInt(); + in.getIntArray(reg_norm.data(), reg_norm.size()); znFlags = in.getInt(); cFlag = in.getInt(); diff --git a/src/emucore/CortexM0.hxx b/src/emucore/CortexM0.hxx index fd3c35e8d..5450f6547 100644 --- a/src/emucore/CortexM0.hxx +++ b/src/emucore/CortexM0.hxx @@ -147,7 +147,7 @@ class CortexM0: public Serializable private: - enum class MemoryRegionType : uInt8 { + enum class MemoryRegionType: uInt8 { directData, directCode, delegate, @@ -208,12 +208,12 @@ class CortexM0: public Serializable err_t execute(uInt16 inst, uInt8 op); private: - std::array reg_norm; // normal execution mode, do not have a thread mode + std::array reg_norm{}; // normal execution mode, do not have a thread mode uInt32 znFlags{0}; uInt32 cFlag{0}; uInt32 vFlag{0}; - std::array myRegions; + std::array myRegions{}; unique_ptr myPageMap; uInt8 myNextRegionIndex{0}; BusTransactionDelegate* myDefaultDelegate{nullptr}; diff --git a/src/emucore/Event.hxx b/src/emucore/Event.hxx index 8a7d6d9d0..d1916cedc 100644 --- a/src/emucore/Event.hxx +++ b/src/emucore/Event.hxx @@ -200,7 +200,7 @@ class Event /** Create a new event object. */ - Event() { clear(); } + Event() { clear(); } // NOLINT: myValues is initialized in clear() ~Event() = default; public: diff --git a/src/emucore/EventHandler.cxx b/src/emucore/EventHandler.cxx index 7641284cb..2a9551085 100644 --- a/src/emucore/EventHandler.cxx +++ b/src/emucore/EventHandler.cxx @@ -2418,7 +2418,7 @@ int EventHandler::getActionListIndex(int idx, Event::Group group) switch(group) { using enum Event::Group; - case Menu: return idx; + case Menu: case Emulation: return idx; case Misc: return getEmulActionListIndex(idx, MiscEvents); case AudioVideo: return getEmulActionListIndex(idx, AudioVideoEvents); diff --git a/src/emucore/EventHandler.hxx b/src/emucore/EventHandler.hxx index 68ed189c1..cbf4d91c8 100644 --- a/src/emucore/EventHandler.hxx +++ b/src/emucore/EventHandler.hxx @@ -549,7 +549,7 @@ class EventHandler ; // The event(s) assigned to each combination event - BSPF::array2D myComboTable; + BSPF::array2D myComboTable{}; // Holds static strings for the remap menu (emulation and menu events) using EmulActionList = std::array; diff --git a/src/emucore/M6532.hxx b/src/emucore/M6532.hxx index 4b3e9fe7b..71624641a 100644 --- a/src/emucore/M6532.hxx +++ b/src/emucore/M6532.hxx @@ -190,7 +190,7 @@ class M6532 : public Device const Settings& mySettings; // An amazing 128 bytes of RAM - std::array myRAM; + std::array myRAM{}; // Current value of the timer uInt8 myTimer{0}; @@ -230,7 +230,7 @@ class M6532 : public Device bool myEdgeDetectPositive{false}; // Last value written to the timer registers - std::array myOutTimer{0}; + std::array myOutTimer{}; // Accessible bits in the interrupt flag register // All other bits are always zeroed @@ -245,19 +245,19 @@ class M6532 : public Device // The arrays containing information about every byte of RIOT // indicating whether and how (RW) it is used. - std::array myRAMAccessBase; - std::array myStackAccessBase; - std::array myIOAccessBase; + std::array myRAMAccessBase{}; + std::array myStackAccessBase{}; + std::array myIOAccessBase{}; // The arrays containing information about every byte of RIOT // indicating how often it is accessed. std::array(RAM_SIZE * 2)> myRAMAccessCounter; + static_cast(RAM_SIZE * 2)> myRAMAccessCounter{}; std::array(STACK_SIZE * 2)> myStackAccessCounter; + static_cast(STACK_SIZE * 2)> myStackAccessCounter{}; std::array(IO_SIZE * 2)> myIOAccessCounter; + static_cast(IO_SIZE * 2)> myIOAccessCounter{}; // The array used to skip the first ZP access tracking - std::array myZPAccessDelay; + std::array myZPAccessDelay{}; // Detect timer being accessed on wraparound bool myTimWrappedOnRead{false}; diff --git a/src/emucore/MD5.cxx b/src/emucore/MD5.cxx index afdd5f04f..8dec4c99d 100644 --- a/src/emucore/MD5.cxx +++ b/src/emucore/MD5.cxx @@ -86,7 +86,7 @@ void MD5::encode(uInt8* output, const uInt32* input, uInt32 len) // Apply MD5 algo on a block. void MD5::transform(const uInt8* block) { - std::array x; + std::array x{}; decode(x.data(), block, BLOCKSIZE); uInt32 a = state[0], b = state[1], c = state[2], d = state[3]; @@ -214,16 +214,12 @@ void MD5::update(const uInt8* input, uInt32 length) // the message digest and zeroizing the context. void MD5::finalize() { - static constexpr std::array padding = { - 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; + static constexpr std::array padding = { 0x80 }; if (!finalized) { // Save number of bits - std::array bits; + std::array bits{}; encode(bits.data(), count.data(), 8); // Pad out to 56 mod 64 diff --git a/src/emucore/MD5.hxx b/src/emucore/MD5.hxx index 2b12ae380..3ddefc2db 100644 --- a/src/emucore/MD5.hxx +++ b/src/emucore/MD5.hxx @@ -122,10 +122,10 @@ class MD5 private: static constexpr uInt32 BLOCKSIZE = 64; bool finalized{false}; - std::array buffer; // bytes that didn't fit in last chunk - std::array count; // 64bit counter for number of bits (lo, hi) - std::array state; // digest so far - std::array digest; // the result + std::array buffer{}; // bytes that didn't fit in last chunk + std::array count{}; // 64bit counter for number of bits (lo, hi) + std::array state{}; // digest so far + std::array digest{}; // the result private: MD5(const MD5&) = delete; diff --git a/src/emucore/MT24LC256.hxx b/src/emucore/MT24LC256.hxx index 4a292dc7b..071b9a47d 100644 --- a/src/emucore/MT24LC256.hxx +++ b/src/emucore/MT24LC256.hxx @@ -96,7 +96,7 @@ class MT24LC256 ByteBuffer myData; // Track which pages are used - std::array myPageHit; + std::array myPageHit{}; // Cached state of the SDA and SCL pins on the last write bool mySDA{false}, mySCL{false}; @@ -121,7 +121,7 @@ class MT24LC256 Int32 jpee_sizemask{0}, jpee_pagemask{0}, jpee_smallmode{0}, jpee_logmode{0}; Int32 jpee_pptr{0}, jpee_state{0}, jpee_nb{0}; uInt32 jpee_address{0}, jpee_ad_known{0}; - std::array jpee_packet; + std::array jpee_packet{}; private: // Following constructors and assignment operators not supported diff --git a/src/emucore/PlusROM.cxx b/src/emucore/PlusROM.cxx index fb4d75815..6c2bf62ff 100644 --- a/src/emucore/PlusROM.cxx +++ b/src/emucore/PlusROM.cxx @@ -72,8 +72,10 @@ class PlusROMRequest { public: PlusROMRequest(const Destination& destination, const PlusStoreId& id, const uInt8* request, uInt8 requestSize) - : myState{State::created}, myDestination{destination}, - myId{id}, myRequestSize{requestSize} + : myState{State::created}, + myDestination{destination}, + myId{id}, + myRequestSize{requestSize} { memcpy(myRequest.data(), request, myRequestSize); } @@ -184,7 +186,7 @@ class PlusROMRequest { Destination myDestination; PlusStoreId myId; - std::array myRequest; + std::array myRequest{}; uInt8 myRequestSize{0}; string myResponse; @@ -201,8 +203,6 @@ PlusROM::PlusROM(const Settings& settings, const Cartridge& cart) : mySettings{settings}, myCart{cart} { - myRxBuffer.fill(0); - myTxBuffer.fill(0); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -433,7 +433,7 @@ void PlusROM::send() // 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([=, this]() + std::thread thread([request, this]() { request->execute(); switch(request->getState()) diff --git a/src/emucore/PlusROM.hxx b/src/emucore/PlusROM.hxx index 86393795f..42277cc76 100644 --- a/src/emucore/PlusROM.hxx +++ b/src/emucore/PlusROM.hxx @@ -178,7 +178,7 @@ class PlusROM : public Serializable string myHost; string myPath; - std::array myRxBuffer, myTxBuffer; + std::array myRxBuffer{}, myTxBuffer{}; uInt8 myRxReadPos{0}, myRxWritePos{0}, myTxPos{0}; std::deque> myPendingRequests; diff --git a/src/emucore/Settings.cxx b/src/emucore/Settings.cxx index 8dd3c12eb..a6a2d79fe 100644 --- a/src/emucore/Settings.cxx +++ b/src/emucore/Settings.cxx @@ -312,7 +312,7 @@ Settings::Settings() setPermanent("dev.extaccess", "true"); // Thumb ARM emulation options setPermanent("dev.thumb.trapfatal", "true"); - setPermanent("dev.arm.mips", CartridgeELF::MIPS_DEF); + setPermanent("dev.arm.mips", CartridgeELF::MIPS_DEF); #ifdef DEBUGGER_SUPPORT setPermanent("dev.thumb.inccycles", "true"); setPermanent("dev.thumb.cyclefactor", "1.05"); @@ -835,7 +835,7 @@ void Settings::usage() #if defined(BSPF_UNIX) || defined(BSPF_MACOS) int height = 25; - struct winsize ws; + struct winsize ws{}; ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws); @@ -906,7 +906,8 @@ void Settings::migrateOne() const int version = getInt(SETTINGS_VERSION_KEY); if (version >= SETTINGS_VERSION) return; - switch (version) { // NOLINT (could be written as IF/ELSE) + // NOLINTBEGIN: could be written as IF/ELSE, bugprone-branch-clone + switch (version) { case 0: #if defined BSPF_MACOS || defined DARWIN setPermanent("video", ""); @@ -915,6 +916,7 @@ void Settings::migrateOne() default: break; } + // NOLINTEND setPermanent(SETTINGS_VERSION_KEY, version + 1); } diff --git a/src/emucore/System.cxx b/src/emucore/System.cxx index 1557b89cf..522ea454f 100644 --- a/src/emucore/System.cxx +++ b/src/emucore/System.cxx @@ -31,17 +31,12 @@ System::System(Random& random, M6502& m6502, M6532& m6532, myM6502{m6502}, myM6532{m6532}, myTIA{mTIA}, - myCart{mCart} + myCart{mCart}, + myCartridgeDoesBusStuffing{myCart.doesBusStuffing()} { // Initialize page access table const PageAccess access(&myNullDevice, System::PageAccessType::READ); myPageAccessTable.fill(access); - myPageIsDirtyTable.fill(false); - - // Bus starts out unlocked (in other words, peek() changes myDataBusState) - myDataBusLocked = false; - - myCartridgeDoesBusStuffing = myCart.doesBusStuffing(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/System.hxx b/src/emucore/System.hxx index d994ed8ef..52bd61fc1 100644 --- a/src/emucore/System.hxx +++ b/src/emucore/System.hxx @@ -430,7 +430,7 @@ class System : public Serializable std::array myPageAccessTable; // The list of dirty pages - std::array myPageIsDirtyTable; + std::array myPageIsDirtyTable{}; // The current state of the Data Bus uInt8 myDataBusState{0}; diff --git a/src/emucore/TIASurface.hxx b/src/emucore/TIASurface.hxx index 944d4ed45..e0426e9c4 100644 --- a/src/emucore/TIASurface.hxx +++ b/src/emucore/TIASurface.hxx @@ -248,17 +248,17 @@ class TIASurface std::array (AtariNTSC::outWidth(TIAConstants::frameBufferWidth) * - TIAConstants::frameBufferHeight)> myRGBFramebuffer; + TIAConstants::frameBufferHeight)> myRGBFramebuffer{}; std::array (AtariNTSC::outWidth(TIAConstants::frameBufferWidth) * - TIAConstants::frameBufferHeight)> myPrevRGBFramebuffer; + TIAConstants::frameBufferHeight)> myPrevRGBFramebuffer{}; ///////////////////////////////////////////////////////////// // Use scanlines in TIA rendering mode bool myScanlinesEnabled{false}; // Palette for normal TIA rendering mode - PaletteArray myPalette; + PaletteArray myPalette{}; // Flag for saving a snapshot bool mySaveSnapFlag{false}; diff --git a/src/emucore/Thumbulator.cxx b/src/emucore/Thumbulator.cxx index 705f5488f..27a221741 100644 --- a/src/emucore/Thumbulator.cxx +++ b/src/emucore/Thumbulator.cxx @@ -2952,7 +2952,7 @@ int Thumbulator::reset() #endif #ifdef THUMB_STATS _stats.reads = _stats.writes - = _stats.nCylces = _stats.sCylces = _stats.iCylces + = _stats.nCycles = _stats.nCycles = _stats.iCycles = _stats.branches = _stats.taken = _stats.mamPrefetchHits = _stats.mamPrefetchMisses = _stats.mamBranchHits = _stats.mamBranchMisses @@ -3191,7 +3191,7 @@ void Thumbulator::incCycles(AccessType accessType, uInt32 cycles) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Thumbulator::incSCycles(uInt32 addr, AccessType accessType) { - THUMB_STAT(_stats.sCylces) + THUMB_STAT(_stats.nCycles) uInt32 cycles = 0; if(addr & 0xC0000000) // RAM, peripherals @@ -3251,7 +3251,7 @@ void Thumbulator::incSCycles(uInt32 addr, AccessType accessType) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Thumbulator::incNCycles(uInt32 addr, AccessType accessType) { - THUMB_STAT(_stats.nCylces) + THUMB_STAT(_stats.nCycles) uInt32 cycles = 0; if(addr & 0xC0000000) // RAM, peripherals @@ -3278,7 +3278,7 @@ void Thumbulator::incNCycles(uInt32 addr, AccessType accessType) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Thumbulator::incICycles(uInt32 m) { - THUMB_STAT(_stats.iCylces) + THUMB_STAT(_stats.iCycles) #ifdef EMULATE_PIPELINE _fetchPipeline += m; diff --git a/src/emucore/Thumbulator.hxx b/src/emucore/Thumbulator.hxx index adfaf8638..63d41bbda 100644 --- a/src/emucore/Thumbulator.hxx +++ b/src/emucore/Thumbulator.hxx @@ -79,7 +79,7 @@ class Thumbulator uInt32 instructions{0}; #ifdef THUMB_STATS uInt32 reads{0}, writes{0}; - uInt32 nCylces{0}, sCylces{0}, iCylces{0}; + uInt32 nCycles{0}, sCycles{0}, iCycles{0}; uInt32 branches{0}, taken{0}; uInt32 mamPrefetchHits{0}, mamPrefetchMisses{0}; uInt32 mamBranchHits{0}, mamBranchMisses{0}; @@ -268,7 +268,7 @@ class Thumbulator const unique_ptr decodedRom; // NOLINT const unique_ptr decodedParam; // NOLINT uInt16* ram{nullptr}; - std::array reg_norm; // normal execution mode, do not have a thread mode + std::array reg_norm{}; // normal execution mode, do not have a thread mode uInt32 znFlags{0}; uInt32 cFlag{0}; uInt32 vFlag{0}; diff --git a/src/emucore/elf/ElfLinker.hxx b/src/emucore/elf/ElfLinker.hxx index 53f82232d..fa959097f 100644 --- a/src/emucore/elf/ElfLinker.hxx +++ b/src/emucore/elf/ElfLinker.hxx @@ -60,7 +60,7 @@ class ElfLinker { enum class SegmentType: uInt8 { text, data, rodata }; struct RelocatedSection { - SegmentType segment; + SegmentType segment{}; uInt32 offset{0}; }; diff --git a/src/emucore/tia/AnalogReadout.hxx b/src/emucore/tia/AnalogReadout.hxx index 9a1cadf13..5924b4fb3 100644 --- a/src/emucore/tia/AnalogReadout.hxx +++ b/src/emucore/tia/AnalogReadout.hxx @@ -88,7 +88,7 @@ class AnalogReadout : public Serializable Connection myConnection{ConnectionType::disconnected, 0}; uInt64 myTimestamp{0}; - ConsoleTiming myConsoleTiming; + ConsoleTiming myConsoleTiming{ConsoleTiming::ntsc}; double myClockFreq{0.0}; bool myIsDumped{false}; diff --git a/src/emucore/tia/Audio.hxx b/src/emucore/tia/Audio.hxx index bfd3e7d3e..66b39d3b3 100644 --- a/src/emucore/tia/Audio.hxx +++ b/src/emucore/tia/Audio.hxx @@ -73,8 +73,8 @@ class Audio : public Serializable uInt32 mySumChannel1{0}; uInt32 mySumCt{0}; - std::array myMixingTableSum; - std::array myMixingTableIndividual; + std::array myMixingTableSum{}; + std::array myMixingTableIndividual{}; Int16* myCurrentFragment{nullptr}; uInt32 mySampleIndex{0}; diff --git a/src/emucore/tia/DelayQueue.hxx b/src/emucore/tia/DelayQueue.hxx index f66069929..583f7f3a2 100644 --- a/src/emucore/tia/DelayQueue.hxx +++ b/src/emucore/tia/DelayQueue.hxx @@ -53,7 +53,7 @@ class DelayQueue : public Serializable private: std::array, length> myMembers; uInt8 myIndex{0}; - std::array myIndices; + std::array myIndices{}; private: DelayQueue(const DelayQueue&) = delete; diff --git a/src/emucore/tia/DrawCounterDecodes.hxx b/src/emucore/tia/DrawCounterDecodes.hxx index 35e92359f..f49d7d58f 100644 --- a/src/emucore/tia/DrawCounterDecodes.hxx +++ b/src/emucore/tia/DrawCounterDecodes.hxx @@ -37,13 +37,12 @@ class DrawCounterDecodes private: - uInt8* myPlayerDecodes[8]{nullptr}; // TJ: one per NUSIZ number and size - - uInt8* myMissileDecodes[8]{nullptr}; // TJ: one per NUSIZ number and size + uInt8* myPlayerDecodes[8]{}; // TJ: one per NUSIZ number and size + uInt8* myMissileDecodes[8]{}; // TJ: one per NUSIZ number and size // TJ: 6 scanline pixel arrays, one for each copy pattern - uInt8 myDecodes0[160], myDecodes1[160], myDecodes2[160], myDecodes3[160], - myDecodes4[160], myDecodes6[160]; + uInt8 myDecodes0[160]{}, myDecodes1[160]{}, myDecodes2[160]{}, + myDecodes3[160]{}, myDecodes4[160]{}, myDecodes6[160]{}; static DrawCounterDecodes myInstance; diff --git a/src/emucore/tia/TIA.hxx b/src/emucore/tia/TIA.hxx index bd7873b46..d150563a4 100644 --- a/src/emucore/tia/TIA.hxx +++ b/src/emucore/tia/TIA.hxx @@ -610,8 +610,8 @@ class TIA : public Device * Palette and indices for fixed debug colors. */ enum FixedObject: uInt8 { P0, M0, P1, M1, PF, BL, BK }; - BSPF::array2D myFixedColorPalette; - std::array myFixedColorNames; + BSPF::array2D myFixedColorPalette{}; + std::array myFixedColorNames{}; private: /** @@ -840,12 +840,12 @@ class TIA : public Device LatchedInput myInput1; // Pointer to the internal color-index-based frame buffer - std::array(TIAConstants::H_PIXEL * TIAConstants::frameBufferHeight)> myFramebuffer; + std::array(TIAConstants::H_PIXEL * TIAConstants::frameBufferHeight)> myFramebuffer{}; // The frame is rendered to the backbuffer and only copied to the framebuffer // upon completion - std::array(TIAConstants::H_PIXEL * TIAConstants::frameBufferHeight)> myBackBuffer; - std::array(TIAConstants::H_PIXEL * TIAConstants::frameBufferHeight)> myFrontBuffer; + std::array(TIAConstants::H_PIXEL * TIAConstants::frameBufferHeight)> myBackBuffer{}; + std::array(TIAConstants::H_PIXEL * TIAConstants::frameBufferHeight)> myFrontBuffer{}; // We snapshot frame statistics when the back buffer is copied to the front buffer // and when the front buffer is copied to the frame buffer @@ -971,7 +971,7 @@ class TIA : public Device * The "shadow registers" track the last written register value for the * debugger. */ - std::array myShadowRegisters; + std::array myShadowRegisters{}; /** * Indicates if color loss should be enabled or disabled. Color loss @@ -991,8 +991,8 @@ class TIA : public Device bool myAutoPhosphorEnabled{false}; bool myAutoPhosphorAutoOn{false}; bool myAutoPhosphorActive{false}; - ObjectPos myPosP0, myPosP1, myPosM0, myPosM1, myPosBL; - ObjectGfx myPatPF; + ObjectPos myPosP0{}, myPosP1{}, myPosM0{}, myPosM1{}, myPosBL{}; + ObjectGfx myPatPF{}; int myFlickerFrame{0}, myFlickerCount{0}; uInt32 myFrameEnd{0}; onPhosphorCallback myPhosphorCallback; @@ -1024,13 +1024,13 @@ class TIA : public Device #ifdef DEBUGGER_SUPPORT // The arrays containing information about every byte of TIA // indicating whether and how (RW) it is used. - std::array myAccessBase; + std::array myAccessBase{}; // The arrays containing information about every byte of TIA // indicating how often it is accessed (read and write). - std::array myAccessCounter; + std::array myAccessCounter{}; // The array used to skip the first two TIA access trackings - std::array myAccessDelay; + std::array myAccessDelay{}; #endif // DEBUGGER_SUPPORT private: diff --git a/src/emucore/tia/frame-manager/FrameManager.hxx b/src/emucore/tia/frame-manager/FrameManager.hxx index 9693d42c4..900bc3bae 100644 --- a/src/emucore/tia/frame-manager/FrameManager.hxx +++ b/src/emucore/tia/frame-manager/FrameManager.hxx @@ -26,7 +26,7 @@ class FrameManager: public AbstractFrameManager { public: - enum Metrics : uInt32 { // NOLINT: use 32-bit, even though 16-bit is sufficient + enum Metrics: uInt32 { // NOLINT: use 32-bit, even though 16-bit is sufficient vblankNTSC = 37, vblankPAL = 45, vsync = 3, diff --git a/src/gui/BrowserDialog.cxx b/src/gui/BrowserDialog.cxx index 019e59766..0fa688d08 100644 --- a/src/gui/BrowserDialog.cxx +++ b/src/gui/BrowserDialog.cxx @@ -117,9 +117,9 @@ void BrowserDialog::show(GuiObject* parent, const GUI::Font& font, const Command& command, const FSNode::NameFilter& namefilter) { - uInt32 w, h; + uInt32 w = 0, h = 0; - const auto parentDialog = dynamic_cast(parent); + const auto* parentDialog = static_cast(parent); if (parentDialog) { parentDialog->getDynamicBounds(w, h); } else { diff --git a/src/gui/EmulationDialog.cxx b/src/gui/EmulationDialog.cxx index 5a5272ded..5ea07d9bb 100644 --- a/src/gui/EmulationDialog.cxx +++ b/src/gui/EmulationDialog.cxx @@ -65,7 +65,8 @@ namespace { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - EmulationDialog::EmulationDialog(OSystem& osystem, DialogContainer& parent, const GUI::Font& font, int max_w, int max_h) - : Dialog(osystem, parent, font, "Emulation settings") + : Dialog(osystem, parent, font, "Emulation settings"), + mySaveOnExitGroup{new RadioButtonGroup()} { const int lineHeight = Dialog::lineHeight(), fontWidth = Dialog::fontWidth(), @@ -139,7 +140,6 @@ EmulationDialog::EmulationDialog(OSystem& osystem, DialogContainer& parent, new StaticTextWidget(this, font, HBORDER, ypos + 1, "When entering/exiting emulation:"); ypos += lineHeight + VGAP; - mySaveOnExitGroup = new RadioButtonGroup(); auto* r = new RadioButtonWidget(this, font, xpos, ypos + 1, "Do nothing", mySaveOnExitGroup); wid.push_back(r); diff --git a/src/gui/LauncherDialog.cxx b/src/gui/LauncherDialog.cxx index 72f619982..00d73be12 100644 --- a/src/gui/LauncherDialog.cxx +++ b/src/gui/LauncherDialog.cxx @@ -68,14 +68,13 @@ LauncherDialog::LauncherDialog(OSystem& osystem, DialogContainer& parent, int x, int y, int w, int h) : Dialog(osystem, parent, osystem.frameBuffer().launcherFont(), "", x, y, w, h), - CommandSender(this) + CommandSender(this), + myUseMinimalUI{instance().settings().getBool("minimal_ui")} { const bool bottomButtons = instance().settings().getBool("launcherbuttons"); int ypos = Dialog::vBorder(); - myUseMinimalUI = instance().settings().getBool("minimal_ui"); - - // if minimalUI, show title within dialog surface instead of showing the filtering control + // If minimalUI, show title within dialog surface instead of showing the filtering control if(myUseMinimalUI) { addTitleWidget(ypos); addPathWidgets(ypos); //-- path widget line will have file count diff --git a/src/gui/ListWidget.cxx b/src/gui/ListWidget.cxx index fc96377e6..3705754f7 100644 --- a/src/gui/ListWidget.cxx +++ b/src/gui/ListWidget.cxx @@ -28,6 +28,8 @@ ListWidget::ListWidget(GuiObject* boss, const GUI::Font& font, int x, int y, int w, int h, bool useScrollbar) : EditableWidget(boss, font, x, y, 16, 16), + _rows{h / _lineHeight}, + _cols{w / _fontWidth}, _useScrollbar{useScrollbar} { _flags = Widget::FLAG_ENABLED | Widget::FLAG_CLEARBG | Widget::FLAG_RETAIN_FOCUS; @@ -38,9 +40,6 @@ ListWidget::ListWidget(GuiObject* boss, const GUI::Font& font, _editMode = false; - _cols = w / _fontWidth; - _rows = h / _lineHeight; - // Set real dimensions _h = h + 2; diff --git a/src/gui/NavigationWidget.cxx b/src/gui/NavigationWidget.cxx index b513f511a..97cc6a59e 100644 --- a/src/gui/NavigationWidget.cxx +++ b/src/gui/NavigationWidget.cxx @@ -28,11 +28,11 @@ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - NavigationWidget::NavigationWidget(GuiObject* boss, const GUI::Font& font, int xpos, int ypos, int w, int h) - : Widget(boss, font, xpos, ypos, w, h) + : Widget(boss, font, xpos, ypos, w, h), + myUseMinimalUI{instance().settings().getBool("minimal_ui")} { // Add some buttons and textfield to show current directory const int lineHeight = _font.getLineHeight(); - myUseMinimalUI = instance().settings().getBool("minimal_ui"); if(!myUseMinimalUI) { diff --git a/src/gui/RomImageWidget.cxx b/src/gui/RomImageWidget.cxx index 9bced5563..d3f19ba8f 100644 --- a/src/gui/RomImageWidget.cxx +++ b/src/gui/RomImageWidget.cxx @@ -32,12 +32,12 @@ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - RomImageWidget::RomImageWidget(GuiObject* boss, const GUI::Font& font, int x, int y, int w, int h) - : Widget(boss, font, x, y, w, h) + : Widget(boss, font, x, y, w, h), + myImageHeight{_h - labelHeight(font) - font.getFontHeight() / 4 - 1} { _flags = Widget::FLAG_ENABLED | Widget::FLAG_TRACK_MOUSE; // | FLAG_WANTS_RAWDATA; _bgcolor = kDlgColor; _bgcolorlo = kBGColorLo; - myImageHeight = _h - labelHeight(font) - font.getFontHeight() / 4 - 1; myZoomRect = Common::Rect(_w * 7 / 16, myImageHeight * 7 / 16, _w * 9 / 16, myImageHeight * 9 / 16); diff --git a/src/gui/ScrollBarWidget.cxx b/src/gui/ScrollBarWidget.cxx index 2a21b203b..623f70fe0 100644 --- a/src/gui/ScrollBarWidget.cxx +++ b/src/gui/ScrollBarWidget.cxx @@ -30,14 +30,14 @@ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ScrollBarWidget::ScrollBarWidget(GuiObject* boss, const GUI::Font& font, int x, int y, int w, int h) - : Widget(boss, font, x, y, w, h), CommandSender(boss) + : Widget(boss, font, x, y, w, h), + CommandSender(boss), + _scrollBarWidth{scrollBarWidth(font)} { _flags = Widget::FLAG_ENABLED | Widget::FLAG_TRACK_MOUSE | Widget::FLAG_CLEARBG; _bgcolor = kWidColor; _bgcolorhi = kWidColor; - _scrollBarWidth = scrollBarWidth(font); - setArrows(); } diff --git a/src/gui/ScrollBarWidget.hxx b/src/gui/ScrollBarWidget.hxx index 6d8becff3..fe6416290 100644 --- a/src/gui/ScrollBarWidget.hxx +++ b/src/gui/ScrollBarWidget.hxx @@ -36,8 +36,7 @@ class ScrollBarWidget : public Widget, public CommandSender static void setWheelLines(int lines) { _WHEEL_LINES = lines; } static int getWheelLines() { return _WHEEL_LINES; } - static int scrollBarWidth(const GUI::Font& font) - { + static int scrollBarWidth(const GUI::Font& font) { return font.getFontHeight() < 24 ? 15 : 23; } diff --git a/src/gui/TabWidget.cxx b/src/gui/TabWidget.cxx index ad8113747..a0d0a47b6 100644 --- a/src/gui/TabWidget.cxx +++ b/src/gui/TabWidget.cxx @@ -27,7 +27,8 @@ TabWidget::TabWidget(GuiObject* boss, const GUI::Font& font, int x, int y, int w, int h) : Widget(boss, font, x, y, w, h), - CommandSender(boss) + CommandSender(boss), + _tabHeight{font.getLineHeight() + 4} { _id = 0; // For dialogs with multiple tab widgets, they should specifically // call ::setID to differentiate among them @@ -36,8 +37,6 @@ TabWidget::TabWidget(GuiObject* boss, const GUI::Font& font, _bgcolorhi = kDlgColor; _textcolor = kTextColor; _textcolorhi = kTextColor; - - _tabHeight = font.getLineHeight() + 4; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/gui/ToolTip.cxx b/src/gui/ToolTip.cxx index 77c334f1f..740397f43 100644 --- a/src/gui/ToolTip.cxx +++ b/src/gui/ToolTip.cxx @@ -27,10 +27,9 @@ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ToolTip::ToolTip(Dialog& dialog, const GUI::Font& font) - : myDialog{dialog} + : myDialog{dialog}, + myScale{myDialog.instance().frameBuffer().hidpiScaleFactor()} { - myScale = myDialog.instance().frameBuffer().hidpiScaleFactor(); - setFont(font); } diff --git a/src/gui/Widget.cxx b/src/gui/Widget.cxx index 3a85b38b7..104275bee 100644 --- a/src/gui/Widget.cxx +++ b/src/gui/Widget.cxx @@ -34,14 +34,13 @@ Widget::Widget(GuiObject* boss, const GUI::Font& font, int x, int y, int w, int h) : GuiObject(boss->instance(), boss->parent(), boss->dialog(), x, y, w, h), _boss{boss}, - _font{font} + _font{font}, + _next{_boss->_firstWidget}, + _fontWidth{_font.getMaxCharWidth()}, + _lineHeight{_font.getLineHeight()} { // Insert into the widget list of the boss - _next = _boss->_firstWidget; _boss->_firstWidget = this; - - _fontWidth = _font.getMaxCharWidth(); - _lineHeight = _font.getLineHeight(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -544,7 +543,6 @@ StaticTextWidget::StaticTextWidget(GuiObject* boss, const GUI::Font& font, _textcolor = kTextColor; _textcolorhi = kTextColor; _shadowcolor = shadowColor; - _cmd = 0; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -862,14 +860,14 @@ CheckboxWidget::CheckboxWidget(GuiObject* boss, const GUI::Font& font, int x, int y, string_view label, int cmd) : ButtonWidget(boss, font, x, y, font.getFontHeight() < 24 ? 16 : 24, - font.getFontHeight() < 24 ? 16 : 24, label, cmd) + font.getFontHeight() < 24 ? 16 : 24, label, cmd), + _boxSize{boxSize(font)} { _flags = Widget::FLAG_ENABLED; _bgcolor = _bgcolorhi = kWidColor; _bgcolorlo = kDlgColor; _editable = true; - _boxSize = boxSize(font); if(label.empty()) _w = _boxSize; diff --git a/src/os/unix/FSNodePOSIX.cxx b/src/os/unix/FSNodePOSIX.cxx index 59aa4bae8..e62ca52fa 100644 --- a/src/os/unix/FSNodePOSIX.cxx +++ b/src/os/unix/FSNodePOSIX.cxx @@ -56,7 +56,7 @@ FSNodePOSIX::FSNodePOSIX(string_view path, bool verify) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool FSNodePOSIX::setFlags() { - struct stat st; + struct stat st{}; if (stat(_path.c_str(), &st) == 0) { _isDirectory = S_ISDIR(st.st_mode); @@ -102,7 +102,7 @@ size_t FSNodePOSIX::getSize() const { if (_size == 0 && _isFile) { - struct stat st; + struct stat st{}; _size = (stat(_path.c_str(), &st) == 0) ? st.st_size : 0; } return _size; diff --git a/src/os/unix/SerialPortUNIX.cxx b/src/os/unix/SerialPortUNIX.cxx index dabf454f3..467d7a100 100644 --- a/src/os/unix/SerialPortUNIX.cxx +++ b/src/os/unix/SerialPortUNIX.cxx @@ -46,7 +46,7 @@ bool SerialPortUNIX::openPort(const string& device) tcflush(myHandle, TCIFLUSH); fcntl(myHandle, F_SETFL, FNDELAY); - struct termios termios; + struct termios termios{}; memset(&termios, 0, sizeof(struct termios)); termios.c_cflag = CREAD | CLOCAL; diff --git a/src/tools/TIDY b/src/tools/TIDY index 84817a487..87221cd23 100755 --- a/src/tools/TIDY +++ b/src/tools/TIDY @@ -15,25 +15,19 @@ run-clang-tidy-18 -header-filter=\(.*\.hxx\) \ -cert-dcl37-c,\ -cert-dcl51-cpp,\ -cert-err58-cpp,\ --clang-analyzer-core.DivideZero,\ -clang-analyzer-cplusplus.NewDeleteLeaks,\ -clang-analyzer-optin.performance.Padding,\ --clang-diagnostic-unsafe-buffer-usage,\ -cppcoreguidelines-avoid-c-arrays,\ -cppcoreguidelines-avoid-do-while,\ -cppcoreguidelines-avoid-magic-numbers,\ --cppcoreguidelines-avoid-non-const-global-variables,\ -cppcoreguidelines-macro-usage,\ --cppcoreguidelines-misleading-capture-default-by-value,\ -cppcoreguidelines-narrowing-conversions,\ -cppcoreguidelines-non-private-member-variables-in-classes,\ -cppcoreguidelines-owning-memory,\ --cppcoreguidelines-prefer-member-initializer,\ -cppcoreguidelines-pro-bounds-array-to-pointer-decay,\ -cppcoreguidelines-pro-bounds-constant-array-index,\ -cppcoreguidelines-pro-bounds-pointer-arithmetic,\ -cppcoreguidelines-pro-type-const-cast,\ --cppcoreguidelines-pro-type-member-init,\ -cppcoreguidelines-pro-type-reinterpret-cast,\ -cppcoreguidelines-pro-type-static-cast-downcast,\ -cppcoreguidelines-pro-type-vararg,\ @@ -45,7 +39,6 @@ run-clang-tidy-18 -header-filter=\(.*\.hxx\) \ -hicpp-avoid-c-arrays,\ -hicpp-braces-around-statements,\ -hicpp-explicit-conversions,\ --hicpp-member-init,\ -hicpp-named-parameter,\ -hicpp-no-array-decay,\ -hicpp-signed-bitwise,\