summaryrefslogtreecommitdiffstats
path: root/sys/netinet6
diff options
context:
space:
mode:
authormarkj <markj@FreeBSD.org>2016-02-12 20:52:53 +0000
committermarkj <markj@FreeBSD.org>2016-02-12 20:52:53 +0000
commit0309ab8781484f9cf0561cbbc3cab6df7139d629 (patch)
tree594712cc77f99585efe43ad783df01192d52de1d /sys/netinet6
parent732687662635b8d910db6ebeda0fc1a4f9f526ec (diff)
downloadFreeBSD-src-0309ab8781484f9cf0561cbbc3cab6df7139d629.zip
FreeBSD-src-0309ab8781484f9cf0561cbbc3cab6df7139d629.tar.gz
Fix style around allocations from M_IP6NDP.
- Don't cast the return value of malloc(9). - Use M_ZERO instead of explicitly calling bzero(9). MFC after: 1 week
Diffstat (limited to 'sys/netinet6')
-rw-r--r--sys/netinet6/nd6.c2
-rw-r--r--sys/netinet6/nd6_rtr.c13
2 files changed, 6 insertions, 9 deletions
diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c
index da48a87..3655b45 100644
--- a/sys/netinet6/nd6.c
+++ b/sys/netinet6/nd6.c
@@ -243,7 +243,7 @@ nd6_ifattach(struct ifnet *ifp)
{
struct nd_ifinfo *nd;
- nd = (struct nd_ifinfo *)malloc(sizeof(*nd), M_IP6NDP, M_WAITOK|M_ZERO);
+ nd = malloc(sizeof(*nd), M_IP6NDP, M_WAITOK | M_ZERO);
nd->initialized = 1;
nd->chlim = IPV6_DEFHLIM;
diff --git a/sys/netinet6/nd6_rtr.c b/sys/netinet6/nd6_rtr.c
index ca64908..895a06d 100644
--- a/sys/netinet6/nd6_rtr.c
+++ b/sys/netinet6/nd6_rtr.c
@@ -779,11 +779,10 @@ defrtrlist_update(struct nd_defrouter *new)
if (new->rtlifetime == 0)
return (NULL);
- n = (struct nd_defrouter *)malloc(sizeof(*n), M_IP6NDP, M_NOWAIT);
+ n = malloc(sizeof(*n), M_IP6NDP, M_NOWAIT | M_ZERO);
if (n == NULL)
return (NULL);
- bzero(n, sizeof(*n));
- *n = *new;
+ memcpy(n, new, sizeof(*n));
insert:
/*
@@ -826,10 +825,9 @@ pfxrtr_add(struct nd_prefix *pr, struct nd_defrouter *dr)
{
struct nd_pfxrouter *new;
- new = (struct nd_pfxrouter *)malloc(sizeof(*new), M_IP6NDP, M_NOWAIT);
+ new = malloc(sizeof(*new), M_IP6NDP, M_NOWAIT | M_ZERO);
if (new == NULL)
return;
- bzero(new, sizeof(*new));
new->router = dr;
LIST_INSERT_HEAD(&pr->ndpr_advrtrs, new, pfr_entry);
@@ -869,10 +867,9 @@ nd6_prelist_add(struct nd_prefixctl *pr, struct nd_defrouter *dr,
int error = 0;
char ip6buf[INET6_ADDRSTRLEN];
- new = (struct nd_prefix *)malloc(sizeof(*new), M_IP6NDP, M_NOWAIT);
+ new = malloc(sizeof(*new), M_IP6NDP, M_NOWAIT | M_ZERO);
if (new == NULL)
- return(ENOMEM);
- bzero(new, sizeof(*new));
+ return (ENOMEM);
new->ndpr_ifp = pr->ndpr_ifp;
new->ndpr_prefix = pr->ndpr_prefix;
new->ndpr_plen = pr->ndpr_plen;
OpenPOWER on IntegriCloud