Declare 'len' as size_t to avoid unneccessary back-and-forth conversions
authorAlan Coopersmith <alan.coopersmith@oracle.com>
Tue, 22 Jan 2013 07:03:48 +0000 (23:03 -0800)
committerAlan Coopersmith <alan.coopersmith@oracle.com>
Tue, 22 Jan 2013 07:03:48 +0000 (23:03 -0800)
Fixes clang warnings:

xdpyinfo.c:1463:12: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int' [-Wshorten-64-to-32]
        int len = strlen(arg);
            ~~~   ^~~~~~~~~~~
xdpyinfo.c:1465:32: warning: implicit conversion changes signedness: 'int' to 'size_t' (aka 'unsigned long') [-Wsign-conversion]
        if (!strncmp("-display", arg, len)) {
             ~~~~~~~                  ^~~
xdpyinfo.c:1468:47: warning: implicit conversion changes signedness: 'int' to 'size_t' (aka 'unsigned long') [-Wsign-conversion]
        } else if (!strncmp("-queryExtensions", arg, len)) {
                    ~~~~~~~                          ^~~
xdpyinfo.c:1470:35: warning: implicit conversion changes signedness: 'int' to 'size_t' (aka 'unsigned long') [-Wsign-conversion]
        } else if (!strncmp("-ext", arg, len)) {
                    ~~~~~~~              ^~~

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
xdpyinfo.c

index fdf2515..c08748c 100644 (file)
@@ -1460,7 +1460,7 @@ main(int argc, char *argv[])
 
     for (i = 1; i < argc; i++) {
        char *arg = argv[i];
-       int len = strlen(arg);
+       size_t len = strlen(arg);
 
        if (!strncmp("-display", arg, len)) {
            if (++i >= argc) usage ();