Index: config.c
===================================================================
RCS file: /cvs/src/usr.sbin/rtadvd/config.c,v
retrieving revision 1.40
diff -u -p -r1.40 config.c
--- config.c    17 Oct 2013 16:27:48 -0000      1.40
+++ config.c    11 Jun 2014 17:27:47 -0000
@@ -240,9 +240,8 @@ getconfig(intface)
                        continue;
 
                /* allocate memory to store prefix information */
-               if ((pfx = malloc(sizeof(struct prefix))) == NULL)
-                       fatal("malloc");
-               memset(pfx, 0, sizeof(*pfx));
+               if ((pfx = calloc(1, sizeof(*pfx))) == NULL)
+                       fatal("calloc");
 
                /* link into chain */
                TAILQ_INSERT_TAIL(&tmp->prefixes, pfx, entry);
@@ -568,9 +567,8 @@ get_prefix(struct rainfo *rai)
                }
 
                /* allocate memory to store prefix info. */
-               if ((pp = malloc(sizeof(*pp))) == NULL)
-                       fatal("malloc");
-               memset(pp, 0, sizeof(*pp));
+               if ((pp = calloc(1, sizeof(*pp))) == NULL)
+                       fatal("calloc");
 
                /* set prefix, sweep bits outside of prefixlen */
                pp->prefixlen = plen;
@@ -634,11 +632,10 @@ add_prefix(struct rainfo *rai, struct in
        struct prefix *prefix;
        u_char ntopbuf[INET6_ADDRSTRLEN];
 
-       if ((prefix = malloc(sizeof(*prefix))) == NULL) {
-               log_warn("malloc");
+       if ((prefix = calloc(1, sizeof(*prefix))) == NULL) {
+               log_warn("calloc");
                return;         /* XXX: error or exit? */
        }
-       memset(prefix, 0, sizeof(*prefix));
        prefix->prefix = ipr->ipr_prefix.sin6_addr;
        prefix->prefixlen = ipr->ipr_plen;
        prefix->validlifetime = ipr->ipr_vltime;
Index: rtadvd.c
===================================================================
RCS file: /cvs/src/usr.sbin/rtadvd/rtadvd.c,v
retrieving revision 1.46
diff -u -p -r1.46 rtadvd.c
--- rtadvd.c    15 May 2014 05:03:24 -0000      1.46
+++ rtadvd.c    11 Jun 2014 17:27:48 -0000
@@ -249,15 +249,14 @@ main(argc, argv)
                fatal("cannot drop privileges");
 
        fdmasks = howmany(maxfd + 1, NFDBITS) * sizeof(fd_mask);
-       if ((fdsetp = malloc(fdmasks)) == NULL) {
-               err(1, "malloc");
+       if ((fdsetp = calloc(1, fdmasks)) == NULL) {
+               err(1, "calloc");
                /*NOTREACHED*/
        }
        if ((selectfdp = malloc(fdmasks)) == NULL) {
                err(1, "malloc");
                /*NOTREACHED*/
        }
-       memset(fdsetp, 0, fdmasks);
        FD_SET(sock, fdsetp);
        if (rtsock >= 0)
                FD_SET(rtsock, fdsetp);
Index: timer.c
===================================================================
RCS file: /cvs/src/usr.sbin/rtadvd/timer.c,v
retrieving revision 1.11
diff -u -p -r1.11 timer.c
--- timer.c     30 Apr 2013 12:30:40 -0000      1.11
+++ timer.c     11 Jun 2014 17:27:48 -0000
@@ -48,10 +48,8 @@ rtadvd_add_timer(void (*timeout)(void *)
 {
        struct rtadvd_timer *newtimer;
 
-       if ((newtimer = malloc(sizeof(*newtimer))) == NULL)
-               fatal("malloc");
-
-       memset(newtimer, 0, sizeof(*newtimer));
+       if ((newtimer = calloc(1, sizeof(*newtimer))) == NULL)
+               fatal("calloc");
 
        if (timeout == NULL)
                fatalx("timeout function unspecified");

Reply via email to