Commit 57e08fae authored by Alan Coopersmith's avatar Alan Coopersmith
Browse files

dmx: attempt to untangle nested loops using same index variable



This doesn't just make gcc sad, it makes my brain sad.

Change from:
    for (i = 0; i < dmxNumScreens; i++) {
        int i;
        for (i = 0; i < nconfigs; i++) {
            for (j = 0; j < dmxScreen->beNumVisuals; j++) {

to the easier to follow:
    for (i = 0; i < dmxNumScreens; i++) {
        for (j = 0; j < nconfigs; j++) {
            for (k = 0; k < dmxScreen->beNumVisuals; k++) {

Gets rid of gcc 4.8 warning:

dmxinit.c: In function ‘InitOutput’:
dmxinit.c:765:17: warning: declaration of ‘i’ shadows a previous local [-Wshadow]
             int i;
                 ^
dmxinit.c:608:9: warning: shadowed declaration is here [-Wshadow]
     int i;
         ^
Signed-off-by: Alan Coopersmith's avatarAlan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: default avatarRémi Cardona <remi@gentoo.org>
Reviewed-by: Keith Packard's avatarKeith Packard <keithp@keithp.com>
parent 0fbebad7
......@@ -762,7 +762,6 @@ InitOutput(ScreenInfo * pScreenInfo, int argc, char *argv[])
dmxGlxVisualPrivate **configprivs = NULL;
int nconfigs = 0;
int (*oldErrorHandler) (Display *, XErrorEvent *);
int i;
/* Catch errors if when using an older GLX w/o FBconfigs */
oldErrorHandler = XSetErrorHandler(dmxNOPErrorHandler);
......@@ -797,28 +796,29 @@ InitOutput(ScreenInfo * pScreenInfo, int argc, char *argv[])
configprivs = malloc(nconfigs * sizeof(dmxGlxVisualPrivate *));
if (configs != NULL && configprivs != NULL) {
int j;
/* Initialize our private info for each visual
* (currently only x_visual_depth and x_visual_class)
*/
for (i = 0; i < nconfigs; i++) {
for (j = 0; j < nconfigs; j++) {
configprivs[i] = (dmxGlxVisualPrivate *)
configprivs[j] = (dmxGlxVisualPrivate *)
malloc(sizeof(dmxGlxVisualPrivate));
configprivs[i]->x_visual_depth = 0;
configprivs[i]->x_visual_class = 0;
configprivs[j]->x_visual_depth = 0;
configprivs[j]->x_visual_class = 0;
/* Find the visual depth */
if (configs[i].vid > 0) {
int j;
for (j = 0; j < dmxScreen->beNumVisuals; j++) {
if (dmxScreen->beVisuals[j].visualid ==
configs[i].vid) {
configprivs[i]->x_visual_depth =
dmxScreen->beVisuals[j].depth;
configprivs[i]->x_visual_class =
dmxScreen->beVisuals[j].class;
if (configs[j].vid > 0) {
int k;
for (k = 0; k < dmxScreen->beNumVisuals; k++) {
if (dmxScreen->beVisuals[k].visualid ==
configs[j].vid) {
configprivs[j]->x_visual_depth =
dmxScreen->beVisuals[k].depth;
configprivs[j]->x_visual_class =
dmxScreen->beVisuals[k].class;
break;
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment