Author: markj
Date: Fri Feb 12 20:52:53 2016
New Revision: 295576
URL: https://svnweb.freebsd.org/changeset/base/295576

Log:
  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

Modified:
  head/sys/netinet6/nd6.c
  head/sys/netinet6/nd6_rtr.c

Modified: head/sys/netinet6/nd6.c
==============================================================================
--- head/sys/netinet6/nd6.c     Fri Feb 12 20:46:53 2016        (r295575)
+++ head/sys/netinet6/nd6.c     Fri Feb 12 20:52:53 2016        (r295576)
@@ -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;

Modified: head/sys/netinet6/nd6_rtr.c
==============================================================================
--- head/sys/netinet6/nd6_rtr.c Fri Feb 12 20:46:53 2016        (r295575)
+++ head/sys/netinet6/nd6_rtr.c Fri Feb 12 20:52:53 2016        (r295576)
@@ -779,11 +779,10 @@ defrtrlist_update(struct nd_defrouter *n
        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 
 {
        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,
        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;
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to