From: Simon Wilkinson Date: Thu, 17 May 2012 12:28:51 +0000 (+0100) Subject: comerr: Don't cast returns from malloc() X-Git-Tag: upstream/1.8.0_pre1^2~2368 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=40123db55ec36e8f5536db749e0a935141de74c7;p=packages%2Fo%2Fopenafs.git comerr: 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: Idc5f098a20809a5f869c4ea9f3970e598520c0e9 Reviewed-on: http://gerrit.openafs.org/7468 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- diff --git a/src/comerr/compile_et.c b/src/comerr/compile_et.c index 01d5e69d1..808c92b5b 100644 --- a/src/comerr/compile_et.c +++ b/src/comerr/compile_et.c @@ -43,7 +43,7 @@ extern int yylineno; char * xmalloc(unsigned int size) { - char *p = (char *)malloc(size); + char *p = malloc(size); if (!p) { perror(whoami); exit(1); diff --git a/src/comerr/error_table.y b/src/comerr/error_table.y index 5b4c7705c..db5692a2c 100644 --- a/src/comerr/error_table.y +++ b/src/comerr/error_table.y @@ -152,7 +152,7 @@ char *gensym(const char *x) gettimeofday(&tv, (void *)0); gensym_n = (tv.tv_sec%10000)*100 + tv.tv_usec/10000; } - symbol = (char *)malloc(32 * sizeof(char)); + symbol = malloc(32 * sizeof(char)); gensym_n++; sprintf(symbol, "et%ld", (long int) gensym_n); return(symbol); @@ -186,7 +186,7 @@ void add_ec(const char *name, const char *description) fprintf(cfile, "\t\"%s\",\n", description); } if (error_codes == (char **)NULL) { - error_codes = (char **)malloc(sizeof(char *)); + error_codes = malloc(sizeof(char *)); *error_codes = (char *)NULL; } error_codes = (char **)realloc((char *)error_codes, @@ -220,7 +220,7 @@ void add_ec_val(const char *name, const char *val, const char *description) fprintf(cfile, "\t\"%s\",\n", description); } if (error_codes == (char **)NULL) { - error_codes = (char **)malloc(sizeof(char *)); + error_codes = malloc(sizeof(char *)); *error_codes = (char *)NULL; } error_codes = (char **)realloc((char *)error_codes, diff --git a/src/comerr/error_table_nt.c b/src/comerr/error_table_nt.c index b0cfeff44..1d852792f 100755 --- a/src/comerr/error_table_nt.c +++ b/src/comerr/error_table_nt.c @@ -810,7 +810,7 @@ yyparse(YYPARSE_PARAM) x < (sizeof(yytname) / sizeof(char *)); x++) if (yycheck[x + yyn] == x) size += strlen(yytname[x]) + 15, count++; - msg = (char *)malloc(size + 15); + msg = malloc(size + 15); if (msg != 0) { strcpy(msg, "parse error"); @@ -968,7 +968,7 @@ gensym(const char *x) gettimeofday(&tv, NULL); gensym_n = (tv.tv_sec % 10000) * 100 + tv.tv_usec / 10000; } - symbol = (char *)malloc(32 * sizeof(char)); + symbol = malloc(32 * sizeof(char)); gensym_n++; sprintf(symbol, "et%ld", gensym_n); return (symbol); @@ -1003,7 +1003,7 @@ add_ec(const char *name, const char *description) fprintf(cfile, "\t\"%s\",\n", description); } if (error_codes == (char **)NULL) { - error_codes = (char **)malloc(sizeof(char *)); + error_codes = malloc(sizeof(char *)); *error_codes = (char *)NULL; } error_codes = realloc(error_codes, (current + 2) * sizeof(char *)); @@ -1036,7 +1036,7 @@ add_ec_val(const char *name, const char *val, const char *description) fprintf(cfile, "\t\"%s\",\n", description); } if (error_codes == (char **)NULL) { - error_codes = (char **)malloc(sizeof(char *)); + error_codes = malloc(sizeof(char *)); *error_codes = (char *)NULL; } error_codes = realloc(error_codes, (current + 2) * sizeof(char *)); diff --git a/src/comerr/et_lex.lex_nt.c b/src/comerr/et_lex.lex_nt.c index c296490f0..f901929e7 100644 --- a/src/comerr/et_lex.lex_nt.c +++ b/src/comerr/et_lex.lex_nt.c @@ -1520,7 +1520,7 @@ static void *yy_flex_alloc( size ) yy_size_t size; #endif { - return (void *) malloc( size ); + return malloc( size ); } #ifdef YY_USE_PROTOS diff --git a/src/tools/dumpscan/afsdump_extract.c b/src/tools/dumpscan/afsdump_extract.c index 1be401466..4a17557d8 100644 --- a/src/tools/dumpscan/afsdump_extract.c +++ b/src/tools/dumpscan/afsdump_extract.c @@ -162,8 +162,8 @@ parse_options(int argc, char **argv) else vnum_count++; } - file_names = (char **)malloc(name_count + sizeof(char *)); - file_vnums = (afs_int32 *) malloc(vnum_count + sizeof(afs_uint32)); + file_names = malloc(name_count + sizeof(char *)); + file_vnums = malloc(vnum_count + sizeof(afs_uint32)); if (name_count) use_realpath = 1; @@ -484,7 +484,7 @@ symlink_cb(afs_vnode * v, XFILE * X, void *refcon) vnodepath = vnpx; } - if (!(linktarget = (char *)malloc(v->size + 1))) { + if (!(linktarget = malloc(v->size + 1))) { if (!use_vnum && use != 2) free(vnodepath); return DSERR_MEM;