Author: pfg
Date: Sat May 14 00:46:38 2016
New Revision: 299707
URL: https://svnweb.freebsd.org/changeset/base/299707

Log:
  timed(8): use NULL instead of zero for pointers.

Modified:
  head/usr.sbin/timed/timed/acksend.c
  head/usr.sbin/timed/timed/master.c
  head/usr.sbin/timed/timed/readmsg.c
  head/usr.sbin/timed/timed/slave.c
  head/usr.sbin/timed/timed/timed.c
  head/usr.sbin/timed/timedc/cmds.c
  head/usr.sbin/timed/timedc/timedc.c

Modified: head/usr.sbin/timed/timed/acksend.c
==============================================================================
--- head/usr.sbin/timed/timed/acksend.c Sat May 14 00:44:23 2016        
(r299706)
+++ head/usr.sbin/timed/timed/acksend.c Sat May 14 00:46:38 2016        
(r299707)
@@ -90,7 +90,7 @@ acksend(struct tsp *message, struct sock
 
        msec = 200;
        count = bad ? 1 : 5;    /* 5 packets in 6.4 seconds */
-       answer = 0;
+       answer = NULL;
        do {
                if (!answer) {
                        /* do not go crazy transmitting just because the
@@ -107,7 +107,7 @@ acksend(struct tsp *message, struct sock
 
                mstotvround(&twait, msec);
                answer  = readmsg(ack, name, &twait, net);
-               if (answer != 0) {
+               if (answer != NULL) {
                        if (answer->tsp_seq != sequence) {
                                if (trace)
                                        fprintf(fd,"acksend: seq # %u!=%u\n",

Modified: head/usr.sbin/timed/timed/master.c
==============================================================================
--- head/usr.sbin/timed/timed/master.c  Sat May 14 00:44:23 2016        
(r299706)
+++ head/usr.sbin/timed/timed/master.c  Sat May 14 00:46:38 2016        
(r299707)
@@ -185,7 +185,7 @@ loop:
                        tsp_time_sec = msg->tsp_time.tv_sec;
                        (void)strcpy(newdate, ctime(&tsp_time_sec));
                        htp = findhost(msg->tsp_name);
-                       if (htp == 0) {
+                       if (htp == NULL) {
                                syslog(LOG_ERR,
                                       "attempted SET DATEREQ by uncontrolled 
%s to %s",
                                       msg->tsp_name, newdate);
@@ -477,7 +477,7 @@ spreadtime(void)
                to.tsp_time.tv_usec = tmptv.tv_usec;
                answer = acksend(&to, &htp->addr, htp->name,
                                 TSP_ACK, 0, htp->noanswer);
-               if (answer == 0) {
+               if (answer == NULL) {
                        /* We client does not respond, then we have
                         * just wasted lots of time on it.
                         */
@@ -566,7 +566,7 @@ addmach(char *name, struct sockaddr_in *
        struct hosttbl *ret, *p, *b, *f;
 
        ret = findhost(name);
-       if (ret == 0) {
+       if (ret == NULL) {
                if (slvcount >= NHOSTS) {
                        if (trace) {
                                fprintf(fd, "no more slots in host table\n");
@@ -684,8 +684,8 @@ remmach(struct hosttbl *htp)
        }
 
        lasthfree->name[0] = '\0';
-       lasthfree->h_fwd = 0;
-       lasthfree->l_fwd = 0;
+       lasthfree->h_fwd = NULL;
+       lasthfree->l_fwd = NULL;
        slvcount--;
 
        return lprv;
@@ -828,7 +828,7 @@ traceoff(char *msg)
        if (trace) {
                fprintf(fd, msg, date());
                (void)fclose(fd);
-               fd = 0;
+               fd = NULL;
        }
 #ifdef GPROF
        moncontrol(0);

Modified: head/usr.sbin/timed/timed/readmsg.c
==============================================================================
--- head/usr.sbin/timed/timed/readmsg.c Sat May 14 00:44:23 2016        
(r299706)
+++ head/usr.sbin/timed/timed/readmsg.c Sat May 14 00:46:38 2016        
(r299707)
@@ -85,9 +85,9 @@ readmsg(int type, char *machfrom, struct
                fprintf(fd, "readmsg: looking for %s from %s, %s\n",
                        tsptype[type], machfrom == NULL ? "ANY" : machfrom,
                        netfrom == NULL ? "ANYNET" : inet_ntoa(netfrom->net));
-               if (head->p != 0) {
+               if (head->p != NULL) {
                        length = 1;
-                       for (ptr = head->p; ptr != 0; ptr = ptr->p) {
+                       for (ptr = head->p; ptr != NULL; ptr = ptr->p) {
                                /* do not repeat the hundreds of messages */
                                if (++length > 3) {
                                        if (ptr == tail) {

Modified: head/usr.sbin/timed/timed/slave.c
==============================================================================
--- head/usr.sbin/timed/timed/slave.c   Sat May 14 00:44:23 2016        
(r299706)
+++ head/usr.sbin/timed/timed/slave.c   Sat May 14 00:46:38 2016        
(r299707)
@@ -78,7 +78,7 @@ slave(void)
        struct utmpx utx;
 
 
-       old_slavenet = 0;
+       old_slavenet = NULL;
        seq = 0;
        refusetime = 0;
        adjtime = 0;
@@ -352,7 +352,7 @@ loop:
                        tsp_time_sec = msg->tsp_time.tv_sec;
                        (void)strcpy(newdate, ctime(&tsp_time_sec));
                        htp = findhost(msg->tsp_name);
-                       if (0 == htp) {
+                       if (htp == NULL) {
                                syslog(LOG_WARNING,
                                       "DATEREQ from uncontrolled machine");
                                break;
@@ -544,7 +544,7 @@ loop:
                                if (msg->tsp_hopcnt-- < 1)
                                    break;
                                bytenetorder(msg);
-                               for (ntp = nettab; ntp != 0; ntp = ntp->next) {
+                               for (ntp = nettab; ntp != NULL; ntp = 
ntp->next) {
                                    if (ntp->status == MASTER
                                        && 0 > sendto(sock, (char *)msg,
                                                      sizeof(struct tsp), 0,

Modified: head/usr.sbin/timed/timed/timed.c
==============================================================================
--- head/usr.sbin/timed/timed/timed.c   Sat May 14 00:44:23 2016        
(r299706)
+++ head/usr.sbin/timed/timed/timed.c   Sat May 14 00:46:38 2016        
(r299707)
@@ -68,7 +68,7 @@ FILE *fd;                             /* trace file FD */
 
 jmp_buf jmpenv;
 
-struct netinfo *nettab = 0;
+struct netinfo *nettab = NULL;
 struct netinfo *slavenet;
 int Mflag;
 int justquit = 0;
@@ -78,7 +78,7 @@ static struct nets {
        char    *name;
        long    net;
        struct nets *next;
-} *nets = 0;
+} *nets = NULL;
 
 struct hosttbl hosttbl[NHOSTS+1];      /* known hosts */
 
@@ -177,7 +177,7 @@ main(int argc, char *argv[])
                        debug = 1;
                        break;
                case 'G':
-                       if (goodgroup != 0)
+                       if (goodgroup != NULL)
                                errx(1, "only one net group");
                        goodgroup = optarg;
                        break;
@@ -193,7 +193,7 @@ main(int argc, char *argv[])
        /* If we care about which machine is the master, then we must
         *      be willing to be a master
         */
-       if (0 != goodgroup || 0 != goodhosts)
+       if (goodgroup != NULL || goodhosts != NULL)
                Mflag = 1;
 
        if (gethostname(hostname, sizeof(hostname) - 1) < 0)
@@ -205,11 +205,11 @@ main(int argc, char *argv[])
        self.head = 1;
        self.good = 1;
 
-       if (goodhosts != 0)             /* trust ourself */
+       if (goodhosts != NULL)          /* trust ourself */
                add_good_host(hostname,1);
 
        srvp = getservbyname("timed", "udp");
-       if (srvp == 0)
+       if (srvp == NULL)
                errx(1, "timed/udp: unknown service");
        port = srvp->s_port;
        bzero(&server, sizeof(struct sockaddr_in));
@@ -242,12 +242,12 @@ main(int argc, char *argv[])
 
        for (nt = nets; nt; nt = nt->next) {
                nentp = getnetbyname(nt->name);
-               if (nentp == 0) {
+               if (nentp == NULL) {
                        nt->net = inet_network(nt->name);
                        if (nt->net != INADDR_NONE)
                                nentp = getnetbyaddr(nt->net, AF_INET);
                }
-               if (nentp != 0) {
+               if (nentp != NULL) {
                        nt->net = nentp->n_net;
                } else if (nt->net == INADDR_NONE) {
                        errx(1, "unknown net %s", nt->name);
@@ -376,7 +376,7 @@ main(int argc, char *argv[])
                        break;
                case 1:
                        /* Just lost our master */
-                       if (slavenet != 0)
+                       if (slavenet != NULL)
                                slavenet->status = election(slavenet);
                        if (!slavenet || slavenet->status == MASTER) {
                                checkignorednets();
@@ -488,12 +488,12 @@ lookformaster(struct netinfo *ntp)
        (void)strcpy(resp.tsp_name, hostname);
        answer = acksend(&resp, &ntp->dest_addr, ANYADDR,
                         TSP_MASTERACK, ntp, 0);
-       if (answer != 0 && !good_host_name(answer->tsp_name)) {
+       if (answer != NULL && !good_host_name(answer->tsp_name)) {
                suppress(&from, answer->tsp_name, ntp);
                ntp->status = NOMASTER;
-               answer = 0;
+               answer = NULL;
        }
-       if (answer == 0) {
+       if (answer == NULL) {
                /*
                 * Various conditions can cause conflict: races between
                 * two just started timedaemons when no master is
@@ -504,7 +504,7 @@ lookformaster(struct netinfo *ntp)
                 */
                ntime.tv_sec = ntime.tv_usec = 0;
                answer = readmsg(TSP_MASTERREQ, ANYADDR, &ntime, ntp);
-               if (answer != 0) {
+               if (answer != NULL) {
                        if (!good_host_name(answer->tsp_name)) {
                                suppress(&from, answer->tsp_name, ntp);
                                ntp->status = NOMASTER;
@@ -514,7 +514,7 @@ lookformaster(struct netinfo *ntp)
 
                ntime.tv_sec = ntime.tv_usec = 0;
                answer = readmsg(TSP_MASTERUP, ANYADDR, &ntime, ntp);
-               if (answer != 0) {
+               if (answer != NULL) {
                        if (!good_host_name(answer->tsp_name)) {
                                suppress(&from, answer->tsp_name, ntp);
                                ntp->status = NOMASTER;
@@ -524,7 +524,7 @@ lookformaster(struct netinfo *ntp)
 
                ntime.tv_sec = ntime.tv_usec = 0;
                answer = readmsg(TSP_ELECTION, ANYADDR, &ntime, ntp);
-               if (answer != 0) {
+               if (answer != NULL) {
                        if (!good_host_name(answer->tsp_name)) {
                                suppress(&from, answer->tsp_name, ntp);
                                ntp->status = NOMASTER;
@@ -664,13 +664,13 @@ checkignorednets(void)
 static void
 pickslavenet(struct netinfo *ntp)
 {
-       if (slavenet != 0 && slavenet->status == SLAVE) {
+       if (slavenet != NULL && slavenet->status == SLAVE) {
                makeslave(slavenet);            /* prune extras */
                return;
        }
 
-       if (ntp == 0 || ntp->status != SLAVE) {
-               for (ntp = nettab; ntp != 0; ntp = ntp->next) {
+       if (ntp == NULL || ntp->status != SLAVE) {
+               for (ntp = nettab; ntp != NULL; ntp = ntp->next) {
                        if (ntp->status == SLAVE)
                                break;
                }
@@ -707,7 +707,7 @@ addnetname(char *name)
        while (*netlist)
                netlist = &((*netlist)->next);
        *netlist = (struct nets *)malloc(sizeof **netlist);
-       if (*netlist == 0)
+       if (*netlist == NULL)
                errx(1, "malloc failed");
        bzero((char *)*netlist, sizeof(**netlist));
        (*netlist)->name = name;
@@ -735,7 +735,7 @@ add_good_host(char *name, int perm)
        goodhosts = ghp;
 
        hentp = gethostbyname(name);
-       if (0 == hentp && perm)
+       if (hentp == NULL && perm)
                warnx("unknown host %s", name);
 }
 
@@ -757,7 +757,7 @@ get_goodgroup(int force)
 
 
        /* if no netgroup, then we are finished */
-       if (goodgroup == 0 || !Mflag)
+       if (goodgroup == NULL || !Mflag)
                return;
 
        /* Do not chatter with the netgroup master too often.
@@ -770,10 +770,10 @@ get_goodgroup(int force)
 
        /* forget the old temporary entries */
        ghpp = &goodhosts;
-       while (0 != (ghp = *ghpp)) {
+       while ((ghp = *ghpp) != NULL) {
                if (!ghp->perm) {
                        *ghpp = ghp->next;
-                       free((char*)ghp);
+                       free(ghp);
                } else {
                        ghpp = &ghp->next;
                }
@@ -795,7 +795,7 @@ get_goodgroup(int force)
        /* mark the entire netgroup as trusted */
        (void)setnetgrent(goodgroup);
        while (getnetgrent(&mach,&usr,&dom)) {
-               if (0 != mach)
+               if (mach != NULL)
                        add_good_host(mach,0);
        }
        (void)endnetgrent();
@@ -824,7 +824,7 @@ good_host_name(char *name)
                if (c == ghp->name[0]
                    && !strcasecmp(name, ghp->name))
                        return 1;       /* found him, so say so */
-       } while (0 != (ghp = ghp->next));
+       } while ((ghp = ghp->next) != NULL);
 
        if (!strcasecmp(name,hostname)) /* trust ourself */
                return 1;

Modified: head/usr.sbin/timed/timedc/cmds.c
==============================================================================
--- head/usr.sbin/timed/timedc/cmds.c   Sat May 14 00:44:23 2016        
(r299706)
+++ head/usr.sbin/timed/timedc/cmds.c   Sat May 14 00:46:38 2016        
(r299707)
@@ -277,7 +277,7 @@ msite(int argc, char *argv[])
        }
 
        srvp = getservbyname("timed", "udp");
-       if (srvp == 0) {
+       if (srvp == NULL) {
                warnx("timed/udp: unknown service");
                return;
        }
@@ -290,7 +290,7 @@ msite(int argc, char *argv[])
        do {
                tgtname = (i >= argc) ? myname : argv[i];
                hp = gethostbyname(tgtname);
-               if (hp == 0) {
+               if (hp == NULL) {
                        warnx("%s: %s", tgtname, hstrerror(h_errno));
                        continue;
                }
@@ -378,7 +378,7 @@ testing(int argc, char *argv[])
        }
 
        srvp = getservbyname("timed", "udp");
-       if (srvp == 0) {
+       if (srvp == NULL) {
                warnx("timed/udp: unknown service");
                return;
        }
@@ -432,7 +432,7 @@ tracing(int argc, char *argv[])
        }
 
        srvp = getservbyname("timed", "udp");
-       if (srvp == 0) {
+       if (srvp == NULL) {
                warnx("timed/udp: unknown service");
                return;
        }

Modified: head/usr.sbin/timed/timedc/timedc.c
==============================================================================
--- head/usr.sbin/timed/timedc/timedc.c Sat May 14 00:44:23 2016        
(r299706)
+++ head/usr.sbin/timed/timedc/timedc.c Sat May 14 00:46:38 2016        
(r299707)
@@ -52,7 +52,7 @@ static const char rcsid[] =
 #include <unistd.h>
 
 int trace = 0;
-FILE *fd = 0;
+FILE *fd = NULL;
 int    margc;
 int    fromatty;
 #define        MAX_MARGV       20
@@ -82,7 +82,7 @@ main(int argc, char *argv[])
                        printf("?Ambiguous command\n");
                        exit(1);
                }
-               if (c == 0) {
+               if (c == NULL) {
                        printf("?Invalid command\n");
                        exit(1);
                }
@@ -108,14 +108,14 @@ main(int argc, char *argv[])
                if (cmdline[0] == 0)
                        break;
                makeargv();
-               if (margv[0] == 0)
+               if (margv[0] == NULL)
                        continue;
                c = getcmd(margv[0]);
                if (c == (struct cmd *)-1) {
                        printf("?Ambiguous command\n");
                        continue;
                }
-               if (c == 0) {
+               if (c == NULL) {
                        printf("?Invalid command\n");
                        continue;
                }
@@ -147,7 +147,7 @@ getcmd(char *name)
 
        longest = 0;
        nmatches = 0;
-       found = 0;
+       found = NULL;
        for (c = cmdtab; c < &cmdtab[NCMDS]; c++) {
                p = c->c_name;
                for (q = name; *q == *p++; q++)
@@ -190,7 +190,7 @@ makeargv(void)
                        break;
                *cp++ = '\0';
        }
-       *argp++ = 0;
+       *argp++ = NULL;
 }
 
 #define HELPINDENT (sizeof ("directory"))
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to