Don't cast arguments to free()

free(3) is defined as:

    void free(void *ptr);

so there is no need to cast the pointer argument being past to it to
(char *), (void *), or whatever other randomness happened to be floating
through the author's mind. Remove all such casts, as they are just
noise.

Change-Id: Ib7c8c259d53e9ce74fc486cb0997360044795395
Reviewed-on: http://gerrit.openafs.org/7453
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
This commit is contained in:
Simon Wilkinson 2012-05-16 20:38:02 +01:00 committed by Derrick Brashear
parent 8961793dbb
commit d142c8f97a
20 changed files with 44 additions and 44 deletions

View File

@ -138,7 +138,7 @@ afsconf_fopen(const char *fname, const char *fmode)
iop->buffer = malloc(BUFFER); iop->buffer = malloc(BUFFER);
if (iop->buffer == NULL) { if (iop->buffer == NULL) {
(void) close(fd); (void) close(fd);
free((void *) iop); free(iop);
errno = ENOMEM; errno = ENOMEM;
return NULL; return NULL;
} }
@ -154,8 +154,8 @@ afsconf_fclose(afsconf_FILE *iop)
return 0; return 0;
} }
close(iop->_file); close(iop->_file);
free((void *)iop->buffer); free(iop->buffer);
free((void *)iop); free(iop);
return 0; return 0;
} }

View File

@ -353,7 +353,7 @@ EvalVolumeSet2(struct bc_config *aconfig,
/* Free memory allocated during VL call */ /* Free memory allocated during VL call */
if (bulkentries.nbulkentries_val) { if (bulkentries.nbulkentries_val) {
free((char *)bulkentries.nbulkentries_val); free(bulkentries.nbulkentries_val);
bulkentries.nbulkentries_val = 0; bulkentries.nbulkentries_val = 0;
entries = 0; entries = 0;
} }
@ -366,7 +366,7 @@ EvalVolumeSet2(struct bc_config *aconfig,
error_exit: error_exit:
if (bulkentries.nbulkentries_val) { if (bulkentries.nbulkentries_val) {
free((char *)bulkentries.nbulkentries_val); free(bulkentries.nbulkentries_val);
} }
return (code); return (code);
} /*EvalVolumeSet2 */ } /*EvalVolumeSet2 */

View File

@ -307,7 +307,7 @@ parseServerList(struct cmd_item *itemPtr)
ERROR(code); ERROR(code);
/* free space for the server args */ /* free space for the server args */
free((char *)serverArgs); free(serverArgs);
error_exit: error_exit:
return (code); return (code);

View File

@ -341,8 +341,8 @@ int ADMINAPI
cfg_CellServDbStatusDeallocate(cfg_cellServDbStatus_t * statusItempP, cfg_CellServDbStatusDeallocate(cfg_cellServDbStatus_t * statusItempP,
afs_status_p st) afs_status_p st)
{ {
if ( statusItempP ) if ( statusItempP )
free((void *)statusItempP); free(statusItempP);
if (st != NULL) { if (st != NULL) {
*st = 0; *st = 0;

View File

@ -1206,7 +1206,7 @@ int ADMINAPI
cfg_StringDeallocate(char *stringDataP, /* (multi)string to deallocate */ cfg_StringDeallocate(char *stringDataP, /* (multi)string to deallocate */
afs_status_p st) afs_status_p st)
{ /* completion status */ { /* completion status */
free((void *)stringDataP); free(stringDataP);
if (st != NULL) { if (st != NULL) {
*st = 0; *st = 0;
} }
@ -1222,7 +1222,7 @@ int ADMINAPI
cfg_PartitionListDeallocate(cfg_partitionEntry_t * partitionListDataP, cfg_PartitionListDeallocate(cfg_partitionEntry_t * partitionListDataP,
afs_status_p st) afs_status_p st)
{ {
free((void *)partitionListDataP); free(partitionListDataP);
if (st != NULL) { if (st != NULL) {
*st = 0; *st = 0;
} }

View File

@ -231,7 +231,7 @@ int LWP_CreateProcess(int (*funP)(), int stacksize, int priority, void *argP,
pcb->fiber = CreateFiber(stacksize, Enter_LWP, pcb); pcb->fiber = CreateFiber(stacksize, Enter_LWP, pcb);
if (pcb->fiber == NULL) { if (pcb->fiber == NULL) {
free((void*)pcb); free(pcb);
return LWP_EINIT; return LWP_EINIT;
} }
Debug(0, ("Create: pcb=0x%p, funP=0x%p, argP=0x%p\n", pcb, funP, argP)) Debug(0, ("Create: pcb=0x%p, funP=0x%p, argP=0x%p\n", pcb, funP, argP))
@ -622,8 +622,8 @@ static void Free_PCB(PROCESS pid)
if (pid->fiber != NULL) { if (pid->fiber != NULL) {
DeleteFiber(pid->fiber); DeleteFiber(pid->fiber);
} }
if (pid->eventlist != NULL) free((void*)pid->eventlist); if (pid->eventlist != NULL) free(pid->eventlist);
free((void*)pid); free(pid);
} }
static void Dispose_of_Dead_PCB(PROCESS cur) static void Dispose_of_Dead_PCB(PROCESS cur)

View File

@ -46,7 +46,7 @@ IOMGR_AllocFDSet(void)
void void
IOMGR_FreeFDSet(fd_set * fds) IOMGR_FreeFDSet(fd_set * fds)
{ {
free((char *)fds); free(fds);
} }
#endif #endif

View File

@ -196,7 +196,7 @@ simplify_bitmap(struct bitmap *map)
mp2->m_page); mp2->m_page);
#endif #endif
*mpp = mp2->m_next; *mpp = mp2->m_next;
free((char *)mp2); free(mp2);
} else } else
mpp = &mp2->m_next; mpp = &mp2->m_next;
} }
@ -214,7 +214,7 @@ or_bitmap(struct bitmap *left, struct bitmap *right)
for (i = 0; i < MDATA; ++i) for (i = 0; i < MDATA; ++i)
lmap->m_data[i] |= rmap->m_data[i]; lmap->m_data[i] |= rmap->m_data[i];
*rightmp = rmap->m_next; *rightmp = rmap->m_next;
free((char *)rmap); free(rmap);
break; break;
} }
} }
@ -237,14 +237,14 @@ and_bitmap(struct bitmap *left, struct bitmap *right)
for (i = 0; i < MDATA; ++i) for (i = 0; i < MDATA; ++i)
sig |= (lmap->m_data[i] &= rmap->m_data[i]); sig |= (lmap->m_data[i] &= rmap->m_data[i]);
*rightmp = rmap->m_next; *rightmp = rmap->m_next;
free((char *)rmap); free(rmap);
break; break;
} }
if (rmap && sig) { if (rmap && sig) {
leftmp = &lmap->m_next; leftmp = &lmap->m_next;
} else { } else {
*leftmp = lmap->m_next; *leftmp = lmap->m_next;
free((char *)lmap); free(lmap);
} }
} }
free_map((struct map *)right); free_map((struct map *)right);
@ -270,14 +270,14 @@ bic_bitmap(struct bitmap *left, struct bitmap *right)
for (i = 0; i < MDATA; ++i) for (i = 0; i < MDATA; ++i)
sig |= (lmap->m_data[i] &= ~rmap->m_data[i]); sig |= (lmap->m_data[i] &= ~rmap->m_data[i]);
*rightmp = rmap->m_next; *rightmp = rmap->m_next;
free((char *)rmap); free(rmap);
break; break;
} }
if (!rmap || sig) { if (!rmap || sig) {
leftmp = &lmap->m_next; leftmp = &lmap->m_next;
} else { } else {
*leftmp = lmap->m_next; *leftmp = lmap->m_next;
free((char *)lmap); free(lmap);
} }
} }
free_map((struct map *)right); free_map((struct map *)right);

View File

@ -123,7 +123,7 @@ popsource(void)
fclose(source); fclose(source);
source = sp->s_file; source = sp->s_file;
shead = sp->s_next; shead = sp->s_next;
free((char *)sp); free(sp);
return 1; return 1;
} }

View File

@ -96,7 +96,7 @@ closedir(DIR * dir)
if (dir->h != INVALID_HANDLE_VALUE) if (dir->h != INVALID_HANDLE_VALUE)
FindClose(dir->h); FindClose(dir->h);
free((void *)dir); free(dir);
return 0; return 0;
} }

View File

@ -354,9 +354,9 @@ inocleanup()
if (inphead == NULL) if (inphead == NULL)
return; return;
for (inpp = &inpsort[inplast - 1]; inpp >= inpsort; inpp--) for (inpp = &inpsort[inplast - 1]; inpp >= inpsort; inpp--)
free((char *)(*inpp)); free(*inpp);
free((char *)inphead); free(inphead);
free((char *)inpsort); free(inpsort);
inphead = inpsort = NULL; inphead = inpsort = NULL;
} }
#endif #endif

View File

@ -893,7 +893,7 @@ checkfilesys(filesys, parname)
ckfini(); ckfini();
free(blockmap); free(blockmap);
free(statemap); free(statemap);
free((char *)lncntp); free(lncntp);
lncntp = NULL; lncntp = NULL;
blockmap = statemap = NULL; blockmap = statemap = NULL;
#ifdef AFS_SUN5_ENV #ifdef AFS_SUN5_ENV

View File

@ -96,7 +96,7 @@ pass4()
zlnp->zlncnt = zlnhead->zlncnt; zlnp->zlncnt = zlnhead->zlncnt;
zlnp = zlnhead; zlnp = zlnhead;
zlnhead = zlnhead->next; zlnhead = zlnhead->next;
free((char *)zlnp); free(zlnp);
clri(&idesc, "UNREF", 1); clri(&idesc, "UNREF", 1);
break; break;
} }
@ -176,7 +176,7 @@ pass4check(idesc)
dlp->dup = duplist->dup; dlp->dup = duplist->dup;
dlp = duplist; dlp = duplist;
duplist = duplist->next; duplist = duplist->next;
free((char *)dlp); free(dlp);
break; break;
} }
if (dlp == 0) { if (dlp == 0) {

View File

@ -364,7 +364,7 @@ ckfini()
flush(fswritefd, bp); flush(fswritefd, bp);
nbp = bp->b_prev; nbp = bp->b_prev;
free(bp->b_un.b_buf); free(bp->b_un.b_buf);
free((char *)bp); free(bp);
} }
#ifdef AFS_SUN5_ENVX #ifdef AFS_SUN5_ENVX
pbp = pdirbp = NULL; pbp = pdirbp = NULL;

View File

@ -999,7 +999,7 @@ h_Enumerate(int (*proc) (struct host*, void *), void *param)
} }
H_UNLOCK; H_UNLOCK;
} }
free((void *)list); free(list);
} /* h_Enumerate */ } /* h_Enumerate */

View File

@ -535,7 +535,7 @@ handleit(struct cmd_syndesc *as, void *arock)
for (i = 0; i < nentries; i++, entry++) for (i = 0; i < nentries; i++, entry++)
display_entry(entry, 0); display_entry(entry, 0);
if (entries.bulkentries_val) if (entries.bulkentries_val)
free((char *)entries.bulkentries_val); free(entries.bulkentries_val);
} else if (!strcmp(oper, "lan2")) { } else if (!strcmp(oper, "lan2")) {
int nentries, i, si, nsi, t = 0; int nentries, i, si, nsi, t = 0;
nbulkentries entries; nbulkentries entries;
@ -572,7 +572,7 @@ handleit(struct cmd_syndesc *as, void *arock)
for (i = 0; i < nentries; i++, entry++) for (i = 0; i < nentries; i++, entry++)
display_entryN(entry, 0); display_entryN(entry, 0);
if (entries.nbulkentries_val) if (entries.nbulkentries_val)
free((char *)entries.nbulkentries_val); free(entries.nbulkentries_val);
} }
printf("--- %d volumes ---\n", t); printf("--- %d volumes ---\n", t);
} else if (!strcmp(oper, "ln")) { } else if (!strcmp(oper, "ln")) {
@ -617,7 +617,7 @@ handleit(struct cmd_syndesc *as, void *arock)
for (vllist = linkedvldbs.node; vllist; vllist = vllist1) { for (vllist = linkedvldbs.node; vllist; vllist = vllist1) {
vllist1 = vllist->next_vldb; vllist1 = vllist->next_vldb;
display_entry((struct vldbentry *)&vllist->VldbEntry, 0); display_entry((struct vldbentry *)&vllist->VldbEntry, 0);
free((char *)vllist); free(vllist);
} }
} else if (!strcmp(oper, "di")) { } else if (!strcmp(oper, "di")) {
sscanf(&(*argp)[0], "%d", &id); sscanf(&(*argp)[0], "%d", &id);
@ -743,7 +743,7 @@ handleit(struct cmd_syndesc *as, void *arock)
printf("[0x%x %u] %s\n", *addrp, *addrp, printf("[0x%x %u] %s\n", *addrp, *addrp,
hostutil_GetNameByINet(ntohl(*addrp))); hostutil_GetNameByINet(ntohl(*addrp)));
} }
free((char *)addrs.bulkaddrs_val); free(addrs.bulkaddrs_val);
} else if (!strcmp(oper, "gau")) { } else if (!strcmp(oper, "gau")) {
int nentries, i, j; int nentries, i, j;
afs_uint32 *addrp; afs_uint32 *addrp;
@ -799,13 +799,13 @@ handleit(struct cmd_syndesc *as, void *arock)
hostutil_GetNameByINet(mhaddrp[j])); hostutil_GetNameByINet(mhaddrp[j]));
} }
if (mhaddrs.bulkaddrs_val) if (mhaddrs.bulkaddrs_val)
free((char *)mhaddrs.bulkaddrs_val); free(mhaddrs.bulkaddrs_val);
} else { } else {
printf("[0x%x %u] %s\n", *addrp, *addrp, printf("[0x%x %u] %s\n", *addrp, *addrp,
hostutil_GetNameByINet(ntohl(*addrp))); hostutil_GetNameByINet(ntohl(*addrp)));
} }
} }
free((char *)addrs.bulkaddrs_val); free(addrs.bulkaddrs_val);
} else if (!strcmp(oper, "mhc")) { } else if (!strcmp(oper, "mhc")) {
afs_uint32 serveraddrs[MAXSERVERID + 1][VL_MAXIPADDRS_PERMH]; afs_uint32 serveraddrs[MAXSERVERID + 1][VL_MAXIPADDRS_PERMH];
afs_int32 serveraddrtype[MAXSERVERID + 1]; afs_int32 serveraddrtype[MAXSERVERID + 1];
@ -860,7 +860,7 @@ handleit(struct cmd_syndesc *as, void *arock)
for (j = 0; j < nentries2; j++) { for (j = 0; j < nentries2; j++) {
serveraddrs[i][j] = ntohl(addrp2[j]); serveraddrs[i][j] = ntohl(addrp2[j]);
} }
free((char *)addrs2.bulkaddrs_val); free(addrs2.bulkaddrs_val);
} }
if (nargs) { if (nargs) {
@ -875,7 +875,7 @@ handleit(struct cmd_syndesc *as, void *arock)
} }
} }
} }
free((char *)addrs1.bulkaddrs_val); free(addrs1.bulkaddrs_val);
/* Look for any duplicates */ /* Look for any duplicates */
for (i = 0; i < MAXSERVERID + 1; i++) { for (i = 0; i < MAXSERVERID + 1; i++) {

View File

@ -1760,7 +1760,7 @@ SVL_ListAttributesN2(struct rx_call *rxcall,
countAbort(this_op); countAbort(this_op);
ubik_AbortTrans(ctx.trans); ubik_AbortTrans(ctx.trans);
if (vldbentries->nbulkentries_val) if (vldbentries->nbulkentries_val)
free((char *)vldbentries->nbulkentries_val); free(vldbentries->nbulkentries_val);
vldbentries->nbulkentries_val = 0; vldbentries->nbulkentries_val = 0;
vldbentries->nbulkentries_len = 0; vldbentries->nbulkentries_len = 0;
*nextstartindex = -1; *nextstartindex = -1;

View File

@ -757,7 +757,7 @@ xfs_ListViceInodes(char *devname, char *mountedOn, FD_t inodeFile,
closedir(top_dirp); closedir(top_dirp);
if (renames) if (renames)
free((char *)renames); free(renames);
if (inodeFile != INVALID_FD) { if (inodeFile != INVALID_FD) {
if (OS_SYNC(inodeFile) == -1) { if (OS_SYNC(inodeFile) == -1) {
Log("Unable to successfully fsync inode file for %s\n", mountedOn); Log("Unable to successfully fsync inode file for %s\n", mountedOn);
@ -787,7 +787,7 @@ xfs_ListViceInodes(char *devname, char *mountedOn, FD_t inodeFile,
if (top_dirp) if (top_dirp)
closedir(top_dirp); closedir(top_dirp);
if (renames) if (renames)
free((char *)renames); free(renames);
return -1; return -1;
} }

View File

@ -6489,7 +6489,7 @@ VGetBitmap_r(Error * ec, Volume * vp, VnodeClass class)
vip->bitmap = BitMap; vip->bitmap = BitMap;
vip->bitmapOffset = 0; vip->bitmapOffset = 0;
} else } else
free((byte *) BitMap); free(BitMap);
#endif /* BITMAP_LATER */ #endif /* BITMAP_LATER */
#ifdef AFS_DEMAND_ATTACH_FS #ifdef AFS_DEMAND_ATTACH_FS
VChangeState_r(vp, state_save); VChangeState_r(vp, state_save);

View File

@ -1295,9 +1295,9 @@ RestoreVolume(struct rx_call *call, Volume * avp, int incremental,
out: out:
/* Free the malloced space above */ /* Free the malloced space above */
if (b1) if (b1)
free((char *)b1); free(b1);
if (b2) if (b2)
free((char *)b2); free(b2);
return error; return error;
} }