summaryrefslogtreecommitdiff
path: root/ospfd
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2008-08-18 14:13:29 -0700
committerPaul Jakma <paul@quagga.net>2009-06-12 17:07:49 +0100
commit393deb9bd663361e6b110d579a8b1d4c22667068 (patch)
treee93ebf2f57bf92ff7a9cd045764b3cdbb99a07e5 /ospfd
parent3453a7122c1d585ad789ed0f63deb90cc5e89fae (diff)
[cleanup] Convert XMALLOC/memset to XCALLOC
Simple conversion of XMALLOC/memset to XCALLOC
Diffstat (limited to 'ospfd')
-rw-r--r--ospfd/ospf_api.c10
-rw-r--r--ospfd/ospf_apiserver.c3
-rw-r--r--ospfd/ospf_asbr.c3
-rw-r--r--ospfd/ospf_interface.c17
-rw-r--r--ospfd/ospf_lsa.c15
-rw-r--r--ospfd/ospf_neighbor.c3
-rw-r--r--ospfd/ospf_snmp.c6
-rw-r--r--ospfd/ospf_te.c6
-rw-r--r--ospfd/ospf_zebra.c5
-rw-r--r--ospfd/ospfd.c3
10 files changed, 18 insertions, 53 deletions
diff --git a/ospfd/ospf_api.c b/ospfd/ospf_api.c
index 9c9997ba..77383191 100644
--- a/ospfd/ospf_api.c
+++ b/ospfd/ospf_api.c
@@ -99,8 +99,7 @@ msg_new (u_char msgtype, void *msgbody, u_int32_t seqnum, u_int16_t msglen)
{
struct msg *new;
- new = XMALLOC (MTYPE_OSPF_API_MSG, sizeof (struct msg));
- memset (new, 0, sizeof (struct msg));
+ new = XCALLOC (MTYPE_OSPF_API_MSG, sizeof (struct msg));
new->hdr.version = OSPF_API_VERSION;
new->hdr.msgtype = msgtype;
@@ -271,12 +270,7 @@ msg_get_seq (struct msg *msg)
struct msg_fifo *
msg_fifo_new ()
{
- struct msg_fifo *new;
-
- new = XMALLOC (MTYPE_OSPF_API_FIFO, sizeof (struct msg_fifo));
- memset (new, 0, sizeof (struct msg_fifo));
-
- return new;
+ return XCALLOC (MTYPE_OSPF_API_FIFO, sizeof (struct msg_fifo));
}
/* Add new message to fifo. */
diff --git a/ospfd/ospf_apiserver.c b/ospfd/ospf_apiserver.c
index dac4c93f..15fd2e5f 100644
--- a/ospfd/ospf_apiserver.c
+++ b/ospfd/ospf_apiserver.c
@@ -937,8 +937,7 @@ ospf_apiserver_register_opaque_type (struct ospf_apiserver *apiserv,
type. */
regtype =
- XMALLOC (MTYPE_OSPF_APISERVER, sizeof (struct registered_opaque_type));
- memset (regtype, 0, sizeof (struct registered_opaque_type));
+ XCALLOC (MTYPE_OSPF_APISERVER, sizeof (struct registered_opaque_type));
regtype->lsa_type = lsa_type;
regtype->opaque_type = opaque_type;
diff --git a/ospfd/ospf_asbr.c b/ospfd/ospf_asbr.c
index a4826237..6f1b0b06 100644
--- a/ospfd/ospf_asbr.c
+++ b/ospfd/ospf_asbr.c
@@ -104,8 +104,7 @@ ospf_external_info_new (u_char type)
struct external_info *new;
new = (struct external_info *)
- XMALLOC (MTYPE_OSPF_EXTERNAL_INFO, sizeof (struct external_info));
- memset (new, 0, sizeof (struct external_info));
+ XCALLOC (MTYPE_OSPF_EXTERNAL_INFO, sizeof (struct external_info));
new->type = type;
ospf_reset_route_map_set_values (&new->route_map_set);
diff --git a/ospfd/ospf_interface.c b/ospfd/ospf_interface.c
index 63681429..951c19a8 100644
--- a/ospfd/ospf_interface.c
+++ b/ospfd/ospf_interface.c
@@ -508,13 +508,11 @@ ospf_new_if_params (void)
{
struct ospf_if_params *oip;
- oip = XMALLOC (MTYPE_OSPF_IF_PARAMS, sizeof (struct ospf_if_params));
+ oip = XCALLOC (MTYPE_OSPF_IF_PARAMS, sizeof (struct ospf_if_params));
if (!oip)
return NULL;
- memset (oip, 0, sizeof (struct ospf_if_params));
-
UNSET_IF_PARAM (oip, output_cost_cmd);
UNSET_IF_PARAM (oip, transmit_delay);
UNSET_IF_PARAM (oip, retransmit_interval);
@@ -638,8 +636,7 @@ ospf_if_new_hook (struct interface *ifp)
{
int rc = 0;
- ifp->info = XMALLOC (MTYPE_OSPF_IF_INFO, sizeof (struct ospf_if_info));
- memset (ifp->info, 0, sizeof (struct ospf_if_info));
+ ifp->info = XCALLOC (MTYPE_OSPF_IF_INFO, sizeof (struct ospf_if_info));
IF_OIFS (ifp) = route_table_init ();
IF_OIFS_PARAMS (ifp) = route_table_init ();
@@ -814,8 +811,7 @@ ospf_vl_data_new (struct ospf_area *area, struct in_addr vl_peer)
{
struct ospf_vl_data *vl_data;
- vl_data = XMALLOC (MTYPE_OSPF_VL_DATA, sizeof (struct ospf_vl_data));
- memset (vl_data, 0, sizeof (struct ospf_vl_data));
+ vl_data = XCALLOC (MTYPE_OSPF_VL_DATA, sizeof (struct ospf_vl_data));
vl_data->vl_peer.s_addr = vl_peer.s_addr;
vl_data->vl_area_id = area->area_id;
@@ -1180,12 +1176,7 @@ ospf_vls_in_area (struct ospf_area *area)
struct crypt_key *
ospf_crypt_key_new ()
{
- struct crypt_key *ck;
-
- ck = XMALLOC (MTYPE_OSPF_CRYPT_KEY, sizeof (struct crypt_key));
- memset (ck, 0, sizeof (struct crypt_key));
-
- return ck;
+ return XCALLOC (MTYPE_OSPF_CRYPT_KEY, sizeof (struct crypt_key));
}
void
diff --git a/ospfd/ospf_lsa.c b/ospfd/ospf_lsa.c
index f453353d..3c9c73a3 100644
--- a/ospfd/ospf_lsa.c
+++ b/ospfd/ospf_lsa.c
@@ -304,12 +304,7 @@ ospf_lsa_discard (struct ospf_lsa *lsa)
struct lsa_header *
ospf_lsa_data_new (size_t size)
{
- struct lsa_header *new;
-
- new = (struct lsa_header *) XMALLOC (MTYPE_OSPF_LSA_DATA, size);
- memset (new, 0, size);
-
- return new;
+ return XCALLOC (MTYPE_OSPF_LSA_DATA, size);
}
/* Duplicate LSA data. */
@@ -3635,9 +3630,7 @@ ospf_schedule_lsa_flood_area (struct ospf_area *area, struct ospf_lsa *lsa)
{
struct lsa_action *data;
- data = XMALLOC (MTYPE_OSPF_MESSAGE, sizeof (struct lsa_action));
- memset (data, 0, sizeof (struct lsa_action));
-
+ data = XCALLOC (MTYPE_OSPF_MESSAGE, sizeof (struct lsa_action));
data->action = LSA_ACTION_FLOOD_AREA;
data->area = area;
data->lsa = ospf_lsa_lock (lsa); /* Message / Flood area */
@@ -3650,9 +3643,7 @@ ospf_schedule_lsa_flush_area (struct ospf_area *area, struct ospf_lsa *lsa)
{
struct lsa_action *data;
- data = XMALLOC (MTYPE_OSPF_MESSAGE, sizeof (struct lsa_action));
- memset (data, 0, sizeof (struct lsa_action));
-
+ data = XCALLOC (MTYPE_OSPF_MESSAGE, sizeof (struct lsa_action));
data->action = LSA_ACTION_FLUSH_AREA;
data->area = area;
data->lsa = ospf_lsa_lock (lsa); /* Message / Flush area */
diff --git a/ospfd/ospf_neighbor.c b/ospfd/ospf_neighbor.c
index 843e93f6..967ca15d 100644
--- a/ospfd/ospf_neighbor.c
+++ b/ospfd/ospf_neighbor.c
@@ -69,8 +69,7 @@ ospf_nbr_new (struct ospf_interface *oi)
struct ospf_neighbor *nbr;
/* Allcate new neighbor. */
- nbr = XMALLOC (MTYPE_OSPF_NEIGHBOR, sizeof (struct ospf_neighbor));
- memset (nbr, 0, sizeof (struct ospf_neighbor));
+ nbr = XCALLOC (MTYPE_OSPF_NEIGHBOR, sizeof (struct ospf_neighbor));
/* Relate neighbor to the interface. */
nbr->oi = oi;
diff --git a/ospfd/ospf_snmp.c b/ospfd/ospf_snmp.c
index c47d432e..5a0aea1a 100644
--- a/ospfd/ospf_snmp.c
+++ b/ospfd/ospf_snmp.c
@@ -1405,11 +1405,7 @@ struct ospf_snmp_if
static struct ospf_snmp_if *
ospf_snmp_if_new ()
{
- struct ospf_snmp_if *osif;
-
- osif = XMALLOC (0, sizeof (struct ospf_snmp_if));
- memset (osif, 0, sizeof (struct ospf_snmp_if));
- return osif;
+ return XCALLOC (0, sizeof (struct ospf_snmp_if));
}
static void
diff --git a/ospfd/ospf_te.c b/ospfd/ospf_te.c
index a3ebe62e..c5ec0ad8 100644
--- a/ospfd/ospf_te.c
+++ b/ospfd/ospf_te.c
@@ -561,13 +561,13 @@ ospf_mpls_te_new_if (struct interface *ifp)
goto out;
}
- if ((new = XMALLOC (MTYPE_OSPF_MPLS_TE_LINKPARAMS,
- sizeof (struct mpls_te_link))) == NULL)
+ new = XCALLOC (MTYPE_OSPF_MPLS_TE_LINKPARAMS,
+ sizeof (struct mpls_te_link));
+ if (new == NULL)
{
zlog_warn ("ospf_mpls_te_new_if: XMALLOC: %s", safe_strerror (errno));
goto out;
}
- memset (new, 0, sizeof (struct mpls_te_link));
new->area = NULL;
new->flags = 0;
diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c
index e27f1394..150ffac3 100644
--- a/ospfd/ospf_zebra.c
+++ b/ospfd/ospf_zebra.c
@@ -1113,10 +1113,7 @@ ospf_prefix_list_update (struct prefix_list *plist)
static struct ospf_distance *
ospf_distance_new (void)
{
- struct ospf_distance *new;
- new = XMALLOC (MTYPE_OSPF_DISTANCE, sizeof (struct ospf_distance));
- memset (new, 0, sizeof (struct ospf_distance));
- return new;
+ return XCALLOC (MTYPE_OSPF_DISTANCE, sizeof (struct ospf_distance));
}
static void
diff --git a/ospfd/ospfd.c b/ospfd/ospfd.c
index c951a29a..f2784887 100644
--- a/ospfd/ospfd.c
+++ b/ospfd/ospfd.c
@@ -1390,9 +1390,8 @@ ospf_nbr_nbma_new (void)
{
struct ospf_nbr_nbma *nbr_nbma;
- nbr_nbma = XMALLOC (MTYPE_OSPF_NEIGHBOR_STATIC,
+ nbr_nbma = XCALLOC (MTYPE_OSPF_NEIGHBOR_STATIC,
sizeof (struct ospf_nbr_nbma));
- memset (nbr_nbma, 0, sizeof (struct ospf_nbr_nbma));
nbr_nbma->priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
nbr_nbma->v_poll = OSPF_POLL_INTERVAL_DEFAULT;