util: Don't cast returns from malloc()
authorSimon Wilkinson <sxw@your-file-system.com>
Thu, 17 May 2012 12:32:28 +0000 (13:32 +0100)
committerDerrick Brashear <shadow@dementix.org>
Thu, 24 May 2012 16:24:08 +0000 (09:24 -0700)
malloc() returns a (void *) on all of our current platforms. So,
don't bother casting the return value before assigning it - it is
unnecessary noise.

Change-Id: I8287709413fe0e34f417936d1fc64c421fea6d28
Reviewed-on: http://gerrit.openafs.org/7472
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>

src/util/dirpath.c
src/util/fileutil.c
src/util/hostparse.c
src/util/tabular_output.c
src/util/work_queue.c

index b307184..3e76824 100644 (file)
@@ -569,7 +569,7 @@ ConstructLocalPath(const char *cpath, const char *relativeTo,
            /* construct path relative to install directory only */
            pathSize += strlen(cpath);
 
-           newPath = (char *)malloc(pathSize);
+           newPath = malloc(pathSize);
            if (!newPath) {
                status = ENOMEM;
            } else {
@@ -579,7 +579,7 @@ ConstructLocalPath(const char *cpath, const char *relativeTo,
            /* construct path relative to 'relativeTo' (and install dir) */
            pathSize += strlen(relativeTo) + 1 + strlen(cpath);
 
-           newPath = (char *)malloc(pathSize);
+           newPath = malloc(pathSize);
            if (!newPath) {
                status = ENOMEM;
            } else {
index 509d728..fcd6f58 100644 (file)
@@ -102,7 +102,7 @@ BufioOpen(char *path, int oflag, int mode)
 {
     bufio_p bp;
 
-    bp = (bufio_p) malloc(sizeof(bufio_t));
+    bp = malloc(sizeof(bufio_t));
     if (bp == NULL) {
        return NULL;
     }
index 0079d8c..9caf422 100644 (file)
@@ -244,7 +244,7 @@ gettmpdir(void)
 
     if (saveTmpDir == NULL) {
        /* initialize global temporary directory string */
-       char *dirp = (char *)malloc(MAX_PATH+1);
+       char *dirp = malloc(MAX_PATH+1);
        int freeDirp = 1;
 
        if (dirp != NULL) {
index bc8f3e4..5866fbe 100644 (file)
@@ -337,13 +337,12 @@ util_newCellContents(struct util_Table* Table) {
     char **CellContents=NULL;
     int i;
 
-    if ( (CellContents=(char **) malloc( sizeof(char *) * Table->numColumns))\
-          == NULL ) {
+    if ( (CellContents=malloc( sizeof(char *) * Table->numColumns))== NULL ) {
         fprintf(stderr,"Internal Error. Cannot allocate memory for new CellContents-array.\n");
         exit(EXIT_FAILURE);
     }
     for (i=0;i<Table->numColumns;i++) {
-        if ( (CellContents[i]=(char *) malloc(UTIL_T_MAX_CELLCONTENT_LEN)) == NULL)  {
+        if ( (CellContents[i]=malloc(UTIL_T_MAX_CELLCONTENT_LEN)) == NULL)  {
             fprintf(stderr,\
                     "Internal Error. Cannot allocate memory for new CellContents-array.\n");
             exit(EXIT_FAILURE);
@@ -417,7 +416,7 @@ struct util_TableRow*
 newTableRow(struct util_Table* Table) {
     struct util_TableRow *aRow =NULL;
 
-    if ( (aRow= (struct util_TableRow*) malloc(sizeof(struct util_TableRow))) == NULL) {
+    if ( (aRow = malloc(sizeof(struct util_TableRow))) == NULL) {
         fprintf(stderr,\
                 "Internal Error. Cannot allocate memory for new TableRow.\n");
         exit(EXIT_FAILURE);
index e2f1553..d1ffa6f 100644 (file)
@@ -1180,7 +1180,7 @@ afs_wq_node_alloc(struct afs_work_queue_node ** node_out)
     int ret = 0;
     struct afs_work_queue_node * node;
 
-    *node_out = node = (struct afs_work_queue_node *) malloc(sizeof(*node));
+    *node_out = node = malloc(sizeof(*node));
     if (node == NULL) {
        ret = ENOMEM;
        goto error;