backup: 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: I6a878d53007e27179c11d8f745b09dacade4c83d
Reviewed-on: http://gerrit.openafs.org/7460
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
This commit is contained in:
Simon Wilkinson 2012-05-17 10:18:24 +01:00 committed by Derrick Brashear
parent 0cf3c58d80
commit ca48be9161
19 changed files with 54 additions and 63 deletions

View File

@ -313,7 +313,7 @@ EvalVolumeSet2(struct bc_config *aconfig,
ERROR(BC_NOMEM);
}
tvd->name = (char *)malloc(strlen(entries[e].name) + 10);
tvd->name = malloc(strlen(entries[e].name) + 10);
if (!(tvd->name)) {
afs_com_err(whoami, BC_NOMEM, NULL);
free(tvd);
@ -581,7 +581,7 @@ EvalVolumeSet1(struct bc_config *aconfig,
return (BC_NOMEM);
}
tvd->name = (char *)malloc(strlen(entry.name) + 10);
tvd->name = malloc(strlen(entry.name) + 10);
if (!(tvd->name)) {
afs_com_err(whoami, BC_NOMEM, NULL);
free(tvd);
@ -759,7 +759,7 @@ concatParams(struct cmd_item *itemPtr)
return (NULL);
}
string = (char *)malloc(length); /* allocate the string */
string = malloc(length); /* allocate the string */
if (!string) {
afs_com_err(whoami, BC_NOMEM, NULL);
return (NULL);
@ -1186,7 +1186,7 @@ bc_VolRestoreCmd(struct cmd_syndesc *as, void *arock)
return BC_NOMEM;
}
tvol->name = (char *)malloc(VOLSER_MAXVOLNAME + 1);
tvol->name = malloc(VOLSER_MAXVOLNAME + 1);
if (!tvol->name) {
afs_com_err(whoami, BC_NOMEM, NULL);
return BC_NOMEM;
@ -1226,7 +1226,7 @@ bc_VolRestoreCmd(struct cmd_syndesc *as, void *arock)
if (as->parms[5].items) {
for (ti = as->parms[5].items; ti; ti = ti->next)
portCount++;
ports = (afs_int32 *) malloc(portCount * sizeof(afs_int32));
ports = malloc(portCount * sizeof(afs_int32));
if (!ports) {
afs_com_err(whoami, BC_NOMEM, NULL);
return BC_NOMEM;
@ -1356,7 +1356,7 @@ bc_DiskRestoreCmd(struct cmd_syndesc *as, void *arock)
if (as->parms[2].items) {
for (ti = as->parms[2].items; ti; ti = ti->next)
portCount++;
ports = (afs_int32 *) malloc(portCount * sizeof(afs_int32));
ports = malloc(portCount * sizeof(afs_int32));
if (!ports) {
afs_com_err(whoami, BC_NOMEM, NULL);
return BC_NOMEM;
@ -1525,7 +1525,7 @@ bc_VolsetRestoreCmd(struct cmd_syndesc *as, void *arock)
/* Allocate a volumeDump structure and link it in */
tvol = calloc(1, sizeof(struct bc_volumeDump));
tvol->name = (char *)malloc(VOLSER_MAXVOLNAME + 1);
tvol->name = malloc(VOLSER_MAXVOLNAME + 1);
if (!tvol->name) {
afs_com_err(whoami, BC_NOMEM, NULL);
return BC_NOMEM;
@ -1551,7 +1551,7 @@ bc_VolsetRestoreCmd(struct cmd_syndesc *as, void *arock)
if (as->parms[2].items) {
for (ti = as->parms[2].items; ti; ti = ti->next)
portCount++;
ports = (afs_int32 *) malloc(portCount * sizeof(afs_int32));
ports = malloc(portCount * sizeof(afs_int32));
if (!ports) {
afs_com_err(whoami, BC_NOMEM, NULL);
return BC_NOMEM;
@ -1706,7 +1706,7 @@ bc_DumpCmd(struct cmd_syndesc *as, void *arock)
/* get the port number, if one was specified */
if (as->parms[2].items) {
portp = (afs_int32 *) malloc(sizeof(afs_int32));
portp = malloc(sizeof(afs_int32));
if (!portp) {
afs_com_err(whoami, BC_NOMEM, NULL);
return BC_NOMEM;
@ -1787,7 +1787,7 @@ bc_DumpCmd(struct cmd_syndesc *as, void *arock)
sprintf(statusPtr->taskName, "Scheduled Dump");
statusPtr->jobNumber = bc_jobNumber();
statusPtr->scheduledDump = atTime;
statusPtr->cmdLine = (char *)malloc(length);
statusPtr->cmdLine = malloc(length);
if (!statusPtr->cmdLine) {
afs_com_err(whoami, BC_NOMEM, NULL);
return BC_NOMEM;

View File

@ -418,7 +418,7 @@ bc_ParseExpiration(struct cmd_parmdesc *paramPtr, afs_int32 *expType,
if (length == 0) /* no actual date string */
FAIL(1);
dateString = (char *)malloc(length);
dateString = malloc(length);
if (dateString == 0)
FAIL(2);

View File

@ -185,14 +185,13 @@ bc_Restorer(afs_int32 aindex)
time_t did;
int foundtape, c;
dlevels = (struct dumpinfo *) malloc(num_dlevels * sizeof(*dlevels));
dlevels = malloc(num_dlevels * sizeof(*dlevels));
dumpTaskPtr = &bc_dumpTasks[aindex];
serverAll = HOSTADDR(&dumpTaskPtr->destServer);
partitionAll = dumpTaskPtr->destPartition;
volumeEntries = (struct budb_volumeEntry *)
malloc(MAXTAPESATONCE * sizeof(struct budb_volumeEntry));
volumeEntries = malloc(MAXTAPESATONCE * sizeof(struct budb_volumeEntry));
if (!volumeEntries) {
afs_com_err(whoami, BC_NOMEM, NULL);
ERROR(BC_NOMEM);
@ -332,7 +331,7 @@ bc_Restorer(afs_int32 aindex)
struct dumpinfo *tdl = dlevels;
num_dlevels += num_dlevels; /* double */
dlevels = (struct dumpinfo *) malloc(num_dlevels * sizeof(*dlevels));
dlevels = malloc(num_dlevels * sizeof(*dlevels));
memcpy(dlevels, tdl, (num_dlevels/2) * sizeof(*dlevels));
free(tdl);
}

View File

@ -489,7 +489,7 @@ bcdb_GetTextFile(udbClientTextP ctPtr)
/* allocate a buffer */
bufferSize = 1024;
charList.charListT_val = (char *)malloc(bufferSize);
charList.charListT_val = malloc(bufferSize);
if (charList.charListT_val == 0)
ERROR(BUDB_INTERNALERROR);
charList.charListT_len = bufferSize;
@ -558,7 +558,7 @@ bcdb_SaveTextFile(udbClientTextP ctPtr)
/* allocate a buffer */
bufferSize = 1024;
charList.charListT_val = (char *)malloc(bufferSize);
charList.charListT_val = malloc(bufferSize);
if (charList.charListT_val == 0)
ERROR(BUDB_INTERNALERROR);
charList.charListT_len = bufferSize;

View File

@ -175,7 +175,7 @@ ht_AllocTable(struct ubik_trans *ut, struct memoryHashTable *mht)
b = mht->blocks = calloc(1, mht->size);
for (i = 0; i < nb; i++) {
b[i] = (struct memoryHTBlock *)malloc(sizeof(struct memoryHTBlock));
b[i] = malloc(sizeof(struct memoryHTBlock));
code = AllocBlock(ut, (struct block *)&b[i]->b, &b[i]->a);
if (code)
return code;
@ -302,8 +302,7 @@ ht_GetTableBlock(struct ubik_trans *ut, struct memoryHashTable *mht,
db_panic("non-zero length, but no table");
}
/* else ta is set from last time around loop */
b[i] =
(struct memoryHTBlock *)malloc(sizeof(struct memoryHTBlock));
b[i] = malloc(sizeof(struct memoryHTBlock));
b[i]->a = ta;
b[i]->valid = 0;
}

View File

@ -118,7 +118,7 @@ GetText(struct rx_call *call, afs_uint32 lockHandle, afs_int32 textType,
charListPtr->charListT_val = NULL;
} else {
charListPtr->charListT_len = transferSize;
charListPtr->charListT_val = (char *)malloc(transferSize);
charListPtr->charListT_val = malloc(transferSize);
if (charListPtr->charListT_val == 0)
ABORT(BUDB_NOMEM);
}
@ -177,7 +177,7 @@ GetText(struct rx_call *call, afs_uint32 lockHandle, afs_int32 textType,
no_xfer_abort:
charListPtr->charListT_len = 0;
charListPtr->charListT_val = (char *)malloc(0);
charListPtr->charListT_val = malloc(0);
abort_exit:
if (ut)

View File

@ -219,7 +219,7 @@ DumpDB(struct rx_call *call,
ObtainWriteLock(&dumpSyncPtr->ds_lock);
}
charListPtr->charListT_val = (char *)malloc(maxLength);
charListPtr->charListT_val = malloc(maxLength);
readSize =
read(dumpSyncPtr->pipeFid[0], charListPtr->charListT_val, maxLength);

View File

@ -365,7 +365,7 @@ AddToReturnList(struct returnList *list, dbadr a, afs_int32 *to_skipP)
if (list->nElements >= list->allocSize) {
if (list->elements == 0) {
size = 10;
tmp = (char *)malloc(sizeof(dbadr) * size);
tmp = malloc(sizeof(dbadr) * size);
} else {
size = list->allocSize + 10;
tmp = realloc(list->elements, sizeof(dbadr) * size);
@ -939,8 +939,7 @@ deleteDump(struct rx_call *call, dumpId id, budb_dumpsList *dumps)
/* Record the dump just deleted */
if (dumps && (dumps->budb_dumpsList_len < BUDB_MAX_RETURN_LIST)) {
if (dumps->budb_dumpsList_len == 0)
dumps->budb_dumpsList_val =
(afs_int32 *) malloc(sizeof(afs_int32));
dumps->budb_dumpsList_val = malloc(sizeof(afs_int32));
else
dumps->budb_dumpsList_val =
realloc(dumps->budb_dumpsList_val,
@ -1630,11 +1629,9 @@ ListDumps(struct rx_call *call, afs_int32 sflags, afs_int32 groupid,
count += 10;
if (count == 10) {
dumps->budb_dumpsList_val =
(afs_int32 *) malloc(count *
sizeof(afs_int32));
malloc(count * sizeof(afs_int32));
flags->budb_dumpsList_val =
(afs_int32 *) malloc(count *
sizeof(afs_int32));
malloc(count * sizeof(afs_int32));
} else {
dumps->budb_dumpsList_val =
realloc(dumps->budb_dumpsList_val,

View File

@ -285,7 +285,7 @@ parseServerList(struct cmd_item *itemPtr)
LogDebug(3, "%d servers\n", nservers);
/* now can allocate the space for the server arguments */
serverArgs = (char **)malloc((nservers + 2) * sizeof(char *));
serverArgs = malloc((nservers + 2) * sizeof(char *));
if (serverArgs == 0)
ERROR(-1);

View File

@ -1271,7 +1271,7 @@ BSA_Int16 BSAGetEnvironment(
for (i=0; i< ADSM_ENV_STRS; i++) {
if ( *envP == NULL ) { /* watch for NULL pointers */
/* Allocating memory for *envP.*/
*envP = (char *) malloc(sizeof(char) * BSA_MAX_DESC +1);
*envP = malloc(sizeof(char) * BSA_MAX_DESC +1);
/* copy the content of envString[i] to *envP. */
strcpy(*envP,envString[i]);

View File

@ -42,8 +42,8 @@ threadEntryDir(void *anEntry, afs_int32 size, afs_int32 type)
int tried;
for (tried = 0; tried < 5; tried++) {
entryPtr = (dlqlinkP) malloc(sizeof(dlqlinkT));
entry = (char *)malloc(size);
entryPtr = malloc(sizeof(dlqlinkT));
entry = malloc(size);
if (entryPtr && entry)
break;
@ -86,7 +86,7 @@ threadEntry(void *anEntry, afs_int32 size, afs_int32 type)
for (tried = 0; tried < 5; tried++) {
entryPtr = (dlqlinkP) malloc(sizeof(dlqlinkT));
entry = (char *)malloc(size);
entry = malloc(size);
if (entryPtr && entry)
break;

View File

@ -421,7 +421,7 @@ WorkerBee(struct cmd_syndesc *as, void *arock)
/*
* Initialize the tape block buffers
*/
tapeblock1 = (char *)malloc(3 * 16384);
tapeblock1 = malloc(3 * 16384);
if (tapeblock1 == NULL) {
printf("Failed to allocate I/O buffers.\n");
exit(1);

View File

@ -168,7 +168,7 @@ scanVolData(afs_int32 taskId, struct butm_tapeInfo *curTapePtr,
memset(volumeHeader, 0, sizeof(struct volumeHeader));
block = (char *)malloc(2 * BUTM_BLOCKSIZE);
block = malloc(2 * BUTM_BLOCKSIZE);
if (!block)
return (TC_NOMEMORY);
buffer[0] = &block[sizeof(struct blockMark)];

View File

@ -1060,8 +1060,7 @@ WorkerBee(struct cmd_syndesc *as, void *arock)
/*initialize the dumpNode list */
InitNodeList(portOffset);
deviceLatch =
(struct deviceSyncNode *)(malloc(sizeof(struct deviceSyncNode)));
deviceLatch = malloc(sizeof(struct deviceSyncNode));
Lock_Init(&(deviceLatch->lock));
deviceLatch->flags = 0;
@ -1208,11 +1207,11 @@ main(int argc, char **argv)
if (argc == 1) {
ts = calloc(1, sizeof(struct cmd_syndesc));
ti = (struct cmd_item *)malloc(sizeof(struct cmd_item));
ti = malloc(sizeof(struct cmd_item));
ti->next = 0;
ti->data = "0";
ts->parms[0].items = ti;
ti = (struct cmd_item *)malloc(sizeof(struct cmd_item));
ti = malloc(sizeof(struct cmd_item));
ti->next = 0;
ti->data = "0";
ts->parms[1].items = ti;

View File

@ -146,7 +146,7 @@ STC_LabelTape(struct rx_call *acid, struct tc_tapeLabel *label, afs_uint32 *task
if (callPermitted(acid) == 0)
return (TC_NOTPERMITTED);
ptr = (struct labelTapeIf *)malloc(sizeof(*ptr));
ptr = malloc(sizeof(*ptr));
if (!ptr)
ERROR_EXIT(TC_NOMEMORY);
memcpy(&ptr->label, label, sizeof(ptr->label));
@ -231,9 +231,8 @@ STC_PerformDump(struct rx_call *rxCallId, struct tc_dumpInterface *tcdiPtr, tc_d
CopyTapeSetDesc(&(newNode->tapeSetDesc), &tcdiPtr->tapeSet);
newNode->dumps = (struct tc_dumpDesc *)
malloc(sizeof(struct tc_dumpDesc) *
tc_dumpArrayPtr->tc_dumpArray_len);
newNode->dumps = malloc(sizeof(struct tc_dumpDesc) *
tc_dumpArrayPtr->tc_dumpArray_len);
newNode->arraySize = tc_dumpArrayPtr->tc_dumpArray_len;
CopyDumpDesc(newNode->dumps, tc_dumpArrayPtr);
@ -314,9 +313,8 @@ STC_PerformRestore(struct rx_call *acid, char *dumpSetName, tc_restoreArray *are
/* this creates a node in list, alots an id for it and prepares it for locking */
CreateNode(&newNode);
newNode->restores = (struct tc_restoreDesc *)
malloc(sizeof(struct tc_restoreDesc) *
arestores->tc_restoreArray_len);
newNode->restores = malloc(sizeof(struct tc_restoreDesc) *
arestores->tc_restoreArray_len);
newNode->arraySize = arestores->tc_restoreArray_len;
CopyRestoreDesc(newNode->restores, arestores);
*taskID = newNode->taskID;
@ -477,7 +475,7 @@ STC_SaveDb(struct rx_call *rxCall, Date archiveTime, afs_uint32 *taskId)
*taskId = allocTaskId();
ptr = (struct saveDbIf *)malloc(sizeof(struct saveDbIf));
ptr = malloc(sizeof(struct saveDbIf));
if (!ptr)
ERROR_EXIT(TC_NOMEMORY);
ptr->archiveTime = archiveTime;
@ -556,7 +554,7 @@ STC_ScanDumps(struct rx_call *acid, afs_int32 addDbFlag, afs_uint32 *taskId)
*taskId = allocTaskId();
ptr = (struct scanTapeIf *)malloc(sizeof(*ptr));
ptr = malloc(sizeof(*ptr));
if (!ptr)
ERROR_EXIT(TC_NOMEMORY);
ptr->addDbFlag = addDbFlag;
@ -644,7 +642,7 @@ STC_DeleteDump(struct rx_call *acid, afs_uint32 dumpID, afs_uint32 *taskId)
if (callPermitted(acid) == 0)
return (TC_NOTPERMITTED);
ptr = (struct deleteDumpIf *)malloc(sizeof(*ptr));
ptr = malloc(sizeof(*ptr));
if (!ptr)
ERROR_EXIT(TC_NOMEMORY);

View File

@ -415,7 +415,7 @@ writeDbDump(struct butm_tapeInfo *tapeInfoPtr, afs_uint32 taskId,
charList.charListT_val = 0;
charList.charListT_len = 0;
blockSize = BUTM_BLKSIZE;
writeBlock = (char *)malloc(BUTM_BLOCKSIZE);
writeBlock = malloc(BUTM_BLOCKSIZE);
if (!writeBlock)
ERROR_EXIT(TC_NOMEMORY);
@ -1408,7 +1408,7 @@ restoreText(struct butm_tapeInfo *tapeInfo,
udbClientTextP ctPtr = 0;
afs_int32 textType;
ctPtr = (udbClientTextP) malloc(sizeof(*ctPtr));
ctPtr = malloc(sizeof(*ctPtr));
if (!ctPtr)
ERROR_EXIT(TC_NOMEMORY);
@ -1444,7 +1444,7 @@ restoreText(struct butm_tapeInfo *tapeInfo,
/* allocate buffer for text */
readBlockSize = BUTM_BLKSIZE;
readBuffer = (char *)malloc(readBlockSize);
readBuffer = malloc(readBlockSize);
if (!readBuffer)
ERROR_EXIT(TC_NOMEMORY);
@ -1533,7 +1533,7 @@ getTapeData(struct butm_tapeInfo *tapeInfoPtr,
ERROR_EXIT(TC_ABORTEDBYREQUEST);
if (!tapeReadBuffer) {
tapeReadBuffer = (char *)malloc(BUTM_BLOCKSIZE);
tapeReadBuffer = malloc(BUTM_BLOCKSIZE);
if (!tapeReadBuffer)
ERROR_EXIT(TC_NOMEMORY);
}

View File

@ -103,8 +103,7 @@ PerformDump(struct cmd_syndesc *as, void *arock)
strcpy(ttapeSet.format, "tapeName%u");
strcpy(ttapeSet.tapeServer, "diskTapes");
tdumps.tc_dumpArray_val =
(struct tc_dumpDesc
*)(malloc(tdumps.tc_dumpArray_len * sizeof(struct tc_dumpDesc)));
malloc(tdumps.tc_dumpArray_len * sizeof(struct tc_dumpDesc));
ptr = tdumps.tc_dumpArray_val;
for (i = 0; i < tdumps.tc_dumpArray_len; i++) {
fscanf(fp, "%s\n", ptr->name);
@ -146,9 +145,9 @@ PerformRestore(struct cmd_syndesc *as, void *arock)
strcpy(tdumpSetName, "Test");
fp = fopen("restoreScr", "r");
fscanf(fp, "%u\n", &trestores.tc_restoreArray_len);
trestores.tc_restoreArray_val =
(struct tc_restoreDesc *)malloc(trestores.tc_restoreArray_len *
sizeof(struct tc_restoreDesc));
trestores.tc_restoreArray_val
= malloc(trestores.tc_restoreArray_len *
sizeof(struct tc_restoreDesc));
ptr = trestores.tc_restoreArray_val;
for (i = 0; i < trestores.tc_restoreArray_len; i++) {
fscanf(fp, "%s\n", ptr->oldName);

View File

@ -1052,7 +1052,7 @@ file_Mount(struct butm_tapeInfo *info, char *tape)
(void)PrepareAccess(fid); /* for NT */
p = (struct progress *)malloc(sizeof(*p));
p = malloc(sizeof(*p));
info->tmRock = (char *)p;
p->fid = fid;
p->mountId = config.mountId = time(0);

View File

@ -111,7 +111,7 @@ main(argc, argv)
if (argc < 2)
goto usage;
files = (char **)malloc(argc * sizeof(char *));
files = malloc(argc * sizeof(char *));
nFiles = 0;
for (i = 1; i < argc; i++) {
if (argv[i][0] == '-') {
@ -213,7 +213,7 @@ PerformDumpTest(TestInfo * tip)
int i, past, code;
struct timeval tp;
bufferBlock = (struct BufferBlock *)malloc(sizeof(struct BufferBlock));
bufferBlock = malloc(sizeof(struct BufferBlock));
info.structVersion = BUTM_MAJORVERSION;
if (code = butm_file_Instantiate(&info, tip->tc_Infop)) {