From 152bda64c662f719b167d05c0489ce4cb6e65c36 Mon Sep 17 00:00:00 2001 From: Simon Wilkinson Date: Thu, 17 May 2012 13:32:28 +0100 Subject: [PATCH] util: Don't cast returns from malloc() 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 Reviewed-by: Derrick Brashear --- src/util/dirpath.c | 4 ++-- src/util/fileutil.c | 2 +- src/util/hostparse.c | 2 +- src/util/tabular_output.c | 7 +++---- src/util/work_queue.c | 2 +- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/util/dirpath.c b/src/util/dirpath.c index b307184..3e76824 100644 --- a/src/util/dirpath.c +++ b/src/util/dirpath.c @@ -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 { diff --git a/src/util/fileutil.c b/src/util/fileutil.c index 509d728..fcd6f58 100644 --- a/src/util/fileutil.c +++ b/src/util/fileutil.c @@ -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; } diff --git a/src/util/hostparse.c b/src/util/hostparse.c index 0079d8c..9caf422 100644 --- a/src/util/hostparse.c +++ b/src/util/hostparse.c @@ -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) { diff --git a/src/util/tabular_output.c b/src/util/tabular_output.c index bc8f3e4..5866fbe 100644 --- a/src/util/tabular_output.c +++ b/src/util/tabular_output.c @@ -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;inumColumns;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); diff --git a/src/util/work_queue.c b/src/util/work_queue.c index e2f1553..d1ffa6f 100644 --- a/src/util/work_queue.c +++ b/src/util/work_queue.c @@ -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; -- 1.9.4