From 7977b9f8f1c6b0ab9a37ce33fc53b8ef36400262 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 9 Jan 2020 21:44:30 +0100 Subject: Pixmap.c: fix variable shadowing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pixmap.c: In function ‘nxagentDisconnectAllPixmaps’: Pixmap.c:677:19: warning: declaration of ‘r’ shadows a previous local [-Wshadow=compatible-local] for (int i = 0, r = 1; i < MAXCLIENTS; r = 1, i++) ^ Pixmap.c:652:7: note: shadowed declaration is here int r = 1; ^ Pixmap.c: In function ‘nxagentReconnectAllPixmaps’: Pixmap.c:840:19: warning: declaration of ‘result’ shadows a previous local [-Wshadow=compatible-local] for (int i = 0, result = 1; i < MAXCLIENTS; result = 1, i++) ^~~~~~ Pixmap.c:807:8: note: shadowed declaration is here Bool result = 1; ^~~~~~ --- nx-X11/programs/Xserver/hw/nxagent/Pixmap.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'nx-X11/programs/Xserver/hw/nxagent/Pixmap.c') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c b/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c index 695d14618..bb0e7302a 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c @@ -674,7 +674,14 @@ Bool nxagentDisconnectAllPixmaps(void) #endif - for (int i = 0, r = 1; i < MAXCLIENTS; r = 1, i++) + /* + * FIXME: This is a bit cumbersome: + * - as stated below nxagentDisconnectPixmap will not modify r, so the result will stay at 1 + * - at the end of each iteration r will be set to 1 anyway. + * So at the end of the loop r will always be 1. So the whole function will always return 1... + */ + r = 1; + for (int i = 0; i < MAXCLIENTS; r = 1, i++) { if (clients[i]) { @@ -837,7 +844,13 @@ Bool nxagentReconnectAllPixmaps(void *p0) #endif - for (int i = 0, result = 1; i < MAXCLIENTS; result = 1, i++) + /* + * FIXME: This is a bit cumbersome: at the end of each iteration + * result will be reset to 1. Therefore at loop exit result will + * always be 1 meaning the whole function will always return 1... + */ + result = 1; + for (int i = 0; i < MAXCLIENTS; result = 1, i++) { if (clients[i] != NULL) { -- cgit v1.2.3