diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2022-10-15 13:00:22 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2022-10-15 13:04:52 -0700 |
commit | 2900d7a7e7929414268cb142bf00c57d370e1396 (patch) | |
tree | 4c19cc7b6d5e440a32bf7579db3ef8d3112ffad9 /do_complex.c | |
parent | f021fe33579e75bd19e7b5784858be14c3e3c4b6 (diff) |
Variable scope reductions as recommended by cppcheck
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'do_complex.c')
-rw-r--r-- | do_complex.c | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/do_complex.c b/do_complex.c index 88f1d4f..82a2f9d 100644 --- a/do_complex.c +++ b/do_complex.c @@ -38,7 +38,7 @@ static GC pgc; int InitComplexPoly(XParms xp, Parms p, int64_t reps) { - int i, j, numPoints; + int numPoints; int x, y; int size, iradius; double phi, phiinc, radius, delta, phi2; @@ -71,8 +71,8 @@ InitComplexPoly(XParms xp, Parms p, int64_t reps) curPoint = points; x = iradius; y = iradius; - for (i = 0; i != p->objects; i++) { - for (j = 0; j != NUM_ANGLES; j++) { + for (int i = 0; i != p->objects; i++) { + for (int j = 0; j != NUM_ANGLES; j++) { phi2 = phi + ((double) j) * delta; curPoint->x = (int) ((double)x + (radius * cos(phi2)) + 0.5); curPoint->y = (int) ((double)y + (radius * sin(phi2)) + 0.5); @@ -98,12 +98,9 @@ InitComplexPoly(XParms xp, Parms p, int64_t reps) void DoComplexPoly(XParms xp, Parms p, int64_t reps) { - int i, j; - XPoint *curPoint; - - for (i = 0; i != reps; i++) { - curPoint = points; - for (j = 0; j != p->objects; j++) { + for (int i = 0; i != reps; i++) { + XPoint *curPoint = points; + for (int j = 0; j != p->objects; j++) { XFillPolygon(xp->d, xp->w, pgc, curPoint, NUM_POINTS, Complex, CoordModeOrigin); curPoint += NUM_POINTS; @@ -125,7 +122,7 @@ EndComplexPoly(XParms xp, Parms p) int InitGeneralPoly(XParms xp, Parms p, int64_t reps) { - int i, j, numPoints; + int numPoints; int nsides; int x, y; int size, iradius; @@ -147,9 +144,9 @@ InitGeneralPoly(XParms xp, Parms p, int64_t reps) iradius = outer_radius + 1; x = iradius; y = iradius; - for (i = 0; i < p->objects; i++) { + for (int i = 0; i < p->objects; i++) { phi2 = phi; - for (j = 0; j < nsides; j++) { + for (int j = 0; j < nsides; j++) { curPoint->x = x + (outer_radius * cos(phi2) + 0.5); curPoint->y = y + (outer_radius * sin(phi2) + 0.5); curPoint++; @@ -171,16 +168,14 @@ InitGeneralPoly(XParms xp, Parms p, int64_t reps) void DoGeneralPoly(XParms xp, Parms p, int64_t reps) { - int i, j; int nsides; int mode; - XPoint *curPoint; nsides = (long) p->font; mode = (long) p->bfont; - for (i = 0; i != reps; i++) { - curPoint = points; - for (j = 0; j != p->objects; j++) { + for (int i = 0; i != reps; i++) { + XPoint *curPoint = points; + for (int j = 0; j != p->objects; j++) { XFillPolygon(xp->d, xp->w, pgc, curPoint, nsides, mode, CoordModeOrigin); curPoint += nsides; |