When printing out rotations, we print a space before any item other than
the first, and set `first = False` in each block where we print.
However, this is done in the same line as the conditional that checks if
first is set, which may give the impression that the assignment is also
under the conditional. This is not the case, and recent GCC warns about
this.

Move the assignment to after we print the value we want to print, which
(1) doesn't mislead about the indentation, and
(2) makes logical sense as the _next_ entry is what won't be the first.

Signed-off-by: Giuseppe Bilotta <[email protected]>
---
 xrandr.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

A possible alternative would be to wrap the whole line (after the conditional)
in { }, but I wasn't sure if this was the intent or not.

diff --git a/xrandr.c b/xrandr.c
index dcfdde0..2aad946 100644
--- a/xrandr.c
+++ b/xrandr.c
@@ -3703,14 +3703,16 @@ main (int argc, char **argv)
                printf (" (");
                for (i = 0; i < 4; i ++) {
                    if ((rotations >> i) & 1) {
-                       if (!first) printf (" "); first = False;
+                       if (!first) printf (" ");
                        printf("%s", direction[i]);
+                       first = False;
                    }
                }
                if (rotations & RR_Reflect_X)
                {
-                   if (!first) printf (" "); first = False;
+                   if (!first) printf (" ");
                    printf ("x axis");
+                   first = False;
                }
                if (rotations & RR_Reflect_Y)
                {
-- 
2.8.1.372.g9612035

_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to