Remove useless casts
authorRan Benita <ran234@gmail.com>
Wed, 29 Feb 2012 19:26:28 +0000 (21:26 +0200)
committerRan Benita <ran234@gmail.com>
Fri, 2 Mar 2012 23:17:57 +0000 (01:17 +0200)
Signed-off-by: Ran Benita <ran234@gmail.com>
src/atom.c
src/galloc.c
src/maprules.c
src/xkbcomp/expr.c
src/xkbcomp/symbols.c
src/xkbcomp/utils.c
src/xkbcomp/utils.h
src/xkbcomp/xkbpath.c

index 571c34c..8f9aa0d 100644 (file)
@@ -170,11 +170,11 @@ xkb_intern_atom(const char *string)
     if (makeit) {
         NodePtr nd;
 
-        nd = (NodePtr)malloc(sizeof(NodeRec));
+        nd = malloc(sizeof(NodeRec));
         if (!nd)
             return BAD_RESOURCE;
 
-        nd->string = (char *)malloc(len + 1);
+        nd->string = malloc(len + 1);
         if (!nd->string) {
             free(nd);
             return BAD_RESOURCE;
index 92242da..e33e37d 100644 (file)
@@ -332,9 +332,9 @@ _XkbGeomAlloc(char **old, unsigned short *num, unsigned short *total,
     *total = (*num) + num_new;
 
     if (*old)
-        *old = (char *)realloc(*old, (*total) * sz_elem);
+        *old = realloc(*old, (*total) * sz_elem);
     else
-        *old = (char *)calloc(*total, sz_elem);
+        *old = calloc(*total, sz_elem);
     if (!(*old)) {
         *total = *num = 0;
         return BadAlloc;
index 37ada76..6d86ac1 100644 (file)
@@ -97,11 +97,11 @@ InputLineAddChar(InputLine *line,int ch)
 {
     if (line->num_line>=line->sz_line) {
        if (line->line==line->buf) {
-           line->line= (char *)malloc(line->sz_line*2);
+            line->line = malloc(line->sz_line * 2);
            memcpy(line->line,line->buf,line->sz_line);
        }
        else {
-           line->line=(char *)realloc((char *)line->line,line->sz_line*2);
+            line->line = realloc(line->line, line->sz_line * 2);
        }
        line->sz_line*= 2;
     }
@@ -793,7 +793,7 @@ XkbRF_SubstituteVars(char *name, XkbRF_MultiDefsPtr mdefs)
        }
        str= strchr(&str[0],'%');
     }
-    name= (char *)malloc(len+1);
+    name = malloc(len + 1);
     str= orig;
     outstr= name;
     while (*str!='\0') {
index c5b8655..dcf6ead 100644 (file)
@@ -746,7 +746,7 @@ ExprResolveString(ExprDef * expr,
             int len;
             char *new;
             len = strlen(leftRtrn.str) + strlen(rightRtrn.str) + 1;
-            new = (char *) malloc(len);
+            new = malloc(len);
             if (new)
             { sprintf(new, "%s%s", leftRtrn.str, rightRtrn.str);
                 free(leftRtrn.str);
index 1415890..e6f8022 100644 (file)
@@ -179,8 +179,7 @@ CopyKeyInfo(KeyInfo * old, KeyInfo * new, Bool clearOld)
                     new->numLevels[i] = 0;
                     return False;
                 }
-                memcpy((char *) new->syms[i], (char *) old->syms[i],
-                       width * sizeof(uint32_t));
+                memcpy(new->syms[i], old->syms[i], width * sizeof(uint32_t));
             }
             if (old->acts[i] != NULL)
             {
@@ -190,7 +189,7 @@ CopyKeyInfo(KeyInfo * old, KeyInfo * new, Bool clearOld)
                     new->acts[i] = NULL;
                     return False;
                 }
-                memcpy((char *) new->acts[i], (char *) old->acts[i],
+                memcpy(new->acts[i], old->acts[i],
                        width * sizeof(union xkb_action));
             }
         }
@@ -1487,10 +1486,10 @@ SetExplicitGroup(SymbolsInfo * info, KeyInfo * key)
         {
             key->numLevels[i] = 0;
             free(key->syms[i]);
-            key->syms[i] = (uint32_t *) NULL;
+            key->syms[i] = NULL;
             free(key->acts[i]);
-            key->acts[i] = (union xkb_action *) NULL;
-            key->types[i] = (uint32_t) 0;
+            key->acts[i] = NULL;
+            key->types[i] = 0;
         }
     }
     key->typesDefined = key->symsDefined = key->actsDefined = 1 << group;
@@ -1498,11 +1497,11 @@ SetExplicitGroup(SymbolsInfo * info, KeyInfo * key)
     key->numLevels[group] = key->numLevels[0];
     key->numLevels[0] = 0;
     key->syms[group] = key->syms[0];
-    key->syms[0] = (uint32_t *) NULL;
+    key->syms[0] = NULL;
     key->acts[group] = key->acts[0];
-    key->acts[0] = (union xkb_action *) NULL;
+    key->acts[0] = NULL;
     key->types[group] = key->types[0];
-    key->types[0] = (uint32_t) 0;
+    key->types[0] = 0;
     return True;
 }
 
@@ -1798,7 +1797,7 @@ PrepareKeyDef(KeyInfo * key)
             key->acts[i] = uTypedCalloc(width, union xkb_action);
             if (key->acts[i] == NULL)
                 continue;
-            memcpy((void *) key->acts[i], (void *) key->acts[0],
+            memcpy(key->acts[i], key->acts[0],
                    width * sizeof(union xkb_action));
             key->actsDefined |= 1 << i;
         }
@@ -1807,8 +1806,7 @@ PrepareKeyDef(KeyInfo * key)
             key->syms[i] = uTypedCalloc(width, uint32_t);
             if (key->syms[i] == NULL)
                 continue;
-            memcpy((void *) key->syms[i], (void *) key->syms[0],
-                   width * sizeof(uint32_t));
+            memcpy(key->syms[i], key->syms[0], width * sizeof(uint32_t));
             key->symsDefined |= 1 << i;
         }
         if (defined & 1)
@@ -1829,7 +1827,7 @@ PrepareKeyDef(KeyInfo * key)
         }
         if ((key->syms[i] != key->syms[0]) &&
             (key->syms[i] == NULL || key->syms[0] == NULL ||
-             memcmp((void *) key->syms[i], (void *) key->syms[0],
+             memcmp(key->syms[i], key->syms[0],
                     sizeof(uint32_t) * key->numLevels[0])))
         {
             identical = False;
@@ -1837,7 +1835,7 @@ PrepareKeyDef(KeyInfo * key)
         }
         if ((key->acts[i] != key->acts[0]) &&
             (key->acts[i] == NULL || key->acts[0] == NULL ||
-             memcmp((void *) key->acts[i], (void *) key->acts[0],
+             memcmp(key->acts[i], key->acts[0],
                     sizeof(union xkb_action) * key->numLevels[0])))
         {
             identical = False;
@@ -1850,10 +1848,10 @@ PrepareKeyDef(KeyInfo * key)
         {
             key->numLevels[i] = 0;
             free(key->syms[i]);
-            key->syms[i] = (uint32_t *) NULL;
+            key->syms[i] = NULL;
             free(key->acts[i]);
-            key->acts[i] = (union xkb_action *) NULL;
-            key->types[i] = (uint32_t) 0;
+            key->acts[i] = NULL;
+            key->types[i] = 0;
         }
         key->symsDefined &= 1;
         key->actsDefined &= 1;
index 65128d7..0ba389b 100644 (file)
@@ -36,16 +36,16 @@ recalloc(void * old, unsigned nOld, unsigned nNew, unsigned itemSize)
     char *rtrn;
 
     if (old == NULL)
-        rtrn = (char *) calloc(nNew, itemSize);
+        rtrn = calloc(nNew, itemSize);
     else
     {
-        rtrn = (char *) realloc((char *) old, nNew * itemSize);
+        rtrn = realloc(old, nNew * itemSize);
         if ((rtrn) && (nNew > nOld))
         {
             memset(&rtrn[nOld * itemSize], 0, (nNew - nOld) * itemSize);
         }
     }
-    return (void *) rtrn;
+    return rtrn;
 }
 
 static FILE *errorFile = NULL;
index c82ee9f..020ed75 100644 (file)
@@ -70,10 +70,10 @@ recalloc(void * old, unsigned nOld, unsigned nNew, unsigned newSize);
 
 #define        uTypedAlloc(t)          ((t *)malloc((unsigned)sizeof(t)))
 #define        uTypedCalloc(n,t)       ((t *)calloc((unsigned)n,(unsigned)sizeof(t)))
-#define        uTypedRealloc(pO,n,t)   ((t *)realloc((void *)pO,((unsigned)n)*sizeof(t)))
-#define        uTypedRecalloc(pO,o,n,t) ((t *)recalloc((void *)pO,((unsigned)o),((unsigned)n),sizeof(t)))
+#define        uTypedRealloc(pO,n,t)   ((t *)realloc(pO,((unsigned)n)*sizeof(t)))
+#define        uTypedRecalloc(pO,o,n,t) ((t *)recalloc(pO,((unsigned)o),((unsigned)n),sizeof(t)))
 #if (defined mdHasAlloca) && (mdHasAlloca)
-#define        uTmpAlloc(n)    ((void *)alloca((unsigned)n))
+#define        uTmpAlloc(n)    alloca((unsigned)n)
 #define        uTmpFree(p)
 #else
 #define        uTmpAlloc(n)    malloc(n)
index a446d57..c8e7578 100644 (file)
@@ -170,7 +170,7 @@ XkbInitIncludePath(void)
         return True;
 
     szPath = PATH_CHUNK;
-    includePath = (char **) calloc(szPath, sizeof(char *));
+    includePath = calloc(szPath, sizeof(char *));
     if (!includePath)
         return False;
 
@@ -231,7 +231,7 @@ XkbAddDirectoryToPath(const char *dir)
     if (nPathEntries >= szPath)
     {
         szPath += PATH_CHUNK;
-        includePath = (char **) realloc(includePath, szPath * sizeof(char *));
+        includePath = realloc(includePath, szPath * sizeof(char *));
         if (includePath == NULL)
         {
             WSGO("Allocation failed (includePath)\n");
@@ -432,7 +432,7 @@ XkbFindFileInPath(const char *name, unsigned type, char **pathRtrn)
 
     if ((file != NULL) && (pathRtrn != NULL))
     {
-        *pathRtrn = (char *) calloc(strlen(buf) + 1, sizeof(char));
+        *pathRtrn = calloc(strlen(buf) + 1, sizeof(char));
         if (*pathRtrn != NULL)
             strcpy(*pathRtrn, buf);
     }