Skip to content

Commit

Permalink
Fix "clang-tidy -check=modernize-loop-convert" warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
m9710797 committed Dec 31, 2016
1 parent 5e170a9 commit ea5512a
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 38 deletions.
8 changes: 4 additions & 4 deletions src/fdc/DMKDiskImage.cc
Expand Up @@ -34,11 +34,11 @@ static bool isValidDmkHeader(const DmkHeader& header)
if (trackLen >= 0x4000) return false; // too large track length
if (trackLen <= 128) return false; // too small
if (header.flags & ~0xd0) return false; // unknown flag set
for (int i = 0; i < 7; ++i) {
if (header.reserved[i] != 0) return false;
for (auto& r : header.reserved) {
if (r != 0) return false;
}
for (int i = 0; i < 4; ++i) {
if (header.format[i] != 0) return false;
for (auto& f : header.format) {
if (f != 0) return false;
}
return true;
}
Expand Down
6 changes: 2 additions & 4 deletions src/fdc/MSXtar.cc
Expand Up @@ -691,8 +691,7 @@ string MSXtar::dir()
for (unsigned sector = chrootSector; sector != 0; sector = getNextSector(sector)) {
SectorBuffer buf;
readLogicalSector(sector, buf);
for (unsigned i = 0; i < 16; ++i) {
auto& dirEntry = buf.dirEntry[i];
for (auto& dirEntry : buf.dirEntry) {
if ((dirEntry.filename[0] == char(0xe5)) ||
(dirEntry.filename[0] == char(0x00)) ||
(dirEntry.attrib == T_MSX_LFN)) continue;
Expand Down Expand Up @@ -822,8 +821,7 @@ void MSXtar::recurseDirExtract(string_ref dirName, unsigned sector)
for (/* */ ; sector != 0; sector = getNextSector(sector)) {
SectorBuffer buf;
readLogicalSector(sector, buf);
for (unsigned i = 0; i < 16; ++i) {
auto& dirEntry = buf.dirEntry[i];
for (auto& dirEntry : buf.dirEntry) {
if ((dirEntry.filename[0] == char(0xe5)) ||
(dirEntry.filename[0] == char(0x00)) ||
(dirEntry.filename[0] == '.')) continue;
Expand Down
2 changes: 1 addition & 1 deletion src/fdc/SectorBasedDisk.cc
Expand Up @@ -111,7 +111,7 @@ void SectorBasedDisk::readTrack(byte track, byte side, RawTrack& output)
auto logicalSector = physToLog(track, side, j + 1);
SectorBuffer buf;
readSector(logicalSector, buf);
for (int i = 0; i < 512; ++i) output.write(idx++, buf.raw[i]);
for (auto& r : buf.raw) output.write(idx++, r);

word dataCrc = output.calcCrc(idx - (512 + 4), 512 + 4);
output.write(idx++, dataCrc >> 8); // CRC (high byte)
Expand Down
8 changes: 4 additions & 4 deletions src/sound/SCC.cc
Expand Up @@ -149,10 +149,10 @@ void SCC::powerUp(EmuTime::param time)
// Initialize ch_enable, deform (initialize this before period)
reset(time);

// Initialize waveform (initialize before volumes)
for (unsigned i = 0; i < 5; ++i) {
for (unsigned j = 0; j < 32; ++j) {
wave[i][j] = ~0;
// Initialize waveforms (initialize before volumes)
for (auto& w1 : wave) {
for (auto& w2 : w1) {
w2 = ~0;
}
}
// Initialize volume (initialize this before period)
Expand Down
12 changes: 5 additions & 7 deletions src/sound/YMF262.cc
Expand Up @@ -527,8 +527,7 @@ void YMF262::advance()

++eg_cnt;
for (auto& ch : channel) {
for (int s = 0; s < 2; ++s) {
auto& op = ch.slot[s];
for (auto& op : ch.slot) {
op.advanceEnvelopeGenerator(eg_cnt);
op.advancePhaseGenerator(ch, lfo_pm);
}
Expand Down Expand Up @@ -1428,9 +1427,9 @@ void YMF262::reset(EmuTime::param time)

// reset operator parameters
for (auto& ch : channel) {
for (int s = 0; s < 2; s++) {
ch.slot[s].state = EG_OFF;
ch.slot[s].volume = MAX_ATT_INDEX;
for (auto& sl : ch.slot) {
sl.state = EG_OFF;
sl.volume = MAX_ATT_INDEX;
}
}
}
Expand Down Expand Up @@ -1493,8 +1492,7 @@ bool YMF262::checkMuteHelper()
{
// TODO this doesn't always mute when possible
for (auto& ch : channel) {
for (int j = 0; j < 2; j++) {
auto& sl = ch.slot[j];
for (auto& sl : ch.slot) {
if (!((sl.state == EG_OFF) ||
((sl.state == EG_RELEASE) &&
((sl.TLL + sl.volume) >= ENV_QUIET)))) {
Expand Down
16 changes: 7 additions & 9 deletions src/utils/sha1.cc
Expand Up @@ -114,13 +114,13 @@ static inline unsigned hex(char x, const char* str)
void Sha1Sum::parse40(const char* str)
{
const char* p = str;
for (int i = 0; i < 5; ++i) {
for (auto& ai : a) {
unsigned t = 0;
for (int j = 0; j < 8; ++j) {
t <<= 4;
t |= hex(*p++, str);
}
a[i] = t;
ai = t;
}
}

Expand All @@ -132,26 +132,24 @@ std::string Sha1Sum::toString() const
{
char buf[40];
char* p = buf;
for (int i = 0; i < 5; ++i) {
for (const auto& ai : a) {
for (int j = 28; j >= 0; j -= 4) {
*p++ = digit((a[i] >> j) & 0xf);
*p++ = digit((ai >> j) & 0xf);
}
}
return string(buf, 40);
}

bool Sha1Sum::empty() const
{
for (int i = 0; i < 5; ++i) {
if (a[i] != 0) return false;
for (const auto& ai : a) {
if (ai != 0) return false;
}
return true;
}
void Sha1Sum::clear()
{
for (int i = 0; i < 5; ++i) {
a[i] = 0;
}
for (auto& ai : a) ai = 0;
}


Expand Down
8 changes: 4 additions & 4 deletions src/video/scalers/GLHQLiteScaler.cc
Expand Up @@ -17,10 +17,10 @@ GLHQLiteScaler::GLHQLiteScaler(GLScaler& fallback_)
: GLScaler("hqlite")
, fallback(fallback_)
{
for (int i = 0; i < 2; ++i) {
program[i].activate();
glUniform1i(program[i].getUniformLocation("edgeTex"), 2);
glUniform1i(program[i].getUniformLocation("offsetTex"), 3);
for (auto& p : program) {
p.activate();
glUniform1i(p.getUniformLocation("edgeTex"), 2);
glUniform1i(p.getUniformLocation("offsetTex"), 3);
}

edgeTexture.bind();
Expand Down
10 changes: 5 additions & 5 deletions src/video/scalers/GLHQScaler.cc
Expand Up @@ -17,11 +17,11 @@ GLHQScaler::GLHQScaler(GLScaler& fallback_)
: GLScaler("hq")
, fallback(fallback_)
{
for (int i = 0; i < 2; ++i) {
program[i].activate();
glUniform1i(program[i].getUniformLocation("edgeTex"), 2);
glUniform1i(program[i].getUniformLocation("offsetTex"), 3);
glUniform1i(program[i].getUniformLocation("weightTex"), 4);
for (auto& p : program) {
p.activate();
glUniform1i(p.getUniformLocation("edgeTex"), 2);
glUniform1i(p.getUniformLocation("offsetTex"), 3);
glUniform1i(p.getUniformLocation("weightTex"), 4);
}

edgeTexture.bind();
Expand Down

0 comments on commit ea5512a

Please sign in to comment.