Fixes for suggestions from clang-tidy; mostly missing initializations.

This commit is contained in:
Stephen Anthony 2024-08-23 20:00:44 -02:30
parent ee7190851e
commit 0849a647e3
85 changed files with 270 additions and 322 deletions

View File

@ -31,7 +31,7 @@ class BankRomCheat : public Cheat
void evaluate() override;
private:
std::array<uInt8, 16> savedRom;
std::array<uInt8, 16> savedRom{};
uInt16 address{0};
uInt8 value{0};
uInt8 count{0};

View File

@ -135,7 +135,7 @@ shared_ptr<Cheat> CheatManager::createCheat(string_view name, string_view code)
{
case 4: return make_shared<RamCheat>(myOSystem, name, code);
case 6: return make_shared<CheetahCheat>(myOSystem, name, code);
case 7: return make_shared<BankRomCheat>(myOSystem, name, code);
case 7: [[fallthrough]];
case 8: return make_shared<BankRomCheat>(myOSystem, name, code);
default: return nullptr;
}

View File

@ -31,7 +31,7 @@ class CheetahCheat : public Cheat
void evaluate() override;
private:
std::array<uInt8, 16> savedRom;
std::array<uInt8, 16> savedRom{};
uInt16 address{0};
uInt8 value{0};
uInt8 count{0};

View File

@ -47,44 +47,44 @@ class DevSettingsHandler
protected:
OSystem& myOSystem;
// Emulator sets
std::array<bool, numSets> myFrameStats;
std::array<bool, numSets> myDetectedInfo;
std::array<bool, numSets> myExternAccess;
std::array<int, numSets> myConsole;
std::array<bool, numSets> myRandomBank;
std::array<bool, numSets> myRandomizeTIA;
std::array<bool, numSets> myRandomizeRAM;
std::array<string, numSets> myRandomizeCPU;
std::array<bool, numSets> myColorLoss;
std::array<bool, numSets> myTVJitter;
std::array<int, numSets> myTVJitterSense;
std::array<int, numSets> myTVJitterRec;
std::array<bool, numSets> myDebugColors;
std::array<bool, numSets> myRandomHotspots;
std::array<bool, numSets> myUndrivenPins;
std::array<bool, numSets> myFrameStats{};
std::array<bool, numSets> myDetectedInfo{};
std::array<bool, numSets> myExternAccess{};
std::array<int, numSets> myConsole{};
std::array<bool, numSets> myRandomBank{};
std::array<bool, numSets> myRandomizeTIA{};
std::array<bool, numSets> myRandomizeRAM{};
std::array<string, numSets> myRandomizeCPU{};
std::array<bool, numSets> myColorLoss{};
std::array<bool, numSets> myTVJitter{};
std::array<int, numSets> myTVJitterSense{};
std::array<int, numSets> myTVJitterRec{};
std::array<bool, numSets> myDebugColors{};
std::array<bool, numSets> myRandomHotspots{};
std::array<bool, numSets> myUndrivenPins{};
#ifdef DEBUGGER_SUPPORT
std::array<bool, numSets> myRWPortBreak;
std::array<bool, numSets> myWRPortBreak;
std::array<bool, numSets> myRWPortBreak{};
std::array<bool, numSets> myWRPortBreak{};
#endif
std::array<bool, numSets> myThumbException;
std::array<int, numSets> myArmSpeed;
std::array<bool, numSets> myThumbException{};
std::array<int, numSets> myArmSpeed{};
// TIA sets
std::array<string, numSets> myTIAType;
std::array<bool, numSets> myPlInvPhase;
std::array<bool, numSets> myMsInvPhase;
std::array<bool, numSets> myBlInvPhase;
std::array<bool, numSets> myPFBits;
std::array<bool, numSets> myPFColor;
std::array<bool, numSets> myPFScore;
std::array<bool, numSets> myBKColor;
std::array<bool, numSets> myPlSwap;
std::array<bool, numSets> myBlSwap;
std::array<string, numSets> myTIAType{};
std::array<bool, numSets> myPlInvPhase{};
std::array<bool, numSets> myMsInvPhase{};
std::array<bool, numSets> myBlInvPhase{};
std::array<bool, numSets> myPFBits{};
std::array<bool, numSets> myPFColor{};
std::array<bool, numSets> myPFScore{};
std::array<bool, numSets> myBKColor{};
std::array<bool, numSets> myPlSwap{};
std::array<bool, numSets> myBlSwap{};
// States sets
std::array<bool, numSets> myTimeMachine;
std::array<int, numSets> myStateSize;
std::array<int, numSets> myUncompressed;
std::array<string, numSets> myStateInterval;
std::array<string, numSets> myStateHorizon;
std::array<bool, numSets> myTimeMachine{};
std::array<int, numSets> myStateSize{};
std::array<int, numSets> myUncompressed{};
std::array<string, numSets> myStateInterval{};
std::array<string, numSets> myStateHorizon{};
private:
void handleEnableDebugColors(bool enable);

View File

@ -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)
{

View File

@ -63,8 +63,9 @@ class FSNodeFactory
#endif
break;
default:
return nullptr;
break;
}
return nullptr; // satisfy compiler
}
private:

View File

@ -65,7 +65,7 @@ namespace HSM {
bool specialZeroBased{false};
string notes;
// Addresses
ScoreAddresses scoreAddr;
ScoreAddresses scoreAddr{};
uInt16 varsAddr{0};
uInt16 specialAddr{0};
};

View File

@ -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<uInt8[]> 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

View File

@ -31,7 +31,7 @@ template <typename T, size_t CAPACITY = 50>
class FixedStack
{
private:
std::array<T, CAPACITY> _stack;
std::array<T, CAPACITY> _stack{};
size_t _size{0};
public:

View File

@ -27,8 +27,7 @@ namespace {
{
const std::tm now = BSPF::localTime();
std::array<char, 100> formattedTime;
formattedTime.fill(0);
std::array<char, 100> formattedTime{};
std::ignore = std::strftime(formattedTime.data(), 99, "%H:%M:%S", &now);
return formattedTime.data();

View File

@ -18,7 +18,7 @@
#ifndef STATE_MANAGER_HXX
#define STATE_MANAGER_HXX
#define STATE_HEADER "06070020state"
#define STATE_HEADER "06070030state"
class OSystem;
class RewindManager;

View File

@ -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

View File

@ -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;

View File

@ -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,

View File

@ -154,8 +154,8 @@ class AtariNTSC
luma_cutoff = 0.20F
;
std::array<uInt8, palette_size * 3L> myRGBPalette;
BSPF::array2D<uInt32, palette_size, entry_size> myColorTable;
std::array<uInt8, palette_size * 3L> myRGBPalette{};
BSPF::array2D<uInt32, palette_size, entry_size> myColorTable{};
// Rendering threads
unique_ptr<std::thread[]> myThreads;

View File

@ -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)

View File

@ -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<bool, 16> TIARead{false};
std::array<bool, 64> TIAWrite{false};
std::array<bool, 32> IOReadWrite{false};
std::array<bool, 128> ZPRAM{false};
std::array<bool, 16> TIARead{};
std::array<bool, 64> TIAWrite{};
std::array<bool, 32> IOReadWrite{};
std::array<bool, 128> ZPRAM{};
AddrToLabel Label;
bool breakFound{false};
};

View File

@ -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

View File

@ -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<uInt16>(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

View File

@ -44,7 +44,7 @@ class TrapArray
private:
// The actual counts
std::array<uInt8, 0x10000> myCount;
std::array<uInt8, 0x10000> myCount{};
// Indicates whether we should treat this array as initialized
bool myInitialized{false};

View File

@ -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)

View File

@ -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();

View File

@ -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<string> _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};

View File

@ -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);

View File

@ -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)

View File

@ -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};

View File

@ -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<uInt32, 320> myLineBuffer;
std::array<uInt32, 320> myLineBuffer{};
private:
void handleMouseDown(int x, int y, MouseButton b, int clickCount) override;

View File

@ -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;

View File

@ -20,6 +20,8 @@
#include "YaccParser.hxx"
// NOLINTBEGIN: this entire class is due to be rewritten
namespace YaccParser {
#include <cctype>
@ -409,3 +411,5 @@ int yylex() {
}
} // namespace YaccParser
// NOLINTEND

View File

@ -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<uInt16, intervals> count; // up to 128 256 byte interval origins
std::array<uInt16, intervals> 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)

View File

@ -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<uInt8, 256> myRWPRandomValues;
std::array<uInt8, 256> myRWPRandomValues{};
// If myRandomHotspots is true, peeks to hotspots return semi-random values.
bool myRandomHotspots{false};

View File

@ -217,7 +217,7 @@ class Cartridge4A50 : public Cartridge
ByteBuffer myImage;
// The 32K of RAM on the cartridge
std::array<uInt8, 32_KB> myRAM;
std::array<uInt8, 32_KB> myRAM{};
// (Actual) Size of the ROM image
size_t mySize{0};

View File

@ -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<uInt8>(mySize / LOAD_SIZE)}
{
// Create a load image buffer and copy the given image
myLoadImages = make_unique<uInt8[]>(mySize);
myNumberOfLoadImages = static_cast<uInt8>(mySize / LOAD_SIZE);
std::copy_n(image.get(), size, myLoadImages.get());
// Add header if image doesn't include it

View File

@ -194,13 +194,13 @@ class CartridgeAR : public Cartridge
private:
// Indicates the offset within the image for the corresponding bank
std::array<uInt32, 2> myImageOffset;
std::array<uInt32, 2> myImageOffset{};
// The 6K of RAM and 2K of ROM contained in the Supercharger
std::array<uInt8, 8_KB> myImage;
std::array<uInt8, 8_KB> myImage{};
// The 256 byte header for the current 8448 byte load
std::array<uInt8, 256> myHeader;
std::array<uInt8, 256> myHeader{};
// Size of the ROM image
size_t mySize{0};

View File

@ -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<uInt8, 8_KB> myRAM;
std::array<uInt8, 8_KB> 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<uInt32, 3> myMusicCounters{0};
std::array<uInt32, 3> myMusicCounters{};
// The music frequency
std::array<uInt32, 3> myMusicFrequencies{0};
std::array<uInt32, 3> myMusicFrequencies{};
// The music waveform sizes
std::array<uInt8, 3> myMusicWaveformSize{0};
std::array<uInt8, 3> myMusicWaveformSize{};
// Fractional DPC music OSC clocks unused during the last update
double myFractionalClocks{0.0};

View File

@ -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

View File

@ -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<uInt8, 32_KB> myRAM;
std::array<uInt8, 32_KB> myRAM{};
// Indicates the offset into the ROM image (aligns to current bank)
uInt16 myBankOffset{0};

View File

@ -515,7 +515,7 @@ void CartridgeCTY::loadScore(uInt8 index)
const Serializer serializer(myEEPROMFile, Serializer::Mode::ReadOnly);
if(serializer)
{
std::array<uInt8, 256> scoreRAM;
std::array<uInt8, 256> scoreRAM{};
try
{
serializer.getByteArray(scoreRAM.data(), scoreRAM.size());
@ -537,7 +537,7 @@ void CartridgeCTY::saveScore(uInt8 index)
if(serializer)
{
// Load score RAM
std::array<uInt8, 256> scoreRAM;
std::array<uInt8, 256> scoreRAM{};
try
{
serializer.getByteArray(scoreRAM.data(), scoreRAM.size());
@ -571,7 +571,7 @@ void CartridgeCTY::wipeAllScores()
if(serializer)
{
// Erase score RAM
std::array<uInt8, 256> scoreRAM = {};
std::array<uInt8, 256> scoreRAM{};
try
{
serializer.putByteArray(scoreRAM.data(), scoreRAM.size());

View File

@ -274,10 +274,10 @@ class CartridgeCTY : public Cartridge
ByteBuffer myImage;
// The 28K ROM image of the music
std::array<uInt8, 28_KB> myTuneData;
std::array<uInt8, 28_KB> myTuneData{};
// The 64 bytes of RAM accessible at $1000 - $1080
std::array<uInt8, 64> myRAM;
std::array<uInt8, 64> 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<uInt32, 3> myMusicCounters{0};
std::array<uInt32, 3> myMusicCounters{};
// The music frequency
std::array<uInt32, 3> myMusicFrequencies{0};
std::array<uInt32, 3> myMusicFrequencies{};
// Flags that last byte peeked was A9 (LDA #)
bool myLDAimmediate{false};

View File

@ -235,25 +235,25 @@ class CartridgeDPCPlus : public CartridgeARM
// 3K DPC+ driver
// 4K Display Data
// 1K Frequency Data
std::array<uInt8, 8_KB> myDPCRAM;
std::array<uInt8, 8_KB> myDPCRAM{};
// Pointer to the 1K frequency table
uInt8* myFrequencyImage{nullptr};
// The top registers for the data fetchers
std::array<uInt8, 8> myTops;
std::array<uInt8, 8> myTops{};
// The bottom registers for the data fetchers
std::array<uInt8, 8> myBottoms;
std::array<uInt8, 8> myBottoms{};
// The counter registers for the data fetchers
std::array<uInt16, 8> myCounters;
std::array<uInt16, 8> myCounters{};
// The counter registers for the fractional data fetchers
std::array<uInt32, 8> myFractionalCounters;
std::array<uInt32, 8> myFractionalCounters{};
// The fractional increments for the data fetchers
std::array<uInt8, 8> myFractionalIncrements;
std::array<uInt8, 8> 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<uInt8, 8> myParameter;
std::array<uInt8, 8> myParameter{};
// Parameter pointer for special functions
uInt8 myParameterPointer{0};
// The music mode counters
std::array<uInt32, 3> myMusicCounters;
std::array<uInt32, 3> myMusicCounters{};
// The music frequency
std::array<uInt32, 3> myMusicFrequencies;
std::array<uInt32, 3> myMusicFrequencies{};
// The music waveforms
std::array<uInt16, 3> myMusicWaveforms;
std::array<uInt16, 3> myMusicWaveforms{};
// The random number generator register
uInt32 myRandomNumber{1};

View File

@ -259,10 +259,10 @@ class CartridgeE7 : public Cartridge
size_t mySize{0};
// The 2K of RAM
std::array<uInt8, RAM_SIZE> myRAM;
std::array<uInt8, RAM_SIZE> myRAM{};
// Indicates which bank is in the segment
std::array<uInt16, NUM_SEGMENTS> myCurrentBank;
std::array<uInt16, NUM_SEGMENTS> myCurrentBank{};
// Indicates which 256 byte bank of RAM is being used
uInt16 myCurrentRAM{0};

View File

@ -411,7 +411,7 @@ std::pair<unique_ptr<uInt8[]>, 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);

View File

@ -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<uInt8, CartridgeMVC::MVC_FIELD_SIZE> myBuffer1;
std::array<uInt8, CartridgeMVC::MVC_FIELD_SIZE> myBuffer2;
std::array<uInt8, CartridgeMVC::MVC_FIELD_SIZE> myBuffer1{};
std::array<uInt8, CartridgeMVC::MVC_FIELD_SIZE> 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<uInt8, 1_KB> myROM;
std::array<uInt8, 1_KB> myROM{};
// title screen state
int myTitleCycles{0};

View File

@ -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<MovieCart> myMovie;

View File

@ -116,9 +116,10 @@ Console::Console(OSystem& osystem, unique_ptr<Cartridge>& 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<EmulationTiming>();
myCart->setProperties(&myProperties);
@ -170,9 +171,6 @@ Console::Console(OSystem& osystem, unique_ptr<Cartridge>& cart,
myDevSettingsHandler = make_unique<DevSettingsHandler>(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<Cartridge>& cart,
myOSystem.sound().pause(true);
myOSystem.frameBuffer().clear();
string autodetected;
if(myDisplayFormat == "AUTO" || myOSystem.settings().getBool("rominfo"))
{
autodetectFrameLayout();

View File

@ -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<EmulationTiming> myEmulationTiming;
// The audio settings
AudioSettings& myAudioSettings;
private:
// Following constructors and assignment operators not supported
Console() = delete;

View File

@ -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;

View File

@ -551,9 +551,8 @@ string CortexM0::describeError(err_t err) {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CortexM0::CortexM0()
: myPageMap{make_unique<uInt8[]>(PAGEMAP_SIZE)}
{
myPageMap = make_unique<uInt8[]>(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();

View File

@ -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<uInt32, 16> reg_norm; // normal execution mode, do not have a thread mode
std::array<uInt32, 16> reg_norm{}; // normal execution mode, do not have a thread mode
uInt32 znFlags{0};
uInt32 cFlag{0};
uInt32 vFlag{0};
std::array<MemoryRegion, 0x100> myRegions;
std::array<MemoryRegion, 0x100> myRegions{};
unique_ptr<uInt8[]> myPageMap;
uInt8 myNextRegionIndex{0};
BusTransactionDelegate* myDefaultDelegate{nullptr};

View File

@ -200,7 +200,7 @@ class Event
/**
Create a new event object.
*/
Event() { clear(); }
Event() { clear(); } // NOLINT: myValues is initialized in clear()
~Event() = default;
public:

View File

@ -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);

View File

@ -549,7 +549,7 @@ class EventHandler
;
// The event(s) assigned to each combination event
BSPF::array2D<Event::Type, COMBO_SIZE, EVENTS_PER_COMBO> myComboTable;
BSPF::array2D<Event::Type, COMBO_SIZE, EVENTS_PER_COMBO> myComboTable{};
// Holds static strings for the remap menu (emulation and menu events)
using EmulActionList = std::array<ActionList, EMUL_ACTIONLIST_SIZE>;

View File

@ -190,7 +190,7 @@ class M6532 : public Device
const Settings& mySettings;
// An amazing 128 bytes of RAM
std::array<uInt8, 128> myRAM;
std::array<uInt8, 128> 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<uInt8, 4> myOutTimer{0};
std::array<uInt8, 4> 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<Device::AccessFlags, RAM_SIZE> myRAMAccessBase;
std::array<Device::AccessFlags, STACK_SIZE> myStackAccessBase;
std::array<Device::AccessFlags, IO_SIZE> myIOAccessBase;
std::array<Device::AccessFlags, RAM_SIZE> myRAMAccessBase{};
std::array<Device::AccessFlags, STACK_SIZE> myStackAccessBase{};
std::array<Device::AccessFlags, IO_SIZE> myIOAccessBase{};
// The arrays containing information about every byte of RIOT
// indicating how often it is accessed.
std::array<Device::AccessCounter,
static_cast<size_t>(RAM_SIZE * 2)> myRAMAccessCounter;
static_cast<size_t>(RAM_SIZE * 2)> myRAMAccessCounter{};
std::array<Device::AccessCounter,
static_cast<size_t>(STACK_SIZE * 2)> myStackAccessCounter;
static_cast<size_t>(STACK_SIZE * 2)> myStackAccessCounter{};
std::array<Device::AccessCounter,
static_cast<size_t>(IO_SIZE * 2)> myIOAccessCounter;
static_cast<size_t>(IO_SIZE * 2)> myIOAccessCounter{};
// The array used to skip the first ZP access tracking
std::array<uInt8, RAM_SIZE> myZPAccessDelay;
std::array<uInt8, RAM_SIZE> myZPAccessDelay{};
// Detect timer being accessed on wraparound
bool myTimWrappedOnRead{false};

View File

@ -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<uInt32, 16> x;
std::array<uInt32, 16> 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<uInt8, BLOCKSIZE> 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<uInt8, BLOCKSIZE> padding = { 0x80 };
if (!finalized)
{
// Save number of bits
std::array<uInt8, 8> bits;
std::array<uInt8, 8> bits{};
encode(bits.data(), count.data(), 8);
// Pad out to 56 mod 64

View File

@ -122,10 +122,10 @@ class MD5
private:
static constexpr uInt32 BLOCKSIZE = 64;
bool finalized{false};
std::array<uInt8, BLOCKSIZE> buffer; // bytes that didn't fit in last chunk
std::array<uInt32, 2> count; // 64bit counter for number of bits (lo, hi)
std::array<uInt32, 4> state; // digest so far
std::array<uInt8, 16> digest; // the result
std::array<uInt8, BLOCKSIZE> buffer{}; // bytes that didn't fit in last chunk
std::array<uInt32, 2> count{}; // 64bit counter for number of bits (lo, hi)
std::array<uInt32, 4> state{}; // digest so far
std::array<uInt8, 16> digest{}; // the result
private:
MD5(const MD5&) = delete;

View File

@ -96,7 +96,7 @@ class MT24LC256
ByteBuffer myData;
// Track which pages are used
std::array<bool, PAGE_NUM> myPageHit;
std::array<bool, PAGE_NUM> 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<uInt8, 70> jpee_packet;
std::array<uInt8, 70> jpee_packet{};
private:
// Following constructors and assignment operators not supported

View File

@ -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<uInt8, 256> myRequest;
std::array<uInt8, 256> 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())

View File

@ -178,7 +178,7 @@ class PlusROM : public Serializable
string myHost;
string myPath;
std::array<uInt8, 256> myRxBuffer, myTxBuffer;
std::array<uInt8, 256> myRxBuffer{}, myTxBuffer{};
uInt8 myRxReadPos{0}, myRxWritePos{0}, myTxPos{0};
std::deque<shared_ptr<PlusROMRequest>> myPendingRequests;

View File

@ -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);
}

View File

@ -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();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -430,7 +430,7 @@ class System : public Serializable
std::array<PageAccess, NUM_PAGES> myPageAccessTable;
// The list of dirty pages
std::array<bool, NUM_PAGES> myPageIsDirtyTable;
std::array<bool, NUM_PAGES> myPageIsDirtyTable{};
// The current state of the Data Bus
uInt8 myDataBusState{0};

View File

@ -248,17 +248,17 @@ class TIASurface
std::array<uInt32, static_cast<std::size_t>
(AtariNTSC::outWidth(TIAConstants::frameBufferWidth) *
TIAConstants::frameBufferHeight)> myRGBFramebuffer;
TIAConstants::frameBufferHeight)> myRGBFramebuffer{};
std::array<uInt32, static_cast<std::size_t>
(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};

View File

@ -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;

View File

@ -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<Op[]> decodedRom; // NOLINT
const unique_ptr<uInt32[]> decodedParam; // NOLINT
uInt16* ram{nullptr};
std::array<uInt32, 16> reg_norm; // normal execution mode, do not have a thread mode
std::array<uInt32, 16> reg_norm{}; // normal execution mode, do not have a thread mode
uInt32 znFlags{0};
uInt32 cFlag{0};
uInt32 vFlag{0};

View File

@ -60,7 +60,7 @@ class ElfLinker {
enum class SegmentType: uInt8 { text, data, rodata };
struct RelocatedSection {
SegmentType segment;
SegmentType segment{};
uInt32 offset{0};
};

View File

@ -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};

View File

@ -73,8 +73,8 @@ class Audio : public Serializable
uInt32 mySumChannel1{0};
uInt32 mySumCt{0};
std::array<Int16, 0x1e + 1> myMixingTableSum;
std::array<Int16, 0x0f + 1> myMixingTableIndividual;
std::array<Int16, 0x1e + 1> myMixingTableSum{};
std::array<Int16, 0x0f + 1> myMixingTableIndividual{};
Int16* myCurrentFragment{nullptr};
uInt32 mySampleIndex{0};

View File

@ -53,7 +53,7 @@ class DelayQueue : public Serializable
private:
std::array<DelayQueueMember<capacity>, length> myMembers;
uInt8 myIndex{0};
std::array<uInt8, 0xFF> myIndices;
std::array<uInt8, 0xFF> myIndices{};
private:
DelayQueue(const DelayQueue&) = delete;

View File

@ -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;

View File

@ -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<FixedColor, 3, 7> myFixedColorPalette;
std::array<string, 7> myFixedColorNames;
BSPF::array2D<FixedColor, 3, 7> myFixedColorPalette{};
std::array<string, 7> myFixedColorNames{};
private:
/**
@ -840,12 +840,12 @@ class TIA : public Device
LatchedInput myInput1;
// Pointer to the internal color-index-based frame buffer
std::array<uInt8, static_cast<size_t>(TIAConstants::H_PIXEL * TIAConstants::frameBufferHeight)> myFramebuffer;
std::array<uInt8, static_cast<size_t>(TIAConstants::H_PIXEL * TIAConstants::frameBufferHeight)> myFramebuffer{};
// The frame is rendered to the backbuffer and only copied to the framebuffer
// upon completion
std::array<uInt8, static_cast<size_t>(TIAConstants::H_PIXEL * TIAConstants::frameBufferHeight)> myBackBuffer;
std::array<uInt8, static_cast<size_t>(TIAConstants::H_PIXEL * TIAConstants::frameBufferHeight)> myFrontBuffer;
std::array<uInt8, static_cast<size_t>(TIAConstants::H_PIXEL * TIAConstants::frameBufferHeight)> myBackBuffer{};
std::array<uInt8, static_cast<size_t>(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<uInt8, 64> myShadowRegisters;
std::array<uInt8, 64> 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<Device::AccessFlags, TIA_SIZE> myAccessBase;
std::array<Device::AccessFlags, TIA_SIZE> myAccessBase{};
// The arrays containing information about every byte of TIA
// indicating how often it is accessed (read and write).
std::array<Device::AccessCounter, TIA_SIZE + TIA_READ_SIZE> myAccessCounter;
std::array<Device::AccessCounter, TIA_SIZE + TIA_READ_SIZE> myAccessCounter{};
// The array used to skip the first two TIA access trackings
std::array<uInt8, TIA_SIZE> myAccessDelay;
std::array<uInt8, TIA_SIZE> myAccessDelay{};
#endif // DEBUGGER_SUPPORT
private:

View File

@ -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,

View File

@ -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<Dialog*>(parent);
const auto* parentDialog = static_cast<Dialog*>(parent);
if (parentDialog) {
parentDialog->getDynamicBounds(w, h);
} else {

View File

@ -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);

View File

@ -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

View File

@ -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;

View File

@ -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)
{

View File

@ -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);

View File

@ -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();
}

View File

@ -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;
}

View File

@ -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;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -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);
}

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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,\