summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2022-10-15 13:00:22 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2022-10-15 13:04:52 -0700
commit2900d7a7e7929414268cb142bf00c57d370e1396 (patch)
tree4c19cc7b6d5e440a32bf7579db3ef8d3112ffad9
parentf021fe33579e75bd19e7b5784858be14c3e3c4b6 (diff)
Variable scope reductions as recommended by cppcheck
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--do_arcs.c14
-rw-r--r--do_blt.c18
-rw-r--r--do_complex.c29
-rw-r--r--do_dots.c8
-rw-r--r--do_lines.c7
-rw-r--r--do_movewin.c40
-rw-r--r--do_rects.c11
-rw-r--r--do_simple.c34
-rw-r--r--do_text.c72
-rw-r--r--do_traps.c27
-rw-r--r--do_tris.c23
-rw-r--r--do_valgc.c3
-rw-r--r--do_windows.c43
-rw-r--r--x11perf.c47
14 files changed, 140 insertions, 236 deletions
diff --git a/do_arcs.c b/do_arcs.c
index 5afd434..ecf381f 100644
--- a/do_arcs.c
+++ b/do_arcs.c
@@ -31,7 +31,6 @@ static GC pgc;
static void
GenerateCircles(XParms xp, Parms p, Bool partialArcs, Bool ddashed)
{
- int i;
int rows; /* Number of rows filled in current column */
int x, y; /* base of square to draw the circle in */
int xorg, yorg; /* Used to get from column to column or row to row */
@@ -52,7 +51,7 @@ GenerateCircles(XParms xp, Parms p, Bool partialArcs, Bool ddashed)
startAngle = DegreesToX(0);
arcAngle = DegreesToX(360);
- for (i = 0; i != p->objects; i++) {
+ for (int i = 0; i != p->objects; i++) {
arcs[i].x = x;
arcs[i].y = y;
arcs[i].width = size;
@@ -239,7 +238,6 @@ GenerateEllipses(XParms xp, Parms p, int partialArcs, Bool ddashed)
int size;
int half;
int rows; /* Number of rows filled in current column */
- int i;
int x, y; /* base of square to draw ellipse in */
int vsize, vsizeinc;
int dir;
@@ -263,7 +261,7 @@ GenerateEllipses(XParms xp, Parms p, int partialArcs, Bool ddashed)
startAngle = DegreesToX(0);
arcAngle = DegreesToX(360);
- for (i = 0; i != p->objects; i++) {
+ for (int i = 0; i != p->objects; i++) {
arcs[i].x = x;
arcs[i].y = y;
if ((i & 1) ^ dir) {
@@ -454,9 +452,7 @@ InitWideDoubleDashedEllipses(XParms xp, Parms p, int64_t reps)
void
DoArcs(XParms xp, Parms p, int64_t reps)
{
- int i;
-
- for (i = 0; i != reps; i++) {
+ for (int i = 0; i != reps; i++) {
XDrawArcs(xp->d, xp->w, pgc, arcs, p->objects);
if (pgc == xp->ddbggc)
pgc = xp->ddfggc;
@@ -473,9 +469,7 @@ DoArcs(XParms xp, Parms p, int64_t reps)
void
DoFilledArcs(XParms xp, Parms p, int64_t reps)
{
- int i;
-
- for (i = 0; i != reps; i++) {
+ for (int i = 0; i != reps; i++) {
XFillArcs(xp->d, xp->w, pgc, arcs, p->objects);
if (pgc == xp->ddbggc)
pgc = xp->ddfggc;
diff --git a/do_blt.c b/do_blt.c
index 3374ca6..b44eb42 100644
--- a/do_blt.c
+++ b/do_blt.c
@@ -37,10 +37,10 @@ static XSegment *segsa2, *segsb2;
static void
InitBltLines(void)
{
- int i, x, y;
+ int x, y;
points[0].x = points[0].y = y = 0;
- for (i = 1; i != NUMPOINTS/2; i++) {
+ for (int i = 1; i != NUMPOINTS/2; i++) {
if (i & 1) {
points[i].x = WIDTH-1;
} else {
@@ -51,7 +51,7 @@ InitBltLines(void)
}
x = 0;
- for (i = NUMPOINTS/2; i!= NUMPOINTS; i++) {
+ for (int i = NUMPOINTS/2; i!= NUMPOINTS; i++) {
if (i & 1) {
points[i].y = HEIGHT-1;
} else {
@@ -73,7 +73,7 @@ InitScroll(XParms xp, Parms p, int64_t reps)
void
DoScroll(XParms xp, Parms p, int64_t reps)
{
- int i, size, x, y, xorg, yorg, delta;
+ int size, x, y, xorg, yorg, delta;
size = p->special;
xorg = 0; yorg = 0;
@@ -88,7 +88,7 @@ DoScroll(XParms xp, Parms p, int64_t reps)
delta = 13;
}
- for (i = 0; i != reps; i++) {
+ for (int i = 0; i != reps; i++) {
XCopyArea(xp->d, xp->w, xp->w, xp->fggc, x, y + delta,
size, size, x, y);
y += size;
@@ -127,7 +127,7 @@ static void
InitCopyLocations(int size, int mul, int div,
int64_t reps, XSegment **ap, XSegment **bp)
{
- int x1, y1, x2, y2, i;
+ int x1, y1, x2, y2;
int xinc, yinc;
int width, height;
XSegment *a, *b;
@@ -151,7 +151,7 @@ InitCopyLocations(int size, int mul, int div,
*ap = a = (XSegment *)malloc(reps * sizeof(XSegment));
*bp = b = (XSegment *)malloc(reps * sizeof(XSegment));
- for (i = 0; i != reps; i++) {
+ for (int i = 0; i != reps; i++) {
a[i].x1 = x1 * div / mul;
a[i].y1 = y1 * div / mul;
a[i].x2 = x2 * div / mul;
@@ -716,7 +716,7 @@ EndCompositeWin (XParms xp, Parms p)
static void
CompositeArea(XParms xp, Parms p, int64_t reps, Picture src, Picture dst)
{
- int i, size;
+ int size;
XSegment *sa, *sb;
XSegment *sa2, *sb2;
@@ -726,7 +726,7 @@ CompositeArea(XParms xp, Parms p, int64_t reps, Picture src, Picture dst)
sb = segsb;
sa2 = segsa2 ? segsa2 : segsa;
sb2 = segsb2 ? segsb2 : segsb;
- for (i = 0; i < reps; i++) {
+ for (int i = 0; i < reps; i++) {
XRenderComposite (xp->d, xp->func,
src, None, dst,
sa2->x1, sa2->y1, 0, 0, sa->x2, sa->y2, size, size);
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;
diff --git a/do_dots.c b/do_dots.c
index fe9ca2e..a02cb10 100644
--- a/do_dots.c
+++ b/do_dots.c
@@ -29,13 +29,11 @@ static GC pgc;
int
InitDots(XParms xp, Parms p, int64_t reps)
{
- int i;
-
pgc = xp->fggc;
points = (XPoint *)malloc(p->objects * sizeof(XPoint));
- for (i = 0; i != p->objects; i++) {
+ for (int i = 0; i != p->objects; i++) {
points[i].x = 2 * (i/MAXROWS);
points[i].y = 2 * (i%MAXROWS);
}
@@ -45,9 +43,7 @@ InitDots(XParms xp, Parms p, int64_t reps)
void
DoDots(XParms xp, Parms p, int64_t reps)
{
- int i;
-
- for (i = 0; i != reps; i++) {
+ for (int i = 0; i != reps; i++) {
XDrawPoints(xp->d, xp->w, pgc, points, p->objects, CoordModeOrigin);
if (pgc == xp->bggc)
pgc = xp->fggc;
diff --git a/do_lines.c b/do_lines.c
index d2ad1d6..de9608d 100644
--- a/do_lines.c
+++ b/do_lines.c
@@ -31,7 +31,6 @@ GenerateLines(XParms xp, Parms p, Bool ddashed)
{
int size;
int half; /* Half of width if wide line */
- int i;
int rows; /* Number of rows filled in current column */
int x, y; /* Next point */
int xdir, ydir; /* Which direction x, y are going */
@@ -76,7 +75,7 @@ GenerateLines(XParms xp, Parms p, Bool ddashed)
points[0].x = x;
points[0].y = y;
- for (i = 1; i != (p->objects+1); i++) {
+ for (int i = 1; i != (p->objects+1); i++) {
phase = phasef;
switch (phase / (size+1)) {
case 0:
@@ -275,9 +274,7 @@ InitWideDoubleDashedLines(XParms xp, Parms p, int64_t reps)
void
DoLines(XParms xp, Parms p, int64_t reps)
{
- int i;
-
- for (i = 0; i != reps; i++)
+ for (int i = 0; i != reps; i++)
{
XDrawLines(xp->d, xp->w, pgc, points, p->objects+1, CoordModeOrigin);
if (pgc == xp->ddbggc)
diff --git a/do_movewin.c b/do_movewin.c
index 27b0389..05fb2ce 100644
--- a/do_movewin.c
+++ b/do_movewin.c
@@ -36,8 +36,6 @@ static int delta1; /* Private global data for DoResizeWindows */
int
InitMoveWindows(XParms xp, Parms p, int64_t reps)
{
- int i = 0;
-
rows = (p->objects + MAXCOLS - 1) / MAXCOLS;
x_offset = 0;
@@ -50,7 +48,7 @@ InitMoveWindows(XParms xp, Parms p, int64_t reps)
xmax = (CHILDSIZE+CHILDSPACE) * (rows > 1 ? MAXCOLS : p->objects);
ymax = rows * (CHILDSIZE+CHILDSPACE);
- for (i = 0; i != p->objects; i++) {
+ for (int i = 0; i != p->objects; i++) {
positions[i].x = (CHILDSIZE+CHILDSPACE) * (i/rows) + CHILDSPACE/2;
positions[i].y = (CHILDSIZE+CHILDSPACE) * (i%rows) + CHILDSPACE/2;
children[i] = XCreateSimpleWindow(xp->d, xp->w,
@@ -65,16 +63,14 @@ InitMoveWindows(XParms xp, Parms p, int64_t reps)
void
DoMoveWindows(XParms xp, Parms p, int64_t reps)
{
- int i, j;
-
- for (i = 0; i != reps; i++) {
+ for (int i = 0; i != reps; i++) {
x_offset += 1;
y_offset += 3;
if (y_offset + ymax > HEIGHT)
y_offset = 0;
if (x_offset + xmax > WIDTH)
x_offset = 0;
- for (j = 0; j != p->objects; j++) {
+ for (int j = 0; j != p->objects; j++) {
XMoveWindow(xp->d, children[j],
positions[j].x + x_offset, positions[j].y + y_offset);
}
@@ -92,12 +88,12 @@ EndMoveWindows(XParms xp, Parms p)
void
DoResizeWindows(XParms xp, Parms p, int64_t reps)
{
- int i, j, delta2;
+ for (int i = 0; i != reps; i++) {
+ int delta2;
- for (i = 0; i != reps; i++) {
delta1 = -delta1;
delta2 = delta1;
- for (j = 0; j != p->objects; j++) {
+ for (int j = 0; j != p->objects; j++) {
delta2 = -delta2;
XResizeWindow(xp->d, children[j],
CHILDSIZE+delta2, CHILDSIZE-delta2);
@@ -109,14 +105,10 @@ DoResizeWindows(XParms xp, Parms p, int64_t reps)
int
InitCircWindows(XParms xp, Parms p, int64_t reps)
{
- int i;
- int pos;
- int color;
-
children = (Window *) malloc (p->objects * sizeof (Window));
- for (i = 0; i != p->objects; i++) {
- pos = i % STACK;
- color = (i & 1 ? xp->foreground : xp->background);
+ for (int i = 0; i != p->objects; i++) {
+ int pos = i % STACK;
+ int color = (i & 1 ? xp->foreground : xp->background);
children[i] = XCreateSimpleWindow (xp->d, xp->w,
pos*CHILDSIZE/4 + (i/STACK)*2*CHILDSIZE, pos*CHILDSIZE/4,
CHILDSIZE, CHILDSIZE, 0, color, color);
@@ -129,11 +121,9 @@ InitCircWindows(XParms xp, Parms p, int64_t reps)
void
DoCircWindows(XParms xp, Parms p, int64_t reps)
{
- int i, j;
-
- for (i = 0; i != reps; i++)
+ for (int i = 0; i != reps; i++)
{
- for (j = 0; j != p->objects; j++)
+ for (int j = 0; j != p->objects; j++)
XCirculateSubwindows (xp->d, xp->w, RaiseLowest);
CheckAbort ();
}
@@ -149,8 +139,6 @@ EndCircWindows(XParms xp, Parms p)
int
InitMoveTree(XParms xp, Parms p, int64_t reps)
{
- int i = 0;
-
rows = (p->objects + MAXCOLS - 1) / MAXCOLS;
x_offset = 0;
@@ -167,7 +155,7 @@ InitMoveTree(XParms xp, Parms p, int64_t reps)
0, 0, xmax, ymax, 0,
xp->background, xp->background);
- for (i = 0; i != p->objects; i++) {
+ for (int i = 0; i != p->objects; i++) {
positions[i].x = (CHILDSIZE+CHILDSPACE) * (i/rows) + CHILDSPACE/2;
positions[i].y = (CHILDSIZE+CHILDSPACE) * (i%rows) + CHILDSPACE/2;
children[i] = XCreateSimpleWindow(xp->d, cover,
@@ -182,9 +170,7 @@ InitMoveTree(XParms xp, Parms p, int64_t reps)
void
DoMoveTree(XParms xp, Parms p, int64_t reps)
{
- int i;
-
- for (i = 0; i != reps; i++) {
+ for (int i = 0; i != reps; i++) {
x_offset += 1;
y_offset += 3;
if (y_offset + ymax > HEIGHT)
diff --git a/do_rects.c b/do_rects.c
index b4507bc..a3d1195 100644
--- a/do_rects.c
+++ b/do_rects.c
@@ -30,7 +30,6 @@ static GC pgc;
int
InitRectangles(XParms xp, Parms p, int64_t reps)
{
- int i;
int size = p->special;
int step;
int x, y;
@@ -61,7 +60,7 @@ InitRectangles(XParms xp, Parms p, int64_t reps)
step = size + 1 + (size % 2);
}
- for (i = 0; i != p->objects; i++) {
+ for (int i = 0; i != p->objects; i++) {
rects[i].x = x;
rects[i].y = y;
rects[i].width = rects[i].height = size;
@@ -86,9 +85,7 @@ InitRectangles(XParms xp, Parms p, int64_t reps)
void
DoRectangles(XParms xp, Parms p, int64_t reps)
{
- int i;
-
- for (i = 0; i != reps; i++) {
+ for (int i = 0; i != reps; i++) {
XFillRectangles(xp->d, xp->w, pgc, rects, p->objects);
if (pgc == xp->bggc)
pgc = xp->fggc;
@@ -101,9 +98,7 @@ DoRectangles(XParms xp, Parms p, int64_t reps)
void
DoOutlineRectangles(XParms xp, Parms p, int64_t reps)
{
- int i;
-
- for (i = 0; i != reps; i++) {
+ for (int i = 0; i != reps; i++) {
XDrawRectangles (xp->d, xp->w, pgc, rects, p->objects);
if (pgc == xp->bggc)
pgc = xp->fggc;
diff --git a/do_simple.c b/do_simple.c
index d6c4d59..29970a6 100644
--- a/do_simple.c
+++ b/do_simple.c
@@ -34,9 +34,7 @@ static Atom XA_PK_TEMP;
void
DoNoOp(XParms xp, Parms p, int64_t reps)
{
- int i;
-
- for (i = 0; i != reps; i++) {
+ for (int i = 0; i != reps; i++) {
XNoOp(xp->d);
CheckAbort ();
}
@@ -46,11 +44,8 @@ DoNoOp(XParms xp, Parms p, int64_t reps)
void
DoGetAtom(XParms xp, Parms p, int64_t reps)
{
- char *atom;
- int i;
-
- for (i = 0; i != reps; i++) {
- atom = XGetAtomName (xp->d, 1);
+ for (int i = 0; i != reps; i++) {
+ char *atom = XGetAtomName (xp->d, 1);
XFree(atom); /* fix XBUG 6480 */
CheckAbort ();
}
@@ -59,12 +54,11 @@ DoGetAtom(XParms xp, Parms p, int64_t reps)
void
DoQueryPointer(XParms xp, Parms p, int64_t reps)
{
- int i;
- Window w;
- int x;
- unsigned int m;
+ for (int i = 0; i != reps; i++) {
+ Window w;
+ int x;
+ unsigned int m;
- for (i = 0; i != reps; i++) {
XQueryPointer (xp->d, xp->w, &w, &w, &x, &x, &x, &x, &m);
CheckAbort ();
}
@@ -89,14 +83,12 @@ InitGetProperty(XParms xp, Parms p, int64_t reps)
void
DoGetProperty(XParms xp, Parms p, int64_t reps)
{
- int i;
- int actual_format;
- unsigned long actual_length, bytes_remaining;
- unsigned char *prop;
-
- Atom actual_type;
-
- for (i = 0; i != reps; i++) {
+ for (int i = 0; i != reps; i++) {
+ int actual_format;
+ unsigned long actual_length, bytes_remaining;
+ unsigned char *prop;
+ Atom actual_type;
+
XGetWindowProperty (
xp->d, xp->w, XA_PK_TEMP, 0, 4,
False, AnyPropertyType, &actual_type, &actual_format,
diff --git a/do_text.c b/do_text.c
index 01845e1..6ba8715 100644
--- a/do_text.c
+++ b/do_text.c
@@ -37,8 +37,6 @@ static int charsPerLine, totalLines;
int
InitText(XParms xp, Parms p, int64_t reps)
{
- int i, j;
- char ch;
XGCValues gcv;
font = XLoadQueryFont(xp->d, p->font);
@@ -78,10 +76,12 @@ InitText(XParms xp, Parms p, int64_t reps)
if (p->special)
items = (XTextItem *) malloc(totalLines*SEGS*sizeof (XTextItem));
- for (i = 0; i != totalLines; i++) {
+ for (int i = 0; i != totalLines; i++) {
+ char ch;
+
charBuf[i] = (char *) malloc (sizeof (char)*charsPerLine);
ch = i + ' ';
- for (j = 0; j != charsPerLine; j++) {
+ for (int j = 0; j != charsPerLine; j++) {
charBuf[i][j] = ch;
if (ch == '\177') ch = ' '; else ch++;
}
@@ -121,8 +121,6 @@ InitText(XParms xp, Parms p, int64_t reps)
int
InitText16(XParms xp, Parms p, int64_t reps)
{
- register int i, j;
- register char *pbuf0, *pbuf1, *pbuf2;
XGCValues gcv;
int rows, columns, totalChars, ch;
int brows, bcolumns = 0, btotalChars = 0, bch = 0;
@@ -173,7 +171,9 @@ InitText16(XParms xp, Parms p, int64_t reps)
items = (XTextItem *) malloc(totalLines*SEGS*sizeof (XTextItem));
- for (i = 0; i < totalLines; i++) {
+ for (int i = 0; i < totalLines; i++) {
+ char *pbuf0, *pbuf1, *pbuf2;
+
pbuf0 = items[i*SEGS+0].chars =
(char *) malloc (sizeof (char)*charsPerLine/2);
items[i*SEGS+0].nchars = charsPerLine/4;
@@ -189,7 +189,7 @@ InitText16(XParms xp, Parms p, int64_t reps)
items[i*SEGS+2].nchars = charsPerLine/4;
items[i*SEGS+2].delta = 3;
items[i*SEGS+2].font = font->fid;
- for (j = 0; j < charsPerLine/4; j++) {
+ for (int j = 0; j < charsPerLine/4; j++) {
GetRealChar(font, totalChars, ch);
*pbuf0++ = ch / columns + font->min_byte1;
*pbuf0++ = ch % columns + font->min_char_or_byte2;
@@ -197,7 +197,7 @@ InitText16(XParms xp, Parms p, int64_t reps)
*pbuf2++ = ch / columns + font->min_byte1;
*pbuf2++ = ch % columns + font->min_char_or_byte2;
}
- for (j = 0; j < charsPerLine/2; j++) {
+ for (int j = 0; j < charsPerLine/2; j++) {
GetRealChar(bfont, btotalChars, bch);
*pbuf1++ = bch / bcolumns + bfont->min_byte1;
*pbuf1++ = bch % bcolumns + bfont->min_char_or_byte2;
@@ -205,9 +205,10 @@ InitText16(XParms xp, Parms p, int64_t reps)
}
} else {
charBuf = (char **) malloc(totalLines*sizeof (char *));
- for (i = 0; i < totalLines; i++) {
- pbuf0 = charBuf[i] = (char *) malloc (sizeof (char)*charsPerLine*2);
- for (j = 0; j < charsPerLine; j++) {
+ for (int i = 0; i < totalLines; i++) {
+ char *pbuf0 = charBuf[i] =
+ (char *) malloc (sizeof (char)*charsPerLine*2);
+ for (int j = 0; j < charsPerLine; j++) {
GetRealChar(font, totalChars, ch);
*pbuf0++ = ch / columns + font->min_byte1;
*pbuf0++ = ch % columns + font->min_char_or_byte2;
@@ -220,11 +221,11 @@ InitText16(XParms xp, Parms p, int64_t reps)
void
DoText(XParms xp, Parms p, int64_t reps)
{
- int i, line, startLine;
+ int line, startLine;
startLine = 0;
line = 0;
- for (i = 0; i != reps; i++) {
+ for (int i = 0; i != reps; i++) {
XDrawString(
xp->d, xp->w, xp->fggc, XPOS, ypos, charBuf[line], charsPerLine);
ypos += height;
@@ -242,11 +243,11 @@ DoText(XParms xp, Parms p, int64_t reps)
void
DoText16(XParms xp, Parms p, int64_t reps)
{
- int i, line, startLine;
+ int line, startLine;
startLine = 0;
line = 0;
- for (i = 0; i < reps; i++) {
+ for (int i = 0; i < reps; i++) {
XDrawString16(
xp->d, xp->w, xp->fggc, XPOS, ypos, (XChar2b *)charBuf[line], charsPerLine);
ypos += height;
@@ -264,11 +265,11 @@ DoText16(XParms xp, Parms p, int64_t reps)
void
DoPolyText(XParms xp, Parms p, int64_t reps)
{
- int i, line, startLine;
+ int line, startLine;
startLine = 0;
line = 0;
- for (i = 0; i != reps; i++) {
+ for (int i = 0; i != reps; i++) {
XDrawText(
xp->d, xp->w, xp->fggc, XPOS, ypos, &items[line*SEGS], SEGS);
ypos += height;
@@ -286,11 +287,11 @@ DoPolyText(XParms xp, Parms p, int64_t reps)
void
DoPolyText16(XParms xp, Parms p, int64_t reps)
{
- int i, line, startLine;
+ int line, startLine;
startLine = 0;
line = 0;
- for (i = 0; i != reps; i++) {
+ for (int i = 0; i != reps; i++) {
XDrawText16(
xp->d, xp->w, xp->fggc, XPOS, ypos, (XTextItem16 *)&items[line*SEGS], SEGS);
ypos += height;
@@ -308,11 +309,11 @@ DoPolyText16(XParms xp, Parms p, int64_t reps)
void
DoImageText(XParms xp, Parms p, int64_t reps)
{
- int i, line, startLine;
+ int line, startLine;
startLine = 0;
line = 0;
- for (i = 0; i != reps; i++) {
+ for (int i = 0; i != reps; i++) {
XDrawImageString(
xp->d, xp->w, xp->fggc, XPOS, ypos, charBuf[line], charsPerLine);
ypos += height;
@@ -330,11 +331,11 @@ DoImageText(XParms xp, Parms p, int64_t reps)
void
DoImageText16(XParms xp, Parms p, int64_t reps)
{
- int i, line, startLine;
+ int line, startLine;
startLine = 0;
line = 0;
- for (i = 0; i != reps; i++) {
+ for (int i = 0; i != reps; i++) {
XDrawImageString16(
xp->d, xp->w, xp->fggc, XPOS, ypos, (XChar2b *)charBuf[line], charsPerLine);
ypos += height;
@@ -358,10 +359,8 @@ ClearTextWin(XParms xp, Parms p)
void
EndText(XParms xp, Parms p)
{
- int i;
-
if(font==NULL)return;
- for (i = 0; i != totalLines; i++)
+ for (int i = 0; i != totalLines; i++)
free(charBuf[i]);
free(charBuf);
if (p->special)
@@ -374,18 +373,16 @@ EndText(XParms xp, Parms p)
void
EndText16(XParms xp, Parms p)
{
- int i;
-
if(font==NULL)return;
if (p->special) {
- for (i = 0; i < totalLines; i++) {
+ for (int i = 0; i < totalLines; i++) {
free(items[i*SEGS+0].chars);
free(items[i*SEGS+1].chars);
free(items[i*SEGS+2].chars);
}
free(items);
} else {
- for (i = 0; i < totalLines; i++) {
+ for (int i = 0; i < totalLines; i++) {
free(charBuf[i]);
}
free(charBuf);
@@ -407,7 +404,6 @@ static XftColor aacolor;
int
InitAAText(XParms xp, Parms p, int64_t reps)
{
- int i, j;
char ch;
XRenderColor color;
@@ -459,10 +455,10 @@ InitAAText(XParms xp, Parms p, int64_t reps)
charBuf = (char **) malloc(totalLines*sizeof (char *));
- for (i = 0; i != totalLines; i++) {
+ for (int i = 0; i != totalLines; i++) {
charBuf[i] = (char *) malloc (sizeof (char)*charsPerLine);
ch = i + ' ';
- for (j = 0; j != charsPerLine; j++) {
+ for (int j = 0; j != charsPerLine; j++) {
charBuf[i][j] = ch;
if (ch == '\177') ch = ' '; else ch++;
}
@@ -473,11 +469,11 @@ InitAAText(XParms xp, Parms p, int64_t reps)
void
DoAAText(XParms xp, Parms p, int64_t reps)
{
- int i, line, startLine;
+ int line, startLine;
startLine = 0;
line = 0;
- for (i = 0; i != reps; i++) {
+ for (int i = 0; i != reps; i++) {
XftDrawString8 (aadraw, &aacolor, aafont,
XPOS, ypos, (unsigned char *) charBuf[line], charsPerLine);
ypos += height;
@@ -495,10 +491,8 @@ DoAAText(XParms xp, Parms p, int64_t reps)
void
EndAAText(XParms xp, Parms p)
{
- int i;
-
if(!aadraw)return;
- for (i = 0; i != totalLines; i++)
+ for (int i = 0; i != totalLines; i++)
free(charBuf[i]);
free(charBuf);
XftDrawDestroy (aadraw);
diff --git a/do_traps.c b/do_traps.c
index 1c33ab0..b1b3e2b 100644
--- a/do_traps.c
+++ b/do_traps.c
@@ -31,7 +31,7 @@ static GC pgc;
int
InitTrapezoids(XParms xp, Parms p, int64_t reps)
{
- int i, numPoints;
+ int numPoints;
int rows;
int x, y;
int size, skew;
@@ -48,7 +48,7 @@ InitTrapezoids(XParms xp, Parms p, int64_t reps)
rows = 0;
skew = size;
- for (i = 0; i != p->objects; i++, curPoint += NUM_POINTS) {
+ for (int i = 0; i != p->objects; i++, curPoint += NUM_POINTS) {
curPoint[0].x = x - skew;
curPoint[0].y = y;
curPoint[1].x = x - skew + size;
@@ -80,12 +80,9 @@ InitTrapezoids(XParms xp, Parms p, int64_t reps)
void
DoTrapezoids(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, Convex,
CoordModeOrigin);
curPoint += NUM_POINTS;
@@ -120,7 +117,7 @@ static Picture mask;
int
InitFixedTraps(XParms xp, Parms p, int64_t reps)
{
- int i, numTraps;
+ int numTraps;
int rows;
int x, y;
int size, skew;
@@ -202,7 +199,7 @@ InitFixedTraps(XParms xp, Parms p, int64_t reps)
if (width == 0)
width = size;
- for (i = 0; i != p->objects; i++, curTrap ++) {
+ for (int i = 0; i != p->objects; i++, curTrap ++) {
curTrap->top.y = XDoubleToFixed (y);
curTrap->top.left = XDoubleToFixed (x - skew);
curTrap->top.right = XDoubleToFixed (x - skew + width);
@@ -232,7 +229,6 @@ InitFixedTraps(XParms xp, Parms p, int64_t reps)
void
DoFixedTraps(XParms xp, Parms p, int64_t reps)
{
- int i;
Picture white, black, src, dst;
white = XftDrawSrcPicture (aadraw, &aawhite);
@@ -240,7 +236,7 @@ DoFixedTraps(XParms xp, Parms p, int64_t reps)
dst = XftDrawPicture (aadraw);
src = black;
- for (i = 0; i != reps; i++) {
+ for (int i = 0; i != reps; i++) {
XRenderFillRectangle (xp->d, PictOpSrc, mask, &transparent,
0, 0, WIDTH, HEIGHT);
XRenderAddTraps (xp->d, mask, 0, 0, traps, p->objects);
@@ -266,7 +262,7 @@ EndFixedTraps (XParms xp, Parms p)
int
InitFixedTrapezoids(XParms xp, Parms p, int64_t reps)
{
- int i, numTraps;
+ int numTraps;
int rows;
int x, y;
int size, skew;
@@ -330,7 +326,7 @@ InitFixedTrapezoids(XParms xp, Parms p, int64_t reps)
return 0;
}
- for (i = 0; i != p->objects; i++, curTrap ++) {
+ for (int i = 0; i != p->objects; i++, curTrap++) {
curTrap->top = XDoubleToFixed (y);
curTrap->bottom = XDoubleToFixed (y + size);
curTrap->left.p1.x = XDoubleToFixed (x - skew);
@@ -366,7 +362,6 @@ InitFixedTrapezoids(XParms xp, Parms p, int64_t reps)
void
DoFixedTrapezoids(XParms xp, Parms p, int64_t reps)
{
- int i;
Picture white, black, src, dst;
white = XftDrawSrcPicture (aadraw, &aawhite);
@@ -374,7 +369,7 @@ DoFixedTrapezoids(XParms xp, Parms p, int64_t reps)
dst = XftDrawPicture (aadraw);
src = black;
- for (i = 0; i != reps; i++) {
+ for (int i = 0; i != reps; i++) {
XRenderCompositeTrapezoids (xp->d, PictOpOver, src, dst, maskFormat,
0, 0, trapezoids, p->objects);
if (src == black)
diff --git a/do_tris.c b/do_tris.c
index 0a8d511..6605fd1 100644
--- a/do_tris.c
+++ b/do_tris.c
@@ -1,3 +1,6 @@
+
+
+
/*****************************************************************************
Copyright 1988, 1989 by Digital Equipment Corporation, Maynard, Massachusetts.
@@ -58,7 +61,7 @@ Distance(XPoint p1, XPoint p2)
int
InitTriangles(XParms xp, Parms p, int64_t reps)
{
- int i, j, numPoints;
+ int numPoints;
int rows;
int x, y;
int size, iradius;
@@ -95,8 +98,8 @@ InitTriangles(XParms xp, Parms p, int64_t reps)
rows = 0;
aarea = 0.0;
- for (i = 0; i != p->objects; i++) {
- for (j = 0; j != NUM_POINTS; j++) {
+ for (int i = 0; i != p->objects; i++) {
+ for (int j = 0; j != NUM_POINTS; 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);
@@ -134,12 +137,9 @@ InitTriangles(XParms xp, Parms p, int64_t reps)
void
DoTriangles(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, Convex,
CoordModeOrigin);
curPoint += NUM_POINTS;
@@ -209,10 +209,7 @@ XPolyTriangle(register Display *dpy,
void
DoTriangles(XParms xp, Parms p, int64_t reps)
{
- int i, j;
- XPoint *curPoint;
-
- for (i = 0; i != reps; i++) {
+ for (int i = 0; i != reps; i++) {
XPolyTriangle (xp->d, xp->w, pgc, points, p->objects, Convex,
CoordModeOrigin);
if (pgc == xp->bggc)
diff --git a/do_valgc.c b/do_valgc.c
index 68559f9..8edf764 100644
--- a/do_valgc.c
+++ b/do_valgc.c
@@ -44,10 +44,9 @@ InitGC(XParms xp, Parms p, int64_t reps)
void
DoChangeGC(XParms xp, Parms p, int64_t reps)
{
- int i;
XGCValues gcv;
- for (i = 0; i != reps; i++) {
+ for (int i = 0; i != reps; i++) {
gcv.foreground = xp->foreground;
XChangeGC(xp->d, xp->fggc, GCForeground , &gcv);
XDrawPoint(xp->d, win[0], xp->fggc, 5, 5);
diff --git a/do_windows.c b/do_windows.c
index ebd095a..386be6a 100644
--- a/do_windows.c
+++ b/do_windows.c
@@ -44,8 +44,6 @@ ComputeSizes(XParms xp, Parms p)
int
CreateParents(XParms xp, Parms p, int64_t reps)
{
- int i;
-
ComputeSizes(xp, p);
parentcolumns = WIDTH / parentwidth;
@@ -70,7 +68,7 @@ CreateParents(XParms xp, Parms p, int64_t reps)
* the number of children we are trying to get benchmarks on.
*/
- for (i = 0; i != parentwindows; i++) {
+ for (int i = 0; i != parentwindows; i++) {
isolates[i] = XCreateSimpleWindow(xp->d, xp->w,
(i/parentrows)*parentwidth, (i%parentrows)*parentheight,
parentwidth, parentheight, 0, xp->background, xp->background);
@@ -86,9 +84,7 @@ CreateParents(XParms xp, Parms p, int64_t reps)
void
MapParents(XParms xp, Parms p, int64_t reps)
{
- int i;
-
- for (i = 0; i != parentwindows; i++) {
+ for (int i = 0; i != parentwindows; i++) {
XMapWindow(xp->d, parents[i]);
}
}
@@ -96,9 +92,7 @@ MapParents(XParms xp, Parms p, int64_t reps)
void
MapParentsCleanup(XParms xp, Parms p)
{
- int i;
-
- for (i = 0; i != parentwindows; i++) {
+ for (int i = 0; i != parentwindows; i++) {
XMapWindow(xp->d, parents[i]);
}
}
@@ -115,9 +109,7 @@ InitCreate(XParms xp, Parms p, int64_t reps)
static void
CreateChildGroup(XParms xp, Parms p, Window parent)
{
- int j;
-
- for (j = 0; j != childwindows; j++) {
+ for (int j = 0; j != childwindows; j++) {
(void) XCreateSimpleWindow (xp->d, parent,
(CHILDSIZE+CHILDSPACE) * (j/childrows) + CHILDSPACE/2,
(CHILDSIZE+CHILDSPACE) * (j%childrows) + CHILDSPACE/2,
@@ -131,9 +123,7 @@ CreateChildGroup(XParms xp, Parms p, Window parent)
void
CreateChildren(XParms xp, Parms p, int64_t reps)
{
- int i;
-
- for (i = 0; i != parentwindows; i++) {
+ for (int i = 0; i != parentwindows; i++) {
CreateChildGroup(xp, p, parents[i]);
} /* end i */
}
@@ -141,9 +131,7 @@ CreateChildren(XParms xp, Parms p, int64_t reps)
void
DestroyChildren(XParms xp, Parms p)
{
- int i;
-
- for (i = 0; i != parentwindows; i++) {
+ for (int i = 0; i != parentwindows; i++) {
XDestroySubwindows(xp->d, parents[i]);
}
}
@@ -168,9 +156,7 @@ InitMap(XParms xp, Parms p, int64_t reps)
void
UnmapParents(XParms xp, Parms p, int64_t reps)
{
- int i;
-
- for (i = 0; i != parentwindows; i++) {
+ for (int i = 0; i != parentwindows; i++) {
XUnmapWindow(xp->d, parents[i]);
}
}
@@ -178,9 +164,7 @@ UnmapParents(XParms xp, Parms p, int64_t reps)
void
UnmapParentsCleanup(XParms xp, Parms p)
{
- int i;
-
- for (i = 0; i != parentwindows; i++) {
+ for (int i = 0; i != parentwindows; i++) {
XUnmapWindow(xp->d, parents[i]);
}
}
@@ -197,9 +181,7 @@ InitDestroy(XParms xp, Parms p, int64_t reps)
void
DestroyParents(XParms xp, Parms p, int64_t reps)
{
- int i;
-
- for (i = 0; i != parentwindows; i++) {
+ for (int i = 0; i != parentwindows; i++) {
XDestroyWindow(xp->d, parents[i]);
}
}
@@ -208,9 +190,7 @@ DestroyParents(XParms xp, Parms p, int64_t reps)
void
RenewParents(XParms xp, Parms p)
{
- int i;
-
- for (i = 0; i != parentwindows; i++) {
+ for (int i = 0; i != parentwindows; i++) {
parents[i] = XCreateSimpleWindow(xp->d, isolates[i],
0, 0, parentwidth, parentheight, 0, xp->background, xp->background);
}
@@ -262,8 +242,7 @@ InitPopups(XParms xp, Parms p, int64_t reps)
void
DoPopUps(XParms xp, Parms p, int64_t reps)
{
- int i;
- for (i = 0; i != reps; i++) {
+ for (int i = 0; i != reps; i++) {
XMapWindow(xp->d, popup);
XUnmapWindow(xp->d, popup);
CheckAbort ();
diff --git a/x11perf.c b/x11perf.c
index e2e8efd..5adbc39 100644
--- a/x11perf.c
+++ b/x11perf.c
@@ -289,12 +289,10 @@ RoundTo3Digits(double d)
static void
ReportTimes(double usecs, int64_t n, char *str, int average)
{
- double msecsperobj, objspersec;
-
if(usecs != 0.0)
{
- msecsperobj = usecs / (1000.0 * (double)n);
- objspersec = (double) n * 1000000.0 / usecs;
+ double msecsperobj = usecs / (1000.0 * (double)n);
+ double objspersec = (double) n * 1000000.0 / usecs;
/* Round obj/sec to 3 significant digits. Leave msec untouched, to
allow averaging results from several repetitions. */
@@ -334,9 +332,8 @@ Get_Display_Name(int *pargc, /* MODIFIED */
int argc = *pargc;
char **pargv = argv+1;
char *displayname = NULL;
- int i;
- for (i = 1; i != argc; i++) {
+ for (int i = 1; i != argc; i++) {
char *arg = argv[i];
if (!strcmp (arg, "-display") || !strcmp (arg, "-d")) {
@@ -370,10 +367,9 @@ GetVersion(int *pargc, /* MODIFIED */
int argc = *pargc;
char **pargv = argv+1;
Version version = VERSION1_6;
- int i;
Bool found = False;
- for (i = 1; i != argc; i++) {
+ for (int i = 1; i != argc; i++) {
char *arg = argv[i];
if (!strcmp (arg, "-v1.2")) {
@@ -549,9 +545,7 @@ HardwareSync(XParms xp)
static void
DoHardwareSync(XParms xp, Parms p, int64_t reps)
{
- int i;
-
- for (i = 0; i != reps; i++) {
+ for (int i = 0; i != reps; i++) {
HardwareSync(xp);
CheckAbort ();
}
@@ -600,12 +594,11 @@ CreatePerfWindow(XParms xp, int x, int y, int width, int height)
static void
CreateClipWindows(XParms xp, int clips)
{
- int j;
XWindowAttributes xwa;
(void) XGetWindowAttributes(xp->d, xp->w, &xwa);
if (clips > MAXCLIP) clips = MAXCLIP;
- for (j = 0; j != clips; j++) {
+ for (int j = 0; j != clips; j++) {
clipWindows[j] = CreatePerfWindow(xp,
xwa.x + ws[j].x, xwa.y + ws[j].y, ws[j].width, ws[j].height);
}
@@ -615,10 +608,8 @@ CreateClipWindows(XParms xp, int clips)
static void
DestroyClipWindows(XParms xp, int clips)
{
- int j;
-
if (clips > MAXCLIP) clips = MAXCLIP;
- for (j = 0; j != clips; j++) {
+ for (int j = 0; j != clips; j++) {
XDestroyWindow(xp->d, clipWindows[j]);
}
} /* DestroyClipWindows */
@@ -832,7 +823,6 @@ ProcessTest(XParms xp, Test *test, int func, unsigned long pm, char *label)
{
double time, totalTime;
long long reps;
- int j;
xp->planemask = pm;
xp->func = func;
@@ -862,7 +852,7 @@ ProcessTest(XParms xp, Test *test, int func, unsigned long pm, char *label)
CreateClipWindows(xp, test->clips);
totalTime = 0.0;
- for (j = 0; j != repeat; j++) {
+ for (int j = 0; j != repeat; j++) {
DisplayStatus(xp->d, "Testing", label, j+1);
time = DoTest(xp, test, reps);
if (abortTest)
@@ -1119,7 +1109,6 @@ main(int argc, char *argv[])
/* Just print out list of tests for use with .sh programs that
assemble data from different x11perf runs into a nice format */
ForEachTest (i) {
- int child;
if (doit[i]) {
switch (test[i].testType) {
case NONROP:
@@ -1162,7 +1151,7 @@ main(int argc, char *argv[])
break;
case WINDOW:
- for (child = 0; child != numSubWindows; child++) {
+ for (int child = 0; child != numSubWindows; child++) {
printf ("%s (%ld kids)\n",
LABELP(i), subWindows[child]);
}
@@ -1327,7 +1316,6 @@ main(int argc, char *argv[])
printf("Sync time adjustment is %6.4f msecs.\n\n", syncTime/1000);
ForEachTest (i) {
- int child;
char label[200];
if (doit[i] && (test[i].versions & xparms.version)) {
@@ -1379,7 +1367,7 @@ main(int argc, char *argv[])
case WINDOW:
/* Loop through number of children array */
- for (child = 0; child != numSubWindows; child++) {
+ for (int child = 0; child != numSubWindows; child++) {
test[i].parms.objects = subWindows[child];
sprintf(label, "%s (%d kids)",
LABELP(i), test[i].parms.objects);
@@ -1468,12 +1456,10 @@ GetNumbers (int argi, int argc, char **argv, unsigned long *intsp, int *nump)
{
char *words[256];
int count;
- int i;
- int flip;
count = GetWords (argi, argc, argv, words, nump);
- for (i = 0; i < count; i++) {
- flip = 0;
+ for (int i = 0; i < count; i++) {
+ int flip = 0;
if (!strncmp (words[i], "~", 1)) {
words[i]++;
flip = ~0;
@@ -1491,11 +1477,10 @@ GetRops (int argi, int argc, char **argv, int *ropsp, int *nump)
{
char *words[256];
int count;
- int i;
int rop;
count = GetWords (argi, argc, argv, words, nump);
- for (i = 0; i < count; i++) {
+ for (int i = 0; i < count; i++) {
if (!strncmp (words[i], "GX", 2))
words[i] += 2;
if (!strcmp (words[i], "all")) {
@@ -1563,8 +1548,7 @@ FormatFromName (char *name)
static const char *
NameFromFormat (int format)
{
- int i;
- for (i = 0; i < NUM_FORMATS; i++)
+ for (int i = 0; i < NUM_FORMATS; i++)
if (formatNames[i].rop == format)
return formatNames[i].name;
return NULL;
@@ -1576,10 +1560,11 @@ GetFormats (int argi, int argc, char **argv, int *formatsp, int *nump)
char *words[256];
int count;
int i;
- int format;
count = GetWords (argi, argc, argv, words, nump);
for (i = 0; i < count; i++) {
+ int format;
+
if (!strcmp (words[i], "all")) {
for (i = 0; i < NUM_FORMATS; i++)
formatsp[i] = formatNames[i].rop;