[PATCH app/xprop] Add missing braces around else clause in Read_Quoted()

Alan Coopersmith alan.coopersmith at oracle.com
Sat May 5 20:34:38 UTC 2018


Found by gcc 7.3:

xprop.c: In function ‘Read_Quoted’:
xprop.c:163:8: warning: this ‘else’ clause does not guard... [-Wmisleading-indentation]
      } else
        ^~~~
xprop.c:164:17: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘else’
   ptr++[0] = c; length--;
                 ^~~~~~

Introduced in initial commit to X Consortium RCS in 1987:
https://cgit.freedesktop.org/~alanc/xc-historical/commit/xc/programs/xprop/xprop.c?id=18ea83d7457743936e99a574b50e208f7697f096

Actual effect is minimal - for every \-escaped newline in the DFORMAT
portion of a xprop formats file, xprop subtracted one byte too many
from the count of bytes still available in the buffer, which could lead
it to return an error of "Bad format file format: dformat too long." when
there was still room left.  Since the original buffer size was 10,000
characters, and the current size is 500,000 characters, it's unlikely
anyone ever hit this in real usage.

Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 xprop.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/xprop.c b/xprop.c
index e7a66d9..88229e8 100644
--- a/xprop.c
+++ b/xprop.c
@@ -160,8 +160,9 @@ Read_Quoted (FILE *stream)
 	    c = Read_Char(stream);
 	    if (c == '\n') {
 		ptr--; length++;
-	    } else
+	    } else {
 		ptr++[0] = c; length--;
+	    }
 	}
     }
     ptr++[0] = '\0';
-- 
2.15.0



More information about the xorg-devel mailing list