[PATCH:setxkbmap 2/3] Make len a size_t instead of converting back & forth to an int

Alan Coopersmith alan.coopersmith at oracle.com
Sun Feb 10 20:31:56 PST 2013


Gets rid of a number of clang warnings:
setxkbmap.c:689:28: warning: implicit conversion loses integer precision:
    'unsigned long' to 'int' [-Wshorten-64-to-32]
        len = strlen(orig) + 1;
            ~ ~~~~~~~~~~~~~^~~
setxkbmap.c:701:39: warning: implicit conversion changes signedness:
    'int' to 'size_t' (aka 'unsigned long') [-Wsign-conversion]
        orig = (char *) realloc(orig, len);
                        ~~~~~~~       ^~~
setxkbmap.c:707:32: warning: implicit conversion changes signedness:
    'int' to 'size_t' (aka 'unsigned long') [-Wsign-conversion]
        orig = (char *) calloc(len, 1);
                        ~~~~~~ ^~~

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

diff --git a/setxkbmap.c b/setxkbmap.c
index b573b14..e50ad16 100644
--- a/setxkbmap.c
+++ b/setxkbmap.c
@@ -683,7 +683,8 @@ addStringToOptions(char *opt_str, list_t *opts)
 char *
 stringFromOptions(char *orig, list_t *newOpts)
 {
-    int len, i, nOut;
+    size_t len;
+    int i, nOut;
 
     if (orig)
         len = strlen(orig) + 1;
-- 
1.7.9.2



More information about the xorg-devel mailing list