From 57e08fae82f733304200a473f55b86e689404c13 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Fri, 12 Dec 2014 21:07:12 -0800 Subject: [PATCH] dmx: attempt to untangle nested loops using same index variable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Rémi Cardona Reviewed-by: Keith Packard --- hw/dmx/dmxinit.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/hw/dmx/dmxinit.c b/hw/dmx/dmxinit.c index 37961b812..025dc8637 100644 --- a/hw/dmx/dmxinit.c +++ b/hw/dmx/dmxinit.c @@ -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; + if (configs[j].vid > 0) { + int k; - 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; + 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; } }