summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpfg <pfg@FreeBSD.org>2016-05-14 00:46:38 +0000
committerpfg <pfg@FreeBSD.org>2016-05-14 00:46:38 +0000
commit69cdab8aa86defee681db824959d69660163578d (patch)
tree744bd83d337c707fa5300ec4b73acd3bdcdb2591
parent2773c653430e3fac6d3b245160efbd33879bc690 (diff)
downloadFreeBSD-src-69cdab8aa86defee681db824959d69660163578d.zip
FreeBSD-src-69cdab8aa86defee681db824959d69660163578d.tar.gz
timed(8): use NULL instead of zero for pointers.
-rw-r--r--usr.sbin/timed/timed/acksend.c4
-rw-r--r--usr.sbin/timed/timed/master.c12
-rw-r--r--usr.sbin/timed/timed/readmsg.c4
-rw-r--r--usr.sbin/timed/timed/slave.c6
-rw-r--r--usr.sbin/timed/timed/timed.c50
-rw-r--r--usr.sbin/timed/timedc/cmds.c8
-rw-r--r--usr.sbin/timed/timedc/timedc.c12
7 files changed, 48 insertions, 48 deletions
diff --git a/usr.sbin/timed/timed/acksend.c b/usr.sbin/timed/timed/acksend.c
index 8492f9e..dca3a68 100644
--- a/usr.sbin/timed/timed/acksend.c
+++ b/usr.sbin/timed/timed/acksend.c
@@ -90,7 +90,7 @@ acksend(struct tsp *message, struct sockaddr_in *addr, char *name,
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 sockaddr_in *addr, char *name,
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",
diff --git a/usr.sbin/timed/timed/master.c b/usr.sbin/timed/timed/master.c
index 2bc3f85..2bb8451 100644
--- a/usr.sbin/timed/timed/master.c
+++ b/usr.sbin/timed/timed/master.c
@@ -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 *addr, struct netinfo *ntp)
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);
diff --git a/usr.sbin/timed/timed/readmsg.c b/usr.sbin/timed/timed/readmsg.c
index 8168612..e637912 100644
--- a/usr.sbin/timed/timed/readmsg.c
+++ b/usr.sbin/timed/timed/readmsg.c
@@ -85,9 +85,9 @@ readmsg(int type, char *machfrom, struct timeval *intvl, struct netinfo *netfrom
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) {
diff --git a/usr.sbin/timed/timed/slave.c b/usr.sbin/timed/timed/slave.c
index 15c0c43..947d878 100644
--- a/usr.sbin/timed/timed/slave.c
+++ b/usr.sbin/timed/timed/slave.c
@@ -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,
diff --git a/usr.sbin/timed/timed/timed.c b/usr.sbin/timed/timed/timed.c
index e178912..37e5607 100644
--- a/usr.sbin/timed/timed/timed.c
+++ b/usr.sbin/timed/timed/timed.c
@@ -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;
diff --git a/usr.sbin/timed/timedc/cmds.c b/usr.sbin/timed/timedc/cmds.c
index e39bf03..1eb6a75f 100644
--- a/usr.sbin/timed/timedc/cmds.c
+++ b/usr.sbin/timed/timedc/cmds.c
@@ -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;
}
diff --git a/usr.sbin/timed/timedc/timedc.c b/usr.sbin/timed/timedc/timedc.c
index 2f3e508..4124661 100644
--- a/usr.sbin/timed/timedc/timedc.c
+++ b/usr.sbin/timed/timedc/timedc.c
@@ -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"))
OpenPOWER on IntegriCloud