[cleanup] Convert XMALLOC/memset to XCALLOC
Simple conversion of XMALLOC/memset to XCALLOC
diff --git a/ospfd/ospf_api.c b/ospfd/ospf_api.c
index 9c9997b..7738319 100644
--- a/ospfd/ospf_api.c
+++ b/ospfd/ospf_api.c
@@ -99,8 +99,7 @@
{
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 @@
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 dac4c93..15fd2e5 100644
--- a/ospfd/ospf_apiserver.c
+++ b/ospfd/ospf_apiserver.c
@@ -937,8 +937,7 @@
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 a482623..6f1b0b0 100644
--- a/ospfd/ospf_asbr.c
+++ b/ospfd/ospf_asbr.c
@@ -104,8 +104,7 @@
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 6368142..951c19a 100644
--- a/ospfd/ospf_interface.c
+++ b/ospfd/ospf_interface.c
@@ -508,13 +508,11 @@
{
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 @@
{
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 @@
{
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 @@
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 f453353..3c9c73a 100644
--- a/ospfd/ospf_lsa.c
+++ b/ospfd/ospf_lsa.c
@@ -304,12 +304,7 @@
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 @@
{
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 @@
{
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 843e93f..967ca15 100644
--- a/ospfd/ospf_neighbor.c
+++ b/ospfd/ospf_neighbor.c
@@ -69,8 +69,7 @@
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 c47d432..5a0aea1 100644
--- a/ospfd/ospf_snmp.c
+++ b/ospfd/ospf_snmp.c
@@ -1405,11 +1405,7 @@
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 a3ebe62..c5ec0ad 100644
--- a/ospfd/ospf_te.c
+++ b/ospfd/ospf_te.c
@@ -561,13 +561,13 @@
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 e27f139..150ffac 100644
--- a/ospfd/ospf_zebra.c
+++ b/ospfd/ospf_zebra.c
@@ -1113,10 +1113,7 @@
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 c951a29..f278488 100644
--- a/ospfd/ospfd.c
+++ b/ospfd/ospfd.c
@@ -1390,9 +1390,8 @@
{
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;