Commit 266dfae589a51f48cf620fd0e6eaad8694649a4f

Ran Benita 2012-02-29T21:26:28

Remove useless casts Signed-off-by: Ran Benita <ran234@gmail.com>

diff --git a/src/atom.c b/src/atom.c
index 571c34c..8f9aa0d 100644
--- a/src/atom.c
+++ b/src/atom.c
@@ -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;
diff --git a/src/galloc.c b/src/galloc.c
index 92242da..e33e37d 100644
--- a/src/galloc.c
+++ b/src/galloc.c
@@ -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;
diff --git a/src/maprules.c b/src/maprules.c
index 37ada76..6d86ac1 100644
--- a/src/maprules.c
+++ b/src/maprules.c
@@ -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') {
diff --git a/src/xkbcomp/expr.c b/src/xkbcomp/expr.c
index c5b8655..dcf6ead 100644
--- a/src/xkbcomp/expr.c
+++ b/src/xkbcomp/expr.c
@@ -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);
diff --git a/src/xkbcomp/symbols.c b/src/xkbcomp/symbols.c
index 1415890..e6f8022 100644
--- a/src/xkbcomp/symbols.c
+++ b/src/xkbcomp/symbols.c
@@ -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;
diff --git a/src/xkbcomp/utils.c b/src/xkbcomp/utils.c
index 65128d7..0ba389b 100644
--- a/src/xkbcomp/utils.c
+++ b/src/xkbcomp/utils.c
@@ -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;
diff --git a/src/xkbcomp/utils.h b/src/xkbcomp/utils.h
index c82ee9f..020ed75 100644
--- a/src/xkbcomp/utils.h
+++ b/src/xkbcomp/utils.h
@@ -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)
diff --git a/src/xkbcomp/xkbpath.c b/src/xkbcomp/xkbpath.c
index a446d57..c8e7578 100644
--- a/src/xkbcomp/xkbpath.c
+++ b/src/xkbcomp/xkbpath.c
@@ -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);
     }