From: Simon Wilkinson Date: Thu, 17 May 2012 09:52:46 +0000 (+0100) Subject: fileserver & friends: Don't cast from malloc() X-Git-Tag: upstream/1.8.0_pre1^2~2380 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=0df1f0023a4aef7126c031e2e30990446093ac7e;p=packages%2Fo%2Fopenafs.git fileserver & friends: Don't cast from malloc() malloc() returns a (void *) on all of our current platforms. So, don't bother casting the return value before assigning it - it's unecessary noise. Change-Id: I9d41f2f1aee03d9317b4c5780fb00e13d30b0821 Reviewed-on: http://gerrit.openafs.org/7461 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- diff --git a/src/fsint/afsaux.c b/src/fsint/afsaux.c index cdceb9553..2c3cd4d48 100644 --- a/src/fsint/afsaux.c +++ b/src/fsint/afsaux.c @@ -128,7 +128,7 @@ xdr_CBS(XDR * x, struct CBS * abbs) return FALSE; } if (!abbs->SeqBody) - abbs->SeqBody = (char *)NVALLOC(len); + abbs->SeqBody = NVALLOC(len); abbs->SeqLen = len; xdr_opaque(x, abbs->SeqBody, len); return TRUE; @@ -157,7 +157,7 @@ xdr_BBS(XDR * x, struct BBS * abbs) return FALSE; } if (!abbs->SeqBody) - abbs->SeqBody = (char *)NVALLOC(maxLen); + abbs->SeqBody = NVALLOC(maxLen); abbs->MaxSeqLen = maxLen; abbs->SeqLen = len; xdr_opaque(x, abbs->SeqBody, len); @@ -187,7 +187,7 @@ xdr_AFSAccessList(XDR * x, AFSAccessList * abbs) return FALSE; } if (!abbs->SeqBody) - abbs->SeqBody = (char *)NVALLOC(maxLen); + abbs->SeqBody = NVALLOC(maxLen); abbs->MaxSeqLen = maxLen; abbs->SeqLen = len; xdr_opaque(x, abbs->SeqBody, len); diff --git a/src/libacl/aclprocs.c b/src/libacl/aclprocs.c index 2db3f9869..70c25732b 100644 --- a/src/libacl/aclprocs.c +++ b/src/libacl/aclprocs.c @@ -92,8 +92,7 @@ acl_NewACL(int nEntries, struct acl_accessList **acl) t = sizeof(struct acl_accessList) + (nEntries - 1) * sizeof(struct acl_accessEntry); if (GetFromList(&freeList, &e, t) < 0) { - e = (struct freeListEntry *)malloc(t + sizeof(int) + - sizeof(struct freeListEntry *)); + e = malloc(t + sizeof(int) + sizeof(struct freeListEntry *)); if (e == NULL) { perror("acl_NewACL: malloc() failed"); abort(); @@ -136,8 +135,7 @@ acl_NewExternalACL(int nEntries, char **r) * name plus decimal 2**32 (for largest rights mask) plus some formatting */ if (GetFromList(&freeList, &e, t)) { - e = (struct freeListEntry *)malloc(t + sizeof(int) + - sizeof(struct freeListEntry *)); + e = malloc(t + sizeof(int) + sizeof(struct freeListEntry *)); if (e == NULL) { perror("acl_NewExternalACL(): malloc() failed"); abort(); @@ -255,8 +253,7 @@ acl_Internalize_pr(int (*func)(namelist *names, idlist *ids), char *elist, struc return 0; } lnames.namelist_len = (*acl)->total; - lnames.namelist_val = - (prname *) malloc(lnames.namelist_len * PR_MAXNAMELEN); + lnames.namelist_val = malloc(lnames.namelist_len * PR_MAXNAMELEN); if (lnames.namelist_val == 0) { return -1; } diff --git a/src/libacl/test/acltest.c b/src/libacl/test/acltest.c index ffd4f6d01..dbaa8b49f 100644 --- a/src/libacl/test/acltest.c +++ b/src/libacl/test/acltest.c @@ -172,7 +172,7 @@ main() if (externalstore[which] != NULL) { /* we're adding to access list */ size = strlen(externalstore[which]); - ptr = (char *)malloc(size); + ptr = malloc(size); sscanf(externalstore[which], "%d\n%d\n", &p, &n); strncpy(ptr, externalstore[which], size); p++; @@ -235,7 +235,7 @@ main() continue; } names.namelist_len = 1; - names.namelist_val = (prname *) malloc(strlen(name) + 1); + names.namelist_val = malloc(strlen(name) + 1); strncpy(names.namelist_val, name, PR_MAXNAMELEN); code = pr_NameToId(&names, &ids); if (code) { diff --git a/src/vfsck/main.c b/src/vfsck/main.c index 55bb12ba8..dc466033c 100644 --- a/src/vfsck/main.c +++ b/src/vfsck/main.c @@ -558,7 +558,7 @@ finddisk(name) if (strncmp(dk->name, name, len) == 0 && dk->name[len] == 0) return (dk); } - if ((*dkp = (struct disk *)malloc(sizeof(struct disk))) == NULL) + if ((*dkp = malloc(sizeof(struct disk))) == NULL) errexit("out of memory"); dk = *dkp; if ((dk->name = strdup(name)) == NULL) @@ -581,7 +581,7 @@ addpart(name, fsname) printf("%s in fstab more than once!\n", name); return; } - if ((*ppt = (struct part *)malloc(sizeof(struct part))) == NULL) + if ((*ppt = malloc(sizeof(struct part))) == NULL) errexit("out of memory"); pt = *ppt; if ((pt->name = strdup(name)) == NULL) diff --git a/src/vfsck/pass1.c b/src/vfsck/pass1.c index bb8046a86..cbcfabd4e 100644 --- a/src/vfsck/pass1.c +++ b/src/vfsck/pass1.c @@ -292,7 +292,7 @@ pass1() n_files++; lncntp[inumber] = dp->di_nlink; if (dp->di_nlink <= 0) { - zlnp = (struct zlncnt *)malloc(sizeof *zlnp); + zlnp = malloc(sizeof *zlnp); if (zlnp == NULL) { pfatal("LINK COUNT TABLE OVERFLOW"); if (reply("CONTINUE") == 0) @@ -433,7 +433,7 @@ pass1check(idesc) #endif return (STOP); } - new = (struct dups *)malloc(sizeof(struct dups)); + new = malloc(sizeof(struct dups)); if (new == NULL) { pfatal("DUP TABLE OVERFLOW."); if (reply("CONTINUE") == 0) diff --git a/src/vfsck/proplist.c b/src/vfsck/proplist.c index 954637184..a7068497e 100644 --- a/src/vfsck/proplist.c +++ b/src/vfsck/proplist.c @@ -166,8 +166,7 @@ proplist_blkscan(dp, idesc, entry_list) valueresid = 0; } if (valueresid == 0) { - entry = (struct prop_entry_desc *) - malloc(sizeof(struct prop_entry_desc)); + entry = malloc(sizeof(struct prop_entry_desc)); if (entry == NULL) return (SKIP); entry->next = NULL; diff --git a/src/vfsck/utilities.c b/src/vfsck/utilities.c index 19f6dc50d..680c41d7c 100644 --- a/src/vfsck/utilities.c +++ b/src/vfsck/utilities.c @@ -194,7 +194,7 @@ bufinit() if (bufcnt < MINBUFS) bufcnt = MINBUFS; for (i = 0; i < bufcnt; i++) { - bp = (struct bufarea *)malloc(sizeof(struct bufarea)); + bp = malloc(sizeof(struct bufarea)); bufp = malloc((unsigned int)sblock.fs_bsize); if (bp == NULL || bufp == NULL) { if (i >= MINBUFS) diff --git a/src/viced/afsfileprocs.c b/src/viced/afsfileprocs.c index 1ba3cda6b..221ecf82a 100644 --- a/src/viced/afsfileprocs.c +++ b/src/viced/afsfileprocs.c @@ -1255,7 +1255,7 @@ CopyOnWrite(Vnode * targetptr, Volume * volptr, afs_foff_t off, afs_fsize_t len) if (size > len) size = len; - buff = (char *)malloc(COPYBUFFSIZE); + buff = malloc(COPYBUFFSIZE); if (buff == NULL) { return EIO; } @@ -2534,14 +2534,12 @@ SRXAFS_BulkStatus(struct rx_call * acall, struct AFSCBFids * Fids, } /* allocate space for return output parameters */ - OutStats->AFSBulkStats_val = (struct AFSFetchStatus *) - malloc(nfiles * sizeof(struct AFSFetchStatus)); + OutStats->AFSBulkStats_val = malloc(nfiles * sizeof(struct AFSFetchStatus)); if (!OutStats->AFSBulkStats_val) { ViceLogThenPanic(0, ("Failed malloc in SRXAFS_BulkStatus\n")); } OutStats->AFSBulkStats_len = nfiles; - CallBacks->AFSCBs_val = (struct AFSCallBack *) - malloc(nfiles * sizeof(struct AFSCallBack)); + CallBacks->AFSCBs_val = malloc(nfiles * sizeof(struct AFSCallBack)); if (!CallBacks->AFSCBs_val) { ViceLogThenPanic(0, ("Failed malloc in SRXAFS_BulkStatus\n")); } @@ -5372,7 +5370,7 @@ SRXAFS_GetXStats(struct rx_call *a_call, afs_int32 a_clientVersionNum, * for the File Server. */ dataBytes = sizeof(struct afs_Stats); - dataBuffP = (afs_int32 *) malloc(dataBytes); + dataBuffP = malloc(dataBytes); memcpy(dataBuffP, &afs_cmstats, dataBytes); a_dataP->AFS_CollData_len = dataBytes >> 2; a_dataP->AFS_CollData_val = dataBuffP; @@ -5399,7 +5397,7 @@ SRXAFS_GetXStats(struct rx_call *a_call, afs_int32 a_clientVersionNum, */ dataBytes = sizeof(struct afs_PerfStats); - dataBuffP = (afs_int32 *) malloc(dataBytes); + dataBuffP = malloc(dataBytes); memcpy(dataBuffP, &afs_perfstats, dataBytes); a_dataP->AFS_CollData_len = dataBytes >> 2; a_dataP->AFS_CollData_val = dataBuffP; @@ -5425,7 +5423,7 @@ SRXAFS_GetXStats(struct rx_call *a_call, afs_int32 a_clientVersionNum, */ dataBytes = sizeof(struct fs_stats_FullPerfStats); - dataBuffP = (afs_int32 *) malloc(dataBytes); + dataBuffP = malloc(dataBytes); memcpy(dataBuffP, &afs_FullPerfStats, dataBytes); a_dataP->AFS_CollData_len = dataBytes >> 2; a_dataP->AFS_CollData_val = dataBuffP; @@ -5435,7 +5433,7 @@ SRXAFS_GetXStats(struct rx_call *a_call, afs_int32 a_clientVersionNum, afs_perfstats.numPerfCalls++; dataBytes = sizeof(struct cbcounters); - dataBuffP = (afs_int32 *) malloc(dataBytes); + dataBuffP = malloc(dataBytes); { extern struct cbcounters cbstuff; dataBuffP[0]=cbstuff.DeleteFiles; @@ -5601,7 +5599,7 @@ SRXAFS_GetCapabilities(struct rx_call * acall, Capabilities * capabilities) goto Bad_GetCaps; dataBytes = 1 * sizeof(afs_int32); - dataBuffP = (afs_uint32 *) malloc(dataBytes); + dataBuffP = malloc(dataBytes); dataBuffP[0] = VICED_CAPABILITY_ERRORTRANS | VICED_CAPABILITY_WRITELOCKACL; dataBuffP[0] |= VICED_CAPABILITY_64BITFILES; if (saneacls) @@ -5881,15 +5879,15 @@ SRXAFS_GetVolumeStatus(struct rx_call * acall, afs_int32 avolid, ViceLog(2, ("SAFS_GetVolumeStatus returns %d\n", errorCode)); /* next is to guarantee out strings exist for stub */ if (*Name == 0) { - *Name = (char *)malloc(1); + *Name = malloc(1); **Name = 0; } if (*Motd == 0) { - *Motd = (char *)malloc(1); + *Motd = malloc(1); **Motd = 0; } if (*OfflineMsg == 0) { - *OfflineMsg = (char *)malloc(1); + *OfflineMsg = malloc(1); **OfflineMsg = 0; } errorCode = CallPostamble(tcon, errorCode, thost); diff --git a/src/viced/fsprobe.c b/src/viced/fsprobe.c index 59b5a3881..fa2e80d24 100644 --- a/src/viced/fsprobe.c +++ b/src/viced/fsprobe.c @@ -275,7 +275,6 @@ FetchData(char **argp) static afs_int32 FetchProc(struct rx_call *acall) { - extern char *malloc(); char *tbuffer; afs_int32 tlen, length, code; @@ -834,7 +833,6 @@ Readdir(char **argp) static afs_int32 FetchDir(struct rx_call *acall) { - extern char *malloc(); char *tbuffer; afs_int32 tlen, length, code; struct dirent *dp; diff --git a/src/viced/host.c b/src/viced/host.c index 54d9604fa..7a0afb2d7 100644 --- a/src/viced/host.c +++ b/src/viced/host.c @@ -110,7 +110,7 @@ GetCEBlock(void) struct CEBlock *block; int i; - block = (struct CEBlock *)malloc(sizeof(struct CEBlock)); + block = malloc(sizeof(struct CEBlock)); if (!block) { ViceLog(0, ("Failed malloc in GetCEBlock\n")); ShutDownAndCore(PANIC); @@ -198,7 +198,7 @@ GetHTBlock(void) return; } - block = (struct HTBlock *)malloc(sizeof(struct HTBlock)); + block = malloc(sizeof(struct HTBlock)); if (!block) { ViceLog(0, ("Failed malloc in GetHTBlock\n")); ShutDownAndCore(PANIC); @@ -954,7 +954,7 @@ h_Enumerate(int (*proc) (struct host*, void *), void *param) H_UNLOCK; return; } - list = (struct host **)malloc(hostCount * sizeof(struct host *)); + list = malloc(hostCount * sizeof(struct host *)); if (!list) { ViceLogThenPanic(0, ("Failed malloc in h_Enumerate (list)\n")); } @@ -1130,7 +1130,7 @@ h_AddHostToUuidHashTable_r(struct afsUUID *uuid, struct host *host) } /* insert into beginning of list for this bucket */ - chain = (struct h_UuidHashChain *)malloc(sizeof(struct h_UuidHashChain)); + chain = malloc(sizeof(struct h_UuidHashChain)); if (!chain) { ViceLogThenPanic(0, ("Failed malloc in h_AddHostToUuidHashTable_r\n")); } @@ -1311,7 +1311,7 @@ createHostAddrHashChain_r(int index, afs_uint32 addr, afs_uint16 port, struct ho char hoststr[16]; /* insert into beginning of list for this bucket */ - chain = (struct h_AddrHashChain *)malloc(sizeof(struct h_AddrHashChain)); + chain = malloc(sizeof(struct h_AddrHashChain)); if (!chain) { ViceLogThenPanic(0, ("Failed malloc in h_AddHostToAddrHashTable_r\n")); } @@ -1530,8 +1530,8 @@ addInterfaceAddr_r(struct host *host, afs_uint32 addr, afs_uint16 port) ntohs(host->port), afs_inet_ntoa_r(addr, hoststr2), ntohs(port))); - interface = (struct Interface *) - malloc(sizeof(struct Interface) + (sizeof(struct AddrPort) * number)); + interface = malloc(sizeof(struct Interface) + + (sizeof(struct AddrPort) * number)); if (!interface) { ViceLogThenPanic(0, ("Failed malloc in addInterfaceAddr_r\n")); } @@ -1724,7 +1724,7 @@ h_GetHost_r(struct rx_connection *tcon) H_LOCK; if ((code == RXGEN_OPCODE) || ((code == 0) && (afs_uuid_equal(&interf.uuid, &nulluuid)))) { - identP = (struct Identity *)malloc(sizeof(struct Identity)); + identP = malloc(sizeof(struct Identity)); if (!identP) { ViceLogThenPanic(0, ("Failed malloc in h_GetHost_r\n")); } @@ -1765,7 +1765,7 @@ h_GetHost_r(struct rx_connection *tcon) } } else if (code == 0) { interfValid = 1; - identP = (struct Identity *)malloc(sizeof(struct Identity)); + identP = malloc(sizeof(struct Identity)); if (!identP) { ViceLogThenPanic(0, ("Failed malloc in h_GetHost_r\n")); } @@ -1951,8 +1951,7 @@ h_GetHost_r(struct rx_connection *tcon) if ((code == RXGEN_OPCODE) || ((code == 0) && (afs_uuid_equal(&interf.uuid, &nulluuid)))) { if (!identP) - identP = - (struct Identity *)malloc(sizeof(struct Identity)); + identP = malloc(sizeof(struct Identity)); else pident = 1; @@ -1969,8 +1968,7 @@ h_GetHost_r(struct rx_connection *tcon) code = 0; } else if (code == 0) { if (!identP) - identP = - (struct Identity *)malloc(sizeof(struct Identity)); + identP = malloc(sizeof(struct Identity)); else pident = 1; @@ -2678,7 +2676,7 @@ h_UserName(struct client *client) idlist lids; lids.idlist_len = 1; - lids.idlist_val = (afs_int32 *) malloc(1 * sizeof(afs_int32)); + lids.idlist_val = malloc(1 * sizeof(afs_int32)); if (!lids.idlist_val) { ViceLogThenPanic(0, ("Failed malloc in h_UserName\n")); } @@ -3260,7 +3258,7 @@ h_stateSaveHost(struct host * host, void* rock) if (host->interface) { if_len = sizeof(struct Interface) + ((host->interface->numberOfInterfaces-1) * sizeof(struct AddrPort)); - ifp = (struct Interface *) malloc(if_len); + ifp = malloc(if_len); osi_Assert(ifp != NULL); memcpy(ifp, host->interface, if_len); hdr.interfaces = host->interface->numberOfInterfaces; @@ -3271,7 +3269,7 @@ h_stateSaveHost(struct host * host, void* rock) if (host->hcps.prlist_val) { hdr.hcps = host->hcps.prlist_len; hcps_len = hdr.hcps * sizeof(afs_int32); - hcps = (afs_int32 *) malloc(hcps_len); + hcps = malloc(hcps_len); osi_Assert(hcps != NULL); memcpy(hcps, host->hcps.prlist_val, hcps_len); iov[iovcnt].iov_base = (char *) hcps; @@ -3343,7 +3341,7 @@ h_stateRestoreHost(struct fs_dump_state * state) if (hdr.interfaces) { ifp_len = sizeof(struct Interface) + ((hdr.interfaces-1) * sizeof(struct AddrPort)); - ifp = (struct Interface *) malloc(ifp_len); + ifp = malloc(ifp_len); osi_Assert(ifp != NULL); iov[iovcnt].iov_base = (char *) ifp; iov[iovcnt].iov_len = ifp_len; @@ -3351,7 +3349,7 @@ h_stateRestoreHost(struct fs_dump_state * state) } if (hdr.hcps) { hcps_len = hdr.hcps * sizeof(afs_int32); - hcps = (afs_int32 *) malloc(hcps_len); + hcps = malloc(hcps_len); osi_Assert(hcps != NULL); iov[iovcnt].iov_base = (char *) hcps; iov[iovcnt].iov_len = hcps_len; @@ -3372,7 +3370,7 @@ h_stateRestoreHost(struct fs_dump_state * state) if (!hdr.hcps && hdsk.hcps_valid) { /* valid, zero-length host cps ; does this ever happen? */ - hcps = (afs_int32 *) malloc(sizeof(afs_int32)); + hcps = malloc(sizeof(afs_int32)); osi_Assert(hcps != NULL); } @@ -4066,16 +4064,15 @@ initInterfaceAddr_r(struct host *host, struct interfaceAddr *interf) * Allocate and initialize an interface structure for this host. */ if (found) { - interface = (struct Interface *) - malloc(sizeof(struct Interface) + - (sizeof(struct AddrPort) * (count - 1))); + interface = malloc(sizeof(struct Interface) + + (sizeof(struct AddrPort) * (count - 1))); if (!interface) { ViceLogThenPanic(0, ("Failed malloc in initInterfaceAddr_r 1\n")); } interface->numberOfInterfaces = count; } else { - interface = (struct Interface *) - malloc(sizeof(struct Interface) + (sizeof(struct AddrPort) * count)); + interface = malloc(sizeof(struct Interface) + + (sizeof(struct AddrPort) * count)); if (!interface) { ViceLogThenPanic(0, ("Failed malloc in initInterfaceAddr_r 2\n")); } diff --git a/src/viced/profile.c b/src/viced/profile.c index 9a62828a0..e979cf88a 100644 --- a/src/viced/profile.c +++ b/src/viced/profile.c @@ -93,7 +93,7 @@ AllocProfBuf() if (profBuf != NULL) return; profBufSize = (int)&etext - PROFSTART; - profBuf = (char *)malloc(profBufSize); + profBuf = malloc(profBufSize); if (profBuf == NULL) { fprintf(stderr, "Couldn't get profiling buffer.\n"); return; diff --git a/src/viced/serialize_state.c b/src/viced/serialize_state.c index 5c86e3f88..321b03afe 100644 --- a/src/viced/serialize_state.c +++ b/src/viced/serialize_state.c @@ -1010,13 +1010,13 @@ fs_stateAlloc(struct fs_dump_state * state) memset(state, 0, sizeof(struct fs_dump_state)); state->fd = -1; state->fn = (char *)AFSDIR_SERVER_FSSTATE_FILEPATH; - state->hdr = (struct fs_state_header *)malloc(sizeof(struct fs_state_header)); - state->h_hdr = (struct host_state_header *)malloc(sizeof(struct host_state_header)); - state->cb_hdr = (struct callback_state_header *)malloc(sizeof(struct callback_state_header)); - state->cb_timeout_hdr = (struct callback_state_timeout_header *) - malloc(sizeof(struct callback_state_timeout_header)); - state->cb_fehash_hdr = (struct callback_state_fehash_header *) - malloc(sizeof(struct callback_state_fehash_header)); + state->hdr = malloc(sizeof(struct fs_state_header)); + state->h_hdr = malloc(sizeof(struct host_state_header)); + state->cb_hdr = malloc(sizeof(struct callback_state_header)); + state->cb_timeout_hdr = + malloc(sizeof(struct callback_state_timeout_header)); + state->cb_fehash_hdr = + malloc(sizeof(struct callback_state_fehash_header)); if ((state->hdr == NULL) || (state->h_hdr == NULL) || (state->cb_hdr == NULL) || (state->cb_timeout_hdr == NULL) || (state->cb_fehash_hdr == NULL)) ret = 1; diff --git a/src/viced/state_analyzer.c b/src/viced/state_analyzer.c index ab85bdd21..99962d8d4 100644 --- a/src/viced/state_analyzer.c +++ b/src/viced/state_analyzer.c @@ -1268,7 +1268,7 @@ dump_he_interfaces(void) return; len = sizeof(struct Interface) + ((he_cursor.hdr.interfaces-1)*sizeof(struct AddrPort)); - ifp = (struct Interface *) malloc(len); + ifp = malloc(len); assert(ifp != NULL); memcpy(ifp, he_cursor.ifp, len); @@ -1304,7 +1304,7 @@ dump_he_hcps(void) return; len = (he_cursor.hdr.hcps)*sizeof(afs_uint32); - hcps = (afs_int32 *) malloc(len); + hcps = malloc(len); assert(hcps != NULL); memcpy(hcps, he_cursor.hcps, len); diff --git a/src/vol/clone.c b/src/vol/clone.c index 9d62c9746..87f42bf42 100644 --- a/src/vol/clone.c +++ b/src/vol/clone.c @@ -76,7 +76,7 @@ ci_AddItem(struct clone_head *ah, Inode aino) /* if no last elt (first call) or last item full, get a new one */ if ((!ah->last) || ah->last->nitems >= CLONE_MAXITEMS) { - ti = (struct clone_items *)malloc(sizeof(struct clone_items)); + ti = malloc(sizeof(struct clone_items)); if (!ti) { Log("ci_AddItem: malloc failed\n"); osi_Panic("ci_AddItem: malloc failed\n"); diff --git a/src/vol/ihandle.c b/src/vol/ihandle.c index 58cd546aa..90fd2adeb 100644 --- a/src/vol/ihandle.c +++ b/src/vol/ihandle.c @@ -203,7 +203,7 @@ iHandleAllocateChunk(void) IHandle_t *ihP; osi_Assert(ihAvailHead == NULL); - ihP = (IHandle_t *) malloc(I_HANDLE_MALLOCSIZE * sizeof(IHandle_t)); + ihP = malloc(I_HANDLE_MALLOCSIZE * sizeof(IHandle_t)); osi_Assert(ihP != NULL); for (i = 0; i < I_HANDLE_MALLOCSIZE; i++) { ihP[i].ih_refcnt = 0; @@ -276,7 +276,7 @@ fdHandleAllocateChunk(void) FdHandle_t *fdP; osi_Assert(fdAvailHead == NULL); - fdP = (FdHandle_t *) malloc(FD_HANDLE_MALLOCSIZE * sizeof(FdHandle_t)); + fdP = malloc(FD_HANDLE_MALLOCSIZE * sizeof(FdHandle_t)); osi_Assert(fdP != NULL); for (i = 0; i < FD_HANDLE_MALLOCSIZE; i++) { fdP[i].fd_status = FD_HANDLE_AVAIL; diff --git a/src/vol/listinodes.c b/src/vol/listinodes.c index 22425c0da..140e8c30a 100644 --- a/src/vol/listinodes.c +++ b/src/vol/listinodes.c @@ -715,8 +715,7 @@ xfs_ListViceInodes(char *devname, char *mountedOn, FD_t inodeFile, if (n_renames >= n_avail) { n_avail += N_RENAME_STEP; if (n_avail == N_RENAME_STEP) - renames = (xfs_Rename_t *) - malloc(n_avail * sizeof(xfs_Rename_t)); + renames = malloc(n_avail * sizeof(xfs_Rename_t)); else renames = realloc(renames, n_avail * sizeof(xfs_Rename_t)); @@ -1018,7 +1017,7 @@ ListViceInodes(char *devname, char *mountedOn, FD_t inodeFile, #else bufsize = super.fs.fs_ipg * sizeof(struct dinode); #endif /* AFS_HPUX_ENV */ - inodes = (struct dinode *)malloc(bufsize); + inodes = malloc(bufsize); einodes = (struct dinode *)(((char *)inodes) + bufsize); if (inodes == NULL) { Log("Unable to allocate enough memory to scan inodes; help!\n"); diff --git a/src/vol/namei_ops.c b/src/vol/namei_ops.c index a2e4ad55b..0c006f88b 100644 --- a/src/vol/namei_ops.c +++ b/src/vol/namei_ops.c @@ -3145,7 +3145,7 @@ AddToZLCDeleteList(char dir, char *name) if (zlcCur && zlcCur->zlc_next) zlcCur = zlcCur->zlc_next; else { - zlcList_t *tmp = (zlcList_t *) malloc(sizeof(zlcList_t)); + zlcList_t *tmp = malloc(sizeof(zlcList_t)); if (!tmp) return; if (!zlcAnchor) { diff --git a/src/vol/partition.c b/src/vol/partition.c index 6d0d122b6..91d211c60 100644 --- a/src/vol/partition.c +++ b/src/vol/partition.c @@ -190,7 +190,7 @@ VInitPartition_r(char *path, char *devname, Device dev) { struct DiskPartition64 *dp, *op; - dp = (struct DiskPartition64 *)malloc(sizeof(struct DiskPartition64)); + dp = malloc(sizeof(struct DiskPartition64)); /* Add it to the end, to preserve order when we print statistics */ for (op = DiskPartitionList; op; op = op->next) { if (!op->next) @@ -205,7 +205,7 @@ VInitPartition_r(char *path, char *devname, Device dev) dp->index = volutil_GetPartitionID(path); #if defined(AFS_NAMEI_ENV) && !defined(AFS_NT40_ENV) /* Create a lockfile for the partition, of the form /vicepa/Lock/vicepa */ - dp->devName = (char *)malloc(2 * strlen(path) + 6); + dp->devName = malloc(2 * strlen(path) + 6); strcpy(dp->devName, path); strcat(dp->devName, OS_DIRSEP); strcat(dp->devName, "Lock"); @@ -574,7 +574,7 @@ getmount(struct vmount **vmountpp) /* try the operation until ok or a fatal error */ while (1) { - if ((vm = (struct vmount *)malloc(size)) == NULL) { + if ((vm = malloc(size)) == NULL) { /* failed getting memory for mount status buf */ perror("FATAL ERROR: get_stat malloc failed\n"); exit(-1); diff --git a/src/vol/salvaged.c b/src/vol/salvaged.c index dbd693081..a2c6cc27a 100644 --- a/src/vol/salvaged.c +++ b/src/vol/salvaged.c @@ -646,7 +646,7 @@ SalvageChildReaperThread(void * args) MUTEX_EXIT(&worker_lock); - cleanup = (struct log_cleanup_node *) malloc(sizeof(struct log_cleanup_node)); + cleanup = malloc(sizeof(struct log_cleanup_node)); while (Reap_Child("salvageserver", &pid, &status) < 0) { /* try to prevent livelock if something goes wrong */ @@ -822,8 +822,7 @@ SalvageLogScanningThread(void * arg) continue; } - cleanup = - (struct log_cleanup_node *) malloc(sizeof(struct log_cleanup_node)); + cleanup = malloc(sizeof(struct log_cleanup_node)); cleanup->pid = pid; queue_Append(&log_watch_queue, cleanup); diff --git a/src/vol/test/listVicepx.c b/src/vol/test/listVicepx.c index de46cfb94..b715c5fbd 100644 --- a/src/vol/test/listVicepx.c +++ b/src/vol/test/listVicepx.c @@ -300,7 +300,7 @@ scanLargeVnode(dev, node, partitionName, option) vnode->inodeNumber, vnode->parent); #endif - assert(dirEntry = (DirEnt *) malloc(sizeof(DirEnt))); + assert(dirEntry = malloc(sizeof(DirEnt))); dirEntry->inode = vnode->inodeNumber; dirEntry->numEntries = 0; dirEntry->vnodeName = NULL; @@ -438,7 +438,7 @@ scanSmallVnode(dev, node, partitionName, option) errno); exit(12); } - assert(symLink = (char *)malloc(statLink.st_size + 1)); + assert(symLink = malloc(statLink.st_size + 1)); if (read(fdLink, symLink, statLink.st_size) < 0) { printf("Error in reading symbolic link : %d\n", errno); exit(11); diff --git a/src/vol/vnode.c b/src/vol/vnode.c index 39e797835..2d0f517bb 100644 --- a/src/vol/vnode.c +++ b/src/vol/vnode.c @@ -839,7 +839,7 @@ VAllocVnode_r(Error * ec, Volume * vp, VnodeType type, VnodeId in_vnode, Unique } } else { /* growing file - grow in a reasonable increment */ - char *buf = (char *)malloc(16 * 1024); + char *buf = malloc(16 * 1024); if (!buf) { Log("VAllocVnode: can't grow vnode index: out of memory\n"); *ec = ENOMEM; diff --git a/src/vol/vol-salvage.c b/src/vol/vol-salvage.c index 0f189d992..291f36d49 100644 --- a/src/vol/vol-salvage.c +++ b/src/vol/vol-salvage.c @@ -1258,7 +1258,7 @@ GetInodeSummary(struct SalvInfo *salvinfo, FD_t inodeFile, VolumeId singleVolume deleted = 1; goto error; } - ip = (struct ViceInodeInfo *)malloc(nInodes*sizeof(struct ViceInodeInfo)); + ip = malloc(nInodes*sizeof(struct ViceInodeInfo)); if (ip == NULL) { OS_CLOSE(summaryFile); Abort @@ -1313,7 +1313,7 @@ GetInodeSummary(struct SalvInfo *salvinfo, FD_t inodeFile, VolumeId singleVolume osi_Assert(st_size >= 0); if (st_size != 0) { int ret; - salvinfo->inodeSummary = (struct InodeSummary *)malloc(st_size); + salvinfo->inodeSummary = malloc(st_size); osi_Assert(salvinfo->inodeSummary != NULL); /* For GNU we need to do lseek to get the file pointer moved. */ osi_Assert(OS_SEEK(summaryFile, 0, SEEK_SET) == 0); @@ -1933,7 +1933,7 @@ DoSalvageVolumeGroup(struct SalvInfo *salvinfo, struct InodeSummary *isp, int nV for (i = 0, totalInodes = 0; i < nVols; i++) totalInodes += isp[i].nInodes; size = totalInodes * sizeof(struct ViceInodeInfo); - inodes = (struct ViceInodeInfo *)malloc(size); + inodes = malloc(size); allInodes = inodes - isp->index; /* this would the base of all the inodes * for the partition, if all the inodes * had been read into memory */ @@ -4614,7 +4614,7 @@ PrintInodeList(struct SalvInfo *salvinfo) st_size = OS_SIZE(salvinfo->inodeFd); osi_Assert(st_size >= 0); - buf = (struct ViceInodeInfo *)malloc(st_size); + buf = malloc(st_size); osi_Assert(buf != NULL); nInodes = st_size / sizeof(struct ViceInodeInfo); osi_Assert(OS_READ(salvinfo->inodeFd, buf, st_size) == st_size); diff --git a/src/vol/volume.c b/src/vol/volume.c index 5e13cd11f..7e2e10f4b 100644 --- a/src/vol/volume.c +++ b/src/vol/volume.c @@ -708,7 +708,7 @@ VInitAttachVolumes(ProgramType pt) /* create partition work queue */ for (parts=0, diskP = DiskPartitionList; diskP; diskP = diskP->next, parts++) { - dpq = (diskpartition_queue_t *) malloc(sizeof(struct diskpartition_queue_t)); + dpq = malloc(sizeof(struct diskpartition_queue_t)); osi_Assert(dpq != NULL); dpq->diskP = diskP; queue_Append(¶ms,dpq); @@ -830,7 +830,7 @@ VInitAttachVolumes(ProgramType pt) MUTEX_INIT(&(pq.mutex), "partq", MUTEX_DEFAULT, 0); for (parts = 0, diskP = DiskPartitionList; diskP; diskP = diskP->next, parts++) { struct diskpartition_queue_t *dp; - dp = (struct diskpartition_queue_t*)malloc(sizeof(struct diskpartition_queue_t)); + dp = malloc(sizeof(struct diskpartition_queue_t)); osi_Assert(dp != NULL); dp->diskP = diskP; queue_Append(&pq, dp); @@ -856,7 +856,7 @@ VInitAttachVolumes(ProgramType pt) struct vinitvolumepackage_thread_param *params; AFS_SIGSET_DECL; - params = (struct vinitvolumepackage_thread_param *)malloc(sizeof(struct vinitvolumepackage_thread_param)); + params = malloc(sizeof(struct vinitvolumepackage_thread_param)); osi_Assert(params); params->pq = &pq; params->vq = &vq; @@ -907,7 +907,7 @@ VInitVolumePackageThread(void *args) osi_Assert(pq); osi_Assert(vq); - vb = (struct volume_init_batch*)malloc(sizeof(struct volume_init_batch)); + vb = malloc(sizeof(struct volume_init_batch)); osi_Assert(vb); vb->thread = params->thread; vb->last = 0; @@ -941,7 +941,7 @@ VInitVolumePackageThread(void *args) CV_BROADCAST(&vq->cv); MUTEX_EXIT(&vq->mutex); - vb = (struct volume_init_batch*)malloc(sizeof(struct volume_init_batch)); + vb = malloc(sizeof(struct volume_init_batch)); osi_Assert(vb); vb->thread = params->thread; vb->size = 0; @@ -1246,7 +1246,7 @@ VShutdown_r(void) /* build up the pass 0 shutdown work queue */ - dpq = (struct diskpartition_queue_t *) malloc(sizeof(struct diskpartition_queue_t)); + dpq = malloc(sizeof(struct diskpartition_queue_t)); osi_Assert(dpq != NULL); dpq->diskP = diskP; queue_Prepend(¶ms, dpq); @@ -5254,7 +5254,7 @@ VRegisterVolOp_r(Volume * vp, FSSYNC_VolOp_info * vopinfo) FSSYNC_VolOp_info * info; /* attach a vol op info node to the volume struct */ - info = (FSSYNC_VolOp_info *) malloc(sizeof(FSSYNC_VolOp_info)); + info = malloc(sizeof(FSSYNC_VolOp_info)); osi_Assert(info != NULL); memcpy(info, vopinfo, sizeof(FSSYNC_VolOp_info)); vp->pending_vol_op = info; @@ -6420,7 +6420,7 @@ VGetBitmap_r(Error * ec, Volume * vp, VnodeClass class) osi_Assert(fdP != NULL); file = FDH_FDOPEN(fdP, "r"); osi_Assert(file != NULL); - vnode = (VnodeDiskObject *) malloc(vcp->diskSize); + vnode = malloc(vcp->diskSize); osi_Assert(vnode != NULL); size = OS_SIZE(fdP->fd_fd); osi_Assert(size != -1); @@ -6821,7 +6821,7 @@ VAddToVolumeUpdateList_r(Error * ec, Volume * vp) return; if (UpdateList == NULL) { updateSize = UPDATE_LIST_SIZE; - UpdateList = (VolumeId *) malloc(sizeof(VolumeId) * updateSize); + UpdateList = malloc(sizeof(VolumeId) * updateSize); } else { if (nUpdatedVolumes == updateSize) { updateSize <<= 1; @@ -7603,7 +7603,7 @@ VLRU_Demote_r(int idx) /* no big deal if this allocation fails */ if (volume_LRU.q[idx].len) { - salv_flag_vec = (Volume **) malloc(volume_LRU.q[idx].len * sizeof(Volume *)); + salv_flag_vec = malloc(volume_LRU.q[idx].len * sizeof(Volume *)); } now = FT_ApproxTime(); diff --git a/src/vol/xfs_size_check.c b/src/vol/xfs_size_check.c index cd0046605..5ee492b3e 100644 --- a/src/vol/xfs_size_check.c +++ b/src/vol/xfs_size_check.c @@ -120,8 +120,7 @@ CheckPartitions() if (nAvail <= nParts) { nAvail += ALLOC_STEP; if (nAvail == ALLOC_STEP) - partList = - (partInfo *) malloc(nAvail * sizeof(partInfo)); + partList = malloc(nAvail * sizeof(partInfo)); else partList = realloc(partList, nAvail * sizeof(partInfo)); diff --git a/src/volser/dumpstuff.c b/src/volser/dumpstuff.c index e06210036..601fecc76 100644 --- a/src/volser/dumpstuff.c +++ b/src/volser/dumpstuff.c @@ -1528,7 +1528,7 @@ volser_WriteFile(int vn, struct iod *iodp, FdHandle_t * handleP, int tag, } FillInt64(filesize, filesize_high, filesize_low); } - p = (unsigned char *)malloc(size); + p = malloc(size); if (p == NULL) { *status = 2; return (0); diff --git a/src/volser/restorevol.c b/src/volser/restorevol.c index be88b69e5..e723e427d 100644 --- a/src/volser/restorevol.c +++ b/src/volser/restorevol.c @@ -537,7 +537,7 @@ ReadVNode(afs_int32 count) buffer = NULL; - buffer = (char *)malloc(vn.dataSize); + buffer = malloc(vn.dataSize); readdata(buffer, vn.dataSize); page0 = (struct Page0 *)buffer; diff --git a/src/volser/vol-dump.c b/src/volser/vol-dump.c index 47a7cc090..38c1060f1 100644 --- a/src/volser/vol-dump.c +++ b/src/volser/vol-dump.c @@ -587,7 +587,7 @@ DumpFile(int dumpfd, int vnode, FdHandle_t * handleP, struct VnodeDiskObject *v return VOLSERDUMPERROR; } - p = (unsigned char *)malloc(howMany); + p = malloc(howMany); if (!p) { fprintf(stderr, "out of memory!\n"); return VOLSERDUMPERROR; diff --git a/src/volser/volprocs.c b/src/volser/volprocs.c index c002b3233..73b3e3e38 100644 --- a/src/volser/volprocs.c +++ b/src/volser/volprocs.c @@ -411,8 +411,7 @@ SAFSVolPartitionInfo(struct rx_call *acid, char *pname, struct diskPartition *partition) { afs_int32 code; - struct diskPartition64 *dp = (struct diskPartition64 *) - malloc(sizeof(struct diskPartition64)); + struct diskPartition64 *dp = malloc(sizeof(struct diskPartition64)); code = VolPartitionInfo(acid, pname, dp); if (!code) { @@ -1361,8 +1360,7 @@ SAFSVolForwardMultiple(struct rx_call *acid, afs_int32 fromTrans, afs_int32 if (results) { memset(results, 0, sizeof(manyResults)); i = results->manyResults_len = destinations->manyDests_len; - results->manyResults_val = codes = - (afs_int32 *) malloc(i * sizeof(afs_int32)); + results->manyResults_val = codes = malloc(i * sizeof(afs_int32)); } if (!results || !results->manyResults_val) return ENOMEM; @@ -1383,12 +1381,11 @@ SAFSVolForwardMultiple(struct rx_call *acid, afs_int32 fromTrans, afs_int32 /* (fromDate == 0) ==> full dump */ is_incremental = (fromDate ? 1 : 0); - tcons = - (struct rx_connection **)malloc(i * sizeof(struct rx_connection *)); + tcons = malloc(i * sizeof(struct rx_connection *)); if (!tcons) { return ENOMEM; } - tcalls = (struct rx_call **)malloc(i * sizeof(struct rx_call *)); + tcalls = malloc(i * sizeof(struct rx_call *)); if (!tcalls) { free(tcons); return ENOMEM; @@ -1772,7 +1769,7 @@ VolGetName(struct rx_call *acid, afs_int32 atrans, char **aname) int len; /* We need to at least fill it in */ - *aname = (char *)malloc(1); + *aname = malloc(1); if (!*aname) return ENOMEM; tt = FindTrans(atrans); @@ -1891,7 +1888,7 @@ XVolListPartitions(struct rx_call *acid, struct partEntries *pEntries) partList.partId[j++] = i; } if (j > 0) { - pEntries->partEntries_val = (afs_int32 *) malloc(j * sizeof(int)); + pEntries->partEntries_val = malloc(j * sizeof(int)); if (!pEntries->partEntries_val) return ENOMEM; memcpy((char *)pEntries->partEntries_val, (char *)&partList, @@ -2805,7 +2802,7 @@ VolMonitor(struct rx_call *acid, transDebugEntries *transInfo) struct volser_trans *tt, *nt, *allTrans; transInfo->transDebugEntries_val = - (transDebugInfo *) malloc(allocSize * sizeof(transDebugInfo)); + malloc(allocSize * sizeof(transDebugInfo)); if (!transInfo->transDebugEntries_val) return ENOMEM; pntr = transInfo->transDebugEntries_val; diff --git a/src/volser/vos.c b/src/volser/vos.c index 529ccdd2a..fc43f5dd9 100644 --- a/src/volser/vos.c +++ b/src/volser/vos.c @@ -104,7 +104,7 @@ qPut(struct tqHead *ahead, afs_uint32 volid) { struct tqElem *elem; - elem = (struct tqElem *)malloc(sizeof(struct tqElem)); + elem = malloc(sizeof(struct tqElem)); elem->next = ahead->next; elem->volid = volid; ahead->next = elem; @@ -282,7 +282,7 @@ SendFile(usd_handle_t ufd, struct rx_call *call, long blksize) int done = 0; afs_uint32 nbytes; - buffer = (char *)malloc(blksize); + buffer = malloc(blksize); if (!buffer) { fprintf(STDERR, "malloc failed\n"); return -1; @@ -392,7 +392,7 @@ ReceiveFile(usd_handle_t ufd, struct rx_call *call, long blksize) afs_uint32 bytesleft, w; afs_int32 error = 0; - buffer = (char *)malloc(blksize); + buffer = malloc(blksize); if (!buffer) { fprintf(STDERR, "memory allocation failed\n"); ERROR_EXIT(-1); diff --git a/src/volser/vsprocs.c b/src/volser/vsprocs.c index bf5986022..0ac7e1e2f 100644 --- a/src/volser/vsprocs.c +++ b/src/volser/vsprocs.c @@ -646,8 +646,7 @@ UV_PartitionInfo64(afs_uint32 server, char *pname, aconn = UV_Bind(server, AFSCONF_VOLUMEPORT); code = AFSVolPartitionInfo64(aconn, pname, partition); if (code == RXGEN_OPCODE) { - struct diskPartition *dpp = - (struct diskPartition *)malloc(sizeof(struct diskPartition)); + struct diskPartition *dpp = malloc(sizeof(struct diskPartition)); code = AFSVolPartitionInfo(aconn, pname, dpp); if (!code) { strncpy(partition->name, dpp->name, 32);