diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2014-12-12 21:07:12 -0800 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2015-02-10 18:14:44 -0800 |
commit | 57e08fae82f733304200a473f55b86e689404c13 (patch) | |
tree | a551b85b31c0b569b5b8c1ffcc3824aee3fa0705 /hw/dmx | |
parent | 0fbebad72428abbc9fc3fa9f406f7a7e1b9d95b2 (diff) |
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 <alan.coopersmith@oracle.com>
Reviewed-by: Rémi Cardona <remi@gentoo.org>
Reviewed-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'hw/dmx')
-rw-r--r-- | hw/dmx/dmxinit.c | 30 |
1 files changed, 15 insertions, 15 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; - - 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; } } |