afs: clean afs_osi_Alloc() usage

Add asserts for any failures cases not explicitly handled and remove
any casting.

Reviewed-on: http://gerrit.openafs.org/3012
Reviewed-by: Simon Wilkinson <sxw@inf.ed.ac.uk>
Tested-by: Derrick Brashear <shadow@dementia.org>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
(cherry picked from commit 0e8cce457763b131de48395a9beed889fd529c1f)

Change-Id: I23497ea7a75a66c01ba7b1013e01dfaa005c9892
Reviewed-on: http://gerrit.openafs.org/7936
Reviewed-by: Derrick Brashear <shadow@dementix.org>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
This commit is contained in:
Chas Williams (CONTRACTOR) 2010-10-19 14:50:35 -04:00 committed by Derrick Brashear
parent 85432bf0b4
commit 67a1e4069d
31 changed files with 140 additions and 68 deletions

View File

@ -31,7 +31,8 @@ struct vcache *
osi_NewVnode(void) {
struct vcache *tvc;
tvc = (struct vcache *)afs_osi_Alloc(sizeof(struct vcache));
tvc = afs_osi_Alloc(sizeof(struct vcache));
osi_Assert(tvc != NULL);
#ifdef KERNEL_HAVE_PIN
pin((char *)tvc, sizeof(struct vcache)); /* XXX */

View File

@ -17,7 +17,8 @@ struct vcache *
osi_NewVnode(void) {
struct vcache *tvc;
tvc = (struct vcache *)afs_osi_Alloc(sizeof(struct vcache));
tvc = afs_osi_Alloc(sizeof(struct vcache));
osi_Assert(tvc != NULL);
tvc->v = NULL; /* important to clean this, or use memset 0 */
return tvc;

View File

@ -223,6 +223,7 @@ void osi_linux_nfssrv_init(void)
}
afs_new_authtab[i] = afs_osi_Alloc(sizeof(struct auth_ops));
osi_Assert(afs_new_authtab[i] != NULL);
*(afs_new_authtab[i]) = *(afs_orig_authtab[i]);
afs_new_authtab[i]->owner = THIS_MODULE;
afs_new_authtab[i]->accept = svcauth_afs_accept;

View File

@ -94,6 +94,7 @@ osi_NewVnode(void)
tvc = VTOAFS(ip);
#else
tvc = afs_osi_Alloc(sizeof(struct vcache));
osi_Assert(tvc != NULL);
ip->u.generic_ip = tvc;
tvc->v = ip;
#endif

View File

@ -28,7 +28,11 @@ osi_TryEvictVCache(struct vcache *avc, int *slept, int defersleep) {
struct vcache *
osi_NewVnode(void) {
return (struct vcache *)afs_osi_Alloc(sizeof(struct vcache));
struct vcache *avc;
avc = afs_osi_Alloc(sizeof(struct vcache));
osi_Assert(avc != NULL);
return avc;
}
void

View File

@ -277,7 +277,8 @@ afs_symlink(OSI_VC_DECL(adp), char *aname, struct vattr *attrs,
}
if (!tvc->linkData) {
tvc->linkData = (char *)afs_osi_Alloc(alen);
tvc->linkData = afs_osi_Alloc(alen);
osi_Assert(tvc->linkData != NULL);
strncpy(tvc->linkData, atargetName, alen - 1);
tvc->linkData[alen - 1] = 0;
}
@ -334,6 +335,7 @@ afs_MemHandleLink(struct vcache *avc, struct vrequest *areq)
rbuf[alen - 1] = 0;
alen = strlen(rbuf) + 1;
tp = afs_osi_Alloc(alen); /* make room for terminating null */
osi_Assert(tp != NULL);
memcpy(tp, rbuf, alen);
osi_FreeLargeSpace(rbuf);
if (code != len) {
@ -390,6 +392,7 @@ afs_UFSHandleLink(struct vcache *avc, struct vrequest *areq)
rbuf[alen - 1] = '\0';
alen = strlen(rbuf) + 1;
tp = afs_osi_Alloc(alen); /* make room for terminating null */
osi_Assert(tp != NULL);
memcpy(tp, rbuf, alen);
osi_FreeLargeSpace(rbuf);
if (code != tlen) {

View File

@ -111,6 +111,7 @@ VLDB_Same(struct VenusFid *afid, struct vrequest *areq)
if ((i = afs_InitReq(&treq, afs_osi_credp)))
return DUNNO;
v = afs_osi_Alloc(sizeof(*v));
osi_Assert(v != NULL);
tcell = afs_GetCell(afid->Cell, READ_LOCK);
bp = afs_cv2string(&tbuf[CVBS], afid->Fid.Volume);
do {

View File

@ -69,6 +69,7 @@ axs_Alloc(void)
return i;
} else {
h = afs_osi_Alloc(sizeof(struct xfreelist));
osi_Assert(h != NULL);
afs_xaxscnt++;
xsp = xfreemallocs;
xfreemallocs = h;

View File

@ -119,8 +119,8 @@ DInit(int abuffers)
abuffers = ((abuffers - 1) | (NPB - 1)) + 1;
afs_max_buffers = abuffers << 2; /* possibly grow up to 4 times as big */
LOCK_INIT(&afs_bufferLock, "afs_bufferLock");
Buffers =
(struct buffer *)afs_osi_Alloc(afs_max_buffers * sizeof(struct buffer));
Buffers = afs_osi_Alloc(afs_max_buffers * sizeof(struct buffer));
osi_Assert(Buffers != NULL);
timecounter = 1;
afs_stats_cmperf.bufAlloced = nbuffers = abuffers;
for (i = 0; i < PHSIZE; i++)
@ -128,7 +128,8 @@ DInit(int abuffers)
for (i = 0; i < abuffers; i++) {
if ((i & (NPB - 1)) == 0) {
/* time to allocate a fresh buffer */
BufferData = (char *) afs_osi_Alloc(AFS_BUFFER_PAGESIZE * NPB);
BufferData = afs_osi_Alloc(AFS_BUFFER_PAGESIZE * NPB);
osi_Assert(BufferData != NULL);
}
/* Fill in each buffer with an empty indication. */
tb = &Buffers[i];
@ -337,7 +338,8 @@ afs_newslot(struct dcache *adc, afs_int32 apage, struct buffer *lp)
return 0;
}
BufferData = (char *) afs_osi_Alloc(AFS_BUFFER_PAGESIZE * NPB);
BufferData = afs_osi_Alloc(AFS_BUFFER_PAGESIZE * NPB);
osi_Assert(BufferData != NULL);
for (i = 0; i< NPB; i++) {
/* Fill in each buffer with an empty indication. */
tp = &Buffers[i + nbuffers];

View File

@ -664,7 +664,9 @@ afs_syscall_call(long parm, long parm2, long parm3,
sizeof(struct afs_uspc_param), code);
namebufsz = mvParam->bufSz;
param1 = afs_osi_Alloc(namebufsz);
osi_Assert(param1 != NULL);
param2 = afs_osi_Alloc(namebufsz);
osi_Assert(param2 != NULL);
while (afs_initState < AFSOP_START_BKG)
afs_osi_Sleep(&afs_initState);
@ -869,6 +871,7 @@ afs_syscall_call(long parm, long parm2, long parm3,
* home cell flag (0x1 bit) and the nosuid flag (0x2 bit) */
struct afsop_cell *tcell = afs_osi_Alloc(sizeof(struct afsop_cell));
osi_Assert(tcell != NULL);
code = afs_InitDynroot();
if (!code) {
AFS_COPYIN(AFSKPTR(parm2), (caddr_t)tcell->hosts, sizeof(tcell->hosts),
@ -891,6 +894,9 @@ afs_syscall_call(long parm, long parm2, long parm3,
char *tbuffer1 = osi_AllocSmallSpace(AFS_SMALLOCSIZ);
int cflags = parm4;
osi_Assert(tcell != NULL);
osi_Assert(tbuffer != NULL);
osi_Assert(tbuffer1 != NULL);
code = afs_InitDynroot();
if (!code) {
#if 0
@ -1095,6 +1101,9 @@ afs_syscall_call(long parm, long parm2, long parm3,
afs_osi_Alloc(sizeof(afs_int32) * AFS_MAX_INTERFACE_ADDR);
int i;
osi_Assert(buffer != NULL);
osi_Assert(maskbuffer != NULL);
osi_Assert(mtubuffer != NULL);
/* This is a refresh */
if (count & 0x40000000) {
count &= ~0x40000000;
@ -1273,6 +1282,8 @@ afs_syscall_call(long parm, long parm2, long parm3,
afs_int32 *kmsg = afs_osi_Alloc(kmsgLen);
char *cellname = afs_osi_Alloc(cellLen);
osi_Assert(kmsg != NULL);
osi_Assert(cellname != NULL);
#ifndef UKERNEL
afs_osi_MaskUserLoop();
#endif

View File

@ -898,6 +898,7 @@ SRXAFSCB_GetXStats(struct rx_call *a_call, afs_int32 a_clientVersionNum,
*/
dataBytes = sizeof(struct afs_CMStats);
dataBuffP = (afs_int32 *) afs_osi_Alloc(dataBytes);
osi_Assert(dataBuffP != NULL);
memcpy((char *)dataBuffP, (char *)&afs_cmstats, dataBytes);
a_dataP->AFSCB_CollData_len = dataBytes >> 2;
a_dataP->AFSCB_CollData_val = dataBuffP;
@ -918,6 +919,7 @@ SRXAFSCB_GetXStats(struct rx_call *a_call, afs_int32 a_clientVersionNum,
afs_CountServers();
dataBytes = sizeof(afs_stats_cmperf);
dataBuffP = (afs_int32 *) afs_osi_Alloc(dataBytes);
osi_Assert(dataBuffP != NULL);
memcpy((char *)dataBuffP, (char *)&afs_stats_cmperf, dataBytes);
a_dataP->AFSCB_CollData_len = dataBytes >> 2;
a_dataP->AFSCB_CollData_val = dataBuffP;
@ -942,6 +944,7 @@ SRXAFSCB_GetXStats(struct rx_call *a_call, afs_int32 a_clientVersionNum,
dataBytes = sizeof(afs_stats_cmfullperf);
dataBuffP = (afs_int32 *) afs_osi_Alloc(dataBytes);
osi_Assert(dataBuffP != NULL);
memcpy((char *)dataBuffP, (char *)(&afs_stats_cmfullperf), dataBytes);
a_dataP->AFSCB_CollData_len = dataBytes >> 2;
a_dataP->AFSCB_CollData_val = dataBuffP;
@ -1295,8 +1298,8 @@ SRXAFSCB_GetCellServDB(struct rx_call *a_call, afs_int32 a_index,
p_name = tcell->cellName;
for (j = 0; j < AFSMAXCELLHOSTS && tcell->cellHosts[j]; j++);
i = strlen(p_name);
a_hosts->serverList_val =
(afs_int32 *) afs_osi_Alloc(j * sizeof(afs_int32));
a_hosts->serverList_val = afs_osi_Alloc(j * sizeof(afs_int32));
osi_Assert(a_hosts->serverList_val != NULL);
a_hosts->serverList_len = j;
for (j = 0; j < AFSMAXCELLHOSTS && tcell->cellHosts[j]; j++)
a_hosts->serverList_val[j] =
@ -1304,7 +1307,7 @@ SRXAFSCB_GetCellServDB(struct rx_call *a_call, afs_int32 a_index,
afs_PutCell(tcell, READ_LOCK);
}
t_name = (char *)afs_osi_Alloc(i + 1);
t_name = afs_osi_Alloc(i + 1);
if (t_name == NULL) {
afs_osi_Free(a_hosts->serverList_val, (j * sizeof(afs_int32)));
RX_AFS_GUNLOCK();
@ -1362,7 +1365,7 @@ SRXAFSCB_GetLocalCell(struct rx_call *a_call, char **a_name)
plen = strlen(p_name);
else
plen = 0;
t_name = (char *)afs_osi_Alloc(plen + 1);
t_name = afs_osi_Alloc(plen + 1);
if (t_name == NULL) {
if (tcell)
afs_PutCell(tcell, READ_LOCK);
@ -1459,7 +1462,7 @@ SRXAFSCB_GetCacheConfig(struct rx_call *a_call, afs_uint32 callerVersion,
* Currently only support version 1
*/
allocsize = sizeof(cm_initparams_v1);
t_config = (afs_uint32 *) afs_osi_Alloc(allocsize);
t_config = afs_osi_Alloc(allocsize);
if (t_config == NULL) {
RX_AFS_GUNLOCK();
return ENOMEM;
@ -1600,8 +1603,8 @@ SRXAFSCB_GetCellByNum(struct rx_call *a_call, afs_int32 a_cellnum,
for (sn = 0; sn < AFSMAXCELLHOSTS && tcell->cellHosts[sn]; sn++);
a_hosts->serverList_len = sn;
a_hosts->serverList_val =
(afs_int32 *) afs_osi_Alloc(sn * sizeof(afs_int32));
a_hosts->serverList_val = afs_osi_Alloc(sn * sizeof(afs_int32));
osi_Assert(a_hosts->serverList_val != NULL);
for (i = 0; i < sn; i++)
a_hosts->serverList_val[i] = ntohl(tcell->cellHosts[i]->addr->sa_ip);
@ -1642,7 +1645,8 @@ SRXAFSCB_TellMeAboutYourself(struct rx_call *a_call,
RX_AFS_GUNLOCK();
dataBytes = 1 * sizeof(afs_uint32);
dataBuffP = (afs_uint32 *) afs_osi_Alloc(dataBytes);
dataBuffP = afs_osi_Alloc(dataBytes);
osi_Assert(dataBuffP != NULL);
dataBuffP[0] = CLIENT_CAPABILITY_ERRORTRANS;
capabilities->Capabilities_len = dataBytes / sizeof(afs_uint32);
capabilities->Capabilities_val = dataBuffP;

View File

@ -233,7 +233,8 @@ afs_cellname_new(char *name, afs_int32 cellnum)
if (cellnum == 0)
cellnum = afs_cellnum_next;
cn = (struct cell_name *)afs_osi_Alloc(sizeof(*cn));
cn = afs_osi_Alloc(sizeof(*cn));
osi_Assert(cn != NULL);
cn->next = afs_cellname_head;
cn->cellnum = cellnum;
cn->cellname = afs_strdup(name);
@ -515,7 +516,8 @@ afs_NewCellAlias(char *alias, char *cell)
}
UpgradeSToWLock(&afs_xcell, 682);
tc = (struct cell_alias *)afs_osi_Alloc(sizeof(struct cell_alias));
tc = afs_osi_Alloc(sizeof(struct cell_alias));
osi_Assert(tc != NULL);
tc->alias = afs_strdup(alias);
tc->cell = afs_strdup(cell);
tc->next = afs_cellalias_head;
@ -917,7 +919,8 @@ afs_NewCell(char *acellName, afs_int32 * acellHosts, int aflags,
if (tc) {
aflags &= ~CNoSUID;
} else {
tc = (struct cell *)afs_osi_Alloc(sizeof(struct cell));
tc = afs_osi_Alloc(sizeof(struct cell));
osi_Assert(tc != NULL);
memset(tc, 0, sizeof(*tc));
tc->cellName = afs_strdup(acellName);
tc->fsport = AFS_FSPORT;

View File

@ -270,7 +270,8 @@ afs_ConnBySA(struct srvAddr *sap, unsigned short aport, afs_int32 acell,
* gets set, marking the time of its ``birth''.
*/
UpgradeSToWLock(&afs_xconn, 37);
tc = (struct afs_conn *)afs_osi_Alloc(sizeof(struct afs_conn));
tc = afs_osi_Alloc(sizeof(struct afs_conn));
osi_Assert(tc != NULL);
memset(tc, 0, sizeof(struct afs_conn));
tc->user = tu;

View File

@ -2594,7 +2594,8 @@ afs_MemGetDSlot(afs_int32 aslot, struct dcache *tmpdc)
if (!afs_freeDSList) {
/* none free, making one is better than a panic */
afs_stats_cmperf.dcacheXAllocs++; /* count in case we have a leak */
tdc = (struct dcache *)afs_osi_Alloc(sizeof(struct dcache));
tdc = afs_osi_Alloc(sizeof(struct dcache));
osi_Assert(tdc != NULL);
#ifdef KERNEL_HAVE_PIN
pin((char *)tdc, sizeof(struct dcache)); /* XXX */
#endif
@ -2691,7 +2692,8 @@ afs_UFSGetDSlot(afs_int32 aslot, struct dcache *tmpdc)
if (!afs_freeDSList) {
/* none free, making one is better than a panic */
afs_stats_cmperf.dcacheXAllocs++; /* count in case we have a leak */
tdc = (struct dcache *)afs_osi_Alloc(sizeof(struct dcache));
tdc = afs_osi_Alloc(sizeof(struct dcache));
osi_Assert(tdc != NULL);
#ifdef KERNEL_HAVE_PIN
pin((char *)tdc, sizeof(struct dcache)); /* XXX */
#endif
@ -3064,37 +3066,41 @@ afs_dcacheInit(int afiles, int ablocks, int aDentries, int achunk, int aflags)
if (aDentries > 512)
afs_dhashsize = 2048;
/* initialize hash tables */
afs_dvhashTbl =
(afs_int32 *) afs_osi_Alloc(afs_dhashsize * sizeof(afs_int32));
afs_dchashTbl =
(afs_int32 *) afs_osi_Alloc(afs_dhashsize * sizeof(afs_int32));
afs_dvhashTbl = afs_osi_Alloc(afs_dhashsize * sizeof(afs_int32));
osi_Assert(afs_dvhashTbl != NULL);
afs_dchashTbl = afs_osi_Alloc(afs_dhashsize * sizeof(afs_int32));
osi_Assert(afs_dchashTbl != NULL);
for (i = 0; i < afs_dhashsize; i++) {
afs_dvhashTbl[i] = NULLIDX;
afs_dchashTbl[i] = NULLIDX;
}
afs_dvnextTbl = (afs_int32 *) afs_osi_Alloc(afiles * sizeof(afs_int32));
afs_dcnextTbl = (afs_int32 *) afs_osi_Alloc(afiles * sizeof(afs_int32));
afs_dvnextTbl = afs_osi_Alloc(afiles * sizeof(afs_int32));
osi_Assert(afs_dvnextTbl != NULL);
afs_dcnextTbl = afs_osi_Alloc(afiles * sizeof(afs_int32));
osi_Assert(afs_dcnextTbl != NULL);
for (i = 0; i < afiles; i++) {
afs_dvnextTbl[i] = NULLIDX;
afs_dcnextTbl[i] = NULLIDX;
}
/* Allocate and zero the pointer array to the dcache entries */
afs_indexTable = (struct dcache **)
afs_osi_Alloc(sizeof(struct dcache *) * afiles);
afs_indexTable = afs_osi_Alloc(sizeof(struct dcache *) * afiles);
osi_Assert(afs_indexTable != NULL);
memset(afs_indexTable, 0, sizeof(struct dcache *) * afiles);
afs_indexTimes =
(afs_hyper_t *) afs_osi_Alloc(afiles * sizeof(afs_hyper_t));
afs_indexTimes = afs_osi_Alloc(afiles * sizeof(afs_hyper_t));
osi_Assert(afs_indexTimes != NULL);
memset(afs_indexTimes, 0, afiles * sizeof(afs_hyper_t));
afs_indexUnique =
(afs_int32 *) afs_osi_Alloc(afiles * sizeof(afs_uint32));
afs_indexUnique = afs_osi_Alloc(afiles * sizeof(afs_uint32));
osi_Assert(afs_indexUnique != NULL);
memset(afs_indexUnique, 0, afiles * sizeof(afs_uint32));
afs_indexFlags = (u_char *) afs_osi_Alloc(afiles * sizeof(u_char));
afs_indexFlags = afs_osi_Alloc(afiles * sizeof(u_char));
osi_Assert(afs_indexFlags != NULL);
memset(afs_indexFlags, 0, afiles * sizeof(char));
/* Allocate and thread the struct dcache entries themselves */
tdp = afs_Initial_freeDSList =
(struct dcache *)afs_osi_Alloc(aDentries * sizeof(struct dcache));
afs_osi_Alloc(aDentries * sizeof(struct dcache));
osi_Assert(tdp != NULL);
memset(tdp, 0, aDentries * sizeof(struct dcache));
#ifdef KERNEL_HAVE_PIN
pin((char *)afs_indexTable, sizeof(struct dcache *) * afiles); /* XXX */
@ -3348,7 +3354,7 @@ afs_MakeShadowDir(struct vcache *avc, struct dcache *adc)
ReleaseWriteLock(&afs_xdcache);
/* Alloc a 4k block. */
data = (char *) afs_osi_Alloc(4096);
data = afs_osi_Alloc(4096);
if (!data) {
afs_warn("afs_MakeShadowDir: could not alloc data\n");
ret_code = ENOMEM;

View File

@ -563,7 +563,7 @@ afs_ProcessOpRename(struct vcache *avc, struct vrequest *areq)
old_pdir_fid.Fid.Unique = avc->f.oldParent.unique;
/* Get old name. */
old_name = (char *) afs_osi_Alloc(AFSNAMEMAX);
old_name = afs_osi_Alloc(AFSNAMEMAX);
if (!old_name) {
/* printf("afs_ProcessOpRename: Couldn't alloc space for old name.\n"); */
return ENOMEM;
@ -575,7 +575,7 @@ afs_ProcessOpRename(struct vcache *avc, struct vrequest *areq)
}
/* Alloc data first. */
new_name = (char *) afs_osi_Alloc(AFSNAMEMAX);
new_name = afs_osi_Alloc(AFSNAMEMAX);
if (!new_name) {
/* printf("afs_ProcessOpRename: Couldn't alloc space for new name.\n"); */
code = ENOMEM;

View File

@ -347,6 +347,7 @@ afs_RebuildDynroot(void)
}
dotLen = strlen(c->cellName) + 2;
dotCell = afs_osi_Alloc(dotLen);
osi_Assert(dotCell != NULL);
strcpy(dotCell, ".");
afs_strcat(dotCell, c->cellName);
@ -365,6 +366,7 @@ afs_RebuildDynroot(void)
dotLen = strlen(ca->alias) + 2;
dotCell = afs_osi_Alloc(dotLen);
osi_Assert(dotCell != NULL);
strcpy(dotCell, ".");
afs_strcat(dotCell, ca->alias);
@ -385,6 +387,7 @@ afs_RebuildDynroot(void)
dirSize = (curPage + 1) * AFS_PAGESIZE;
newDir = afs_osi_Alloc(dirSize);
osi_Assert(newDir != NULL);
/*
* Now actually construct the directory.
@ -424,6 +427,7 @@ afs_RebuildDynroot(void)
dotLen = strlen(c->cellName) + 2;
dotCell = afs_osi_Alloc(dotLen);
osi_Assert(dotCell != NULL);
strcpy(dotCell, ".");
afs_strcat(dotCell, c->cellName);
afs_dynroot_addDirEnt(dirHeader, &curPage, &curChunk, c->cellName,
@ -443,6 +447,7 @@ afs_RebuildDynroot(void)
dotLen = strlen(ca->alias) + 2;
dotCell = afs_osi_Alloc(dotLen);
osi_Assert(dotCell != NULL);
strcpy(dotCell, ".");
afs_strcat(dotCell, ca->alias);
afs_dynroot_addDirEnt(dirHeader, &curPage, &curChunk, ca->alias,
@ -481,6 +486,7 @@ afs_RebuildDynrootMount(void)
struct DirHeader *dirHeader;
newDir = afs_osi_Alloc(AFS_PAGESIZE);
osi_Assert(newDir != NULL);
/*
* Now actually construct the directory.
@ -648,6 +654,7 @@ afs_DynrootNewVnode(struct vcache *avc, struct AFSFetchStatus *status)
if (ts) {
linklen = strlen(ts->target);
avc->linkData = afs_osi_Alloc(linklen + 1);
osi_Assert(avc->linkData != NULL);
strcpy(avc->linkData, ts->target);
status->Length = linklen;
@ -696,6 +703,7 @@ afs_DynrootNewVnode(struct vcache *avc, struct AFSFetchStatus *status)
int namelen = strlen(realName);
linklen = rw + namelen;
avc->linkData = afs_osi_Alloc(linklen + 1);
osi_Assert(avc->linkData != NULL);
strcpy(avc->linkData, rw ? "." : "");
afs_strcat(avc->linkData, realName);
}
@ -718,6 +726,7 @@ afs_DynrootNewVnode(struct vcache *avc, struct AFSFetchStatus *status)
bp = afs_cv2string(&tbuf[CVBS], avc->f.fid.Fid.Unique);
linklen = 2 + namelen + strlen(bp);
avc->linkData = afs_osi_Alloc(linklen + 1);
osi_Assert(avc->linkData != NULL);
strcpy(avc->linkData, "%");
afs_strcat(avc->linkData, c->cellName);
afs_strcat(avc->linkData, ":");
@ -741,6 +750,7 @@ afs_DynrootNewVnode(struct vcache *avc, struct AFSFetchStatus *status)
namelen = strlen(c->cellName);
linklen = 1 + namelen + 10;
avc->linkData = afs_osi_Alloc(linklen + 1);
osi_Assert(avc->linkData != NULL);
strcpy(avc->linkData, rw ? "%" : "#");
afs_strcat(avc->linkData, c->cellName);
afs_strcat(avc->linkData, ":root.cell");
@ -881,11 +891,14 @@ afs_DynrootVOPSymlink(struct vcache *avc, afs_ucred_t *acred,
/* Doesn't already exist -- go ahead and create it */
tps = afs_osi_Alloc(sizeof(*tps));
osi_Assert(tps != NULL);
tps->index = afs_dynSymlinkIndex++;
tps->next = afs_dynSymlinkBase;
tps->name = afs_osi_Alloc(strlen(aname) + 1);
osi_Assert(tps->name != NULL);
strcpy(tps->name, aname);
tps->target = afs_osi_Alloc(strlen(atargetName) + 1);
osi_Assert(tps->target != NULL);
strcpy(tps->target, atargetName);
afs_dynSymlinkBase = tps;
ReleaseWriteLock(&afs_dynSymlinkLock);

View File

@ -35,7 +35,8 @@ exporter_add(afs_int32 size, struct exporterops *ops, afs_int32 state,
LOCK_INIT(&afs_xexp, "afs_xexp");
}
length = (size ? size : sizeof(struct afs_exporter));
ex = (struct afs_exporter *)afs_osi_Alloc(length);
ex = afs_osi_Alloc(length);
osi_Assert(ex != NULL);
memset(ex, 0, length);
ObtainWriteLock(&afs_xexp, 308);
for (op = root_exported; op; op = op->exp_next) {

View File

@ -931,8 +931,8 @@ afs_icl_LogUse(struct afs_icl_log *logp)
/* we weren't passed in a hint and it wasn't set */
logp->logSize = ICL_DEFAULT_LOGSIZE;
}
logp->datap =
(afs_int32 *) afs_osi_Alloc(sizeof(afs_int32) * logp->logSize);
logp->datap = afs_osi_Alloc(sizeof(afs_int32) * logp->logSize);
osi_Assert(logp->datap != NULL);
#ifdef KERNEL_HAVE_PIN
pin((char *)logp->datap, sizeof(afs_int32) * logp->logSize);
#endif
@ -979,8 +979,8 @@ afs_icl_LogSetSize(struct afs_icl_log *logp, afs_int32 logSize)
#ifdef KERNEL_HAVE_PIN
unpin((char *)logp->datap, sizeof(afs_int32) * logp->logSize);
#endif
logp->datap =
(afs_int32 *) afs_osi_Alloc(sizeof(afs_int32) * logSize);
logp->datap = afs_osi_Alloc(sizeof(afs_int32) * logSize);
osi_Assert(logp->datap != NULL);
#ifdef KERNEL_HAVE_PIN
pin((char *)logp->datap, sizeof(afs_int32) * logSize);
#endif
@ -1170,6 +1170,7 @@ afs_icl_CreateSetWithFlags(char *name, struct afs_icl_log *baseLogp,
strcpy(setp->name, name);
setp->nevents = ICL_DEFAULTEVENTS;
setp->eventFlags = afs_osi_Alloc(ICL_DEFAULTEVENTS);
osi_Assert(setp->eventFlags != NULL);
#ifdef KERNEL_HAVE_PIN
pin((char *)setp->eventFlags, ICL_DEFAULTEVENTS);
#endif

View File

@ -141,7 +141,8 @@ afs_CacheInit(afs_int32 astatSize, afs_int32 afiles, afs_int32 ablocks,
else if (aVolumes > 32767)
aVolumes = 32767;
tv = (struct volume *)afs_osi_Alloc(aVolumes * sizeof(struct volume));
tv = afs_osi_Alloc(aVolumes * sizeof(struct volume));
osi_Assert(tv != NULL);
for (i = 0; i < aVolumes - 1; i++)
tv[i].next = &tv[i + 1];
tv[aVolumes - 1].next = NULL;
@ -533,8 +534,10 @@ afs_ResourceInit(int preallocs)
afs_resourceinit_flag = 1;
for (i = 0; i < NFENTRIES; i++)
fvTable[i] = 0;
for (i = 0; i < MAXNUMSYSNAMES; i++)
for (i = 0; i < MAXNUMSYSNAMES; i++) {
afs_sysnamelist[i] = afs_osi_Alloc(MAXSYSNAME);
osi_Assert(afs_sysnamelist[i] != NULL);
}
afs_sysname = afs_sysnamelist[0];
strcpy(afs_sysname, SYS_NAME);
afs_sysnamecount = 1;

View File

@ -35,8 +35,9 @@ afs_InitMemCache(int blkCount, int blkSize, int flags)
memCacheBlkSize = blkSize;
memMaxBlkNumber = blkCount;
memCache = (struct memCacheEntry *)
memCache =
afs_osi_Alloc(memMaxBlkNumber * sizeof(struct memCacheEntry));
osi_Assert(memCache != NULL);
for (index = 0; index < memMaxBlkNumber; index++) {
char *blk;

View File

@ -76,7 +76,8 @@ afs_GetNfsClientPag(afs_int32 uid, afs_uint32 host)
return np;
}
}
np = (struct nfsclientpag *)afs_osi_Alloc(sizeof(struct nfsclientpag));
np = afs_osi_Alloc(sizeof(struct nfsclientpag));
osi_Assert(np != NULL);
memset(np, 0, sizeof(struct nfsclientpag));
/* Copy the necessary afs_exporter fields */
memcpy((char *)np, (char *)afs_nfsexporter, sizeof(struct afs_exporter));
@ -479,6 +480,7 @@ afs_nfsclient_sysname(struct nfsclientpag *np, char *inname,
}
for(count=0; count < *num;++count) {
np->sysname[count]= afs_osi_Alloc(MAXSYSNAME);
osi_Assert(np->sysname[count] != NULL);
}
cp = inname;
for(count=0; count < *num;++count) {

View File

@ -168,7 +168,7 @@ osi_AllocLargeSpace(size_t size)
char *p;
afs_stats_cmperf.LargeBlocksAlloced++;
p = (char *)afs_osi_Alloc(AFS_LRALLOCSIZ);
p = afs_osi_Alloc(AFS_LRALLOCSIZ);
#ifdef KERNEL_HAVE_PIN
/*
* Need to pin this memory since under heavy conditions this memory

View File

@ -113,8 +113,10 @@ afspag_Init(afs_int32 nfs_server_addr)
afs_resourceinit_flag = 1;
afs_nfs_server_addr = nfs_server_addr;
for (i = 0; i < MAXNUMSYSNAMES; i++)
for (i = 0; i < MAXNUMSYSNAMES; i++) {
afs_sysnamelist[i] = afs_osi_Alloc(MAXSYSNAME);
osi_Assert(afs_sysnamelist[i] != NULL);
}
afs_sysname = afs_sysnamelist[0];
strcpy(afs_sysname, SYS_NAME);
afs_sysnamecount = 1;

View File

@ -45,10 +45,10 @@ afspag_GetCell(char *acell)
}
if (!tcell) {
tcell = (struct afspag_cell *)afs_osi_Alloc(sizeof(struct afspag_cell));
tcell = afs_osi_Alloc(sizeof(struct afspag_cell));
if (!tcell)
goto out;
tcell->cellname = (char *)afs_osi_Alloc(strlen(acell) + 1);
tcell->cellname = afs_osi_Alloc(strlen(acell) + 1);
if (!tcell->cellname) {
afs_osi_Free(tcell, sizeof(struct afspag_cell));
tcell = 0;
@ -251,8 +251,7 @@ SPAGCB_GetCreds(struct rx_call *a_call, afs_int32 a_uid,
return UAESRCH;
}
a_creds->CredInfos_val =
(CredInfo *)afs_osi_Alloc(count * sizeof(CredInfo));
a_creds->CredInfos_val = afs_osi_Alloc(count * sizeof(CredInfo));
if (!a_creds->CredInfos_val)
goto out;
a_creds->CredInfos_len = count;

View File

@ -1937,6 +1937,8 @@ DECL_PIOCTL(PGetVolumeStatus)
struct rx_connection *rxconn;
XSTATS_DECLS;
osi_Assert(offLineMsg != NULL);
osi_Assert(motd != NULL);
AFS_STATCNT(PGetVolumeStatus);
if (!avc) {
code = EINVAL;
@ -3824,7 +3826,8 @@ ReSortCells(int s, afs_int32 * l, int vlonly)
if (vlonly) {
afs_int32 *p;
p = (afs_int32 *) afs_osi_Alloc(sizeof(afs_int32) * (s + 1));
p = afs_osi_Alloc(sizeof(afs_int32) * (s + 1));
osi_Assert(p != NULL);
p[0] = s;
memcpy(p + 1, l, s * sizeof(afs_int32));
afs_TraverseCells(&ReSortCells_cb, p);
@ -5082,6 +5085,7 @@ DECL_PIOCTL(PCallBackAddr)
}
addrs = afs_osi_Alloc(srvAddrCount * sizeof(*addrs));
osi_Assert(addrs != NULL);
j = 0;
for (i = 0; i < NSERVERS; i++) {
for (sa = afs_srvAddrs[i]; sa; sa = sa->next_bkt) {

View File

@ -593,7 +593,7 @@ afs_ExtendSegments(struct vcache *avc, afs_size_t alen, struct vrequest *areq)
struct dcache *tdc;
void *zeros;
zeros = (void *) afs_osi_Alloc(AFS_PAGESIZE);
zeros = afs_osi_Alloc(AFS_PAGESIZE);
if (zeros == NULL)
return ENOMEM;
memset(zeros, 0, AFS_PAGESIZE);

View File

@ -507,6 +507,7 @@ ForceAllNewConnections(void)
}
addrs = afs_osi_Alloc(srvAddrCount * sizeof(*addrs));
osi_Assert(addrs != NULL);
j = 0;
for (i = 0; i < NSERVERS; i++) {
for (sa = afs_srvAddrs[i]; sa; sa = sa->next_bkt) {
@ -800,6 +801,7 @@ afs_LoopServers(int adown, struct cell *acellp, int vlalso,
}
addrs = afs_osi_Alloc(srvAddrCount * sizeof(*addrs));
osi_Assert(addrs != NULL);
j = 0;
for (i = 0; i < NSERVERS; i++) {
for (sa = afs_srvAddrs[i]; sa; sa = sa->next_bkt) {
@ -1939,7 +1941,7 @@ afs_GetServer(afs_uint32 *aserverp, afs_int32 nservers, afs_int32 acell,
if (oldts) {
newts = oldts;
} else {
newts = (struct server *)afs_osi_Alloc(sizeof(struct server));
newts = afs_osi_Alloc(sizeof(struct server));
if (!newts)
panic("malloc of server struct");
afs_totalServers++;
@ -1984,7 +1986,7 @@ afs_GetServer(afs_uint32 *aserverp, afs_int32 nservers, afs_int32 acell,
if (oldsa) {
newsa = oldsa;
} else {
newsa = (struct srvAddr *)afs_osi_Alloc(sizeof(struct srvAddr));
newsa = afs_osi_Alloc(sizeof(struct srvAddr));
if (!newsa)
panic("malloc of srvAddr struct");
afs_totalSrvAddrs++;
@ -2034,8 +2036,7 @@ afs_GetServer(afs_uint32 *aserverp, afs_int32 nservers, afs_int32 acell,
/* Have a srvAddr struct. Now get a server struct (if not already) */
if (!orphts) {
orphts =
(struct server *)afs_osi_Alloc(sizeof(struct server));
orphts = afs_osi_Alloc(sizeof(struct server));
if (!orphts)
panic("malloc of lo server struct");
memset(orphts, 0, sizeof(struct server));

View File

@ -485,7 +485,8 @@ afs_GetUser(afs_int32 auid, afs_int32 acell, afs_int32 locktype)
}
}
}
tu = (struct unixuser *)afs_osi_Alloc(sizeof(struct unixuser));
tu = afs_osi_Alloc(sizeof(struct unixuser));
osi_Assert(tu != NULL);
#ifndef AFS_NOSTATS
afs_stats_cmfullperf.authent.PAGCreations++;
#endif /* AFS_NOSTATS */

View File

@ -187,7 +187,7 @@ afs_strdup(char *s)
int cc;
cc = strlen(s) + 1;
n = (char *)afs_osi_Alloc(cc);
n = afs_osi_Alloc(cc);
if (n)
memcpy(n, s, cc);

View File

@ -309,9 +309,8 @@ afs_AllocCBR(void)
afs_stats_cmperf.CallBackFlushes++;
} else {
/* try allocating */
tsp =
(struct afs_cbr *)afs_osi_Alloc(AFS_NCBRS *
sizeof(struct afs_cbr));
tsp = afs_osi_Alloc(AFS_NCBRS * sizeof(struct afs_cbr));
osi_Assert(tsp != NULL);
for (i = 0; i < AFS_NCBRS - 1; i++) {
tsp[i].next = &tsp[i + 1];
}
@ -379,6 +378,7 @@ afs_FlushVCBs(afs_int32 lockit)
return code;
treq.flags |= O_NONBLOCK;
tfids = afs_osi_Alloc(sizeof(struct AFSFid) * AFS_MAXCBRSCALL);
osi_Assert(tfids != NULL);
if (lockit)
ObtainWriteLock(&afs_xvcb, 273);
@ -2897,7 +2897,8 @@ afs_vcacheInit(int astatSize)
#if !defined(AFS_LINUX22_ENV)
/* Allocate and thread the struct vcache entries */
tvp = (struct vcache *)afs_osi_Alloc(astatSize * sizeof(struct vcache));
tvp = afs_osi_Alloc(astatSize * sizeof(struct vcache));
osi_Assert(tvp != NULL);
memset(tvp, 0, sizeof(struct vcache) * astatSize);
Initial_freeVCList = tvp;

View File

@ -245,7 +245,8 @@ afs_MemGetVolSlot(void)
if (!afs_freeVolList) {
struct volume *newVp;
newVp = (struct volume *)afs_osi_Alloc(sizeof(struct volume));
newVp = afs_osi_Alloc(sizeof(struct volume));
osi_Assert(newVp != NULL);
newVp->next = NULL;
afs_freeVolList = newVp;
@ -317,7 +318,7 @@ afs_CheckVolumeNames(int flags)
for (tv = afs_volumes[i]; tv; tv = tv->next)
++vsize;
volumeID = (afs_int32 *) afs_osi_Alloc(2 * vsize * sizeof(*volumeID));
volumeID = afs_osi_Alloc(2 * vsize * sizeof(*volumeID));
cellID = (volumeID) ? volumeID + vsize : 0;
}
@ -635,6 +636,7 @@ afs_SetupVolume(afs_int32 volid, char *aname, void *ve, struct cell *tcell,
if (agood) {
if (!tv->name) {
tv->name = afs_osi_Alloc(strlen(aname) + 1);
osi_Assert(tv->name != NULL);
strcpy(tv->name, aname);
}
}
@ -702,6 +704,7 @@ afs_NewDynrootVolume(struct VenusFid *fid)
if (!tcell)
return NULL;
tve = afs_osi_Alloc(sizeof(*tve));
osi_Assert(tve != NULL);
if (!(tcell->states & CHasVolRef))
tcell->states |= CHasVolRef;