pimd: Use XCALLOC instead of XMALLOC

Ensure that all data structures start out
as 0 filled.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
Donald Sharp 2016-07-16 02:45:33 -04:00 committed by Donald Sharp
parent 0e6ae42582
commit 36d9e7dcea
6 changed files with 16 additions and 16 deletions

View File

@ -80,9 +80,9 @@ struct pim_interface *pim_if_new(struct interface *ifp, int igmp, int pim)
zassert(ifp);
zassert(!ifp->info);
pim_ifp = XMALLOC(MTYPE_PIM_INTERFACE, sizeof(*pim_ifp));
pim_ifp = XCALLOC(MTYPE_PIM_INTERFACE, sizeof(*pim_ifp));
if (!pim_ifp) {
zlog_err("PIM XMALLOC(%zu) failure", sizeof(*pim_ifp));
zlog_err("PIM XCALLOC(%zu) failure", sizeof(*pim_ifp));
return 0;
}
@ -997,13 +997,13 @@ static struct igmp_join *igmp_join_new(struct interface *ifp,
return 0;
}
ij = XMALLOC(MTYPE_PIM_IGMP_JOIN, sizeof(*ij));
ij = XCALLOC(MTYPE_PIM_IGMP_JOIN, sizeof(*ij));
if (!ij) {
char group_str[100];
char source_str[100];
pim_inet4_dump("<grp?>", group_addr, group_str, sizeof(group_str));
pim_inet4_dump("<src?>", source_addr, source_str, sizeof(source_str));
zlog_err("%s: XMALLOC(%zu) failure for IGMP group %s source %s on interface %s",
zlog_err("%s: XCALLOC(%zu) failure for IGMP group %s source %s on interface %s",
__PRETTY_FUNCTION__,
sizeof(*ij), group_str, source_str, ifp->name);
close(join_fd);

View File

@ -1184,9 +1184,9 @@ static struct igmp_sock *igmp_sock_new(int fd,
fd, inet_ntoa(ifaddr), ifp->name);
}
igmp = XMALLOC(MTYPE_PIM_IGMP_SOCKET, sizeof(*igmp));
igmp = XCALLOC(MTYPE_PIM_IGMP_SOCKET, sizeof(*igmp));
if (!igmp) {
zlog_warn("%s %s: XMALLOC() failure",
zlog_warn("%s %s: XCALLOC() failure",
__FILE__, __PRETTY_FUNCTION__);
return 0;
}
@ -1392,9 +1392,9 @@ struct igmp_group *igmp_add_group_by_addr(struct igmp_sock *igmp,
of INCLUDE and an empty source list.
*/
group = XMALLOC(MTYPE_PIM_IGMP_GROUP, sizeof(*group));
group = XCALLOC(MTYPE_PIM_IGMP_GROUP, sizeof(*group));
if (!group) {
zlog_warn("%s %s: XMALLOC() failure",
zlog_warn("%s %s: XCALLOC() failure",
__FILE__, __PRETTY_FUNCTION__);
return 0; /* error, not found, could not create */
}

View File

@ -495,9 +495,9 @@ source_new (struct igmp_group *group,
group->group_igmp_sock->interface->name);
}
src = XMALLOC(MTYPE_PIM_IGMP_GROUP_SOURCE, sizeof(*src));
src = XCALLOC(MTYPE_PIM_IGMP_GROUP_SOURCE, sizeof(*src));
if (!src) {
zlog_warn("%s %s: XMALLOC() failure",
zlog_warn("%s %s: XCALLOC() failure",
__FILE__, __PRETTY_FUNCTION__);
return 0; /* error, not found, could not create */
}

View File

@ -298,9 +298,9 @@ static struct pim_neighbor *pim_neighbor_new(struct interface *ifp,
pim_ifp = ifp->info;
zassert(pim_ifp);
neigh = XMALLOC(MTYPE_PIM_NEIGHBOR, sizeof(*neigh));
neigh = XCALLOC(MTYPE_PIM_NEIGHBOR, sizeof(*neigh));
if (!neigh) {
zlog_err("%s: PIM XMALLOC(%zu) failure",
zlog_err("%s: PIM XCALLOC(%zu) failure",
__PRETTY_FUNCTION__, sizeof(*neigh));
return 0;
}

View File

@ -364,11 +364,11 @@ static struct ssmpingd_sock *ssmpingd_new(struct in_addr source_addr)
return 0;
}
ss = XMALLOC(MTYPE_PIM_SSMPINGD, sizeof(*ss));
ss = XCALLOC(MTYPE_PIM_SSMPINGD, sizeof(*ss));
if (!ss) {
char source_str[100];
pim_inet4_dump("<src?>", source_addr, source_str, sizeof(source_str));
zlog_err("%s: XMALLOC(%zu) failure for ssmpingd source %s",
zlog_err("%s: XCALLOC(%zu) failure for ssmpingd source %s",
__PRETTY_FUNCTION__,
sizeof(*ss), source_str);
close(sock_fd);

View File

@ -367,9 +367,9 @@ static struct pim_upstream *pim_upstream_new(struct in_addr source_addr,
struct pim_upstream *up;
enum pim_rpf_result rpf_result;
up = XMALLOC(MTYPE_PIM_UPSTREAM, sizeof(*up));
up = XCALLOC(MTYPE_PIM_UPSTREAM, sizeof(*up));
if (!up) {
zlog_err("%s: PIM XMALLOC(%zu) failure",
zlog_err("%s: PIM XCALLOC(%zu) failure",
__PRETTY_FUNCTION__, sizeof(*up));
return NULL;
}