summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authorarr <arr@FreeBSD.org>2002-05-16 23:28:40 +0000
committerarr <arr@FreeBSD.org>2002-05-16 23:28:40 +0000
commit0f9e8dbadd5ef34e6369d22899b81b78cc75179c (patch)
tree3020135368e8d1a2f9fc75599857338d1373d57c /usr.sbin
parentbd977939fa8b4e9d1153b82341bfe776c0939c49 (diff)
downloadFreeBSD-src-0f9e8dbadd5ef34e6369d22899b81b78cc75179c.zip
FreeBSD-src-0f9e8dbadd5ef34e6369d22899b81b78cc75179c.tar.gz
- 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.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/atm/atmarpd/atmarp_config.c8
-rw-r--r--usr.sbin/atm/atmarpd/atmarp_scsp.c59
-rw-r--r--usr.sbin/atm/atmarpd/atmarp_subr.c47
-rw-r--r--usr.sbin/atm/atmarpd/atmarp_timer.c15
4 files changed, 56 insertions, 73 deletions
diff --git a/usr.sbin/atm/atmarpd/atmarp_config.c b/usr.sbin/atm/atmarpd/atmarp_config.c
index 4f7d62e..d6d124e 100644
--- a/usr.sbin/atm/atmarpd/atmarp_config.c
+++ b/usr.sbin/atm/atmarpd/atmarp_config.c
@@ -89,10 +89,9 @@ atmarp_cfg_netif(netif)
/*
* Get an ATMARP interface block
*/
- aip = (Atmarp_intf *)UM_ALLOC(sizeof(Atmarp_intf));
- if (!aip)
+ aip = calloc(1, sizeof(Atmarp_intf));
+ if (aip == NULL)
atmarp_mem_err("atmarp_cfg_netif: sizeof(Atmarp_intf)");
- UM_ZERO(aip, sizeof(Atmarp_intf));
/*
* Make sure we're configuring a valid
@@ -123,7 +122,6 @@ atmarp_cfg_netif(netif)
cfg_fail:
if (aip)
- UM_FREE(aip);
-
+ free(aip);
return(rc);
}
diff --git a/usr.sbin/atm/atmarpd/atmarp_scsp.c b/usr.sbin/atm/atmarpd/atmarp_scsp.c
index 0f842e4..6a22217 100644
--- a/usr.sbin/atm/atmarpd/atmarp_scsp.c
+++ b/usr.sbin/atm/atmarpd/atmarp_scsp.c
@@ -103,12 +103,9 @@ atmarp_scsp_cache(aip, msg)
/*
* Get memory for the cache message
*/
- smp = (Scsp_if_msg *)UM_ALLOC(len);
- if (!smp) {
+ smp = calloc(1, len);
+ if (smp == NULL)
atmarp_mem_err("atmarp_scsp_cache: len");
- }
- UM_ZERO(smp, len);
-
/*
* Set header fields in SCSP message
*/
@@ -144,8 +141,7 @@ atmarp_scsp_cache(aip, msg)
* Free the message
*/
if (smp)
- UM_FREE(smp);
-
+ free(smp);
return(rc);
}
@@ -190,11 +186,9 @@ atmarp_scsp_solicit(aip, smp)
/*
* Get storage for a Solicit Response
*/
- rsp = (Scsp_if_msg *)UM_ALLOC(sizeof(Scsp_if_msg));
- if (!rsp) {
+ rsp = calloc(1, sizeof(Scsp_if_msg));
+ if (rsp == NULL)
atmarp_mem_err("atmarp_scsp_solicit: sizeof(Scsp_if_msg)");
- }
- UM_ZERO(rsp, sizeof(Scsp_if_msg));
/*
* Fill out the Solicit Rsp
@@ -231,8 +225,7 @@ atmarp_scsp_solicit(aip, smp)
* Send the message to SCSP
*/
rc = atmarp_scsp_out(aip, (char *)rsp, rsp->si_len);
- UM_FREE(rsp);
-
+ free(rsp);
return(rc);
}
@@ -268,11 +261,9 @@ atmarp_scsp_update(aap, state)
/*
* Get memory for the cache message
*/
- smp = (Scsp_if_msg *)UM_ALLOC(sizeof(Scsp_if_msg));
- if (!smp) {
+ smp = calloc(1, sizeof(Scsp_if_msg));
+ if (smp == NULL)
atmarp_mem_err("atmarp_scsp_update: sizeof(Scsp_if_msg)");
- }
- UM_ZERO(smp, sizeof(Scsp_if_msg));
/*
* Set header fields in SCSP message
@@ -298,7 +289,7 @@ atmarp_scsp_update(aap, state)
*/
rc = atmarp_scsp_out(aap->aa_intf, (char *)smp, smp->si_len);
- UM_FREE(smp);
+ free(smp);
return(rc);
}
@@ -381,10 +372,9 @@ atmarp_scsp_update_in(aip, smp)
/*
* Copy info from SCSP to a new cache entry
*/
- aap = (Atmarp *)UM_ALLOC(sizeof(Atmarp));
- if (!aap)
+ aap = calloc(1, sizeof(Atmarp));
+ if (aap == NULL)
atmarp_mem_err("atmarp_scsp_update_in: sizeof(Atmarp)");
- UM_ZERO(aap, sizeof(Atmarp));
aap->aa_dstip = smp->si_atmarp.sa_cpa;
aap->aa_dstatm = smp->si_atmarp.sa_cha;
@@ -475,10 +465,10 @@ atmarp_scsp_read(aip)
/*
* Get a buffer that will hold the message
*/
- buff = UM_ALLOC(msg_hdr.sh_len);
- if (!buff)
+ buff = malloc(msg_hdr.sh_len);
+ if (buff == NULL)
atmarp_mem_err("atmarp_scsp_read: msg_hdr.sh_len");
- UM_COPY(&msg_hdr, buff, sizeof(msg_hdr));
+ bcopy(&msg_hdr, buff, sizeof(msg_hdr));
/*
* Read the rest of the message, if there is more than
@@ -526,14 +516,12 @@ atmarp_scsp_read(aip)
atmarp_log(LOG_ERR, "Unexpected SCSP message received");
return(EOPNOTSUPP);
}
-
- UM_FREE(buff);
+ free(buff);
return(rc);
read_fail:
- if (buff) {
- UM_FREE(buff);
- }
+ if (buff)
+ free(buff);
/*
* Error on socket to SCSP--close the socket and set the state
@@ -652,7 +640,7 @@ atmarp_scsp_connect(aip)
*/
sd = socket(PF_UNIX, SOCK_STREAM, 0);
if (sd == -1) {
- UM_FREE(sn);
+ free(sn);
return(errno);
}
if (sd > atmarp_max_socket) {
@@ -700,7 +688,7 @@ atmarp_scsp_connect(aip)
/*
* Send configuration information to SCSP
*/
- UM_ZERO(&cfg_msg, sizeof(cfg_msg));
+ bzero(&cfg_msg, sizeof(cfg_msg));
cfg_msg.si_type = SCSP_CFG_REQ;
cfg_msg.si_proto = SCSP_PROTO_ATMARP;
strcpy(cfg_msg.si_cfg.atmarp_netif, aip->ai_intf);
@@ -716,7 +704,7 @@ atmarp_scsp_connect(aip)
scsp_connect_fail:
(void)close(sd);
aip->ai_scsp_sock = -1;
- UM_FREE(sn);
+ free(sn);
aip->ai_scsp_sockname = NULL;
aip->ai_state = AI_STATE_NULL;
return(rc);
@@ -744,7 +732,7 @@ atmarp_scsp_close(aip)
(void)close(aip->ai_scsp_sock);
aip->ai_scsp_sock = -1;
(void)unlink(aip->ai_scsp_sockname);
- UM_FREE(aip->ai_scsp_sockname);
+ free(aip->ai_scsp_sockname);
aip->ai_scsp_sockname = NULL;
aip->ai_state = AI_STATE_NULL;
@@ -781,9 +769,8 @@ atmarp_scsp_disconnect(aip)
* Free the ATMARP cache associated with the interface
*/
for (i = 0; i < ATMARP_HASHSIZ; i++) {
- for (aap = aip->ai_arptbl[i]; aap; aap = aap->aa_next) {
- UM_FREE(aap);
- }
+ for (aap = aip->ai_arptbl[i]; aap; aap = aap->aa_next)
+ free(aap);
aip->ai_arptbl[i] = (Atmarp *)0;
}
diff --git a/usr.sbin/atm/atmarpd/atmarp_subr.c b/usr.sbin/atm/atmarpd/atmarp_subr.c
index 8f5db45..4015a34 100644
--- a/usr.sbin/atm/atmarpd/atmarp_subr.c
+++ b/usr.sbin/atm/atmarpd/atmarp_subr.c
@@ -202,7 +202,7 @@ atmarp_is_server(aip)
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);
}
@@ -235,7 +235,7 @@ atmarp_if_ready(aip)
* 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, aip->ai_intf);
len = do_info_ioctl(&air, sizeof(struct air_netif_rsp));
@@ -272,7 +272,7 @@ atmarp_if_ready(aip)
/*
* Get physical interface information
*/
- 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));
@@ -351,7 +351,7 @@ atmarp_if_ready(aip)
ATMARP_LOOKUP(aip, aip->ai_ip_addr.s_addr, aap);
if (aap) {
ATMARP_DELETE(aip, aap);
- UM_FREE(aap);
+ free(aap);
}
/*
@@ -378,11 +378,9 @@ atmarp_if_ready(aip)
/*
* Get a new ATMARP cache for the interface
*/
- aap = (Atmarp *)UM_ALLOC(sizeof(Atmarp));
- if (!aap) {
+ aap = calloc(1, sizeof(Atmarp));
+ if (aap == NULL)
atmarp_mem_err("atmarp_if_ready: sizeof(Atmarp)");
- }
- UM_ZERO(aap, sizeof(Atmarp));
/*
* Fill out the entry
@@ -396,8 +394,7 @@ atmarp_if_ready(aip)
SCSP_ATMARP_KEY_LEN, aap->aa_key.key);
aap->aa_oid.id_len = SCSP_ATMARP_ID_LEN;
aap->aa_seq = SCSP_CSA_SEQ_MIN;
- UM_COPY(&aap->aa_dstip.s_addr, aap->aa_oid.id,
- SCSP_ATMARP_ID_LEN);
+ bcopy(&aap->aa_dstip.s_addr, aap->aa_oid.id, SCSP_ATMARP_ID_LEN);
aap->aa_intf = aip;
aap->aa_flags = AAF_SERVER;
aap->aa_origin = UAO_LOCAL;
@@ -410,17 +407,15 @@ atmarp_if_ready(aip)
/*
* Free dynamic data
*/
- UM_FREE(netif_rsp);
- UM_FREE(intf_rsp);
-
+ free(netif_rsp);
+ free(intf_rsp);
return(1);
if_ready_fail:
if (netif_rsp)
- UM_FREE(netif_rsp);
+ free(netif_rsp);
if (intf_rsp)
- UM_FREE(intf_rsp);
-
+ free(intf_rsp);
return(0);
}
@@ -458,20 +453,19 @@ atmarp_copy_cache_entry(cp)
/*
* Get a new cache entry
*/
- aap = (Atmarp *)UM_ALLOC(sizeof(Atmarp));
- if (!aap) {
+ aap = calloc(1, sizeof(Atmarp));
+ if (aap == NULL) {
errno = ENOMEM;
- return((Atmarp *)0);
+ return(NULL);
}
- UM_ZERO(aap, sizeof(Atmarp));
aap->aa_intf = aip;
/*
* Copy fields from the kernel entry to the new entry
*/
ipp = (struct sockaddr_in *)&cp->aap_arp_addr;
- UM_COPY(&ipp->sin_addr.s_addr, &aap->aa_dstip.s_addr,
- sizeof(aap->aa_dstip.s_addr));
+ bcopy(&ipp->sin_addr.s_addr, &aap->aa_dstip.s_addr,
+ sizeof(aap->aa_dstip.s_addr));
ATM_ADDR_COPY(&cp->aap_addr, &aap->aa_dstatm);
ATM_ADDR_COPY(&cp->aap_subaddr, &aap->aa_dstatmsub);
if (cp->aap_origin == UAO_PERM)
@@ -485,8 +479,7 @@ atmarp_copy_cache_entry(cp)
scsp_cache_key(&cp->aap_addr, &aap->aa_dstip,
SCSP_ATMARP_KEY_LEN, (char *)aap->aa_key.key);
aap->aa_oid.id_len = SCSP_ATMARP_ID_LEN;
- UM_COPY(&aip->ai_ip_addr.s_addr, aap->aa_oid.id,
- SCSP_ATMARP_ID_LEN);
+ bcopy(&aip->ai_ip_addr.s_addr, aap->aa_oid.id, SCSP_ATMARP_ID_LEN);
aap->aa_seq = SCSP_CSA_SEQ_MIN;
return(aap);
@@ -515,7 +508,7 @@ atmarp_update_kernel(aap)
/*
* Build ioctl request
*/
- UM_ZERO(&aar, sizeof(aar));
+ bzero(&aar, sizeof(aar));
aar.aar_opcode = AIOCS_ADD_ARP;
strncpy(aar.aar_arp_intf, aap->aa_intf->ai_intf,
sizeof(aar.aar_arp_intf));
@@ -628,7 +621,7 @@ atmarp_get_updated_cache()
/*
* Free the ioctl response
*/
- UM_FREE(air.air_buf_addr);
+ free(air.air_buf_addr);
}
@@ -933,7 +926,7 @@ atmarp_sigint(sig)
/*
* Build a file name
*/
- UM_ZERO(fname, sizeof(fname));
+ bzero(&fname, sizeof(fname));
sprintf(fname, "/tmp/atmarpd.%d.%03d.out", getpid(), dump_no++);
/*
diff --git a/usr.sbin/atm/atmarpd/atmarp_timer.c b/usr.sbin/atm/atmarpd/atmarp_timer.c
index ad7c987..c1c6cd9 100644
--- a/usr.sbin/atm/atmarpd/atmarp_timer.c
+++ b/usr.sbin/atm/atmarpd/atmarp_timer.c
@@ -197,11 +197,16 @@ atmarp_keepalive_timeout(tp)
/*
* Get a message buffer
+ *
+ * XXX arr: Previously, the check on the returned value from
+ * the memory allocation routine was checked and _nothing_
+ * resulted from the check (which would cause problems since
+ * the bzero() of NULL is not fun). At the moment, I am having
+ * it soley return -- this should be reviewed again soon.
*/
- msg = (Scsp_if_msg *)UM_ALLOC(sizeof(Scsp_if_msg));
- if (!msg) {
- }
- UM_ZERO(msg, sizeof(Scsp_if_msg));
+ msg = calloc(1, sizeof(Scsp_if_msg));
+ if (msg == NULL)
+ return;
/*
* Build a NOP message
@@ -214,7 +219,7 @@ atmarp_keepalive_timeout(tp)
* Send the message to SCSP
*/
(void)atmarp_scsp_out(aip, (char *)msg, msg->si_len);
- UM_FREE(msg);
+ free(msg);
/*
* Restart the keepalive timer
OpenPOWER on IntegriCloud