dbservers: 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's
unecessary noise.

Change-Id: I5a7c800e2836e7401f5f8bccf1aa2a1b223100b7
Reviewed-on: http://gerrit.openafs.org/7463
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
This commit is contained in:
Simon Wilkinson 2012-05-17 12:26:37 +01:00 committed by Derrick Brashear
parent 4d96d0d5e4
commit cbdf31d9ff
23 changed files with 60 additions and 68 deletions

View File

@ -1522,7 +1522,7 @@ MyBeforeProc(struct cmd_syndesc *as, void *arock)
afs_com_err(whoami, code, "prompting for %s", p + 1);
return code;
}
ip = (struct cmd_item *)malloc(sizeof(struct cmd_item));
ip = malloc(sizeof(struct cmd_item));
ip->data = strdup(password);
ip->next = 0;
as->parms[i].items = ip;

View File

@ -35,7 +35,7 @@ xdr_ka_CBS(XDR * x, struct ka_CBS *abbs)
if (len < 0 || len > MAXBS)
return FALSE;
if (!abbs->SeqBody)
abbs->SeqBody = (char *)malloc(len);
abbs->SeqBody = malloc(len);
abbs->SeqLen = len;
xdr_opaque(x, abbs->SeqBody, len);
return TRUE;
@ -62,7 +62,7 @@ xdr_ka_BBS(XDR * x, struct ka_BBS *abbs)
|| (len > MAXBS) || (len > maxLen))
return FALSE;
if (!abbs->SeqBody)
abbs->SeqBody = (char *)malloc(maxLen);
abbs->SeqBody = malloc(maxLen);
abbs->MaxSeqLen = maxLen;
abbs->SeqLen = len;
if (!xdr_opaque(x, abbs->SeqBody, len))

View File

@ -99,8 +99,7 @@ init_kadatabase(int initFlags)
Lock_Init(&keycache_lock);
maxCachedKeys = 10;
keyCache =
(struct cachedKey *)malloc(maxCachedKeys * sizeof(struct cachedKey));
keyCache = malloc(maxCachedKeys * sizeof(struct cachedKey));
keyCacheVersion = 0;
if (initFlags & 4) {
maxKeyLifetime = 90;

View File

@ -238,7 +238,7 @@ ParseAcl(char *astr)
sscanf(astr, "%d", &nminus);
SkipLine(astr);
ta = (struct Acl *)malloc(sizeof(struct Acl));
ta = malloc(sizeof(struct Acl));
ta->nplus = nplus;
last = 0;
@ -246,7 +246,7 @@ ParseAcl(char *astr)
for (i = 0; i < nplus; i++) {
sscanf(astr, "%100s %d", tname, &trights);
SkipLine(astr);
tl = (struct AclEntry *)malloc(sizeof(struct AclEntry));
tl = malloc(sizeof(struct AclEntry));
if (!first)
first = tl;
strcpy(tl->name, tname);

View File

@ -392,7 +392,7 @@ main(int argc, char **argv)
i = 0;
while (environ[i] != NULL)
i++;
envnew = (char **)malloc(sizeof(char *) * (i + 1));
envnew = malloc(sizeof(char *) * (i + 1));
for (; i >= 0; i--)
envnew[i] = environ[i];
environ = envnew;

View File

@ -404,7 +404,7 @@ ParseAcl(astr)
sscanf(astr, "%d", &nminus);
astr = SkipLine(astr);
ta = (struct Acl *)malloc(sizeof(struct Acl));
ta = malloc(sizeof(struct Acl));
ta->nplus = nplus;
ta->nminus = nminus;
@ -413,7 +413,7 @@ ParseAcl(astr)
for (i = 0; i < nplus; i++) {
sscanf(astr, "%100s %d", tname, &trights);
astr = SkipLine(astr);
tl = (struct AclEntry *)malloc(sizeof(struct AclEntry));
tl = malloc(sizeof(struct AclEntry));
if (!first)
first = tl;
strcpy(tl->name, tname);
@ -430,7 +430,7 @@ ParseAcl(astr)
for (i = 0; i < nminus; i++) {
sscanf(astr, "%100s %d", tname, &trights);
astr = SkipLine(astr);
tl = (struct AclEntry *)malloc(sizeof(struct AclEntry));
tl = malloc(sizeof(struct AclEntry));
if (!first)
first = tl;
strcpy(tl->name, tname);
@ -516,7 +516,7 @@ AddTester(pathname)
}
al->nplus -= PruneList(&al->pluslist);
tlist = (struct AclEntry *)malloc(sizeof(struct AclEntry));
tlist = malloc(sizeof(struct AclEntry));
tlist->rights = 9;
strcpy(tlist->name, tester);
tlist->next = al->pluslist;

View File

@ -146,7 +146,7 @@ add_map(struct map *parm, int node)
if (map->m_page == page)
break;
if (!map) {
map = (struct bitmap *)malloc(sizeof *map);
map = malloc(sizeof *map);
if (!map) {
#ifdef PRINT_MAP_ERROR
printf("No memory!\n");
@ -378,7 +378,7 @@ copy_map(struct map *parm)
#endif
map = MAP(parm);
for (mpp = &result; (*mpp = 0), map; map = map->m_next) {
*mpp = (struct bitmap *)malloc(sizeof **mpp);
*mpp = malloc(sizeof **mpp);
if (!*mpp) {
#ifdef MAP_DEBUG
if (Mflag)
@ -701,7 +701,7 @@ read_map(int (*f) (void *), char *arg)
if (map->m_page == page)
break;
if (!map) {
map = (struct bitmap *)malloc(sizeof *map);
map = malloc(sizeof *map);
if (!map) {
#ifdef PRINT_MAP_ERROR
printf("No memory!\n");

View File

@ -296,7 +296,7 @@ CommandProc(struct cmd_syndesc *a_as, void *arock)
code = CreateEntry(0, name, &id, 1 /*idflag */ ,
flags & PRGRP, oid, cid);
if (code == PRBADNAM) {
u = (struct usr_list *)malloc(sizeof(struct usr_list));
u = malloc(sizeof(struct usr_list));
u->next = usr_head;
u->uid = id;
strcpy(u->name, name);
@ -395,7 +395,7 @@ add_group(long id)
i = grp_count++ % 1024;
if (i == 0) {
g = (struct grp_list *)malloc(sizeof(struct grp_list));
g = malloc(sizeof(struct grp_list));
g->next = grp_head;
grp_head = g;
}
@ -562,7 +562,7 @@ checkin(struct prentry *pre)
last = he;
he = he->next;
}
he = (struct hash_entry *)malloc(sizeof(struct hash_entry));
he = malloc(sizeof(struct hash_entry));
if (he == 0) {
fprintf(stderr, "pt_util: No Memory for internal hash table.\n");
exit(1);

View File

@ -325,7 +325,7 @@ main(int argc, char **argv)
if (CodeOk(code))
afs_com_err(whoami, code, "on %s %d %d", op, id, gid);
} else if (!strcmp(op, "iton")) {
lid.idlist_val = (afs_int32 *) malloc(20 * sizeof(afs_int32));
lid.idlist_val = malloc(20 * sizeof(afs_int32));
ptr = lid.idlist_val;
lid.idlist_len = 0;
foo = line;
@ -354,8 +354,7 @@ main(int argc, char **argv)
lid.idlist_val = 0;
lid.idlist_len = 0;
} else if (!strcmp(op, "ntoi")) {
lnames.namelist_val =
(prname *) malloc(PR_MAXLIST * PR_MAXNAMELEN);
lnames.namelist_val = malloc(PR_MAXLIST * PR_MAXNAMELEN);
lnames.namelist_len = 0;
foo = line;
skip(&foo);

View File

@ -544,7 +544,7 @@ nameToID(struct rx_call *call, namelist *aname, idlist *aid)
if (size < 0)
return PRTOOMANY;
aid->idlist_val = (afs_int32 *) malloc(size * sizeof(afs_int32));
aid->idlist_val = malloc(size * sizeof(afs_int32));
if (!aid->idlist_val)
return PRNOMEM;
@ -631,7 +631,7 @@ idToName(struct rx_call *call, idlist *aid, namelist *aname)
return 0;
if (size < 0)
return PRTOOMANY;
aname->namelist_val = (prname *) malloc(size * PR_MAXNAMELEN);
aname->namelist_val = malloc(size * PR_MAXNAMELEN);
aname->namelist_len = 0;
if (aname->namelist_val == 0)
return PRNOMEM;
@ -1476,9 +1476,8 @@ put_prentries(struct prentry *tentry, prentries *bulkentries)
if (bulkentries->prentries_val == 0) {
bulkentries->prentries_len = 0;
bulkentries->prentries_val =
(struct prlistentries *)malloc(PR_MAXENTRIES *
sizeof(struct prentry));
bulkentries->prentries_val = malloc(PR_MAXENTRIES *
sizeof(struct prentry));
if (!bulkentries->prentries_val) {
return (PRNOMEM);
}

View File

@ -84,7 +84,7 @@ pts_Source(struct cmd_syndesc *as, void *arock)
perror(as->parms[0].items->data);
return errno;
}
sp = (struct sourcestack *)malloc(sizeof *sp);
sp = malloc(sizeof *sp);
if (!sp) {
return errno ? errno : ENOMEM;
} else {
@ -403,7 +403,7 @@ GetNameOrId(struct cmd_syndesc *as, struct idlist *lids, struct namelist *lnames
n = 0; /* count names */
for (i = as->parms[0].items; i; i = i->next)
n++;
nl->namelist_val = (prname *) malloc(n * PR_MAXNAMELEN);
nl->namelist_val = malloc(n * PR_MAXNAMELEN);
nl->namelist_len = n;
n = 0;
for (i = as->parms[0].items; i; i = i->next)
@ -431,7 +431,7 @@ GetNameOrId(struct cmd_syndesc *as, struct idlist *lids, struct namelist *lnames
n = 0;
for (i = as->parms[1].items; i; i = i->next)
n++;
lids->idlist_val = (afs_int32 *) malloc(n * sizeof(afs_int32));
lids->idlist_val = malloc(n * sizeof(afs_int32));
lids->idlist_len = n;
n = 0;
for (i = as->parms[1].items; i; i = i->next) {
@ -494,7 +494,7 @@ GetNameOrId(struct cmd_syndesc *as, struct idlist *lids,
lnames->namelist_len = 0;
}
for (i = as->parms[0].items; i; i = i->next) {
tnames.namelist_val = (prname *) malloc(PR_MAXNAMELEN);
tnames.namelist_val = malloc(PR_MAXNAMELEN);
strncpy(tnames.namelist_val[0], i->data, PR_MAXNAMELEN);
tnames.namelist_len = 1;
tids.idlist_len = 0;
@ -724,7 +724,7 @@ CheckEntry(struct cmd_syndesc *as, void *arock)
return PRBADARG;
lids.idlist_len = 2;
lids.idlist_val = (afs_int32 *) malloc(sizeof(afs_int32) * 2);
lids.idlist_val = malloc(sizeof(afs_int32) * 2);
lnames.namelist_len = 0;
lnames.namelist_val = 0;

View File

@ -114,7 +114,7 @@ FindId(struct idhash *idhash, afs_int32 id)
}
/* Insert this id but return not found. */
newChain = (struct idchain *)malloc(sizeof(struct idchain));
newChain = malloc(sizeof(struct idchain));
if (!newChain) {
return ENOMEM;
} else {
@ -149,7 +149,7 @@ CreateIdList(struct idhash *idhash, idlist * alist, afs_int32 select)
}
alist->idlist_len = entries;
alist->idlist_val = (afs_int32 *) malloc(sizeof(afs_int32) * entries);
alist->idlist_val = malloc(sizeof(afs_int32) * entries);
if (!alist->idlist_val) {
return ENOMEM;
}
@ -695,7 +695,7 @@ pr_IDListExpandedMembers(afs_int32 aid, namelist * lnames)
if (code) {
return code;
}
stack = (afs_int32 *) malloc(sizeof(afs_int32) * maxstack);
stack = malloc(sizeof(afs_int32) * maxstack);
if (!stack) {
code = ENOMEM;
goto done;

View File

@ -1212,7 +1212,7 @@ AddToPRList(prlist *alist, int *sizeP, afs_int32 id)
if (alist->prlist_val) {
tmp = realloc(alist->prlist_val, count * sizeof(afs_int32));
} else {
tmp = (char *)malloc(count * sizeof(afs_int32));
tmp = malloc(count * sizeof(afs_int32));
}
if (!tmp)
return (PRNOMEM);

View File

@ -86,7 +86,7 @@ main(int argc, char **argv)
verbose = 1;
else {
if (!strcmp(argv[i], "-c")) {
cellname = (char *)malloc(100);
cellname = malloc(100);
strncpy(cellname, argv[++i], 100);
} else
strncpy(buf, argv[i], 150);

View File

@ -65,7 +65,7 @@ main(afs_int32 argc, char **argv)
verbose = 1;
else {
if (!strcmp(argv[i], "-c")) {
cellname = (char *)malloc(100);
cellname = malloc(100);
strncpy(cellname, argv[++i], 100);
} else
strncpy(buf, argv[i], 150);

View File

@ -98,7 +98,7 @@ ListUsedIds(struct cmd_syndesc *as, void *arock)
printf("Checking for %d %sused ids starting at %d.\n", number,
(unused ? "un" : ""), startId);
#define NUM 100
lids.idlist_val = (afs_int32 *) malloc(sizeof(afs_int32) * NUM);
lids.idlist_val = malloc(sizeof(afs_int32) * NUM);
lnames.namelist_len = 0;
lnames.namelist_val = 0;
while (number) {
@ -499,7 +499,7 @@ TestManyMembers(struct cmd_syndesc *as, void *arock)
nCleaned = 0;
ownerUser = lastGroup = 0;
groupOwners = (afs_int32 *) malloc(number * sizeof(afs_int32));
groupOwners = malloc(number * sizeof(afs_int32));
nUsers = nGroups = nAdds = nRems = nUDels = nGDels = 0;
while ((nFilled < number) || (nCleaned < number)) {
@ -558,7 +558,7 @@ TestManyMembers(struct cmd_syndesc *as, void *arock)
/* check the membership list of all users for correctness */
printf("Starting check of memberships\n");
glist = (afs_int32 *) malloc(number * sizeof(afs_int32));
glist = malloc(number * sizeof(afs_int32));
for (u = 0; u < number; u++) {
afs_int32 ui = users[u];
if (ui) {

View File

@ -420,8 +420,7 @@ GetTrunc(void)
{
struct ubik_trunc *tt;
if (!freeTruncList) {
freeTruncList =
(struct ubik_trunc *)malloc(sizeof(struct ubik_trunc));
freeTruncList = malloc(sizeof(struct ubik_trunc));
freeTruncList->next = (struct ubik_trunc *)0;
}
tt = freeTruncList;

View File

@ -403,7 +403,7 @@ ubik_ServerInitCommon(afs_uint32 myHost, short myPort,
initialize_U_error_table();
tdb = (struct ubik_dbase *)malloc(sizeof(struct ubik_dbase));
tdb = malloc(sizeof(struct ubik_dbase));
tdb->pathName = strdup(pathName);
tdb->activeTrans = (struct ubik_trans *)0;
memset(&tdb->version, 0, sizeof(struct ubik_version));
@ -1049,10 +1049,9 @@ ubik_Write(struct ubik_trans *transPtr, void *vbuffer,
if (!transPtr->iovec_info.iovec_wrt_val) {
transPtr->iovec_info.iovec_wrt_len = 0;
transPtr->iovec_info.iovec_wrt_val =
(struct ubik_iovec *)malloc(IOVEC_MAXWRT *
sizeof(struct ubik_iovec));
malloc(IOVEC_MAXWRT * sizeof(struct ubik_iovec));
transPtr->iovec_data.iovec_buf_len = 0;
transPtr->iovec_data.iovec_buf_val = (char *)malloc(IOVEC_MAXBUF);
transPtr->iovec_data.iovec_buf_val = malloc(IOVEC_MAXBUF);
if (!transPtr->iovec_info.iovec_wrt_val
|| !transPtr->iovec_data.iovec_buf_val) {
if (transPtr->iovec_info.iovec_wrt_val)

View File

@ -217,7 +217,7 @@ ubik_ClientInit(struct rx_connection **serverconns,
return UMUTEXDESTROY;
#endif
} else {
tc = (struct ubik_client *)malloc(sizeof(struct ubik_client));
tc = malloc(sizeof(struct ubik_client));
}
if (tc == NULL)
return UNOMEM;

View File

@ -385,7 +385,7 @@ read_mhentries(afs_uint32 mh_addr, int oldfd)
perror("seek MH block");
exit(1);
}
base[0] = (struct extentaddr *)malloc(VL_ADDREXTBLK_SIZE);
base[0] = malloc(VL_ADDREXTBLK_SIZE);
if (!base[0]) {
perror("malloc1");
exit(1);
@ -430,7 +430,7 @@ read_mhentries(afs_uint32 mh_addr, int oldfd)
perror("seek MH block");
exit(1);
}
base[j] = (struct extentaddr *)malloc(VL_ADDREXTBLK_SIZE);
base[j] = malloc(VL_ADDREXTBLK_SIZE);
if (!base[j]) {
perror("malloc1");
exit(1);

View File

@ -286,8 +286,7 @@ handleit(struct cmd_syndesc *as, void *arock)
afs_int32 index, count, num = 0, num1 = 0, next_index;
struct Vlent *vl1;
VL = SVL =
(struct Vlent *)malloc(ALLOCNT * sizeof(struct Vlent));
VL = SVL = malloc(ALLOCNT * sizeof(struct Vlent));
if (VL == NULL) {
printf("Can't allocate memory...\n");
exit(1);
@ -335,8 +334,7 @@ handleit(struct cmd_syndesc *as, void *arock)
0, num31 = 0, num4 = 0, num41 = 0, next_index;
struct vldbentry tentry;
VL = SVL =
(struct Vlent *)malloc(ALLOCNT * sizeof(struct Vlent));
VL = SVL = malloc(ALLOCNT * sizeof(struct Vlent));
if (VL == NULL) {
printf("Can't allocate memory...\n");
exit(1);
@ -408,8 +406,7 @@ handleit(struct cmd_syndesc *as, void *arock)
0;
struct vldbentry tentry;
VL = SVL =
(struct Vlent *)malloc(ALLOCNT * sizeof(struct Vlent));
VL = SVL = malloc(ALLOCNT * sizeof(struct Vlent));
if (VL == NULL) {
printf("Can't allocate memory...\n");
exit(1);
@ -924,7 +921,7 @@ handleit(struct cmd_syndesc *as, void *arock)
printf("Illegal # entries = %d\n", nargs);
continue;
}
addrp = (afs_uint32 *) malloc(20 * 4);
addrp = malloc(20 * 4);
addrs.bulkaddrs_val = addrp;
addrs.bulkaddrs_len = nargs;
while (nargs > 0) {

View File

@ -1263,7 +1263,7 @@ SVL_ListAttributes(struct rx_call *rxcall,
return code;
allocCount = VLDBALLOCCOUNT;
Vldbentry = VldbentryFirst = vldbentries->bulkentries_val =
(vldbentry *) malloc(allocCount * sizeof(vldbentry));
malloc(allocCount * sizeof(vldbentry));
if (Vldbentry == NULL) {
code = VL_NOMEM;
goto abort;
@ -1393,7 +1393,7 @@ SVL_ListAttributesN(struct rx_call *rxcall,
return code;
allocCount = VLDBALLOCCOUNT;
Vldbentry = VldbentryFirst = vldbentries->nbulkentries_val =
(nvldbentry *) malloc(allocCount * sizeof(nvldbentry));
malloc(allocCount * sizeof(nvldbentry));
if (Vldbentry == NULL) {
code = VL_NOMEM;
goto abort;
@ -1543,7 +1543,7 @@ SVL_ListAttributesN2(struct rx_call *rxcall,
return code;
Vldbentry = VldbentryFirst = vldbentries->nbulkentries_val =
(nvldbentry *) malloc(maxCount * sizeof(nvldbentry));
malloc(maxCount * sizeof(nvldbentry));
if (Vldbentry == NULL) {
countAbort(this_op);
ubik_AbortTrans(ctx.trans);
@ -1812,7 +1812,7 @@ SVL_LinkedList(struct rx_call *rxcall,
goto abort;
}
vllist = (single_vldbentry *) malloc(sizeof(single_vldbentry));
vllist = malloc(sizeof(single_vldbentry));
if (vllist == NULL) {
code = VL_NOMEM;
goto abort;
@ -1885,7 +1885,7 @@ SVL_LinkedList(struct rx_call *rxcall,
continue;
}
vllist = (single_vldbentry *) malloc(sizeof(single_vldbentry));
vllist = malloc(sizeof(single_vldbentry));
if (vllist == NULL) {
code = VL_NOMEM;
goto abort;
@ -1948,7 +1948,7 @@ SVL_LinkedListN(struct rx_call *rxcall,
goto abort;
}
vllist = (single_nvldbentry *) malloc(sizeof(single_nvldbentry));
vllist = malloc(sizeof(single_nvldbentry));
if (vllist == NULL) {
code = VL_NOMEM;
goto abort;
@ -2021,7 +2021,7 @@ SVL_LinkedListN(struct rx_call *rxcall,
continue;
}
vllist = (single_nvldbentry *) malloc(sizeof(single_nvldbentry));
vllist = malloc(sizeof(single_nvldbentry));
if (vllist == NULL) {
code = VL_NOMEM;
goto abort;
@ -2107,7 +2107,7 @@ SVL_GetAddrs(struct rx_call *rxcall,
VLog(5, ("GetAddrs\n"));
addrsp->bulkaddrs_val = taddrp =
(afs_uint32 *) malloc(sizeof(afs_int32) * (MAXSERVERID + 1));
malloc(sizeof(afs_int32) * (MAXSERVERID + 1));
nservers = *nentries = addrsp->bulkaddrs_len = 0;
if (!taddrp) {
@ -2596,7 +2596,7 @@ SVL_GetAddrsU(struct rx_call *rxcall,
goto abort;
}
addrsp->bulkaddrs_val = taddrp =
(afs_uint32 *) malloc(sizeof(afs_int32) * (MAXSERVERID + 1));
malloc(sizeof(afs_int32) * (MAXSERVERID + 1));
nservers = *nentries = addrsp->bulkaddrs_len = 0;
if (!taddrp) {
code = VL_NOMEM;

View File

@ -221,7 +221,7 @@ readExtents(struct ubik_trans *trans)
/* Read the first extension block */
if (!rd_ex_addr[0]) {
rd_ex_addr[0] = (struct extentaddr *)malloc(VL_ADDREXTBLK_SIZE);
rd_ex_addr[0] = malloc(VL_ADDREXTBLK_SIZE);
if (!rd_ex_addr[0])
ERROR_EXIT(VL_NOMEM);
}
@ -252,7 +252,7 @@ readExtents(struct ubik_trans *trans)
/* Read the continuation block */
if (!rd_ex_addr[i]) {
rd_ex_addr[i] = (struct extentaddr *)malloc(VL_ADDREXTBLK_SIZE);
rd_ex_addr[i] = malloc(VL_ADDREXTBLK_SIZE);
if (!rd_ex_addr[i])
ERROR_EXIT(VL_NOMEM);
}
@ -402,7 +402,7 @@ GetExtentBlock(struct vl_ctx *ctx, register afs_int32 base)
if (!ctx->ex_addr[0] || !ctx->ex_addr[0]->ex_contaddrs[base]) {
/* Create a new extension block */
if (!ctx->ex_addr[base]) {
ctx->ex_addr[base] = (struct extentaddr *)malloc(VL_ADDREXTBLK_SIZE);
ctx->ex_addr[base] = malloc(VL_ADDREXTBLK_SIZE);
if (!ctx->ex_addr[base])
ERROR_EXIT(VL_NOMEM);
}