diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2022-08-13 15:56:22 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2022-08-13 15:56:22 -0700 |
commit | 9e5fe5ae18c3f6eae93cd1521645717295ce2c23 (patch) | |
tree | 4760473ca77ce1087ed93af926ecc0967d2cea43 | |
parent | bd5040cdec7770501619393021eeffeb591e73f6 (diff) |
Apply scope reduction suggestions from cppcheck
[ico.c:587]: (style) The scope of the variable 'pxvz' can be reduced.
[ico.c:730]: (style) The scope of the variable 't' can be reduced.
[ico.c:1132]: (style) The scope of the variable 'poly' can be reduced.
[ico.c:1149]: (style) The scope of the variable 'poly' can be reduced.
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r-- | ico.c | 19 |
1 files changed, 10 insertions, 9 deletions
@@ -584,7 +584,6 @@ drawPoly(struct closure *closure, Polyinfo *poly, GC gc, int facecolor; int pcount; - double pxvz; XPoint ppts[MAXEDGESPERPOLY]; /* Switch double-buffer and rotate vertices */ @@ -635,9 +634,10 @@ drawPoly(struct closure *closure, Polyinfo *poly, GC gc, XSync(dpy, 0); for (i = NF - 1; i >= 0; --i, pf += pcount) { + double pxvz = 0.0; pcount = *pf++; /* number of edges for this face */ - pxvz = 0.0; + for (j=0; j<pcount; j++) { p0 = pf[j]; pxvz += pxv[p0].z; @@ -727,7 +727,7 @@ static void initDBufs(struct closure *closure, unsigned long fg, unsigned long bg, int planesperbuf) { - int i,j,jj,j0,j1,k,m,t; + int i,j,jj,j0,j1,k,m; DBufInfo *b; XColor bgcolor, fgcolor; @@ -753,8 +753,9 @@ initDBufs(struct closure *closure, unsigned long fg, unsigned long bg, closure->pixels[0] = bg; closure->plane_masks[0] = fg ^ bg; } else { - t = XAllocColorCells(dpy,closure->cmap,0, - closure->plane_masks,closure->totalplanes, closure->pixels,1); + int t = XAllocColorCells(dpy, closure->cmap, 0, + closure->plane_masks, closure->totalplanes, + closure->pixels, 1); /* allocate color planes */ if (t==0) { icoFatal("can't allocate enough color planes"); @@ -1129,12 +1130,12 @@ static void giveObjHelp(void) { unsigned int i; - Polyinfo *poly; printf("%-16s%-12s #Vert. #Edges #Faces %-16s\n", "Name", "ShortName", "Dual"); for (i=0; i<NumberPolygons; i++) { - poly = polygons+i; + Polyinfo *poly = polygons+i; + printf("%-16s%-12s%6d%8d%8d %-16s\n", poly->longname, poly->shortname, poly->numverts, poly->numedges, poly->numfaces, @@ -1146,10 +1147,10 @@ static Polyinfo * findpoly(const char *name) { unsigned int i; - Polyinfo *poly; for (i=0; i<NumberPolygons; i++) { - poly = polygons+i; + Polyinfo *poly = polygons+i; + if (strcmp(name,poly->longname)==0 || strcmp(name,poly->shortname)==0) return poly; } |