Fix cases of variable shadowing in /tools/.

If we manage to fix all the existing cases of variable shadowing, we
could enable -Wshadow.

(Turtle.cpp is #included from a cpp in the tools directory.)

Change-Id: I1685086ec0ceae1d51efa7daa0f46137b535ce77
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/438476
Reviewed-by: Jorge Betancourt <jmbetancourt@google.com>
Commit-Queue: Jorge Betancourt <jmbetancourt@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
This commit is contained in:
John Stiles 2021-08-11 11:01:17 -04:00 committed by SkCQ
parent d6c08c9be8
commit 488654b839
9 changed files with 23 additions and 25 deletions

View File

@ -41,8 +41,7 @@ const char* eval(SkCanvas* canvas, const char* s, char e, float& dist, float& l,
d = std::min(d, l);
dist += d; l -= d;
float r = t.h * 0.01745329f;
auto s = sinf(r), c = cosf(r);
Turtle nt = { t.x + s * d, t.y - c * d, t.h, t.p };
Turtle nt = { t.x + sinf(r) * d, t.y - cosf(r) * d, t.h, t.p };
if (pt && t.p) canvas->drawLine(t.x, t.y, nt.x, nt.y, p());
t = nt;
break;

View File

@ -31,8 +31,8 @@ void DebugLayerManager::setCommand(int nodeId, int frame, int command) {
// Invalidate stored images that depended on this combination of node and frame.
// actually this does all of the events for this nodeId, but close enough.
auto relevantFrames = listFramesForNode(nodeId);
for (const auto& frame : relevantFrames) {
fDraws[{frame, nodeId}].image = nullptr;
for (const auto& f : relevantFrames) {
fDraws[{f, nodeId}].image = nullptr;
}
}

View File

@ -181,8 +181,8 @@ int main(int argc, char** argv) {
printf("%s %s\n", FLAGS_optimize ? "optimized" : "not-optimized", FLAGS_skps[i]);
Dumper dumper(&canvas, record.count());
for (int i = 0; i < record.count(); i++) {
record.visit(i, dumper);
for (int j = 0; j < record.count(); j++) {
record.visit(j, dumper);
}
if (FLAGS_write.count() > 0) {

View File

@ -251,11 +251,11 @@ void CommandLineFlags::Parse(int argc, const char* const* argv) {
allFlags.push_back(flag);
}
SkTQSort(allFlags.begin(), allFlags.end(), CompareFlagsByName());
for (int i = 0; i < allFlags.count(); ++i) {
print_help_for_flag(allFlags[i]);
if (allFlags[i]->extendedHelp().size() > 0) {
for (SkFlagInfo* flag : allFlags) {
print_help_for_flag(flag);
if (flag->extendedHelp().size() > 0) {
SkDebugf(" Use '--help %s' for more information.\n",
allFlags[i]->name().c_str());
flag->name().c_str());
}
}
} else {

View File

@ -636,8 +636,8 @@ int main(int argc, char** argv) {
}
SkMD5::Digest digest = hash.finish();
for (int i = 0; i < 16; i++) {
md5.appendf("%02x", digest.data[i]);
for (int j = 0; j < 16; j++) {
md5.appendf("%02x", digest.data[j]);
}
}

View File

@ -800,13 +800,13 @@ void TestSVGTypeface::exportTtxCbdt(SkWStream* out, SkSpan<unsigned> strikeSizes
out->writeText(" </SmallGlyphMetrics>\n");
out->writeText(" <rawimagedata>");
uint8_t const* bytes = data->bytes();
for (size_t i = 0; i < data->size(); ++i) {
if ((i % 0x10) == 0x0) {
for (size_t j = 0; j < data->size(); ++j) {
if ((j % 0x10) == 0x0) {
out->writeText("\n ");
} else if (((i - 1) % 0x4) == 0x3) {
} else if (((j - 1) % 0x4) == 0x3) {
out->writeText(" ");
}
out->writeHexAsText(bytes[i], 2);
out->writeHexAsText(bytes[j], 2);
}
out->writeText("\n");
out->writeText(" </rawimagedata>\n");
@ -1029,13 +1029,13 @@ void TestSVGTypeface::exportTtxSbix(SkWStream* out, SkSpan<unsigned> strikeSizes
out->writeText(" <hexdata>");
uint8_t const* bytes = data->bytes();
for (size_t i = 0; i < data->size(); ++i) {
if ((i % 0x10) == 0x0) {
for (size_t j = 0; j < data->size(); ++j) {
if ((j % 0x10) == 0x0) {
out->writeText("\n ");
} else if (((i - 1) % 0x4) == 0x3) {
} else if (((j - 1) % 0x4) == 0x3) {
out->writeText(" ");
}
out->writeHexAsText(bytes[i], 2);
out->writeHexAsText(bytes[j], 2);
}
out->writeText("\n");
out->writeText(" </hexdata>\n");

View File

@ -67,8 +67,8 @@ static void add_some_white(SkRandom* rand, SkString* atom) {
SkString MakeRandomParsePathPiece(SkRandom* rand) {
SkString atom;
int index = rand->nextRangeU(0, (int) SK_ARRAY_COUNT(gLegal) - 1);
const Legal& legal = gLegal[index];
int legalIndex = rand->nextRangeU(0, (int) SK_ARRAY_COUNT(gLegal) - 1);
const Legal& legal = gLegal[legalIndex];
gEasy ? atom.append("\n") : add_white(rand, &atom);
char symbol = legal.fSymbol | (rand->nextBool() ? 0x20 : 0);
atom.append(&symbol, 1);

View File

@ -631,9 +631,8 @@ int main(int argc, char** argv) {
}
}
int i;
int numUnflaggedArguments = 0;
for (i = 1; i < argc; i++) {
for (int i = 1; i < argc; i++) {
if (!strcmp(argv[i], "--failonresult")) {
if (argc == ++i) {
SkDebugf("failonresult expects one argument.\n");

View File

@ -128,7 +128,7 @@ void BisectSlide::draw(SkCanvas* canvas) {
canvas->translate(-fDrawBounds.left(), -fDrawBounds.top());
for (const FoundPath& path : fFoundPaths) {
SkAutoCanvasRestore acr(canvas, true);
SkAutoCanvasRestore acr2(canvas, true);
canvas->concat(path.fViewMatrix);
canvas->drawPath(path.fPath, path.fPaint);
}