- Convert a bunch of macros to the actual function they're calling. These

include:

          UM_ALLOC        -> calloc, malloc
          UM_FREE         -> free
          UM_COPY         -> bcopy
          UM_ZERO         -> bzero

    This is the first step towards removing these macros.
This commit is contained in:
Andrew R. Reiter 2002-05-16 23:57:37 +00:00
parent 9e49944008
commit 1effc132ba
13 changed files with 187 additions and 267 deletions

View File

@ -896,7 +896,7 @@ scsp_ca_act_10(dcsp, p)
HARP_CANCEL(&rxp->sr_t);
UNLINK(rxp, Scsp_csu_rexmt,
dcsp->sd_csu_rexmt, sr_next);
UM_FREE(rxp);
free(rxp);
}
break;
@ -964,12 +964,10 @@ scsp_ca_act_11(dcsp, p)
* Add the entry if we don't have it already
*/
if (!csep) {
csep = (Scsp_cse *)UM_ALLOC(
sizeof(Scsp_cse));
if (!csep)
csep = calloc(1, sizeof(Scsp_cse));
if (csep == NULL)
scsp_mem_err("scsp_ca_act_11: sizeof(Scsp_cse)");
UM_ZERO(csep, sizeof(Scsp_cse));
csep->sc_key = csap->key;
SCSP_ADD(dcsp->sd_server, csep);
}
@ -987,7 +985,7 @@ scsp_ca_act_11(dcsp, p)
*/
if (csep) {
SCSP_DELETE(dcsp->sd_server, csep);
UM_FREE(csep);
free(csep);
}
SCSP_FREE_CSA(csap);
@ -1060,7 +1058,7 @@ scsp_ca_act_13(dcsp, p)
*/
csap = rxp->sr_csa;
UNLINK(rxp, Scsp_csu_rexmt, dcsp->sd_csu_rexmt, sr_next);
UM_FREE(rxp);
free(rxp);
/*
* Increment the transmission count for the CSAs in the request
@ -1125,11 +1123,9 @@ scsp_ca_act_14(dcsp, p)
/*
* Get memory for a new entry
*/
csep = (Scsp_cse *)UM_ALLOC(sizeof(Scsp_cse));
if (!csep) {
csep = calloc(1, sizeof(Scsp_cse));
if (csep == NULL)
scsp_mem_err("scsp_ca_act_14: sizeof(Scsp_cse)");
}
UM_ZERO(csep, sizeof(Scsp_cse));
/*
* Fill out the new cache entry
@ -1168,12 +1164,12 @@ scsp_ca_act_14(dcsp, p)
* The null flag is set--delete the entry
*/
SCSP_DELETE(dcsp->sd_server, csep);
UM_FREE(csep);
free(csep);
if (csep1) {
UNLINK(csep1, Scsp_cse,
dcsp->sd_ca_csas,
sc_next);
UM_FREE(csep1);
free(csep1);
}
} else {
/*
@ -1418,12 +1414,9 @@ scsp_ca_act_19(dcsp, p)
/*
* Create a CSAS from the client's update
*/
csap = (Scsp_csa *)UM_ALLOC(sizeof(Scsp_csa));
if (!csap) {
csap = calloc(1, sizeof(Scsp_csa));
if (csap == NULL)
scsp_mem_err("scsp_ca_act_19: sizeof(Scsp_csa)");
}
UM_ZERO(csap, sizeof(Scsp_csa));
csap->hops = 1;
switch (dcsp->sd_server->ss_pid) {
case SCSP_PROTO_ATMARP:

View File

@ -172,11 +172,9 @@ start_dcs()
/*
* Allocate a DCS block
*/
dcsp = (Scsp_dcs *)UM_ALLOC(sizeof(Scsp_dcs));
if (!dcsp) {
dcsp = calloc(1, sizeof(Scsp_dcs));
if (dcsp == NULL)
scsp_mem_err("start_dcs: sizeof(Scsp_dcs)");
}
UM_ZERO(dcsp, sizeof(Scsp_dcs));
/*
* Fill out DCS links and default values
@ -293,9 +291,9 @@ set_dcs_addr(ap, sap)
/*
* Initialize
*/
UM_ZERO(&addr, sizeof(addr));
bzero(&addr, sizeof(addr));
addr.address_format = T_ATM_ABSENT;
UM_ZERO(&subaddr, sizeof(subaddr));
bzero(&subaddr, sizeof(subaddr));
subaddr.address_format = T_ATM_ABSENT;
/*
@ -782,7 +780,7 @@ set_dcs_id(name)
* Set the ID in the DCS block
*/
dcsp->sd_dcsid.id_len = ssp->ss_id_len;
UM_COPY(&ip_addr->sin_addr, dcsp->sd_dcsid.id, ssp->ss_id_len);
bcopy(&ip_addr->sin_addr, dcsp->sd_dcsid.id, ssp->ss_id_len);
return(0);
}
@ -994,7 +992,7 @@ start_server(name)
next_cse = csep->sc_next;
UNLINK(csep, Scsp_cse, ssp->ss_cache[i],
sc_next);
UM_FREE(csep);
free(csep);
}
}
@ -1009,12 +1007,11 @@ start_server(name)
/*
* Get a new server entry
*/
ssp = (Scsp_server *)UM_ALLOC(sizeof(Scsp_server));
if (!ssp) {
ssp = calloc(1, sizeof(Scsp_server));
if (ssp == NULL) {
scsp_log(LOG_ERR, "unable to allocate server entry");
exit(1);
}
UM_ZERO(ssp, sizeof(Scsp_server));
ssp->ss_sock = -1;
ssp->ss_dcs_lsock = -1;

View File

@ -406,8 +406,8 @@ yylex()
if (class_tbl['A'] != CHAR_HEX_DIGIT)
init_class_tbl(class_tbl);
state = TS_INIT;
UM_ZERO(token_buffer, sizeof(token_buffer));
UM_ZERO(&yylval, sizeof(yylval));
bzero(token_buffer, sizeof(token_buffer));
bzero(&yylval, sizeof(yylval));
/*
* Handle a character at a time until a token is built
@ -463,7 +463,7 @@ yylex()
/*
* Clear the token buffer
*/
UM_ZERO(token_buffer, sizeof(token_buffer));
bzero(token_buffer, sizeof(token_buffer));
break;
case 5:
/*

View File

@ -139,7 +139,7 @@ server_stmt: TOK_SERVER TOK_NAME
int rc;
rc = start_server($2);
UM_FREE($2);
free($2);
if (rc)
return(rc);
}
@ -167,7 +167,7 @@ server_spec: /* Nothing */
* Configure the network interface
*/
rc = set_intf($2);
UM_FREE($2);
free($2);
if (rc)
return(rc);
}
@ -234,7 +234,7 @@ dcs_spec: /* Nothing */
* Set DCS address
*/
rc = set_dcs_addr($2, (char *)0);
UM_FREE($2);
free($2);
if (rc)
return(rc);
}
@ -246,8 +246,8 @@ dcs_spec: /* Nothing */
* Set DCS address and subaddress
*/
rc = set_dcs_addr($2, $3);
UM_FREE($2);
UM_FREE($3);
free($2);
free($3);
if (rc)
return(rc);
}
@ -336,7 +336,7 @@ dcs_spec: /* Nothing */
* Configure the DCS ID
*/
rc = set_dcs_id($2);
UM_FREE($2);
free($2);
if (rc)
return(rc);
}
@ -359,7 +359,7 @@ log_spec: /* Nothing */
int rc;
rc = set_log_file($2);
UM_FREE($2);
free($2);
if (rc)
return(rc);
}

View File

@ -419,16 +419,12 @@ scsp_client_act_07(dcsp, msg, cmsg)
/*
* Allocate memory for a CSA record
*/
csap = (Scsp_csa *)UM_ALLOC(sizeof(Scsp_csa));
if (!csap) {
csap = calloc(1, sizeof(Scsp_csa));
if (csap == NULL)
scsp_mem_err("scsp_client_act_07: sizeof(Scsp_csa)");
}
acp = (Scsp_atmarp_csa *)UM_ALLOC(sizeof(Scsp_atmarp_csa));
if (!acp) {
acp = calloc(1, sizeof(Scsp_atmarp_csa));
if (acp == NULL)
scsp_mem_err("scsp_client_act_07: sizeof(Scsp_atmarp_csa)");
}
UM_ZERO(csap, sizeof(Scsp_csa));
UM_ZERO(acp, sizeof(Scsp_atmarp_csa));
/*
* Build a CSA record from the server's message
@ -522,10 +518,9 @@ scsp_client_act_09(dcsp, msg, cmsg)
/*
* Get memory for a Solicit Ind
*/
csip = (Scsp_if_msg *)UM_ALLOC(sizeof(Scsp_if_msg));
if (!csip) {
csip = calloc(1, sizeof(Scsp_if_msg));
if (csip == NULL)
scsp_mem_err("scsp_client_act_09: sizeof(Scsp_if_msg)");
}
/*
* Loop through list of CSAs
@ -535,7 +530,7 @@ scsp_client_act_09(dcsp, msg, cmsg)
/*
* Fill out the Solicit Indication
*/
UM_ZERO(csip, sizeof(Scsp_if_msg));
bzero(csip, sizeof(Scsp_if_msg));
csip->si_type = SCSP_SOLICIT_IND;
csip->si_proto = dcsp->sd_server->ss_pid;
csip->si_tok = (u_long)dcsp;
@ -555,8 +550,7 @@ scsp_client_act_09(dcsp, msg, cmsg)
rrc = rc;
}
}
UM_FREE(csip);
free(csip);
return(rrc);
}
@ -591,10 +585,9 @@ scsp_client_act_10(dcsp, msg, cmsg)
/*
* Get memory for a Cache Update Ind
*/
cuip = (Scsp_if_msg *)UM_ALLOC(sizeof(Scsp_if_msg));
if (!cuip) {
cuip = malloc(sizeof(Scsp_if_msg));
if (cuip == NULL)
scsp_mem_err("scsp_client_act_10: sizeof(Scsp_if_msg)");
}
/*
* Loop through CSAs in message
@ -608,7 +601,7 @@ scsp_client_act_10(dcsp, msg, cmsg)
/*
* Fill out the Cache Update Ind
*/
UM_ZERO(cuip, sizeof(Scsp_if_msg));
bzero(cuip, sizeof(Scsp_if_msg));
cuip->si_type = SCSP_UPDATE_IND;
cuip->si_proto = dcsp->sd_server->ss_pid;
cuip->si_tok = (u_long)dcsp;
@ -639,7 +632,6 @@ scsp_client_act_10(dcsp, msg, cmsg)
rrc = rc;
}
}
UM_FREE(cuip);
free(cuip);
return(rrc);
}

View File

@ -134,7 +134,7 @@ scsp_free_ca(cap)
/*
* Free the CA message structure
*/
UM_FREE(cap);
free(cap);
}
@ -172,7 +172,7 @@ scsp_free_csu(csup)
/*
* Free the CSU message structure
*/
UM_FREE(csup);
free(csup);
}
@ -199,7 +199,7 @@ scsp_free_hello(hp)
/*
* Free the Hello message structure
*/
UM_FREE(hp);
free(hp);
}
@ -247,13 +247,13 @@ scsp_free_msg(msg)
*/
for (exp = msg->sc_ext; exp; exp = nexp) {
nexp = exp->next;
UM_FREE(exp);
free(exp);
}
/*
* Free the message structure
*/
UM_FREE(msg);
free(msg);
}
@ -293,7 +293,7 @@ scsp_parse_id(buff, id_len, idp)
/*
* Get the ID
*/
UM_COPY(buff, idp->id, id_len);
bcopy(buff, idp->id, id_len);
/*
* Return the ID length
@ -408,11 +408,9 @@ scsp_parse_ext(buff, pdu_len, expp)
*/
sep = (struct scsp_next *)buff;
len = sizeof(Scsp_ext) + ntohs(sep->se_len);
exp = (Scsp_ext *)UM_ALLOC(len);
if (!exp) {
exp = calloc(1, len);
if (exp == NULL)
goto ext_invalid;
}
UM_ZERO(exp, len);
/*
* Get the type
@ -428,7 +426,7 @@ scsp_parse_ext(buff, pdu_len, expp)
* Get the value
*/
if (exp->len > 0) {
UM_COPY((caddr_t)sep + sizeof(struct scsp_next),
bcopy((caddr_t)sep + sizeof(struct scsp_next),
(caddr_t)exp + sizeof(Scsp_ext),
exp->len);
}
@ -442,7 +440,7 @@ scsp_parse_ext(buff, pdu_len, expp)
ext_invalid:
if (exp) {
UM_FREE(exp);
free(exp);
}
return(0);
}
@ -488,11 +486,9 @@ scsp_parse_csa(buff, pdu_len, csapp)
len = sizeof(Scsp_csa) + ntohs(scp->scs_len) -
sizeof(struct scsp_ncsa) - scp->scs_ck_len -
scp->scs_oid_len;
csap = (Scsp_csa *)UM_ALLOC(len);
if (!csap) {
csap = calloc(1, len);
if (csap == NULL)
goto csa_invalid;
}
UM_ZERO(csap, len);
/*
* Get the hop count
@ -518,7 +514,7 @@ scsp_parse_csa(buff, pdu_len, csapp)
}
csap->key.key_len = scp->scs_ck_len;
idp = (char *) ((caddr_t)scp + sizeof(struct scsp_ncsa));
UM_COPY(idp, csap->key.key, scp->scs_ck_len);
bcopy(idp, csap->key.key, scp->scs_ck_len);
/*
* Get the originator ID
@ -583,11 +579,9 @@ scsp_parse_ca(buff, pdu_len, capp)
* Get memory for the returned structure
*/
scap = (struct scsp_nca *)buff;
cap = (Scsp_ca *)UM_ALLOC(sizeof(Scsp_ca));
if (!cap) {
cap = calloc(1, sizeof(Scsp_ca));
if (cap == NULL)
goto ca_invalid;
}
UM_ZERO(cap, sizeof(Scsp_ca));
/*
* Get the sequence number
@ -672,11 +666,9 @@ scsp_parse_atmarp(buff, pdu_len, acspp)
/*
* Get memory for the returned structure
*/
acsp = (Scsp_atmarp_csa *)UM_ALLOC(sizeof(Scsp_atmarp_csa));
if (!acsp) {
acsp = calloc(1, sizeof(Scsp_atmarp_csa));
if (acsp == NULL)
goto acs_invalid;
}
UM_ZERO(acsp, sizeof(Scsp_atmarp_csa));
/*
* Get state code
@ -702,7 +694,7 @@ scsp_parse_atmarp(buff, pdu_len, acspp)
acsp->sa_sha.address_length = len;
if (pdu_len < proc_len + len)
goto acs_invalid;
UM_COPY(&buff[proc_len], (char *)acsp->sa_sha.address,
bcopy(&buff[proc_len], (char *)acsp->sa_sha.address,
len);
proc_len += len;
}
@ -720,7 +712,7 @@ scsp_parse_atmarp(buff, pdu_len, acspp)
acsp->sa_ssa.address_length = len;
if (pdu_len < proc_len + len)
goto acs_invalid;
UM_COPY(&buff[proc_len], (char *)acsp->sa_ssa.address,
bcopy(&buff[proc_len], (char *)acsp->sa_ssa.address,
len);
proc_len += len;
}
@ -733,7 +725,7 @@ scsp_parse_atmarp(buff, pdu_len, acspp)
goto acs_invalid;
if (pdu_len < proc_len + len)
goto acs_invalid;
UM_COPY(&buff[proc_len], (char *)&acsp->sa_spa, len);
bcopy(&buff[proc_len], (char *)&acsp->sa_spa, len);
proc_len += len;
} else {
acsp->sa_spa.s_addr = 0;
@ -757,7 +749,7 @@ scsp_parse_atmarp(buff, pdu_len, acspp)
acsp->sa_tha.address_length = len;
if (pdu_len < proc_len + len)
goto acs_invalid;
UM_COPY(&buff[proc_len], (char *)acsp->sa_tha.address,
bcopy(&buff[proc_len], (char *)acsp->sa_tha.address,
len);
proc_len += len;
}
@ -775,7 +767,7 @@ scsp_parse_atmarp(buff, pdu_len, acspp)
acsp->sa_tsa.address_length = len;
if (pdu_len < proc_len + len)
goto acs_invalid;
UM_COPY(&buff[proc_len], (char *)acsp->sa_tsa.address,
bcopy(&buff[proc_len], (char *)acsp->sa_tsa.address,
len);
proc_len += len;
}
@ -788,7 +780,7 @@ scsp_parse_atmarp(buff, pdu_len, acspp)
goto acs_invalid;
if (pdu_len < proc_len + len)
goto acs_invalid;
UM_COPY(&buff[proc_len], (char *)&acsp->sa_tpa, len);
bcopy(&buff[proc_len], (char *)&acsp->sa_tpa, len);
proc_len += len;
} else {
acsp->sa_tpa.s_addr = 0;
@ -805,7 +797,7 @@ scsp_parse_atmarp(buff, pdu_len, acspp)
acs_invalid:
if (acsp)
UM_FREE(acsp);
free(acsp);
return(0);
}
@ -838,11 +830,9 @@ scsp_parse_csu(buff, pdu_len, csupp)
/*
* Get memory for the returned structure
*/
csup = (Scsp_csu_msg *)UM_ALLOC(sizeof(Scsp_csu_msg));
if (!csup) {
csup = calloc(1, sizeof(Scsp_csu_msg));
if (csup == NULL)
goto csu_invalid;
}
UM_ZERO(csup, sizeof(Scsp_csu_msg));
/*
* Process the mandatory common part of the message
@ -906,11 +896,9 @@ scsp_parse_hello(buff, pdu_len, hpp)
/*
* Get memory for the returned structure
*/
hp = (Scsp_hello *)UM_ALLOC(sizeof(Scsp_hello));
if (!hp) {
hp = calloc(1, sizeof(Scsp_hello));
if (hp == NULL)
goto hello_invalid;
}
UM_ZERO(hp, sizeof(Scsp_hello));
/*
* Get the hello interval
@ -946,16 +934,14 @@ scsp_parse_hello(buff, pdu_len, hpp)
for (i = 0, ridpp = &hp->hello_mcp.rid.next;
i < hp->hello_mcp.rec_cnt;
i++, ridpp = &idp->next) {
idp = (Scsp_id *)UM_ALLOC(sizeof(Scsp_id));
if (!idp) {
idp = calloc(1, sizeof(Scsp_id));
if (idp == NULL)
goto hello_invalid;
}
UM_ZERO(idp, sizeof(Scsp_id));
len = scsp_parse_id(buff,
hp->hello_mcp.rid.id_len,
idp);
if (len == 0) {
UM_FREE(idp);
free(idp);
goto hello_invalid;
}
buff += len;
@ -1012,11 +998,9 @@ scsp_parse_msg(buff, pdu_len)
/*
* Allocate storage for the message
*/
msg = (Scsp_msg *)UM_ALLOC(sizeof(Scsp_msg));
if (!msg) {
msg = calloc(1, sizeof(Scsp_msg));
if (msg == NULL)
goto ignore;
}
UM_ZERO(msg, sizeof(Scsp_msg));
/*
* Decode the fixed header

View File

@ -153,7 +153,7 @@ scsp_open_trace()
/*
* Build a file name
*/
UM_ZERO(fname, sizeof(fname));
bzero(fname, sizeof(fname));
sprintf(fname, "/tmp/scspd.%d.trace", getpid());
/*
@ -230,9 +230,8 @@ scsp_trace_msg(dcsp, msg, dir)
/*
* Copy the remote IP address into a struct in_addr
*/
UM_COPY(dcsp->sd_dcsid.id, &addr.s_addr,
sizeof(struct in_addr));
bcopy(dcsp->sd_dcsid.id, &addr.s_addr, sizeof(struct in_addr));
/*
* Write the message to the trace file, if it's open
*/

View File

@ -105,7 +105,7 @@ scsp_ca_csas_setup(dcsp, cap)
LINK2TAIL(csap, Scsp_csa, cap->ca_csa_rec, next);
len += csas_len;
UNLINK(csep, Scsp_cse, dcsp->sd_ca_csas, sc_next);
UM_FREE(csep);
free(csep);
cap->ca_mcp.rec_cnt++;
}
}
@ -213,16 +213,12 @@ scsp_send_ca(dcsp)
/*
* Get memory for a CA message
*/
ca_msg = (Scsp_msg *)UM_ALLOC(sizeof(Scsp_msg));
if (!ca_msg) {
ca_msg = calloc(1, sizeof(Scsp_msg));
if (ca_msg == NULL)
scsp_mem_err("scsp_send_ca: sizeof(Scsp_msg)");
}
cap = (Scsp_ca *)UM_ALLOC(sizeof(Scsp_ca));
if (!cap) {
cap = calloc(1, sizeof(Scsp_ca));
if (cap == NULL)
scsp_mem_err("scsp_send_ca: sizeof(Scsp_ca)");
}
UM_ZERO(ca_msg, sizeof(Scsp_msg));
UM_ZERO(cap, sizeof(Scsp_ca));
/*
* Fill out constant fields
@ -308,16 +304,12 @@ scsp_send_csus(dcsp)
/*
* Get memory for a CSUS message
*/
csus_msg = (Scsp_msg *)UM_ALLOC(sizeof(Scsp_msg));
if (!csus_msg) {
csus_msg = calloc(1, sizeof(Scsp_msg));
if (csus_msg == NULL)
scsp_mem_err("scsp_send_csus: sizeof(Scsp_msg)");
}
csusp = (Scsp_csu_msg *)UM_ALLOC(sizeof(Scsp_csu_msg));
if (!csusp) {
csusp = calloc(1, sizeof(Scsp_csu_msg));
if (csusp == NULL)
scsp_mem_err("scsp_send_csus: sizeof(Scsp_csu_msg)");
}
UM_ZERO(csus_msg, sizeof(Scsp_msg));
UM_ZERO(csusp, sizeof(Scsp_csu_msg));
/*
* Fill out constant fields
@ -407,25 +399,19 @@ scsp_send_csu_req(dcsp, csap)
/*
* Get memory for a CSU Req message
*/
csu_msg = (Scsp_msg *)UM_ALLOC(sizeof(Scsp_msg));
if (!csu_msg) {
csu_msg = calloc(1, sizeof(Scsp_msg));
if (csu_msg == NULL)
scsp_mem_err("scsp_send_csu_req: sizeof(Scsp_msg)");
}
csup = (Scsp_csu_msg *)UM_ALLOC(sizeof(Scsp_csu_msg));
if (!csup) {
csup = calloc(1, sizeof(Scsp_csu_msg));
if (csup == NULL)
scsp_mem_err("scsp_send_csu_req: sizeof(Scsp_csu_msg)");
}
UM_ZERO(csu_msg, sizeof(Scsp_msg));
UM_ZERO(csup, sizeof(Scsp_csu_msg));
/*
* Get memory for a CSU Req retransmission queue entry
*/
rxp = (Scsp_csu_rexmt *)UM_ALLOC(sizeof(Scsp_csu_rexmt));
if (!rxp) {
rxp = calloc(1, sizeof(Scsp_csu_rexmt));
if (rxp == NULL)
scsp_mem_err("scsp_send_csu_req: sizeof(Scsp_csu_rexmt)");
}
UM_ZERO(rxp, sizeof(Scsp_csu_rexmt));
/*
* Fill out constant fields
@ -453,8 +439,8 @@ scsp_send_csu_req(dcsp, csap)
scsp_free_msg(csu_msg);
return(rc);
}
UM_FREE(csu_msg);
UM_FREE(csup);
free(csu_msg);
free(csup);
/*
* Save the CSA entries on the CSU Request retransmission
@ -502,16 +488,12 @@ scsp_send_csu_reply(dcsp, csap)
/*
* Get memory for a CSU Reply message
*/
csu_msg = (Scsp_msg *)UM_ALLOC(sizeof(Scsp_msg));
if (!csu_msg) {
csu_msg = calloc(1, sizeof(Scsp_msg));
if (csu_msg == NULL)
scsp_mem_err("scsp_send_csu_reply: sizeof(Scsp_msg)");
}
csup = (Scsp_csu_msg *)UM_ALLOC(sizeof(Scsp_csu_msg));
if (!csup) {
csup = calloc(1, sizeof(Scsp_csu_msg));
if (csup == NULL)
scsp_mem_err("scsp_send_csu_reply: sizeof(Scsp_csu_msg)");
}
UM_ZERO(csu_msg, sizeof(Scsp_msg));
UM_ZERO(csup, sizeof(Scsp_csu_msg));
/*
* Fill out constant fields
@ -535,7 +517,7 @@ scsp_send_csu_reply(dcsp, csap)
*/
case SCSP_PROTO_ATMARP:
if (csap1->atmarp_data) {
UM_FREE(csap1->atmarp_data);
free(csap1->atmarp_data);
csap1->atmarp_data =
(Scsp_atmarp_csa *)0;
}
@ -576,16 +558,12 @@ scsp_send_hello(dcsp)
/*
* Get memory for a Hello message
*/
hello = (Scsp_msg *)UM_ALLOC(sizeof(Scsp_msg));
if (!hello) {
hello = calloc(1, sizeof(Scsp_msg));
if (hello == NULL)
scsp_mem_err("scsp_send_hello: sizeof(Scsp_msg)");
}
UM_ZERO(hello, sizeof(Scsp_msg));
hp = (Scsp_hello *)UM_ALLOC(sizeof(Scsp_hello));
if (!hp) {
hp = calloc(1, sizeof(Scsp_hello));
if (hp == NULL)
scsp_mem_err("scsp_send_hello: sizeof(Scsp_hello)");
}
UM_ZERO(hp, sizeof(Scsp_hello));
/*
* Set up the Hello message

View File

@ -357,10 +357,9 @@ typedef struct scsp_csa Scsp_csa;
*/
#define SCSP_FREE_CSA(c) \
{ \
if ((c)->atmarp_data) { \
UM_FREE((c)->atmarp_data); \
} \
UM_FREE((c)); \
if ((c)->atmarp_data) \
free((c)->atmarp_data); \
free((c)); \
}

View File

@ -91,7 +91,7 @@ put_long(l, cp)
* Convert to network order and copy to output buffer
*/
nl = htonl(l);
UM_COPY(&nl, cp, sizeof(u_long));
bcopy(&nl, cp, sizeof(u_long));
}
@ -115,7 +115,7 @@ scsp_format_id(idp, buff)
/*
* Copy the ID
*/
UM_COPY(idp->id, buff, idp->id_len);
bcopy(idp->id, buff, idp->id_len);
/*
* Return the ID length
@ -240,7 +240,7 @@ scsp_format_ext(exp, buff, blen)
*/
if (exp->len > 0) {
buff += sizeof(struct scsp_next);
UM_COPY((caddr_t)exp + sizeof(Scsp_ext),
bcopy((caddr_t)exp + sizeof(Scsp_ext),
buff,
exp->len);
}
@ -326,7 +326,7 @@ scsp_format_atmarp(acsp, buff)
sanp->sa_shtl = ARP_TL_NSAPA | (len & ARP_TL_LMASK);
/* sa_sha */
UM_COPY(acsp->sa_sha.address, cp, len);
bcopy(acsp->sa_sha.address, cp, len);
cp += len;
sanp->sa_sstl = 0;
@ -336,7 +336,7 @@ scsp_format_atmarp(acsp, buff)
sanp->sa_shtl = ARP_TL_E164 | (len & ARP_TL_LMASK);
/* sa_sha */
UM_COPY(acsp->sa_sha.address, cp, len);
bcopy(acsp->sa_sha.address, cp, len);
cp += len;
if (acsp->sa_ssa.address_format == T_ATM_ENDSYS_ADDR) {
@ -345,7 +345,7 @@ scsp_format_atmarp(acsp, buff)
(len & ARP_TL_LMASK);
/* sa_ssa */
UM_COPY(acsp->sa_ssa.address, cp, len);
bcopy(acsp->sa_ssa.address, cp, len);
cp += len;
} else
sanp->sa_sstl = 0;
@ -363,7 +363,7 @@ scsp_format_atmarp(acsp, buff)
/* sa_spa */
if (acsp->sa_spa.s_addr != 0) {
sanp->sa_spln = sizeof(struct in_addr);
UM_COPY(&acsp->sa_spa, cp, sizeof(struct in_addr));
bcopy(&acsp->sa_spa, cp, sizeof(struct in_addr));
cp += sizeof(struct in_addr);
}
@ -374,7 +374,7 @@ scsp_format_atmarp(acsp, buff)
sanp->sa_thtl = ARP_TL_NSAPA | (len & ARP_TL_LMASK);
/* sa_tha */
UM_COPY(acsp->sa_tha.address, cp, len);
bcopy(acsp->sa_tha.address, cp, len);
cp += len;
sanp->sa_tstl = 0;
@ -384,7 +384,7 @@ scsp_format_atmarp(acsp, buff)
sanp->sa_thtl = ARP_TL_E164 | (len & ARP_TL_LMASK);
/* sa_tha */
UM_COPY(acsp->sa_tha.address, cp, len);
bcopy(acsp->sa_tha.address, cp, len);
cp += len;
if (acsp->sa_tsa.address_format == T_ATM_ENDSYS_ADDR) {
@ -393,7 +393,7 @@ scsp_format_atmarp(acsp, buff)
(len & ARP_TL_LMASK);
/* sa_tsa */
UM_COPY(acsp->sa_tsa.address, cp, len);
bcopy(acsp->sa_tsa.address, cp, len);
cp += len;
} else
sanp->sa_tstl = 0;
@ -407,7 +407,7 @@ scsp_format_atmarp(acsp, buff)
/* sa_tpa */
if (acsp->sa_tpa.s_addr != 0) {
sanp->sa_tpln = sizeof(struct in_addr);
UM_COPY(&acsp->sa_tpa, cp, sizeof(struct in_addr));
bcopy(&acsp->sa_tpa, cp, sizeof(struct in_addr));
}
return(pkt_len);
@ -459,7 +459,7 @@ scsp_format_csa(csap, buff)
*/
scp->scs_ck_len = csap->key.key_len;
odp = buff + sizeof(struct scsp_ncsa);
UM_COPY(csap->key.key, odp, scp->scs_ck_len);
bcopy(csap->key.key, odp, scp->scs_ck_len);
/*
* Set the originator ID
@ -732,11 +732,9 @@ scsp_format_msg(dcsp, msg, bpp)
* Allocate a buffer for the message
*/
buff_len = dcsp->sd_server->ss_mtu;
buff = (char *)UM_ALLOC(buff_len);
if (!buff) {
buff = calloc(1, buff_len);
if (buff == NULL)
scsp_mem_err("scsp_format_msg: dcsp->sd_server->ss_mtu");
}
UM_ZERO(buff, buff_len);
*bpp = buff;
/*
@ -767,11 +765,9 @@ scsp_format_msg(dcsp, msg, bpp)
* Get a buffer for the extensions
*/
e_buff_len = 1024;
e_buff = (char *)UM_ALLOC(e_buff_len);
if (!buff) {
e_buff = calloc(1, e_buff_len);
if (buff)
scsp_mem_err("scsp_format_msg: e_buff_len");
}
UM_ZERO(e_buff, e_buff_len);
/*
* Encode the extensions
@ -789,7 +785,7 @@ scsp_format_msg(dcsp, msg, bpp)
* Free the buffer if we didn't use it
*/
if (!e_len) {
UM_FREE(e_buff);
free(e_buff);
e_buff = (char *)0;
}
}
@ -825,8 +821,8 @@ scsp_format_msg(dcsp, msg, bpp)
*/
if (e_len) {
shp->sh_ext_off = htons(len);
UM_COPY(e_buff, buff + len, e_len);
UM_FREE(e_buff);
bcopy(e_buff, buff + len, e_len);
free(e_buff);
}
/*
@ -846,9 +842,9 @@ scsp_format_msg(dcsp, msg, bpp)
ignore:
if (buff)
UM_FREE(buff);
free(buff);
if (e_buff)
UM_FREE(e_buff);
free(e_buff);
*bpp = (char *)0;
return(0);
}
@ -905,7 +901,7 @@ scsp_send_msg(dcsp, msg)
* Write the message to the DCS
*/
rc = write(dcsp->sd_sock, (void *)buff, len);
UM_FREE(buff);
free(buff);
if (rc == len || (rc == -1 && errno == EINPROGRESS)) {
rc = 0;
} else {

View File

@ -1248,7 +1248,7 @@ print_scsp_dump()
/*
* Build a file name
*/
UM_ZERO(fname, sizeof(fname));
bzero(fname, sizeof(fname));
sprintf(fname, "/tmp/scspd.%d.%03d.out", getpid(), dump_no++);
/*

View File

@ -231,7 +231,7 @@ scsp_dcs_connect(dcsp)
/*
* Set up connection parameters for SCSP connection
*/
UM_ZERO(&DCS_addr, sizeof(DCS_addr));
bzero(&DCS_addr, sizeof(DCS_addr));
#if (defined(BSD) && (BSD >= 199103))
DCS_addr.satm_len = sizeof(DCS_addr);
#endif
@ -244,7 +244,7 @@ scsp_dcs_connect(dcsp)
dcsp->sd_addr.address_format;
DCS_addr.satm_addr.t_atm_sap_addr.address_length =
dcsp->sd_addr.address_length;
UM_COPY(dcsp->sd_addr.address,
bcopy(dcsp->sd_addr.address,
DCS_addr.satm_addr.t_atm_sap_addr.address,
dcsp->sd_addr.address_length);
@ -423,7 +423,7 @@ scsp_dcs_listen(ssp)
/*
* Set up our address
*/
UM_ZERO(&ls_addr, sizeof(ls_addr));
bzero(&ls_addr, sizeof(ls_addr));
#if (defined(BSD) && (BSD >= 199103))
ls_addr.satm_len = sizeof(ls_addr);
#endif
@ -435,7 +435,7 @@ scsp_dcs_listen(ssp)
ssp->ss_addr.address_format;
ls_addr.satm_addr.t_atm_sap_addr.address_length =
ssp->ss_addr.address_length;
UM_COPY(ssp->ss_addr.address,
bcopy(ssp->ss_addr.address,
ls_addr.satm_addr.t_atm_sap_addr.address,
ssp->ss_addr.address_length);
@ -616,7 +616,7 @@ scsp_dcs_accept(ssp)
} else {
dcs_atmaddr.address_format = dcs_addr->address_format;
dcs_atmaddr.address_length = dcs_addr->address_length;
UM_COPY(dcs_addr->address, dcs_atmaddr.address,
bcopy(dcs_addr->address, dcs_atmaddr.address,
dcs_addr->address_length);
}
@ -724,10 +724,9 @@ scsp_dcs_read(dcsp)
* Get a buffer to hold the entire message
*/
len = ssp->ss_mtu;
buff = (char *)UM_ALLOC(len);
if (!buff) {
buff = calloc(1, len);
if (buff == NULL)
scsp_mem_err("scsp_dcs_read: ssp->ss_mtu");
}
/*
* Read the message
@ -775,7 +774,7 @@ scsp_dcs_read(dcsp)
scsp_trace("\n");
}
}
UM_FREE(buff);
free(buff);
return(0);
@ -804,7 +803,7 @@ dcs_read_fail:
}
if (buff)
UM_FREE(buff);
free(buff);
return(rc);
}
@ -938,10 +937,9 @@ scsp_server_accept(ls)
/*
* Put the new socket on the 'pending' queue
*/
psp = (Scsp_pending *) UM_ALLOC(sizeof(Scsp_pending));
if (!psp) {
psp = calloc(1, sizeof(Scsp_pending));
if (!psp)
scsp_mem_err("scsp_server_accept: sizeof(Scsp_pending)");
}
psp->sp_sock = sd;
LINK2TAIL(psp, Scsp_pending, scsp_pending_head, sp_next);
@ -983,10 +981,9 @@ scsp_if_sock_read(sd)
/*
* Get a buffer and read the rest of the message into it
*/
buff = (char *)UM_ALLOC(msg_hdr.sh_len);
if (!buff) {
buff = malloc(msg_hdr.sh_len);
if (buff == NULL)
scsp_mem_err("scsp_if_sock_read: msg_hdr.sh_len");
}
msg = (Scsp_if_msg *)buff;
msg->si_hdr = msg_hdr;
len = read(sd, &buff[sizeof(Scsp_if_msg_hdr)],
@ -1011,7 +1008,7 @@ scsp_if_sock_read(sd)
socket_read_fail:
if (buff)
UM_FREE(buff);
free(buff);
return((Scsp_if_msg *)0);
}
@ -1165,7 +1162,7 @@ scsp_server_read(ssp)
return(EINVAL);
}
UM_FREE(msg);
free(msg);
return(0);
}
@ -1191,17 +1188,13 @@ scsp_send_cache_ind(ssp)
/*
* Get storage for a server interface message
*/
msg = (Scsp_if_msg *)UM_ALLOC(sizeof(Scsp_if_msg));
if (!msg) {
msg = calloc(1, sizeof(Scsp_if_msg));
if (msg == NULL)
scsp_mem_err("scsp_send_cache_ind: sizeof(Scsp_if_msg)");
}
UM_ZERO(msg, sizeof(Scsp_if_msg));
/*
* Fill out the message
*/
msg->si_type = SCSP_CACHE_IND;
msg->si_rc = 0;
msg->si_proto = ssp->ss_pid;
msg->si_len = sizeof(Scsp_if_msg_hdr);
msg->si_tok = (u_long)ssp;
@ -1210,7 +1203,7 @@ scsp_send_cache_ind(ssp)
* Send the message
*/
rc = scsp_if_sock_write(ssp->ss_sock, msg);
UM_FREE(msg);
free(msg);
return(rc);
}
@ -1282,7 +1275,7 @@ scsp_pending_read(psp)
ssp->ss_sock = psp->sp_sock;
ssp->ss_state = SCSP_SS_CFG;
UNLINK(psp, Scsp_pending, scsp_pending_head, sp_next);
UM_FREE(psp);
free(psp);
/*
* Listen for connections from the server's DCSs
@ -1312,7 +1305,7 @@ scsp_pending_read(psp)
goto config_error;
}
UM_FREE(msg);
free(msg);
return(0);
config_reject:
@ -1334,7 +1327,7 @@ config_error:
ssp->ss_sock = -1;
}
ssp->ss_state = SCSP_SS_NULL;
UM_FREE(msg);
free(msg);
return(rc);
@ -1344,8 +1337,8 @@ pending_read_fail:
*/
(void)close(psp->sp_sock);
UNLINK(psp, Scsp_pending, scsp_pending_head, sp_next);
UM_FREE(psp);
free(psp);
if (msg)
UM_FREE(msg);
free(msg);
return(rc);
}

View File

@ -213,7 +213,7 @@ scsp_is_atmarp_server(netif)
rc = (asrv_info->asp_addr.address_format == T_ATM_ABSENT) &&
(asrv_info->asp_subaddr.address_format ==
T_ATM_ABSENT);
UM_FREE(asrv_info);
free(asrv_info);
return(rc);
}
@ -238,17 +238,15 @@ scsp_dup_cse(csep)
/*
* Allocate memory for the duplicate
*/
dupp = (Scsp_cse *)UM_ALLOC(sizeof(Scsp_cse));
if (!dupp) {
dupp = malloc(sizeof(Scsp_cse));
if (dupp == NULL)
scsp_mem_err("scsp_dup_cse: sizeof(Scsp_cse)");
}
/*
* Copy data to the duplicate
*/
UM_COPY(csep, dupp, sizeof(Scsp_cse));
bcopy(csep, dupp, sizeof(Scsp_cse));
dupp->sc_next = (Scsp_cse *)0;
return(dupp);
}
@ -274,29 +272,26 @@ scsp_dup_csa(csap)
/*
* Allocate memory for the duplicate
*/
dupp = (Scsp_csa *)UM_ALLOC(sizeof(Scsp_csa));
if (!dupp) {
dupp = malloc(sizeof(Scsp_csa));
if (dupp == NULL)
scsp_mem_err("scsp_dup_csa: sizeof(Scsp_csa)");
}
/*
* Copy data to the duplicate
*/
UM_COPY(csap, dupp, sizeof(Scsp_csa));
bcopy(csap, dupp, sizeof(Scsp_csa));
dupp->next = (Scsp_csa *)0;
/*
* Copy protocol-specific data, if it's present
*/
if (csap->atmarp_data) {
adp = (Scsp_atmarp_csa *)UM_ALLOC(sizeof(Scsp_atmarp_csa));
if (!adp) {
adp = malloc(sizeof(Scsp_atmarp_csa));
if (adp == NULL)
scsp_mem_err("scsp_dup_csa: sizeof(Scsp_atmarp_csa)");
}
UM_COPY(csap->atmarp_data, adp, sizeof(Scsp_atmarp_csa));
bcopy(csap->atmarp_data, adp, sizeof(Scsp_atmarp_csa));
dupp->atmarp_data = adp;
}
return(dupp);
}
@ -321,11 +316,9 @@ scsp_cse2csas(csep)
/*
* Allocate memory for the duplicate
*/
csap = (Scsp_csa *)UM_ALLOC(sizeof(Scsp_csa));
if (!csap) {
csap = calloc(1, sizeof(Scsp_csa));
if (csap == NULL)
scsp_mem_err("scsp_cse2csas: sizeof(Scsp_csa)");
}
UM_ZERO(csap, sizeof(Scsp_csa));
/*
* Copy data to the CSAS entry
@ -358,11 +351,9 @@ scsp_atmarp2cse(aap)
/*
* Allocate memory for the duplicate
*/
csep = (Scsp_cse *)UM_ALLOC(sizeof(Scsp_cse));
if (!csep) {
csep = calloc(1, sizeof(Scsp_cse));
if (csep == NULL)
scsp_mem_err("scsp_atmarp2cse: sizeof(Scsp_cse)");
}
UM_ZERO(csep, sizeof(Scsp_cse));
/*
* Copy data to the CSE entry
@ -401,7 +392,7 @@ scsp_dcs_cleanup(dcsp)
for (csep = dcsp->sd_ca_csas; csep; csep = ncsep) {
ncsep = csep->sc_next;
UNLINK(csep, Scsp_cse, dcsp->sd_ca_csas, sc_next);
UM_FREE(csep);
free(csep);
}
/*
@ -445,7 +436,7 @@ scsp_dcs_cleanup(dcsp)
}
UNLINK(rxp, Scsp_csu_rexmt, dcsp->sd_csu_rexmt,
sr_next);
UM_FREE(rxp);
free(rxp);
}
}
@ -501,7 +492,7 @@ scsp_dcs_delete(dcsp)
*/
for (csep = dcsp->sd_ca_csas; csep; csep = next_cse) {
next_cse = csep->sc_next;
UM_FREE(csep);
free(csep);
}
/*
@ -540,13 +531,13 @@ scsp_dcs_delete(dcsp)
* Free the CSU Req retransmission control block
*/
next_rxp = rxp->sr_next;
UM_FREE(rxp);
free(rxp);
}
/*
* Free the DCS block
*/
UM_FREE(dcsp);
free(dcsp);
}
@ -617,7 +608,7 @@ scsp_server_shutdown(ssp)
csep = ssp->ss_cache[i];
UNLINK(csep, Scsp_cse, ssp->ss_cache[i],
sc_next);
UM_FREE(csep);
free(csep);
}
}
}
@ -660,15 +651,15 @@ scsp_server_delete(ssp)
for (i = 0; i < SCSP_HASHSZ; i++) {
for (csep = ssp->ss_cache[i]; csep; csep = next_cse) {
next_cse = csep->sc_next;
UM_FREE(csep);
free(csep);
}
}
/*
* Free the server block
*/
UM_FREE(ssp->ss_name);
UM_FREE(ssp);
free(ssp->ss_name);
free(ssp);
}
@ -707,7 +698,7 @@ scsp_get_server_info(ssp)
* Get the IP address and physical interface name
* associated with the network interface
*/
UM_ZERO(&air, sizeof(struct atminfreq));
bzero(&air, sizeof(struct atminfreq));
air.air_opcode = AIOCS_INF_NIF;
strcpy(air.air_netif_intf, ssp->ss_intf);
len = do_info_ioctl(&air, sizeof(struct air_netif_rsp));
@ -737,7 +728,7 @@ scsp_get_server_info(ssp)
* Get the ATM address associated with the
* physical interface
*/
UM_ZERO(&air, sizeof(struct atminfreq));
bzero(&air, sizeof(struct atminfreq));
air.air_opcode = AIOCS_INF_INT;
strcpy(air.air_int_intf, netif_rsp->anp_phy_intf);
len = do_info_ioctl(&air, sizeof(struct air_int_rsp));
@ -791,7 +782,7 @@ scsp_get_server_info(ssp)
* Get configuration information associated with the
* physical interface
*/
UM_ZERO(&air, sizeof(struct atminfreq));
bzero(&air, sizeof(struct atminfreq));
air.air_opcode = AIOCS_INF_CFG;
strcpy(air.air_int_intf, netif_rsp->anp_phy_intf);
len = do_info_ioctl(&air, sizeof(struct air_cfg_rsp));
@ -804,7 +795,7 @@ scsp_get_server_info(ssp)
/*
* Update the server entry
*/
UM_COPY(&ip_addr->sin_addr, ssp->ss_lsid.id, ssp->ss_id_len);
bcopy(&ip_addr->sin_addr, ssp->ss_lsid.id, ssp->ss_id_len);
ssp->ss_lsid.id_len = ssp->ss_id_len;
ssp->ss_mtu = mtu + 8;
ATM_ADDR_COPY(&intf_rsp->anp_addr, &ssp->ss_addr);
@ -826,11 +817,11 @@ scsp_get_server_info(ssp)
*/
server_info_done:
if (netif_rsp)
UM_FREE(netif_rsp);
free(netif_rsp);
if (intf_rsp)
UM_FREE(intf_rsp);
free(intf_rsp);
if (cfg_rsp)
UM_FREE(cfg_rsp);
free(cfg_rsp);
return(rc);
}
@ -912,7 +903,7 @@ scsp_process_cache_rsp(ssp, smp)
SCSP_LOOKUP(ssp, &aap->sa_key, csep);
if (csep) {
SCSP_DELETE(ssp, csep);
UM_FREE(csep);
free(csep);
}
/*
@ -1037,11 +1028,9 @@ scsp_update_cache(dcsp, csap)
/*
* Get memory for a new entry
*/
csep = (Scsp_cse *)UM_ALLOC(sizeof(Scsp_cse));
if (!csep) {
csep = calloc(1, sizeof(Scsp_cse));
if (csep == NULL)
scsp_mem_err("scsp_update_cache: sizeof(Scsp_cse)");
}
UM_ZERO(csep, sizeof(Scsp_cse));
/*
* Fill out the new cache summary entry
@ -1065,7 +1054,7 @@ scsp_update_cache(dcsp, csap)
*/
if (csep) {
SCSP_DELETE(dcsp->sd_server, csep);
UM_FREE(csep);
free(csep);
}
} else {
/*