This diff converts bzero calls to memset, which is more portable and
compilers can optimize as well.

---
 src/usr.sbin/ntpd/client.c  | 2 +-
 src/usr.sbin/ntpd/config.c  | 6 +++---
 src/usr.sbin/ntpd/control.c | 2 +-
 src/usr.sbin/ntpd/ntp.c     | 6 +++---
 src/usr.sbin/ntpd/ntpd.c    | 4 ++--
 src/usr.sbin/ntpd/parse.y   | 2 +-
 src/usr.sbin/ntpd/server.c  | 2 +-
 7 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/src/usr.sbin/ntpd/client.c b/src/usr.sbin/ntpd/client.c
index 1d982d6..eca2467 100644
--- a/src/usr.sbin/ntpd/client.c
+++ b/src/usr.sbin/ntpd/client.c
@@ -215,7 +215,7 @@ client_dispatch(struct ntp_peer *p, u_int8_t settime)
        double                   T1, T2, T3, T4;
        time_t                   interval;

-       bzero(&somsg, sizeof(somsg));
+       memset(&somsg, 0, sizeof(somsg));
        iov[0].iov_base = buf;
        iov[0].iov_len = sizeof(buf);
        somsg.msg_iov = iov;
diff --git a/src/usr.sbin/ntpd/config.c b/src/usr.sbin/ntpd/config.c
index 3945405..7e2ecb6 100644
--- a/src/usr.sbin/ntpd/config.c
+++ b/src/usr.sbin/ntpd/config.c
@@ -65,7 +65,7 @@ host_v4(const char *s)
        struct sockaddr_in      *sa_in;
        struct ntp_addr         *h;

-       bzero(&ina, sizeof(struct in_addr));
+       memset(&ina, 0, sizeof(struct in_addr));
        if (inet_pton(AF_INET, s, &ina) != 1)
                return (NULL);

@@ -86,7 +86,7 @@ host_v6(const char *s)
        struct sockaddr_in6     *sa_in6;
        struct ntp_addr         *h = NULL;

-       bzero(&hints, sizeof(hints));
+       memset(&hints, 0, sizeof(hints));
        hints.ai_family = AF_INET6;
        hints.ai_socktype = SOCK_DGRAM; /*dummy*/
        hints.ai_flags = AI_NUMERICHOST;
@@ -128,7 +128,7 @@ host_dns(const char *s, struct ntp_addr **hn)
        struct sockaddr_in6     *sa_in6;
        struct ntp_addr         *h, *hh = NULL;

-       bzero(&hints, sizeof(hints));
+       memset(&hints, 0, sizeof(hints));
        hints.ai_family = PF_UNSPEC;
        hints.ai_socktype = SOCK_DGRAM; /* DUMMY */
        /* ntpd MUST NOT use AI_ADDRCONFIG here */
diff --git a/src/usr.sbin/ntpd/control.c b/src/usr.sbin/ntpd/control.c
index 3662971..fa95504 100644
--- a/src/usr.sbin/ntpd/control.c
+++ b/src/usr.sbin/ntpd/control.c
@@ -45,7 +45,7 @@ control_init(char *path)
                return (-1);
        }

-       bzero(&sa, sizeof(sa));
+       memset(&sa, 0, sizeof(sa));
        sa.sun_family = AF_UNIX;
        if (strlcpy(sa.sun_path, path, sizeof(sa.sun_path)) >=
            sizeof(sa.sun_path))
diff --git a/src/usr.sbin/ntpd/ntp.c b/src/usr.sbin/ntpd/ntp.c
index 50fc468..b89ddf2 100644
--- a/src/usr.sbin/ntpd/ntp.c
+++ b/src/usr.sbin/ntpd/ntp.c
@@ -188,7 +188,7 @@ ntp_main(int pipe_prnt[2], int fd_ctl, struct ntpd_conf 
*nconf,
        TAILQ_FOREACH(p, &conf->ntp_peers, entry)
                client_peer_init(p);

-       bzero(&conf->status, sizeof(conf->status));
+       memset(&conf->status, 0, sizeof(conf->status));

        conf->freq.num = 0;
        conf->freq.samples = 0;
@@ -246,8 +246,8 @@ ntp_main(int pipe_prnt[2], int fd_ctl, struct ntpd_conf 
*nconf,
                        pfd_elms = new_cnt;
                }

-               bzero(pfd, sizeof(*pfd) * pfd_elms);
-               bzero(idx2peer, sizeof(*idx2peer) * idx2peer_elms);
+               memset(pfd, 0, sizeof(*pfd) * pfd_elms);
+               memset(idx2peer, 0, sizeof(*idx2peer) * idx2peer_elms);
                nextaction = getmonotime() + 3600;
                pfd[PFD_PIPE_MAIN].fd = ibuf_main->fd;
                pfd[PFD_PIPE_MAIN].events = POLLIN;
diff --git a/src/usr.sbin/ntpd/ntpd.c b/src/usr.sbin/ntpd/ntpd.c
index 045bdd4..3adf4dc 100644
--- a/src/usr.sbin/ntpd/ntpd.c
+++ b/src/usr.sbin/ntpd/ntpd.c
@@ -119,7 +119,7 @@ main(int argc, char *argv[])

        conffile = CONFFILE;

-       bzero(&lconf, sizeof(lconf));
+       memset(&lconf, 0, sizeof(lconf));

        log_init(1);            /* log to stderr until daemonized */

@@ -557,7 +557,7 @@ ctl_main(int argc, char *argv[])
        if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
                err(1, "ntpctl: socket");

-       bzero(&sa, sizeof(sa));
+       memset(&sa, 0, sizeof(sa));
        sa.sun_family = AF_UNIX;
        if (strlcpy(sa.sun_path, sockname, sizeof(sa.sun_path)) >=
            sizeof(sa.sun_path))
diff --git a/src/usr.sbin/ntpd/parse.y b/src/usr.sbin/ntpd/parse.y
index 4b9ef49..999ff24 100644
--- a/src/usr.sbin/ntpd/parse.y
+++ b/src/usr.sbin/ntpd/parse.y
@@ -426,7 +426,7 @@ rtable              : RTABLE NUMBER {
 void
 opts_default(void)
 {
-       bzero(&opts, sizeof opts);
+       memset(&opts, 0, sizeof opts);
        opts.weight = 1;
        opts.rtable = -1;
        opts.stratum = 1;
diff --git a/src/usr.sbin/ntpd/server.c b/src/usr.sbin/ntpd/server.c
index ef448d3..9c71eed 100644
--- a/src/usr.sbin/ntpd/server.c
+++ b/src/usr.sbin/ntpd/server.c
@@ -175,7 +175,7 @@ server_dispatch(int fd, struct ntpd_conf *lconf)
        if (ntp_getmsg((struct sockaddr *)&fsa, buf, size, &query) == -1)
                return (0);

-       bzero(&reply, sizeof(reply));
+       memset(&reply, 0, sizeof(reply));
        if (lconf->status.synced)
                reply.status = lconf->status.leap;
        else
--
2.4.5

Reply via email to