#include <afs/budb_prototypes.h>
#include <afs/butc.h>
#include <afs/bubasics.h> /* PA */
+#include <afs/afsint.h>
#include <afs/volser.h>
#include <afs/voldefs.h> /* PA */
#include <afs/vldbint.h> /* PA */
}
/* No server entry added. Add one */
if (!(*ss)) {
- *ss = (struct serversort *)malloc(sizeof(struct serversort));
+ *ss = calloc(1, sizeof(struct serversort));
if (!(*ss)) {
afs_com_err(whoami, BC_NOMEM, NULL);
*ss = 0;
return (BC_NOMEM);
}
- memset(*ss, 0, sizeof(struct serversort));
(*ss)->ipaddr = server;
(*ss)->next = *serverlist;
*serverlist = *ss;
}
/* No partition entry added. Add one */
if (!(*ps)) {
- *ps = (struct partitionsort *)malloc(sizeof(struct partitionsort));
+ *ps = calloc(1, sizeof(struct partitionsort));
if (!(*ps)) {
afs_com_err(whoami, BC_NOMEM, NULL);
free(*ss);
*ss = 0;
return (BC_NOMEM);
}
- memset(*ps, 0, sizeof(struct partitionsort));
(*ps)->part = partition;
(*ps)->next = (*ss)->partitions;
(*ss)->partitions = *ps;
if (add) {
/* Allocate a volume dump structure and its name */
- tvd = (struct bc_volumeDump *)
- malloc(sizeof(struct bc_volumeDump));
+ tvd = calloc(1, sizeof(struct bc_volumeDump));
if (!tvd) {
afs_com_err(whoami, BC_NOMEM, NULL);
ERROR(BC_NOMEM);
}
- memset(tvd, 0, sizeof(*tvd));
- 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);
/* Free memory allocated during VL call */
if (bulkentries.nbulkentries_val) {
- free((char *)bulkentries.nbulkentries_val);
+ free(bulkentries.nbulkentries_val);
bulkentries.nbulkentries_val = 0;
entries = 0;
}
error_exit:
if (bulkentries.nbulkentries_val) {
- free((char *)bulkentries.nbulkentries_val);
+ free(bulkentries.nbulkentries_val);
}
return (code);
} /*EvalVolumeSet2 */
}
total++;
- tvd = (struct bc_volumeDump *)
- malloc(sizeof(struct bc_volumeDump));
+ tvd = calloc(1, sizeof(struct bc_volumeDump));
if (!tvd) {
afs_com_err(whoami, BC_NOMEM, NULL);
return (BC_NOMEM);
}
- memset(tvd, 0, sizeof(*tvd));
- 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);
char *
bc_CopyString(char *astring)
{
- afs_int32 tlen;
char *tp;
if (!astring)
return (NULL); /* propagate null strings easily */
- tlen = strlen(astring);
- tp = (char *)malloc(tlen + 1); /* don't forget the terminating null */
+ tp = strdup(astring);
if (!tp) {
afs_com_err(whoami, BC_NOMEM, NULL);
return (tp);
}
- strcpy(tp, astring);
return tp;
}
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);
{
int i;
int usefulJobRunning = 1;
+ int printWaiting = 1;
extern dlqlinkT statusHead;
- afs_com_err(whoami, 0, "waiting for job termination");
-
while (usefulJobRunning) {
usefulJobRunning = (dlqEmpty(&statusHead) ? 0 : 1);
if (dispatchLock.excl_locked)
}
/* Wait 5 seconds and check again */
- if (usefulJobRunning)
+ if (usefulJobRunning) {
+ if (printWaiting) {
+ afs_com_err(whoami, 0, "waiting for job termination");
+ printWaiting = 0;
+ }
IOMGR_Sleep(5);
+ }
}
return (lastTaskCode);
}
}
/* specified other destination host */
- if (as->parms[0].items) {
- tp = as->parms[0].items->data;
- if (bc_ParseHost(tp, &destServ)) {
- afs_com_err(whoami, 0, "Failed to locate destination host '%s'", tp);
- return -1;
- }
+ tp = as->parms[0].items->data;
+ if (bc_ParseHost(tp, &destServ)) {
+ afs_com_err(whoami, 0, "Failed to locate destination host '%s'", tp);
+ return -1;
}
/* specified other destination partition */
- if (as->parms[1].items) {
- tp = as->parms[1].items->data;
- if (bc_GetPartitionID(tp, &destPartition)) {
- afs_com_err(whoami, 0, "Can't parse destination partition '%s'", tp);
- return -1;
- }
+ tp = as->parms[1].items->data;
+ if (bc_GetPartitionID(tp, &destPartition)) {
+ afs_com_err(whoami, 0, "Can't parse destination partition '%s'", tp);
+ return -1;
}
for (ti = as->parms[2].items; ti; ti = ti->next) {
/* build list of volume items */
- tvol = (struct bc_volumeDump *)malloc(sizeof(struct bc_volumeDump));
+ tvol = calloc(1, sizeof(struct bc_volumeDump));
if (!tvol) {
afs_com_err(whoami, BC_NOMEM, NULL);
return BC_NOMEM;
}
- memset(tvol, 0, 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;
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;
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;
}
/* Allocate a volumeDump structure and link it in */
- tvol =
- (struct bc_volumeDump *)malloc(sizeof(struct bc_volumeDump));
- memset(tvol, 0, sizeof(struct bc_volumeDump));
+ 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;
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;
/* 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;
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;
* global variables so this can take place in main.
*/
if (loadfile) {
- loadFile = (char *)malloc(strlen(as->parms[6].items->data) + 1);
+ loadFile = strdup(as->parms[6].items->data);
if (!loadFile) {
afs_com_err(whoami, BC_NOMEM, NULL);
return BC_NOMEM;
}
- strcpy(loadFile, as->parms[6].items->data);
return 0;
}
havetime = 1;
}
- port = (as->parms[3].items ? getPortOffset(as->parms[3].items->data) : 0); /* -port */
+ port = (as->parms[3].items ? getPortOffset(as->parms[3].items->data) : 0); /* -portoffset */
if (as->parms[5].items) /* -dbonly */
port = -1;
for (i = 0; i < numEntries; i++) { /*f */
struct dumpedVol *insPtr, **prevPtr;
- tempPtr =
- (struct dumpedVol *)malloc(sizeof(struct dumpedVol));
+ tempPtr = calloc(1, sizeof(struct dumpedVol));
if (!tempPtr)
ERROR(BC_NOMEM);
- memset(tempPtr, 0, sizeof(*tempPtr));
tempPtr->incTime = volumeEntry[i].clone;
tempPtr->dumpID = volumeEntry[i].dump;
strncpy(tempPtr->tapeName, volumeEntry[i].tape,
/* now get the list of tapes */
for (tapeNumber = dumpEntry.tapes.b; tapeNumber <= dumpEntry.tapes.maxTapes; tapeNumber++) { /*f */
- tapeLinkPtr = (struct tapeLink *)malloc(sizeof(struct tapeLink));
+ tapeLinkPtr = calloc(1, sizeof(struct tapeLink));
if (!tapeLinkPtr) {
afs_com_err(whoami, BC_NOMEM, NULL);
ERROR(BC_NOMEM);
}
- memset(tapeLinkPtr, 0, sizeof(*tapeLinkPtr));
code = bcdb_FindTapeSeq(dumpid, tapeNumber, &tapeLinkPtr->tapeEntry);
if (code) {
code = 0;
for (i = 0; i < vl.budb_volumeList_len; i++) {
link = &tapeLinkPtr->firstVolume;
- volumeLinkPtr =
- (struct volumeLink *)malloc(sizeof(struct volumeLink));
+ volumeLinkPtr = calloc(1, sizeof(struct volumeLink));
if (!volumeLinkPtr) {
afs_com_err(whoami, BC_NOMEM, NULL);
ERROR(BC_NOMEM);
}
- memset(volumeLinkPtr, 0, sizeof(*volumeLinkPtr));
memcpy(&volumeLinkPtr->volumeEntry,
&vl.budb_volumeList_val[i],