From: Simon Wilkinson Date: Thu, 17 May 2012 08:01:02 +0000 (+0100) Subject: Don't cast the return from realloc() X-Git-Tag: openafs-stable-1_8_0pre1~2386 X-Git-Url: http://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=bdd8187c040ac3898fe5ae4429b5408f04c685d1 Don't cast the return from realloc() realloc takes, and returns a (void *) argument. So we don't need to cast these parameters into, or out of, realloc. Doing so is just noise, so don't bother. Change-Id: I64e721703536515b2e315e3b033eb2be14f7e18c Reviewed-on: http://gerrit.openafs.org/7455 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- diff --git a/src/budb/procs.c b/src/budb/procs.c index 9258121..cb84520 100644 --- a/src/budb/procs.c +++ b/src/budb/procs.c @@ -368,7 +368,7 @@ AddToReturnList(struct returnList *list, dbadr a, afs_int32 *to_skipP) tmp = (char *)malloc(sizeof(dbadr) * size); } else { size = list->allocSize + 10; - tmp = (char *)realloc(list->elements, sizeof(dbadr) * size); + tmp = realloc(list->elements, sizeof(dbadr) * size); } if (!tmp) return BUDB_NOMEM; @@ -943,9 +943,9 @@ deleteDump(struct rx_call *call, dumpId id, budb_dumpsList *dumps) (afs_int32 *) malloc(sizeof(afs_int32)); else dumps->budb_dumpsList_val = - (afs_int32 *) realloc(dumps->budb_dumpsList_val, - (dumps->budb_dumpsList_len + - 1) * sizeof(afs_int32)); + realloc(dumps->budb_dumpsList_val, + (dumps->budb_dumpsList_len + 1) + * sizeof(afs_int32)); if (!dumps->budb_dumpsList_val) ABORT(BUDB_NOMEM); @@ -1637,15 +1637,11 @@ ListDumps(struct rx_call *call, afs_int32 sflags, afs_int32 groupid, sizeof(afs_int32)); } else { dumps->budb_dumpsList_val = - (afs_int32 *) realloc(dumps-> - budb_dumpsList_val, - count * - sizeof(afs_int32)); + realloc(dumps->budb_dumpsList_val, + count * sizeof(afs_int32)); flags->budb_dumpsList_val = - (afs_int32 *) realloc(flags-> - budb_dumpsList_val, - count * - sizeof(afs_int32)); + realloc(flags->budb_dumpsList_val, + count * sizeof(afs_int32)); } if (!dumps->budb_dumpsList_val || !dumps->budb_dumpsList_val) diff --git a/src/comerr/error_table_nt.c b/src/comerr/error_table_nt.c index c5ea743..b0cfeff 100755 --- a/src/comerr/error_table_nt.c +++ b/src/comerr/error_table_nt.c @@ -1006,8 +1006,7 @@ add_ec(const char *name, const char *description) error_codes = (char **)malloc(sizeof(char *)); *error_codes = (char *)NULL; } - error_codes = - (char **)realloc((char *)error_codes, (current + 2) * sizeof(char *)); + error_codes = realloc(error_codes, (current + 2) * sizeof(char *)); error_codes[current++] = strdup(name); error_codes[current] = (char *)NULL; } @@ -1040,8 +1039,7 @@ add_ec_val(const char *name, const char *val, const char *description) error_codes = (char **)malloc(sizeof(char *)); *error_codes = (char *)NULL; } - error_codes = - (char **)realloc((char *)error_codes, (current + 2) * sizeof(char *)); + error_codes = realloc(error_codes, (current + 2) * sizeof(char *)); error_codes[current++] = strdup(name); error_codes[current] = (char *)NULL; } diff --git a/src/comerr/et_lex.lex_nt.c b/src/comerr/et_lex.lex_nt.c index 910e91a..c296490 100644 --- a/src/comerr/et_lex.lex_nt.c +++ b/src/comerr/et_lex.lex_nt.c @@ -1531,14 +1531,7 @@ void *ptr; yy_size_t size; #endif { - /* The cast to (char *) in the following accommodates both - * implementations that use char* generic pointers, and those - * that use void* generic pointers. It works with the latter - * because both ANSI C and C++ allow castless assignment from - * any pointer type to void*, and deal with argument conversions - * as though doing an assignment. - */ - return (void *) realloc( (char *) ptr, size ); + return realloc( (char *) ptr, size ); } #ifdef YY_USE_PROTOS diff --git a/src/export/cfgexport.c b/src/export/cfgexport.c index 5e1aef4..2eae231 100644 --- a/src/export/cfgexport.c +++ b/src/export/cfgexport.c @@ -459,7 +459,7 @@ xlate_xtok(xp, kp, strp, szp) */ len = strlen(xp->n_nptr) + 1; while (len >= left) { - export_strings = (char *)realloc(*strp, sz += SYMBUFSIZE); + export_strings = realloc(*strp, sz += SYMBUFSIZE); if (!export_strings) error("no memory for EXPORT string table"); *strp = export_strings; diff --git a/src/kauth/kadatabase.c b/src/kauth/kadatabase.c index 9b489a7..5d59ba2 100644 --- a/src/kauth/kadatabase.c +++ b/src/kauth/kadatabase.c @@ -706,10 +706,8 @@ ka_Encache(char *name, char *inst, afs_int32 kvno, return; } /* i == maxCachedKeys */ - keyCache = - (struct cachedKey *)realloc(keyCache, - (maxCachedKeys *= - 2) * sizeof(struct cachedKey)); + keyCache = realloc(keyCache, (maxCachedKeys *=2) + * sizeof(struct cachedKey)); if (keyCache == 0) { es_Report("Can't realloc keyCache! out of memory?"); exit(123); diff --git a/src/kauth/klogin.c b/src/kauth/klogin.c index fa6217e..1300a22 100644 --- a/src/kauth/klogin.c +++ b/src/kauth/klogin.c @@ -605,7 +605,7 @@ setenv(char *var, char *value, int clobber) return; } } - environ = (char **)realloc(environ, sizeof(char *) * (index + 2)); + environ = realloc(environ, sizeof(char *) * (index + 2)); if (environ == NULL) { fprintf(stderr, "login: malloc out of memory\n"); exit(1); diff --git a/src/libadmin/bos/afs_bosAdmin.c b/src/libadmin/bos/afs_bosAdmin.c index cbcf1df..95cde20 100644 --- a/src/libadmin/bos/afs_bosAdmin.c +++ b/src/libadmin/bos/afs_bosAdmin.c @@ -3533,7 +3533,7 @@ bos_Salvage(const void *cellHandle, const void *serverHandle, (serverHandle, AFSDIR_CANONICAL_SERVER_SLVGLOG_FILEPATH, &logLen, logData, &tst)) { if (logLen > INITIAL_LOG_LEN) { - logData = (char *)realloc(logData, (logLen + (logLen / 10))); + logData = realloc(logData, (logLen + (logLen / 10))); if (logData == NULL) { tst = ADMNOMEM; goto fail_bos_Salvage; diff --git a/src/lwp/lwp.c b/src/lwp/lwp.c index d7e599f..2ee83a0 100644 --- a/src/lwp/lwp.c +++ b/src/lwp/lwp.c @@ -723,9 +723,8 @@ LWP_MwaitProcess(int wcount, void *evlist[]) } if (ecount > lwp_cpptr->eventlistsize) { - lwp_cpptr->eventlist = - (void **)realloc(lwp_cpptr->eventlist, - ecount * sizeof(void *)); + lwp_cpptr->eventlist = realloc(lwp_cpptr->eventlist, + ecount * sizeof(void *)); lwp_cpptr->eventlistsize = ecount; } for (i = 0; i < ecount; i++) diff --git a/src/lwp/lwp_nt.c b/src/lwp/lwp_nt.c index 5bfb553..005ae7b 100644 --- a/src/lwp/lwp_nt.c +++ b/src/lwp/lwp_nt.c @@ -433,8 +433,8 @@ int LWP_MwaitProcess(int wcount, void **evlist) if (ecount > lwp_cpptr->eventlistsize) { void **save_eventlist = lwp_cpptr->eventlist; - lwp_cpptr->eventlist = (char **)realloc(lwp_cpptr->eventlist, - ecount*sizeof(char *)); + lwp_cpptr->eventlist = realloc(lwp_cpptr->eventlist, + ecount*sizeof(char *)); if (lwp_cpptr->eventlist == NULL) { lwp_cpptr->eventlist = save_eventlist; Dispatcher(); diff --git a/src/ptserver/ptuser.c b/src/ptserver/ptuser.c index d277091..230ba07 100644 --- a/src/ptserver/ptuser.c +++ b/src/ptserver/ptuser.c @@ -738,9 +738,7 @@ pr_IDListExpandedMembers(afs_int32 aid, namelist * lnames) if (n == maxstack) { /* need more stack space */ afs_int32 *tmp; maxstack += n; - tmp = - (afs_int32 *) realloc(stack, - maxstack * sizeof(afs_int32)); + tmp = realloc(stack, maxstack * sizeof(afs_int32)); if (!tmp) { code = ENOMEM; xdr_free((xdrproc_t) xdr_prlist, &alist); diff --git a/src/ptserver/ptutils.c b/src/ptserver/ptutils.c index cfbe83f..594cdc4 100644 --- a/src/ptserver/ptutils.c +++ b/src/ptserver/ptutils.c @@ -1210,8 +1210,7 @@ AddToPRList(prlist *alist, int *sizeP, afs_int32 id) if (alist->prlist_len >= *sizeP) { count = alist->prlist_len + 100; if (alist->prlist_val) { - tmp = - (char *)realloc(alist->prlist_val, count * sizeof(afs_int32)); + tmp = realloc(alist->prlist_val, count * sizeof(afs_int32)); } else { tmp = (char *)malloc(count * sizeof(afs_int32)); } diff --git a/src/sys/afssyscalls.c b/src/sys/afssyscalls.c index cfd0766..9780491 100644 --- a/src/sys/afssyscalls.c +++ b/src/sys/afssyscalls.c @@ -410,8 +410,7 @@ check_iops(int index, char *fun, char *file, int line) iops_debug[index] = (iops_debug_t *) malloc(avail * sizeof(iops_debug_t)); else - iops_debug[index] = - (iops_debug_t *) realloc(*iops, avail * sizeof(iops_debug_t)); + iops_debug[index] = realloc(*iops, avail * sizeof(iops_debug_t)); if (!iops_debug[index]) { printf("check_iops: Can't %salloc %lu bytes for index %d\n", (avail == IOPS_DEBUG_MALLOC_STEP) ? "m" : "re", diff --git a/src/tools/dumpscan/parsevnode.c b/src/tools/dumpscan/parsevnode.c index 4227a06..0e18e49 100644 --- a/src/tools/dumpscan/parsevnode.c +++ b/src/tools/dumpscan/parsevnode.c @@ -453,7 +453,7 @@ parse_vdata(XFILE * X, unsigned char *tag, tagged_field * field, case vSymlink: if (v->size > symlink_size) { if (symlink_buf) - symlink_buf = (char *)realloc(symlink_buf, v->size + 1); + symlink_buf = realloc(symlink_buf, v->size + 1); else symlink_buf = (char *)malloc(v->size + 1); symlink_size = symlink_buf ? v->size : 0; diff --git a/src/tools/dumpscan/pathname.c b/src/tools/dumpscan/pathname.c index 61f7a86..db24588 100644 --- a/src/tools/dumpscan/pathname.c +++ b/src/tools/dumpscan/pathname.c @@ -362,7 +362,7 @@ Path_Build(XFILE * X, path_hashinfo * phi, afs_uint32 vnode, char **his_path, nl = strlen(name); if (path) { - path = (char *)realloc(path, nl + pl + 2); + path = realloc(path, nl + pl + 2); if (!path) { if (phi->p->cb_error) (phi->p->cb_error) (ENOMEM, 1, phi->p->err_refcon, diff --git a/src/tools/dumpscan/primitive.c b/src/tools/dumpscan/primitive.c index 80e5dbd..d11fbef 100644 --- a/src/tools/dumpscan/primitive.c +++ b/src/tools/dumpscan/primitive.c @@ -93,7 +93,7 @@ ReadString(XFILE * X, unsigned char **val) } /* iff we found a null, i < BUFSIZE and buf[i] holds the NUL */ if (result) - result = (unsigned char *)realloc(result, l + i + 1); + result = realloc(result, l + i + 1); else result = (unsigned char *)malloc(i + 1); if (!result) diff --git a/src/venus/kdump.c b/src/venus/kdump.c index 3db1c06..185e399 100644 --- a/src/venus/kdump.c +++ b/src/venus/kdump.c @@ -677,8 +677,7 @@ read_ksyms(void) while (fgets(line, MAXLINE, fp)) { if (nksyms >= availksyms) { availksyms += KSYM_ALLOC_STEP; - ksyms = - (symlist_t *) realloc(ksyms, availksyms * sizeof(symlist_t)); + ksyms = realloc(ksyms, availksyms * sizeof(symlist_t)); if (!ksyms) { printf("Failed to realloc %d symbols.\n", availksyms); exit(1); @@ -1350,10 +1349,9 @@ add_found_server(struct server *sep) (struct server **)malloc(NserversAllocated * sizeof(struct server *)); } else { - serversFound = - (struct server **)realloc((char *)serversFound, - NserversAllocated * - sizeof(struct server *)); + serversFound = realloc(serversFound, + NserversAllocated * + sizeof(struct server *)); } if (!serversFound) { printf("Can't allocate %lu bytes for list of found servers.\n", diff --git a/src/vlserver/vlprocs.c b/src/vlserver/vlprocs.c index aebc95c..c053329 100644 --- a/src/vlserver/vlprocs.c +++ b/src/vlserver/vlprocs.c @@ -1348,9 +1348,8 @@ SVL_ListAttributes(struct rx_call *rxcall, && (allocCount > vldbentries->bulkentries_len)) { vldbentries->bulkentries_val = - (vldbentry *) realloc(vldbentries->bulkentries_val, - vldbentries->bulkentries_len * - sizeof(vldbentry)); + realloc(vldbentries->bulkentries_val, + vldbentries->bulkentries_len * sizeof(vldbentry)); if (vldbentries->bulkentries_val == NULL) { code = VL_NOMEM; goto abort; @@ -1480,9 +1479,8 @@ SVL_ListAttributesN(struct rx_call *rxcall, && (allocCount > vldbentries->nbulkentries_len)) { vldbentries->nbulkentries_val = - (nvldbentry *) realloc(vldbentries->nbulkentries_val, - vldbentries->nbulkentries_len * - sizeof(nvldbentry)); + realloc(vldbentries->nbulkentries_val, + vldbentries->nbulkentries_len * sizeof(nvldbentry)); if (vldbentries->nbulkentries_val == NULL) { code = VL_NOMEM; goto abort; @@ -2664,9 +2662,8 @@ put_attributeentry(struct vl_ctx *ctx, * then grow in increments of VLDBALLOCINCR. */ allo = (*alloccnt > VLDBALLOCLIMIT) ? VLDBALLOCINCR : *alloccnt; - reall = - (vldbentry *) realloc(*VldbentryFirst, - (*alloccnt + allo) * sizeof(vldbentry)); + reall = realloc(*VldbentryFirst, + (*alloccnt + allo) * sizeof(vldbentry)); if (reall == NULL) return VL_NOMEM; @@ -2711,9 +2708,8 @@ put_nattributeentry(struct vl_ctx *ctx, * then grow in increments of VLDBALLOCINCR. */ allo = (*alloccnt > VLDBALLOCLIMIT) ? VLDBALLOCINCR : *alloccnt; - reall = - (nvldbentry *) realloc(*VldbentryFirst, - (*alloccnt + allo) * sizeof(nvldbentry)); + reall = realloc(*VldbentryFirst, + (*alloccnt + allo) * sizeof(nvldbentry)); if (reall == NULL) return VL_NOMEM; diff --git a/src/vol/listinodes.c b/src/vol/listinodes.c index 5be20ca..22425c0 100644 --- a/src/vol/listinodes.c +++ b/src/vol/listinodes.c @@ -718,9 +718,8 @@ xfs_ListViceInodes(char *devname, char *mountedOn, FD_t inodeFile, renames = (xfs_Rename_t *) malloc(n_avail * sizeof(xfs_Rename_t)); else - renames = (xfs_Rename_t *) - realloc((char *)renames, - n_avail * sizeof(xfs_Rename_t)); + renames = realloc(renames, + n_avail * sizeof(xfs_Rename_t)); if (!renames) { Log("Can't %salloc %lu bytes for rename list.\n", (n_avail == N_RENAME_STEP) ? "m" : "re", diff --git a/src/vol/test/listVicepx.c b/src/vol/test/listVicepx.c index 1044a30..de46cfb 100644 --- a/src/vol/test/listVicepx.c +++ b/src/vol/test/listVicepx.c @@ -339,8 +339,8 @@ createDirEnt(dirEntry, fileName, vnode, unique) (dirEntry->numEntries)++; assert(dirEntry->vnodeName = - (VnodeName *) realloc(dirEntry->vnodeName, - dirEntry->numEntries * sizeof(VnodeName))); + realloc(dirEntry->vnodeName, + dirEntry->numEntries * sizeof(VnodeName))); dirEntry->vnodeName[dirEntry->numEntries - 1].vnode = vnode; dirEntry->vnodeName[dirEntry->numEntries - 1].vunique = unique; dirEntry->vnodeName[dirEntry->numEntries - 1].name = strdup(fileName); diff --git a/src/vol/volume.c b/src/vol/volume.c index c08c46d..2cb6988 100644 --- a/src/vol/volume.c +++ b/src/vol/volume.c @@ -6829,9 +6829,8 @@ VAddToVolumeUpdateList_r(Error * ec, Volume * vp) Log("warning: there is likely a bug in the volume update scanner\n"); return; } - UpdateList = - (VolumeId *) realloc(UpdateList, - sizeof(VolumeId) * updateSize); + UpdateList = realloc(UpdateList, + sizeof(VolumeId) * updateSize); } } osi_Assert(UpdateList != NULL); diff --git a/src/vol/xfs_size_check.c b/src/vol/xfs_size_check.c index 103c342..cd00466 100644 --- a/src/vol/xfs_size_check.c +++ b/src/vol/xfs_size_check.c @@ -123,9 +123,8 @@ CheckPartitions() partList = (partInfo *) malloc(nAvail * sizeof(partInfo)); else - partList = - (partInfo *) realloc((char *)partList, - nAvail * sizeof(partInfo)); + partList = realloc(partList, + nAvail * sizeof(partInfo)); if (!partList) { printf ("Failed to %salloc %d bytes for partition list.\n", diff --git a/src/volser/volprocs.c b/src/volser/volprocs.c index 71d89f7..c002b32 100644 --- a/src/volser/volprocs.c +++ b/src/volser/volprocs.c @@ -1798,7 +1798,7 @@ VolGetName(struct rx_call *acid, afs_int32 atrans, char **aname) TRELE(tt); return E2BIG; } - *aname = (char *)realloc(*aname, len); + *aname = realloc(*aname, len); strcpy(*aname, td->name); TClearRxCall(tt); if (TRELE(tt)) @@ -2595,9 +2595,8 @@ VolListVolumes(struct rx_call *acid, afs_int32 partid, afs_int32 flags, if ((allocSize - volumeInfo->volEntries_len) < 5) { /*running out of space, allocate more space */ allocSize = (allocSize * 3) / 2; - pntr = - (volintInfo *) realloc((char *)volumeInfo->volEntries_val, - allocSize * sizeof(volintInfo)); + pntr = realloc(volumeInfo->volEntries_val, + allocSize * sizeof(volintInfo)); if (pntr == NULL) { closedir(dirp); return VOLSERNO_MEMORY; @@ -2844,11 +2843,8 @@ VolMonitor(struct rx_call *acid, transDebugEntries *transInfo) transInfo->transDebugEntries_len += 1; if ((allocSize - transInfo->transDebugEntries_len) < 5) { /*alloc some more space */ allocSize = (allocSize * 3) / 2; - pntr = - (transDebugInfo *) realloc((char *)transInfo-> - transDebugEntries_val, - allocSize * - sizeof(transDebugInfo)); + pntr = realloc(transInfo->transDebugEntries_val, + allocSize * sizeof(transDebugInfo)); transInfo->transDebugEntries_val = pntr; pntr = transInfo->transDebugEntries_val + diff --git a/src/volser/vos.c b/src/volser/vos.c index fb8a638..529ccdd 100644 --- a/src/volser/vos.c +++ b/src/volser/vos.c @@ -4604,9 +4604,7 @@ ListVLDB(struct cmd_syndesc *as, void *arock) } else { /* Grow the tarray to keep the extra entries */ parraysize = (centries * sizeof(struct nvldbentry)); - ttarray = - (struct nvldbentry *)realloc(tarray, - tarraysize + parraysize); + ttarray = realloc(tarray, tarraysize + parraysize); if (!ttarray) { fprintf(STDERR, "Could not allocate enough space for the VLDB entries\n");