Fix warning from clang-tidy.

This commit is contained in:
Stephen Anthony 2025-04-19 16:11:51 -02:30
parent 709237c79c
commit 7b5c19ff5e
52 changed files with 190 additions and 187 deletions

View File

@ -33,7 +33,7 @@ BankRomCheat::BankRomCheat(OSystem& os, string_view name, string_view code)
count = static_cast<uInt8>(BSPF::stoi<16>(myCode.substr(7, 1)) + 1);
// Back up original data; we need this if the cheat is ever disabled
for(int i = 0; i < count; ++i)
for(int i = 0; std::cmp_less(i, count); ++i)
savedRom[i] = myOSystem.console().cartridge().peek(address + i);
}
@ -50,7 +50,7 @@ bool BankRomCheat::disable()
const int oldBank = myOSystem.console().cartridge().getBank(address);
myOSystem.console().cartridge().bank(bank);
for(int i = 0; i < count; ++i)
for(int i = 0; std::cmp_less(i, count); ++i)
myOSystem.console().cartridge().patch(address + i, savedRom[i]);
myOSystem.console().cartridge().bank(oldBank);
@ -66,7 +66,7 @@ void BankRomCheat::evaluate()
const int oldBank = myOSystem.console().cartridge().getBank(address);
myOSystem.console().cartridge().bank(bank);
for(int i = 0; i < count; ++i)
for(int i = 0; std::cmp_less(i, count); ++i)
myOSystem.console().cartridge().patch(address + i, value);
myOSystem.console().cartridge().bank(oldBank);

View File

@ -28,7 +28,7 @@ CheetahCheat::CheetahCheat(OSystem& os, string_view name, string_view code)
count{static_cast<uInt8>(BSPF::stoi<16>(code.substr(5, 1)) + 1)}
{
// Back up original data; we need this if the cheat is ever disabled
for(int i = 0; i < count; ++i)
for(uInt8 i = 0; i < count; ++i)
savedRom[i] = myOSystem.console().cartridge().peek(address + i);
}
@ -42,7 +42,7 @@ bool CheetahCheat::enable()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CheetahCheat::disable()
{
for(int i = 0; i < count; ++i)
for(uInt8 i = 0; i < count; ++i)
myOSystem.console().cartridge().patch(address + i, savedRom[i]);
return myEnabled = false;
@ -53,7 +53,7 @@ void CheetahCheat::evaluate()
{
if(!myEnabled)
{
for(int i = 0; i < count; ++i)
for(uInt8 i = 0; i < count; ++i)
myOSystem.console().cartridge().patch(address + i, value);
myEnabled = true;

View File

@ -287,8 +287,9 @@ bool FBBackendSDL2::setVideoMode(const VideoModeHandler::Mode& mode,
int w{0}, h{0};
SDL_GetWindowSize(myWindow, &w, &h);
if(d != displayIndex || static_cast<uInt32>(w) != mode.screenS.w ||
static_cast<uInt32>(h) != mode.screenS.h || adaptRefresh)
if(d != displayIndex ||
std::cmp_not_equal(w, mode.screenS.w) ||
std::cmp_not_equal(h, mode.screenS.h) || adaptRefresh)
{
// Renderer has to be destroyed *before* the window gets destroyed to avoid memory leaks
SDL_DestroyRenderer(myRenderer);

View File

@ -70,7 +70,7 @@ class FBSurfaceSDL2 : public FBSurface
private:
bool setSrcPosInternal(uInt32 x, uInt32 y) {
if(x != static_cast<uInt32>(mySrcR.x) || y != static_cast<uInt32>(mySrcR.y))
if(std::cmp_not_equal(x, mySrcR.x) || std::cmp_not_equal(y, mySrcR.y))
{
mySrcR.x = x; mySrcR.y = y;
mySrcGUIR.moveTo(x, y);
@ -79,7 +79,7 @@ class FBSurfaceSDL2 : public FBSurface
return false;
}
bool setSrcSizeInternal(uInt32 w, uInt32 h) {
if(w != static_cast<uInt32>(mySrcR.w) || h != static_cast<uInt32>(mySrcR.h))
if(std::cmp_not_equal(w, mySrcR.w) || std::cmp_not_equal(h, mySrcR.h))
{
mySrcR.w = w; mySrcR.h = h;
mySrcGUIR.setWidth(w); mySrcGUIR.setHeight(h);
@ -88,7 +88,7 @@ class FBSurfaceSDL2 : public FBSurface
return false;
}
bool setDstPosInternal(uInt32 x, uInt32 y) {
if(x != static_cast<uInt32>(myDstR.x) || y != static_cast<uInt32>(myDstR.y))
if(std::cmp_not_equal(x, myDstR.x) || std::cmp_not_equal(y, myDstR.y))
{
myDstR.x = x; myDstR.y = y;
myDstGUIR.moveTo(x, y);
@ -97,7 +97,7 @@ class FBSurfaceSDL2 : public FBSurface
return false;
}
bool setDstSizeInternal(uInt32 w, uInt32 h) {
if(w != static_cast<uInt32>(myDstR.w) || h != static_cast<uInt32>(myDstR.h))
if(std::cmp_not_equal(w, myDstR.w) || std::cmp_not_equal(h, myDstR.h))
{
myDstR.w = w; myDstR.h = h;
myDstGUIR.setWidth(w); myDstGUIR.setHeight(h);

View File

@ -488,8 +488,7 @@ void SoundSDL2::WavHandlerSDL2::processWav(uInt8* stream, uInt32 len)
SDL_assert(cvt.needed); // Obviously, this one is always needed.
cvt.len = len * mySpec.channels; // Mono 8 bit sample frames
if(!myCvtBuffer ||
myCvtBufferSize < static_cast<uInt32>(cvt.len * cvt.len_mult))
if(!myCvtBuffer || std::cmp_less(myCvtBufferSize, cvt.len * cvt.len_mult))
{
myCvtBufferSize = cvt.len * cvt.len_mult;
myCvtBuffer = make_unique<uInt8[]>(myCvtBufferSize);

View File

@ -116,7 +116,9 @@ void StaggeredLogger::startInterval()
Int64 msecSinceLastIntervalEnd =
duration_cast<duration<Int64, std::milli>>(now - myLastIntervalEndTimestamp).count();
while (msecSinceLastIntervalEnd > myCooldownTime && myCurrentIntervalFactor > 1) {
while (std::cmp_greater(msecSinceLastIntervalEnd, myCooldownTime) &&
myCurrentIntervalFactor > 1)
{
msecSinceLastIntervalEnd -= myCooldownTime;
decreaseInterval();
}

View File

@ -634,6 +634,7 @@ string CartDebug::uniqueLabel(const string& label)
string uniqueLabel = label;
int count = 0;
// TODO: does find return multiple items??
while(myUserAddresses.find(uniqueLabel) != myUserAddresses.end())
uniqueLabel = label + "." + std::to_string(++count);
@ -1113,7 +1114,7 @@ string CartDebug::saveDisassembly(string path)
// prepare for switching banks
uInt32 origin = 0;
for(int bank = 0; bank < romBankCount; ++bank)
for(int bank = 0; std::cmp_less(bank, romBankCount); ++bank)
{
// TODO: not every CartDebugWidget does it like that, we need a method
cart.unlockHotspots();

View File

@ -107,7 +107,7 @@ string DebuggerParser::run(string_view command)
getArgs(command, verb);
commandResult.str("");
for(int i = 0; i < static_cast<int>(commands.size()); ++i)
for(int i = 0; std::cmp_less(i, commands.size()); ++i)
{
if(BSPF::equalsIgnoreCase(verb, commands[i].cmdString))
{
@ -205,31 +205,31 @@ int DebuggerParser::decipher_arg(string_view str)
bin=false; dec=false;
}
if(arg.substr(0, 1) == "*") {
if(arg.starts_with("*")) {
derefByte = true;
arg.erase(0, 1);
} else if(arg.substr(0, 1) == "@") {
} else if(arg.starts_with("@")) {
derefWord = true;
arg.erase(0, 1);
}
if(arg.substr(0, 1) == "<") {
if(arg.starts_with("<")) {
lobyte = true;
arg.erase(0, 1);
} else if(arg.substr(0, 1) == ">") {
} else if(arg.starts_with(">")) {
hibyte = true;
arg.erase(0, 1);
}
if(arg.substr(0, 1) == "\\") {
if(arg.starts_with("\\")) {
dec = false;
bin = true;
arg.erase(0, 1);
} else if(arg.substr(0, 1) == "#") {
} else if(arg.starts_with("#")) {
dec = true;
bin = false;
arg.erase(0, 1);
} else if(arg.substr(0, 1) == "$") {
} else if(arg.starts_with("$")) {
dec = false;
bin = false;
arg.erase(0, 1);
@ -1212,7 +1212,7 @@ void DebuggerParser::executeDelTrap()
void DebuggerParser::executeDelWatch()
{
const int which = args[0] - 1;
if(which >= 0 && which < static_cast<int>(myWatches.size()))
if(which >= 0 && std::cmp_less(which, myWatches.size()))
{
Vec::removeAt(myWatches, which);
commandResult << "removed watch";
@ -2028,7 +2028,7 @@ void DebuggerParser::executeRunToPc()
// Update romlist to point to current PC
const int pcline = cartdbg.addressToLine(debugger.cpuDebug().pc());
done = (pcline >= 0) && (list[pcline].address == args[0]);
done = (pcline >= 0) && std::cmp_equal(list[pcline].address, args[0]);
progress.incProgress();
++count;
} while(!done && !progress.isCancelled());
@ -2365,7 +2365,7 @@ void DebuggerParser::executeTimer()
for(uInt32 i = 0; i < argCount; ++i)
{
if(static_cast<uInt32>(args[i]) >= std::max(0x80U, romBankCount - 1))
if(std::cmp_greater_equal(args[i], std::max(0x80U, romBankCount - 1)))
{
if(numAddrs == 2)
{
@ -2381,7 +2381,7 @@ void DebuggerParser::executeTimer()
outputCommandError("too many bank arguments", myCommand);
return;
}
if(static_cast<uInt32>(args[i]) >= romBankCount)
if(std::cmp_greater_equal(args[i], romBankCount))
{
commandResult << red("invalid bank");
return;

View File

@ -73,7 +73,7 @@ DiStella::DiStella(const CartDebug& dbg, CartDebug::DisassemblyList& list,
// Add reserved line equates
ostringstream reservedLabel;
for (int k = 0; k <= myAppData.end; k++) {
for (int k = 0; std::cmp_less_equal(k, myAppData.end); k++) {
if ((myLabels[k] & (Device::REFERENCED | Device::VALID_ENTRY)) == Device::REFERENCED) {
// If we have a piece of code referenced somewhere else, but cannot
// locate the label in code (i.e because the address is inside of a
@ -718,7 +718,7 @@ void DiStella::disasmPass1(CartDebug::AddressList& debuggerAddresses)
// Stella itself can provide hints on whether an address has ever
// been referenced as CODE
while (myAddressQueue.empty() && codeAccessPoint <= myAppData.end) {
while (myAddressQueue.empty() && std::cmp_less_equal(codeAccessPoint, myAppData.end)) {
if ((Debugger::debugger().getAccessFlags(codeAccessPoint + myOffset) & Device::CODE)
&& !(myLabels[codeAccessPoint & myAppData.end] & Device::CODE)) {
myAddressQueue.push(codeAccessPoint + myOffset);
@ -730,7 +730,7 @@ void DiStella::disasmPass1(CartDebug::AddressList& debuggerAddresses)
duplicateFound = !myAddressQueue.empty() && (myAddressQueue.front() == lastPC); // TODO: check!
} // while
for (int k = 0; k <= myAppData.end; k++) {
for (int k = 0; std::cmp_less_equal(k, myAppData.end); k++) {
// Let the emulation core know about tentative code
if (checkBit(k, Device::CODE) &&
!(Debugger::debugger().getAccessFlags(k + myOffset) & Device::CODE)
@ -938,8 +938,8 @@ DiStella::AddressType DiStella::mark(uInt32 address, uInt16 mask, bool directive
else if(type == CartDebug::AddrType::ZPRAM && myOffset != 0) {
return AddressType::ZP_RAM;
}
else if(address >= static_cast<uInt32>(myOffset) &&
address <= static_cast<uInt32>(myAppData.end + myOffset)) {
else if(std::cmp_greater_equal(address, myOffset) &&
std::cmp_less_equal(address, myAppData.end + myOffset)) {
myLabels[address - myOffset] = myLabels[address - myOffset] | mask;
if(directive)
myDirectives[address - myOffset] = mask;

View File

@ -1190,7 +1190,7 @@ string TIADebug::toString()
// build up output, then return it.
buf << std::setfill(' ') << std::left
<< decWithLabel("scanline", myTIA.scanlines(),
static_cast<int>(myTIA.scanlines()) != oldState.info[4]) << " "
std::cmp_not_equal(myTIA.scanlines(), oldState.info[4])) << " "
<< boolWithLabel("vsync", vsync(),
state.vsb[0] != oldState.vsb[0]) << " "
<< boolWithLabel("vblank", vblank(),

View File

@ -162,8 +162,9 @@ void Cartridge3EPlusWidget::handleCommand(CommandSender* sender,
const bool isROM = myBankType[segment]->getSelectedTag() == "ROM";
const int bank = myBankWidgets[segment]->getSelected();
myBankCommit[segment]->setEnabled((isROM && bank < myCart.romBankCount())
|| (!isROM && bank < myCart.ramBankCount()));
myBankCommit[segment]->setEnabled(
(isROM && std::cmp_less(bank, myCart.romBankCount())) ||
(!isROM && std::cmp_less(bank, myCart.ramBankCount())));
break;
}
case kChangeBank:
@ -197,7 +198,7 @@ void Cartridge3EPlusWidget::updateUIState()
{
// Set description for each 1K segment state (@ each index)
// Set contents for actual banks number and type (@ each even index)
for(int seg = 0; seg < myCart3EP.myBankSegs; ++seg)
for(int seg = 0; std::cmp_less(seg, myCart3EP.myBankSegs); ++seg)
{
const uInt16 bank = myCart.getSegmentBank(seg);
const size_t bank_off = static_cast<size_t>(seg) * 2;

View File

@ -367,8 +367,8 @@ void CartridgeBUSWidget::loadConfig()
for(int i = 0; i < 3; ++i)
{
alist.push_back(0); vlist.push_back(myCart.myMusicCounters[i]);
changed.push_back(myCart.myMusicCounters[i] !=
static_cast<uInt32>(myOldState.mcounters[i]));
changed.push_back(std::cmp_not_equal(myCart.myMusicCounters[i],
myOldState.mcounters[i]));
}
myMusicCounters->setList(alist, vlist, changed);
@ -376,8 +376,8 @@ void CartridgeBUSWidget::loadConfig()
for(int i = 0; i < 3; ++i)
{
alist.push_back(0); vlist.push_back(myCart.myMusicFrequencies[i]);
changed.push_back(myCart.myMusicFrequencies[i] !=
static_cast<uInt32>(myOldState.mfreqs[i]));
changed.push_back(std::cmp_not_equal(myCart.myMusicFrequencies[i],
myOldState.mfreqs[i]));
}
myMusicFrequencies->setList(alist, vlist, changed);
@ -385,8 +385,8 @@ void CartridgeBUSWidget::loadConfig()
for(int i = 0; i < 3; ++i)
{
alist.push_back(0); vlist.push_back(myCart.getWaveform(i) >> 5);
changed.push_back((myCart.getWaveform(i) >> 5) !=
static_cast<uInt32>(myOldState.mwaves[i]));
changed.push_back(std::cmp_not_equal(myCart.getWaveform(i) >> 5,
myOldState.mwaves[i]));
}
myMusicWaveforms->setList(alist, vlist, changed);
@ -394,8 +394,8 @@ void CartridgeBUSWidget::loadConfig()
for(int i = 0; i < 3; ++i)
{
alist.push_back(0); vlist.push_back(myCart.getWaveformSize(i));
changed.push_back((myCart.getWaveformSize(i)) !=
static_cast<uInt32>(myOldState.mwavesizes[i]));
changed.push_back(std::cmp_not_equal(myCart.getWaveformSize(i),
myOldState.mwavesizes[i]));
}
myMusicWaveformSizes->setList(alist, vlist, changed);
@ -403,8 +403,8 @@ void CartridgeBUSWidget::loadConfig()
{
alist.clear(); vlist.clear(); changed.clear();
alist.push_back(0); vlist.push_back(myCart.getSample());
changed.push_back((myCart.getSample()) !=
static_cast<uInt32>(myOldState.samplepointer[0]));
changed.push_back(std::cmp_not_equal(myCart.getSample(),
myOldState.samplepointer[0]));
mySamplePointer->setList(alist, vlist, changed);
}

View File

@ -234,7 +234,7 @@ void CartridgeCDFWidget::saveOldState()
if (isCDFJplus())
myOldState.fastfetchoffset.push_back(myCart.myRAM[myCart.myFastFetcherOffset]);
for(uInt32 i = 0; i < static_cast<uInt32>((isCDFJ() || isCDFJplus()) ? 35 : 34); ++i)
for(uInt32 i = 0; i < (isCDFJ() || isCDFJplus() ? 35U : 34U); ++i)
{
// Pointers are stored as:
// PPPFF---
@ -319,7 +319,7 @@ void CartridgeCDFWidget::loadConfig()
alist.clear(); vlist.clear(); changed.clear();
alist.push_back(0);
vlist.push_back(myCart.getDatastreamPointer(0x20) >> ds_shift);
changed.push_back(static_cast<Int32>(myCart.getDatastreamPointer(0x20)) != myOldState.datastreampointers[0x20]);
changed.push_back(std::cmp_not_equal(myCart.getDatastreamPointer(0x20), myOldState.datastreampointers[0x20]));
myCommandStreamPointer->setList(alist, vlist, changed);
alist.clear(); vlist.clear(); changed.clear();
@ -343,7 +343,7 @@ void CartridgeCDFWidget::loadConfig()
alist.clear(); vlist.clear(); changed.clear();
alist.push_back(0);
vlist.push_back(myCart.getDatastreamIncrement(0x20));
changed.push_back(static_cast<Int32>(myCart.getDatastreamIncrement(0x20)) != myOldState.datastreamincrements[0x20]);
changed.push_back(std::cmp_not_equal(myCart.getDatastreamIncrement(0x20), myOldState.datastreamincrements[0x20]));
myCommandStreamIncrement->setList(alist, vlist, changed);
alist.clear(); vlist.clear(); changed.clear();
@ -359,8 +359,8 @@ void CartridgeCDFWidget::loadConfig()
for(int i = 0; i < 3; ++i)
{
alist.push_back(0); vlist.push_back(myCart.myMusicCounters[i]);
changed.push_back(myCart.myMusicCounters[i] !=
static_cast<uInt32>(myOldState.mcounters[i]));
changed.push_back(std::cmp_not_equal(myCart.myMusicCounters[i],
myOldState.mcounters[i]));
}
myMusicCounters->setList(alist, vlist, changed);
@ -368,8 +368,8 @@ void CartridgeCDFWidget::loadConfig()
for(int i = 0; i < 3; ++i)
{
alist.push_back(0); vlist.push_back(myCart.myMusicFrequencies[i]);
changed.push_back(myCart.myMusicFrequencies[i] !=
static_cast<uInt32>(myOldState.mfreqs[i]));
changed.push_back(std::cmp_not_equal(myCart.myMusicFrequencies[i],
myOldState.mfreqs[i]));
}
myMusicFrequencies->setList(alist, vlist, changed);
@ -377,8 +377,8 @@ void CartridgeCDFWidget::loadConfig()
for(int i = 0; i < 3; ++i)
{
alist.push_back(0); vlist.push_back(myCart.getWaveform(i) >> 5);
changed.push_back((myCart.getWaveform(i) >> 5) !=
static_cast<uInt32>(myOldState.mwaves[i]));
changed.push_back(std::cmp_not_equal(myCart.getWaveform(i) >> 5,
myOldState.mwaves[i]));
}
myMusicWaveforms->setList(alist, vlist, changed);
@ -386,15 +386,15 @@ void CartridgeCDFWidget::loadConfig()
for(int i = 0; i < 3; ++i)
{
alist.push_back(0); vlist.push_back(myCart.getWaveformSize(i));
changed.push_back((myCart.getWaveformSize(i)) !=
static_cast<uInt32>(myOldState.mwavesizes[i]));
changed.push_back(std::cmp_not_equal(myCart.getWaveformSize(i),
myOldState.mwavesizes[i]));
}
myMusicWaveformSizes->setList(alist, vlist, changed);
alist.clear(); vlist.clear(); changed.clear();
alist.push_back(0); vlist.push_back(myCart.getSample());
changed.push_back((myCart.getSample()) !=
static_cast<uInt32>(myOldState.samplepointer[0]));
changed.push_back(std::cmp_not_equal(myCart.getSample(),
myOldState.samplepointer[0]));
mySamplePointer->setList(alist, vlist, changed);
myFastFetch->setState((myCart.myMode & 0x0f) == 0);

View File

@ -253,7 +253,7 @@ void CartridgeDPCPlusWidget::loadConfig()
for(int i = 0; i < 8; ++i)
{
alist.push_back(0); vlist.push_back(myCart.myCounters[i]);
changed.push_back(myCart.myCounters[i] != myOldState.counters[i]);
changed.push_back(std::cmp_not_equal(myCart.myCounters[i], myOldState.counters[i]));
}
myCounters->setList(alist, vlist, changed);
@ -261,8 +261,8 @@ void CartridgeDPCPlusWidget::loadConfig()
for(int i = 0; i < 8; ++i)
{
alist.push_back(0); vlist.push_back(myCart.myFractionalCounters[i]);
changed.push_back(myCart.myFractionalCounters[i] !=
static_cast<uInt32>(myOldState.fraccounters[i]));
changed.push_back(std::cmp_not_equal(myCart.myFractionalCounters[i],
myOldState.fraccounters[i]));
}
myFracCounters->setList(alist, vlist, changed);
@ -286,8 +286,8 @@ void CartridgeDPCPlusWidget::loadConfig()
for(int i = 0; i < 3; ++i)
{
alist.push_back(0); vlist.push_back(myCart.myMusicCounters[i]);
changed.push_back(myCart.myMusicCounters[i] !=
static_cast<uInt32>(myOldState.mcounters[i]));
changed.push_back(std::cmp_not_equal(myCart.myMusicCounters[i],
myOldState.mcounters[i]));
}
myMusicCounters->setList(alist, vlist, changed);
@ -295,8 +295,8 @@ void CartridgeDPCPlusWidget::loadConfig()
for(int i = 0; i < 3; ++i)
{
alist.push_back(0); vlist.push_back(myCart.myMusicFrequencies[i]);
changed.push_back(myCart.myMusicFrequencies[i] !=
static_cast<uInt32>(myOldState.mfreqs[i]));
changed.push_back(std::cmp_not_equal(myCart.myMusicFrequencies[i],
myOldState.mfreqs[i]));
}
myMusicFrequencies->setList(alist, vlist, changed);
@ -304,7 +304,8 @@ void CartridgeDPCPlusWidget::loadConfig()
for(int i = 0; i < 3; ++i)
{
alist.push_back(0); vlist.push_back(myCart.myMusicWaveforms[i]);
changed.push_back(myCart.myMusicWaveforms[i] != myOldState.mwaves[i]);
changed.push_back(std::cmp_not_equal(myCart.myMusicWaveforms[i],
myOldState.mwaves[i]));
}
myMusicWaveforms->setList(alist, vlist, changed);

View File

@ -169,7 +169,8 @@ void CartridgeDPCWidget::loadConfig()
for(int i = 0; i < 8; ++i)
{
alist.push_back(0); vlist.push_back(myCart.myTops[i]);
changed.push_back(myCart.myTops[i] != myOldState.tops[i]);
changed.push_back(std::cmp_not_equal(myCart.myTops[i],
myOldState.tops[i]));
}
myTops->setList(alist, vlist, changed);
@ -177,7 +178,8 @@ void CartridgeDPCWidget::loadConfig()
for(int i = 0; i < 8; ++i)
{
alist.push_back(0); vlist.push_back(myCart.myBottoms[i]);
changed.push_back(myCart.myBottoms[i] != myOldState.bottoms[i]);
changed.push_back(std::cmp_not_equal(myCart.myBottoms[i],
myOldState.bottoms[i]));
}
myBottoms->setList(alist, vlist, changed);
@ -185,7 +187,8 @@ void CartridgeDPCWidget::loadConfig()
for(int i = 0; i < 8; ++i)
{
alist.push_back(0); vlist.push_back(myCart.myCounters[i]);
changed.push_back(myCart.myCounters[i] != myOldState.counters[i]);
changed.push_back(std::cmp_not_equal(myCart.myCounters[i],
myOldState.counters[i]));
}
myCounters->setList(alist, vlist, changed);
@ -193,7 +196,8 @@ void CartridgeDPCWidget::loadConfig()
for(int i = 0; i < 8; ++i)
{
alist.push_back(0); vlist.push_back(myCart.myFlags[i]);
changed.push_back(myCart.myFlags[i] != myOldState.flags[i]);
changed.push_back(std::cmp_not_equal(myCart.myFlags[i],
myOldState.flags[i]));
}
myFlags->setList(alist, vlist, changed);

View File

@ -69,7 +69,7 @@ void CartridgeE7Widget::initialize(GuiObject* boss,
int ypos = addBaseInformation(size, "M Network", info.view(), 15) + myLineHeight;
VariantList items0, items1;
for(int i = 0; i < cart.romBankCount(); ++i)
for(int i = 0; std::cmp_less(i, cart.romBankCount()); ++i)
VarList::push_back(items0, getSpotLower(i, myCart.romBankCount()));
for(int i = 0; i < 4; ++i)
VarList::push_back(items1, getSpotUpper(i));

View File

@ -101,7 +101,8 @@ string CartridgeEnhancedWidget::romDescription()
if(myCart.romBankCount() > 1)
{
for(int bank = 0, offset = 0xFFC; bank < myCart.romBankCount(); ++bank, offset += 0x1000)
for(int bank = 0, offset = 0xFFC; std::cmp_less(bank, myCart.romBankCount());
++bank, offset += 0x1000)
{
uInt16 start = (image[offset + 1] << 8) | image[offset];
start -= start % 0x1000;
@ -183,10 +184,10 @@ void CartridgeEnhancedWidget::bankList(uInt16 bankCount, int seg, VariantList& i
const bool hasRamBanks = myCart.myRamBankCount > 0;
for(int bank = 0; bank < bankCount; ++bank)
for(int bank = 0; std::cmp_less(bank, bankCount); ++bank)
{
ostringstream buf;
const bool isRamBank = (bank >= myCart.romBankCount());
const bool isRamBank = std::cmp_greater_equal(bank, myCart.romBankCount());
const int bankNum = (bank - (isRamBank ? myCart.romBankCount() : 0));
buf << std::setw(bankNum < 10 ? 2 : 1) << "#" << std::dec << bankNum;
@ -211,7 +212,7 @@ void CartridgeEnhancedWidget::bankSelect(int& ypos)
myBankWidgets = make_unique<PopUpWidget* []>(bankSegs());
for(int seg = 0; seg < bankSegs(); ++seg)
for(int seg = 0; std::cmp_less(seg, bankSegs()); ++seg)
{
// fill bank and hotspot list
VariantList items;
@ -253,10 +254,10 @@ string CartridgeEnhancedWidget::bankState()
{
buf << "Segments: ";
for(int seg = 0; seg < bankSegs(); ++seg)
for(int seg = 0; std::cmp_less(seg, bankSegs()); ++seg)
{
const int bank = myCart.getSegmentBank(seg);
const bool isRamBank = (bank >= myCart.romBankCount());
const bool isRamBank = std::cmp_greater_equal(bank, myCart.romBankCount());
if(seg > 0)
buf << " / ";
@ -321,8 +322,8 @@ void CartridgeEnhancedWidget::saveOldState()
}
myOldState.banks.clear();
if (bankSegs() > 1)
for(int seg = 0; seg < bankSegs(); ++seg)
if(bankSegs() > 1)
for(int seg = 0; std::cmp_less(seg, bankSegs()); ++seg)
myOldState.banks.push_back(myCart.getSegmentBank(seg));
else
myOldState.banks.push_back(myCart.getBank());
@ -350,7 +351,7 @@ void CartridgeEnhancedWidget::loadConfig()
if(myBankWidgets != nullptr)
{
if(bankSegs() > 1)
for(int seg = 0; seg < bankSegs(); ++seg)
for(int seg = 0; std::cmp_less(seg, bankSegs()); ++seg)
myBankWidgets[seg]->setSelectedIndex(myCart.getSegmentBank(seg),
myCart.getSegmentBank(seg) != myOldState.banks[seg]);
else

View File

@ -225,7 +225,7 @@ void DataGridWidget::setValueInternal(int position, int value, bool changed)
void DataGridWidget::setValue(int position, int value, bool changed,
bool emitSignal)
{
if(position >= 0 && position < static_cast<int>(_valueList.size()))
if(position >= 0 && std::cmp_less(position, _valueList.size()))
{
// Correctly format the data for viewing
editString() = Common::Base::toString(value, _base);

View File

@ -108,7 +108,7 @@ void FlashWidget::loadConfig()
myPage[useCount]->setLabel(label.view());
startPage = -1;
if(++useCount == MAX_PAGES)
if(std::cmp_equal(++useCount, MAX_PAGES))
break;
}
}

View File

@ -580,7 +580,7 @@ int PromptWidget::historyDir(int& index, int direction)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PromptWidget::historyAdd(string_view entry)
{
if(_historyIndex >= static_cast<int>(_history.size()))
if(std::cmp_greater_equal(_historyIndex, _history.size()))
_history.emplace_back(entry);
else
_history[_historyIndex] = entry;

View File

@ -501,7 +501,7 @@ string RamWidget::doCompare(string_view str)
}
const int addr = mySearchAddr[i];
if(ram[addr] == searchVal)
if(std::cmp_equal(ram[addr], searchVal))
{
tempAddrList.push_back(addr);
tempValueList.push_back(searchVal);

View File

@ -126,7 +126,7 @@ void RomListWidget::setList(const CartDebug::Disassembly& disasm)
myCheckList[i]->setFlags(Widget::FLAG_ENABLED);
// Then turn off any extras
if(static_cast<int>(myDisasm->list.size()) < _rows)
if(std::cmp_less(myDisasm->list.size(), _rows))
for(int i = static_cast<int>(myDisasm->list.size()); i < _rows; ++i)
myCheckList[i]->clearFlags(Widget::FLAG_ENABLED);
@ -152,7 +152,7 @@ void RomListWidget::setSelected(int item)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void RomListWidget::setHighlighted(int item)
{
if(item < -1 || item >= static_cast<int>(myDisasm->list.size()))
if(item < -1 || std::cmp_greater_equal(item, myDisasm->list.size()))
return;
if(isEnabled())

View File

@ -257,7 +257,7 @@ uInt16 RomWidget::getAddress(int disasm_line)
const CartDebug::DisassemblyList& list =
instance().debugger().cartDebug().disassembly().list;
if (disasm_line < static_cast<int>(list.size()) && list[disasm_line].address != 0)
if (std::cmp_less(disasm_line, list.size()) && list[disasm_line].address != 0)
return list[disasm_line].address;
else
return 0;

View File

@ -87,9 +87,9 @@ string ToggleBitWidget::getToolTip(const Common::Point& pos) const
string tip = ToggleWidget::getToolTip(pos);
if(idx.x < static_cast<int>(_labelList.size()))
if(std::cmp_less(idx.x, _labelList.size()))
{
const string label = _labelList[idx.x];
const string& label = _labelList[idx.x];
if(!label.empty())
return tip + "\n" + label;

View File

@ -124,9 +124,9 @@ FORCE_INLINE void CartridgeDPC::updateMusicModeDataFetchers()
newLow = 0;
// Update flag register for this data fetcher
if(newLow <= myBottoms[x])
if(std::cmp_less_equal(newLow, myBottoms[x]))
myFlags[x] = 0x00;
else if(newLow <= myTops[x])
else if(std::cmp_less_equal(newLow, myTops[x]))
myFlags[x] = 0xff;
myCounters[x] = (myCounters[x] & 0x0700) | static_cast<uInt16>(newLow);

View File

@ -190,12 +190,12 @@ inline void CartridgeDPCPlus::callFunction(uInt8 value)
myParameterPointer = 0;
break;
case 1: // Copy ROM to fetcher
for(int i = 0; i < myParameter[3]; ++i)
for(int i = 0; std::cmp_less(i, myParameter[3]); ++i)
myDisplayImage[myCounters[myParameter[2] & 0x7]+i] = myProgramImage[ROMdata+i];
myParameterPointer = 0;
break;
case 2: // Copy value to fetcher
for(int i = 0; i < myParameter[3]; ++i)
for(int i = 0; std::cmp_less(i, myParameter[3]); ++i)
myDisplayImage[myCounters[myParameter[2]]+i] = myParameter[0];
myParameterPointer = 0;
break;

View File

@ -2442,14 +2442,14 @@ Event::Type EventHandler::eventAtIndex(int idx, Event::Group group)
if(group == Event::Group::Menu)
{
if(index < 0 || index >= static_cast<int>(ourMenuActionList.size()))
if(index < 0 || std::cmp_greater_equal(index, ourMenuActionList.size()))
return Event::NoType;
else
return ourMenuActionList[index].event;
}
else
{
if(index < 0 || index >= static_cast<int>(ourEmulActionList.size()))
if(index < 0 || std::cmp_greater_equal(index, ourEmulActionList.size()))
return Event::NoType;
else
return ourEmulActionList[index].event;
@ -2463,14 +2463,14 @@ string EventHandler::actionAtIndex(int idx, Event::Group group)
if(group == Event::Group::Menu)
{
if(index < 0 || index >= static_cast<int>(ourMenuActionList.size()))
if(index < 0 || std::cmp_greater_equal(index, ourMenuActionList.size()))
return EmptyString;
else
return ourMenuActionList[index].action;
}
else
{
if(index < 0 || index >= static_cast<int>(ourEmulActionList.size()))
if(index < 0 || std::cmp_greater_equal(index, ourEmulActionList.size()))
return EmptyString;
else
return ourEmulActionList[index].action;
@ -2484,14 +2484,14 @@ string EventHandler::keyAtIndex(int idx, Event::Group group)
if(group == Event::Group::Menu)
{
if(index < 0 || index >= static_cast<int>(ourMenuActionList.size()))
if(index < 0 || std::cmp_greater_equal(index, ourMenuActionList.size()))
return EmptyString;
else
return ourMenuActionList[index].key;
}
else
{
if(index < 0 || index >= static_cast<int>(ourEmulActionList.size()))
if(index < 0 || std::cmp_greater_equal(index, ourEmulActionList.size()))
return EmptyString;
else
return ourEmulActionList[index].key;

View File

@ -167,7 +167,7 @@ void FBSurface::drawChar(const GUI::Font& font, uInt8 chr,
const FontDesc& desc = font.desc();
// If this character is not included in the font, use the default char.
if(chr < desc.firstchar || chr >= desc.firstchar + desc.size)
if(std::cmp_less(chr, desc.firstchar) || chr >= desc.firstchar + desc.size)
{
if (chr == ' ') return;
chr = desc.defaultchar;

View File

@ -532,7 +532,7 @@ void FrameBuffer::update(UpdateMode mode)
// Pause sound if saved states were removed or states are too far apart
myOSystem.sound().pause(stateFrames > intervalFrames ||
frames > static_cast<Int32>(myOSystem.audioSettings().bufferSize() / 2 + 1));
std::cmp_greater(frames, myOSystem.audioSettings().bufferSize() / 2 + 1));
}
redraw |= success;
if(redraw)

View File

@ -501,7 +501,7 @@ ByteArray PlusROM::getSend() const
ByteArray arr;
const uInt8 txPos = myTxPos != 0 ? myTxPos : myLastTxPos;
for(int i = 0; i < txPos; ++i)
for(int i = 0; std::cmp_less(i, txPos); ++i)
arr.push_back(myTxBuffer[i]);
return arr;

View File

@ -409,7 +409,8 @@ void Ball::tick(bool isReceivingRegularClock)
break;
}
} else if (myIsRendering && ++myRenderCounter >= (starfieldEffect ? myEffectiveWidth : myWidth))
} else if (myIsRendering && std::cmp_greater_equal(++myRenderCounter,
starfieldEffect ? myEffectiveWidth : myWidth))
myIsRendering = false;
if (++myCounter >= TIAConstants::H_PIXEL)

View File

@ -145,7 +145,7 @@ void Missile::nusiz(uInt8 value)
myWidth = ourWidths[(value & 0x30) >> 4];
myDecodes = DrawCounterDecodes::get().missileDecodes()[myDecodesOffset];
if (myIsRendering && myRenderCounter >= myWidth)
if (myIsRendering && std::cmp_greater_equal(myRenderCounter, myWidth))
myIsRendering = false;
}

View File

@ -210,7 +210,8 @@ void Missile::tick(uInt8 hclock, bool isReceivingMclock)
}
}
if (++myRenderCounter >= (isMoving ? myEffectiveWidth : myWidth)) myIsRendering = false;
if (std::cmp_greater_equal(++myRenderCounter, isMoving ? myEffectiveWidth : myWidth))
myIsRendering = false;
}
if (++myCounter >= TIAConstants::H_PIXEL) myCounter = 0;

View File

@ -126,11 +126,11 @@ void BrowserDialog::show(Dialog* parent, const GUI::Font& font,
h = FBMinimum::Height;
}
if(w > static_cast<uInt32>(font.getMaxCharWidth() * 80))
if(std::cmp_greater(w, font.getMaxCharWidth() * 80))
w = font.getMaxCharWidth() * 80;
if(ourBrowser == nullptr || &ourBrowser->parent() != &parent->parent()
|| ourBrowser->_w > static_cast<int>(w) || ourBrowser->_h > static_cast<int>(h))
if(ourBrowser == nullptr || &ourBrowser->parent() != &parent->parent() ||
std::cmp_greater(ourBrowser->_w, w) || std::cmp_greater(ourBrowser->_h, h))
{
ourBrowser = make_unique<BrowserDialog>(parent, font, w, h);
}

View File

@ -59,7 +59,7 @@ void CheckListWidget::setList(const StringList& list, const BoolArray& state)
_checkList[i]->setFlags(Widget::FLAG_ENABLED);
// Then turn off any extras
if(static_cast<int>(_stateList.size()) < _rows)
if(std::cmp_less(_stateList.size(), _rows))
for(int i = static_cast<int>(_stateList.size()); i < _rows; ++i)
_checkList[i]->clearFlags(Widget::FLAG_ENABLED);
@ -69,7 +69,7 @@ void CheckListWidget::setList(const StringList& list, const BoolArray& state)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CheckListWidget::setLine(int line, string_view str, const bool& state)
{
if(line >= static_cast<int>(_list.size()))
if(std::cmp_greater_equal(line, _list.size()))
return;
_list[line] = str;
@ -147,7 +147,7 @@ Common::Rect CheckListWidget::getEditRect() const
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CheckListWidget::getState(int line) const
{
if(line >= 0 && line < static_cast<int>(_stateList.size()))
if(line >= 0 && std::cmp_less(line, _stateList.size()))
return _stateList[line];
else
return false;

View File

@ -114,7 +114,7 @@ void ContextMenu::recalc(const Common::Rect& image)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ContextMenu::setSelectedIndex(int idx)
{
if(idx >= 0 && idx < static_cast<int>(_entries.size()))
if(idx >= 0 && std::cmp_less(idx, _entries.size()))
_selectedItem = idx;
else
_selectedItem = -1;
@ -423,12 +423,12 @@ void ContextMenu::moveDown()
// Otherwise, the offset should increase by 1
if(_selectedOffset == _numEntries)
scrollDown();
else if(_selectedOffset < static_cast<int>(_entries.size()))
else if(std::cmp_less(_selectedOffset, _entries.size()))
drawCurrentSelection(_selectedOffset+1);
}
else
{
if(_selectedOffset < static_cast<int>(_entries.size()) - 1)
if(std::cmp_less(_selectedOffset, _entries.size() - 1))
drawCurrentSelection(_selectedOffset+1);
}
}
@ -445,7 +445,7 @@ void ContextMenu::movePgUp()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ContextMenu::movePgDown()
{
if(_firstEntry == static_cast<int>(_entries.size() - _numEntries))
if(std::cmp_equal(_firstEntry, _entries.size() - _numEntries))
moveToLast();
else
scrollDown(_numEntries);
@ -474,7 +474,7 @@ void ContextMenu::moveToLast()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ContextMenu::moveToSelected()
{
if(_selectedItem < 0 || _selectedItem >= static_cast<int>(_entries.size()))
if(_selectedItem < 0 || std::cmp_greater_equal(_selectedItem, _entries.size()))
return;
// First jump immediately to the item

View File

@ -1489,7 +1489,7 @@ void DeveloperDialog::handleDebugColours(int idx, int color)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void DeveloperDialog::handleDebugColours(string_view colors)
{
for(int i = 0; i < DEBUG_COLORS && i < static_cast<int>(colors.length()); ++i)
for(int i = 0; i < DEBUG_COLORS && std::cmp_less(i, colors.length()); ++i)
{
switch(colors[i])
{
@ -1531,11 +1531,11 @@ void DeveloperDialog::handleFontSize()
minH = std::min(size.h, minH);
myDebuggerWidthSlider->setMinValue(minW);
if(minW > static_cast<uInt32>(myDebuggerWidthSlider->getValue()))
if(std::cmp_greater(minW, myDebuggerWidthSlider->getValue()))
myDebuggerWidthSlider->setValue(minW);
myDebuggerHeightSlider->setMinValue(minH);
if(minH > static_cast<uInt32>(myDebuggerHeightSlider->getValue()))
if(std::cmp_greater(minH, myDebuggerHeightSlider->getValue()))
myDebuggerHeightSlider->setValue(minH);
#endif
}

View File

@ -208,7 +208,7 @@ string Dialog::getHelpURL() const
if(_focusedWidget && _focusedWidget->hasHelp())
return _focusedWidget->getHelpURL();
if(_tabID < static_cast<int>(_myTabList.size()))
if(std::cmp_less(_tabID, _myTabList.size()))
{
TabWidget* activeTabGroup = _myTabList[_tabID].widget;
@ -490,7 +490,7 @@ void Dialog::buildCurrentFocusList(int tabID)
// Remember which tab item previously had focus, if applicable
// This only applies if this method was called for a tab change
Widget* tabFocusWidget = nullptr;
if(tabID >= 0 && tabID < static_cast<int>(_myTabList.size()))
if(tabID >= 0 && std::cmp_less(tabID, _myTabList.size()))
{
// Save focus in previously selected tab column,
// and get focus for new tab column
@ -937,7 +937,7 @@ void Dialog::getTabIdForWidget(const Widget* w)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Dialog::cycleTab(int direction)
{
if(_tabID >= 0 && _tabID < static_cast<int>(_myTabList.size()))
if(_tabID >= 0 && std::cmp_less(_tabID, _myTabList.size()))
{
_myTabList[_tabID].widget->cycleTab(direction);
return true;
@ -1086,12 +1086,12 @@ void Dialog::addDefaultsExtraOKCancelBGroup(
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Dialog::TabFocus::appendFocusList(WidgetArray& list)
void Dialog::TabFocus::appendFocusList(WidgetArray& lst)
{
const int active = widget->getActiveTab();
if(active >= 0 && active < static_cast<int>(focus.size()))
Vec::append(list, focus[active].list);
if(active >= 0 && std::cmp_less(active, focus.size()))
Vec::append(lst, focus[active].list);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -1146,7 +1146,7 @@ bool Dialog::shouldResize(uInt32& w, uInt32& h) const
// returns true if the current size is larger than the allowed size or
// if the current size is smaller than the allowed and wanted size
return (static_cast<uInt32>(_w) > w || static_cast<uInt32>(_h) > h ||
(static_cast<uInt32>(_w) < w && static_cast<uInt32>(_w) < _max_w) ||
(static_cast<uInt32>(_h) < h && static_cast<uInt32>(_h) < _max_h));
return (std::cmp_greater(_w, w) || std::cmp_greater(_h, h) ||
(std::cmp_less(_w, w) && std::cmp_less(_w, _max_w)) ||
(std::cmp_less(_h, h) && std::cmp_less(_h, _max_h)));
}

View File

@ -256,7 +256,7 @@ class Dialog : public GuiObject
explicit TabFocus(TabWidget* w = nullptr) : widget{w} { }
void appendFocusList(WidgetArray& list);
void appendFocusList(WidgetArray& lst);
void saveCurrentFocus(Widget* w);
Widget* getNewFocus();
};

View File

@ -127,7 +127,7 @@ int EditableWidget::toCaretPos(int x) const
int i = 0;
x += caretOfs();
for(i = 0; i < static_cast<int>(_editString.size()); ++i)
for(i = 0; std::cmp_less(i, _editString.size()); ++i)
{
x -= _font.getCharWidth(_editString[i]);
if(x <= 0)
@ -248,7 +248,7 @@ bool EditableWidget::tryInsertChar(char c, int pos)
if(_selectSize < 0) // left to right selection
pos += _selectSize; // adjust to new position after removing selected text
killSelectedText();
if(!_maxLen || static_cast<int>(_editString.length()) < _maxLen)
if(!_maxLen || std::cmp_less(_editString.length(), _maxLen))
{
myUndoHandler->doChar(); // aggregate single chars
_editString.insert(pos, 1, c);
@ -296,7 +296,7 @@ bool EditableWidget::handleKeyDown(StellaKey key, StellaMod mod)
case Event::MoveRightChar:
if(_selectSize)
handled = setCaretPos(selectEndPos());
else if(_caretPos < static_cast<int>(_editString.size()))
else if(std::cmp_less(_caretPos, _editString.size()))
handled = setCaretPos(_caretPos + 1);
_selectSize = 0;
break;
@ -327,7 +327,7 @@ bool EditableWidget::handleKeyDown(StellaKey key, StellaMod mod)
break;
case Event::SelectRightChar:
if(_caretPos < static_cast<int>(_editString.size()))
if(std::cmp_less(_caretPos, _editString.size()))
handled = moveCaretPos(+1);
break;
@ -532,7 +532,7 @@ void EditableWidget::drawCaretSelection()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool EditableWidget::setCaretPos(int newPos)
{
assert(newPos >= 0 && newPos <= int(_editString.size()));
assert(newPos >= 0 && std::cmp_less_equal(newPos, _editString.size()));
_caretPos = newPos;
_caretTimer = 0;
@ -612,7 +612,7 @@ bool EditableWidget::killChar(int direction, bool addEdit)
}
else if(direction == 1) // Delete next character (delete)
{
if(_caretPos < static_cast<int>(_editString.size()))
if(std::cmp_less(_caretPos, _editString.size()))
{
if(_selectSize > 0)
_selectSize--;
@ -679,7 +679,7 @@ bool EditableWidget::killWord(int direction)
}
else if(direction == +1) // move to first character of next word
{
while(currentPos < static_cast<int>(_editString.size()))
while(std::cmp_less(currentPos, _editString.size()))
{
if(currentPos && BSPF::isWhiteSpace(_editString[currentPos - 1]))
{
@ -715,11 +715,11 @@ bool EditableWidget::moveWord(int direction, bool select)
if(direction == -1) // move to first character of previous word
{
while (currentPos > 0)
while(currentPos > 0)
{
if (BSPF::isWhiteSpace(_editString[currentPos - 1]))
if(BSPF::isWhiteSpace(_editString[currentPos - 1]))
{
if (!space)
if(!space)
break;
}
else
@ -734,11 +734,11 @@ bool EditableWidget::moveWord(int direction, bool select)
}
else if(direction == +1) // move to first character of next word
{
while (currentPos < static_cast<int>(_editString.size()))
while(std::cmp_less(currentPos, _editString.size()))
{
if (currentPos && BSPF::isWhiteSpace(_editString[currentPos - 1]))
if(currentPos && BSPF::isWhiteSpace(_editString[currentPos - 1]))
{
if (!space)
if(!space)
break;
}
else
@ -798,19 +798,13 @@ string EditableWidget::selectString() const
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int EditableWidget::selectStartPos() const
{
if(_selectSize < 0)
return _caretPos + _selectSize;
else
return _caretPos;
return (_selectSize < 0) ? _caretPos + _selectSize : _caretPos;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int EditableWidget::selectEndPos() const
{
if(_selectSize > 0)
return _caretPos + _selectSize;
else
return _caretPos;
return (_selectSize > 0) ? _caretPos + _selectSize : _caretPos;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -717,7 +717,7 @@ string FileListWidget::getToolTip(const Common::Point& pos) const
if(idx < 0)
return EmptyString;
if(_includeSubDirs && static_cast<int>(_dirList.size()) > idx)
if(_includeSubDirs && std::cmp_greater(_dirList.size(), idx))
return _toolTipText + _dirList[idx];
const string value = _list[idx];

View File

@ -38,7 +38,7 @@ int Font::getCharWidth(uInt8 chr) const
return myFontDesc.maxwidth;
// If this character is not included in the font, use the default char.
if(chr < myFontDesc.firstchar || myFontDesc.firstchar + myFontDesc.size < chr)
if(std::cmp_less(chr, myFontDesc.firstchar) || myFontDesc.firstchar + myFontDesc.size < chr)
{
if(chr == ' ')
return myFontDesc.maxwidth / 2;

View File

@ -409,7 +409,7 @@ void HighScoresDialog::updateWidgets(bool init)
myNameWidgets[r]->setLabel(myScores.scores[r].name);
myDateWidgets[r]->setLabel(myScores.scores[r].date);
if (static_cast<Int32>(r) == myEditRank)
if (std::cmp_equal(r, myEditRank))
{
myNameWidgets[r]->setFlags(EditTextWidget::FLAG_INVISIBLE);
myEditNameWidgets[r]->clearFlags(EditTextWidget::FLAG_INVISIBLE);
@ -440,7 +440,7 @@ void HighScoresDialog::handlePlayedVariation()
const Int32 newSpecial = instance().highScores().special();
const bool scoreInvert = instance().highScores().scoreInvert();
for (myHighScoreRank = 0; myHighScoreRank < static_cast<Int32>(NUM_RANKS); ++myHighScoreRank)
for (myHighScoreRank = 0; std::cmp_less(myHighScoreRank, NUM_RANKS); ++myHighScoreRank)
{
const Int32 highScore = myScores.scores[myHighScoreRank].score;
@ -452,10 +452,10 @@ void HighScoresDialog::handlePlayedVariation()
break;
}
if (myHighScoreRank < static_cast<Int32>(NUM_RANKS))
if (std::cmp_less(myHighScoreRank, NUM_RANKS))
{
myEditRank = myHighScoreRank;
for (uInt32 r = NUM_RANKS - 1; static_cast<Int32>(r) > myHighScoreRank; --r)
for (uInt32 r = NUM_RANKS - 1; std::cmp_greater(r, myHighScoreRank); --r)
{
myScores.scores[r].score = myScores.scores[r - 1].score;
myScores.scores[r].special = myScores.scores[r - 1].special;

View File

@ -657,9 +657,9 @@ void LauncherDialog::setRomInfoFont(const Common::Size& area)
// only use fonts <= launcher fonts
if(Dialog::fontHeight() >= font.height)
{
if(area.h >= static_cast<uInt32>(MIN_ROMINFO_ROWS * font.height + 2
+ MIN_ROMINFO_LINES * font.height)
&& area.w >= static_cast<uInt32>(MIN_ROMINFO_CHARS * font.maxwidth))
if(std::cmp_greater_equal(area.h,
MIN_ROMINFO_ROWS * font.height + 2 + MIN_ROMINFO_LINES * font.height)
&& std::cmp_greater_equal(area.w, MIN_ROMINFO_CHARS * font.maxwidth))
{
myROMInfoFont = make_unique<GUI::Font>(font);
return;

View File

@ -71,7 +71,7 @@ void ListWidget::setSelected(int item)
{
setDirty();
if(item < 0 || item >= static_cast<int>(_list.size()))
if(item < 0 || std::cmp_greater_equal(item, _list.size()))
return;
if(isEnabled())
@ -117,7 +117,7 @@ void ListWidget::setSelected(string_view item)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ListWidget::setHighlighted(int item)
{
if(item < -1 || item >= static_cast<int>(_list.size()))
if(item < -1 || std::cmp_greater_equal(item, _list.size()))
return;
if(isEnabled())
@ -140,7 +140,7 @@ void ListWidget::setHighlighted(int item)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const string& ListWidget::getSelectedString() const
{
return (_selectedItem >= 0 && _selectedItem < static_cast<int>(_list.size()))
return (_selectedItem >= 0 && std::cmp_less(_selectedItem, _list.size()))
? _list[_selectedItem]
: EmptyString;
}
@ -207,18 +207,18 @@ void ListWidget::scrollBarRecalc()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ListWidget::handleMouseDown(int x, int y, MouseButton b, int clickCount)
{
if (!isEnabled())
if(!isEnabled())
return;
resetSelection();
// First check whether the selection changed
const int newSelectedItem = findItem(x, y);
if (newSelectedItem >= static_cast<int>(_list.size()))
if(std::cmp_greater_equal(newSelectedItem, _list.size()))
return;
if (_selectedItem != newSelectedItem)
if(_selectedItem != newSelectedItem)
{
if (_editMode)
if(_editMode)
abortEditMode();
_selectedItem = newSelectedItem;
sendCommand(ListWidget::kSelectionChangedCmd, _selectedItem, _id);
@ -234,7 +234,7 @@ void ListWidget::handleMouseUp(int x, int y, MouseButton b, int clickCount)
{
// If this was a double click and the mouse is still over the selected item,
// send the double click command
if (clickCount == 2 && (_selectedItem == findItem(x, y)))
if(clickCount == 2 && (_selectedItem == findItem(x, y)))
{
sendCommand(ListWidget::kDoubleClickedCmd, _selectedItem, _id);
@ -420,7 +420,7 @@ void ListWidget::scrollToCurrent(int item)
_currentPos = item - _rows + 1;
}
if (_currentPos < 0 || _rows > static_cast<int>(_list.size()))
if (_currentPos < 0 || std::cmp_greater_equal(_rows, _list.size()))
_currentPos = 0;
else if (_currentPos + _rows > static_cast<int>(_list.size()))
_currentPos = static_cast<int>(_list.size()) - _rows;

View File

@ -249,9 +249,9 @@ RadioButtonWidget::RadioButtonWidget(GuiObject* boss, const GUI::Font& font,
// Depending on font size, either the font or box will need to be
// centered vertically
if(_h > static_cast<int>(_buttonSize)) // center box
if(std::cmp_greater(_h, _buttonSize)) // center box
_boxY = (_h - _buttonSize) / 2;
else // center text
else // center text
_textY = (_buttonSize - _font.getFontHeight()) / 2;
setFill(CheckboxWidget::FillType::Normal); // NOLINT

View File

@ -496,7 +496,7 @@ int StellaSettingsDialog::valueToLevel(int value)
for (int i = NUM_LEVELS - 1; i > 0; --i)
{
if (value >= values[i])
if (std::cmp_greater_equal(value, values[i]))
return i;
}
return 0;

View File

@ -54,10 +54,7 @@ int StringListWidget::getToolTipIndex(const Common::Point& pos) const
{
const int idx = (pos.y - getAbsY()) / _lineHeight + _currentPos;
if(idx >= static_cast<int>(_list.size()))
return -1;
else
return idx;
return std::cmp_greater_equal(idx, _list.size()) ? -1 : idx;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -98,7 +98,7 @@ int TabWidget::addTab(string_view title, int tabWidth)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TabWidget::setActiveTab(int tabID, bool show)
{
assert(0 <= tabID && tabID < int(_tabs.size()));
assert(0 <= tabID && std::cmp_less(tabID, _tabs.size()));
if (_activeTab != -1)
{
@ -120,7 +120,7 @@ void TabWidget::setActiveTab(int tabID, bool show)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TabWidget::enableTab(int tabID, bool enable)
{
assert(0 <= tabID && tabID < int(_tabs.size()));
assert(0 <= tabID && std::cmp_less(tabID, _tabs.size()));
_tabs[tabID].enabled = enable;
// Note: We do not have to disable the widgets because the tab is disabled
@ -168,7 +168,7 @@ void TabWidget::cycleTab(int direction)
{
do {
tabID++;
if(tabID == static_cast<int>(_tabs.size()))
if(std::cmp_equal(tabID, _tabs.size()))
tabID = 0;
} while(!_tabs[tabID].enabled);
}
@ -181,14 +181,14 @@ void TabWidget::cycleTab(int direction)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TabWidget::setParentWidget(int tabID, Widget* parent)
{
assert(0 <= tabID && tabID < static_cast<int>(_tabs.size()));
assert(0 <= tabID && std::cmp_less(tabID, _tabs.size()));
_tabs[tabID].parentWidget = parent;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Widget* TabWidget::parentWidget(int tabID)
{
assert(0 <= tabID && tabID < int(_tabs.size()));
assert(0 <= tabID && std::cmp_less(tabID, _tabs.size()));
if(!_tabs[tabID].parentWidget)
{
@ -209,7 +209,7 @@ void TabWidget::handleMouseDown(int x, int y, MouseButton b, int clickCount)
int tabID = -1;
x -= kTabLeftOffset;
for(int i = 0; i < static_cast<int>(_tabs.size()); ++i)
for(int i = 0; std::cmp_less(i, _tabs.size()); ++i)
{
const int tabWidth = _tabs[i].tabWidth ? _tabs[i].tabWidth : _tabWidth;
if(x >= 0 && x < tabWidth)
@ -283,7 +283,7 @@ void TabWidget::drawWidget(bool hilite)
// Iterate over all tabs and draw them
int x = _x + kTabLeftOffset;
for(int i = 0; i < static_cast<int>(_tabs.size()); ++i)
for(int i = 0; std::cmp_less(i, _tabs.size()); ++i)
{
const int tabWidth = _tabs[i].tabWidth ? _tabs[i].tabWidth : _tabWidth;
const ColorId fontcolor = _tabs[i].enabled ? kTextColor : kColor;

View File

@ -101,7 +101,7 @@ void TimeLineWidget::setStepValues(const IntArray& steps)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TimeLineWidget::handleMouseMoved(int x, int y)
{
if(isEnabled() && _isDragging && x >= static_cast<int>(_labelWidth))
if(isEnabled() && _isDragging && std::cmp_greater_equal(x, _labelWidth))
setValue(posToValue(x - _labelWidth));
}

View File

@ -78,7 +78,7 @@ WhatsNewDialog::WhatsNewDialog(OSystem& osystem, DialogContainer& parent,
// Set needed dimensions
ypos += VGAP * 2 + buttonHeight + VBORDER;
assert(ypos <= int(FBMinimum::Height)); // minimal launcher height
assert(std::cmp_less_equal(ypos, FBMinimum::Height)); // minimal launcher height
setSize(MAX_CHARS * fontWidth + HBORDER * 2, ypos, max_w, max_h);
WidgetArray wid;

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash
run-clang-tidy-19 -header-filter=\(.*\.hxx\) \
run-clang-tidy-20 -header-filter=\(.*\.hxx\) \
-checks=*,\
-abseil*,\
-altera*,\