From eecd52b2bf47c1348fa6a8c86aba25e6c4d131d5 Mon Sep 17 00:00:00 2001 From: Sascha Wildner Date: Sun, 25 Nov 2007 18:10:07 +0000 Subject: [PATCH] Fix some mis-usages of NULL. --- bin/df/df.c | 4 ++-- bin/ps/keyword.c | 4 ++-- gnu/usr.bin/gdb/kgdb/kthr.c | 6 +++--- libexec/getty/chat.c | 4 ++-- libexec/rtld-elf/rtld.c | 6 +++--- sbin/init/init.c | 6 +++--- sbin/kldconfig/kldconfig.c | 6 +++--- sbin/kldunload/kldunload.c | 4 ++-- sys/boot/common/load_elf.c | 4 ++-- usr.bin/lock/lock.c | 4 ++-- usr.bin/msgs/msgs.c | 10 +++++----- usr.bin/netstat/main.c | 4 ++-- usr.bin/rdist/expand.c | 4 ++-- usr.bin/vmstat/vmstat.c | 4 ++-- 14 files changed, 35 insertions(+), 35 deletions(-) diff --git a/bin/df/df.c b/bin/df/df.c index f9ff5ccfac..addedbb9d0 100644 --- a/bin/df/df.c +++ b/bin/df/df.c @@ -38,7 +38,7 @@ * @(#) Copyright (c) 1980, 1990, 1993, 1994 The Regents of the University of California. All rights reserved. * @(#)df.c 8.9 (Berkeley) 5/8/95 * $FreeBSD: src/bin/df/df.c,v 1.23.2.9 2002/07/01 00:14:24 iedowse Exp $ - * $DragonFly: src/bin/df/df.c,v 1.8 2006/04/03 01:58:43 dillon Exp $ + * $DragonFly: src/bin/df/df.c,v 1.9 2007/11/25 18:10:06 swildner Exp $ */ #include @@ -606,7 +606,7 @@ makenetvfslist(void) *strptr = ','; free(listptr[i]); } - *(--strptr) = NULL; + *(--strptr) = '\0'; free(listptr); return (str); diff --git a/bin/ps/keyword.c b/bin/ps/keyword.c index e697842fb5..4b5ab111cb 100644 --- a/bin/ps/keyword.c +++ b/bin/ps/keyword.c @@ -32,7 +32,7 @@ * * @(#)keyword.c 8.5 (Berkeley) 4/2/94 * $FreeBSD: src/bin/ps/keyword.c,v 1.24.2.3 2002/10/10 20:05:32 jmallett Exp $ - * $DragonFly: src/bin/ps/keyword.c,v 1.29 2007/08/14 20:29:06 dillon Exp $ + * $DragonFly: src/bin/ps/keyword.c,v 1.30 2007/11/25 18:10:06 swildner Exp $ */ #include @@ -163,7 +163,7 @@ static const VAR var[] = { {"rss", "RSS", NULL, 0, p_rssize, NULL, 4, 0, 0, NULL, NULL}, {"rssize", "", "rsz", 0, NULL, NULL, 0, 0, 0, NULL, NULL}, {"rsz", "RSZ", NULL, 0, rssize, NULL, 4, 0, 0, NULL, NULL}, - {"rtprio", "RTPRIO", NULL, 0, rtprior, NULL, 7, NULL, 0, NULL, NULL}, + {"rtprio", "RTPRIO", NULL, 0, rtprior, NULL, 7, 0, 0, NULL, NULL}, {"ruid", "RUID", NULL, 0, pvar, NULL, UIDLEN, POFF(ruid), UINT, UIDFMT, NULL}, {"ruser", "RUSER", NULL, LJUST|DSIZ, runame, s_runame, USERLEN, 0, 0, NULL, diff --git a/gnu/usr.bin/gdb/kgdb/kthr.c b/gnu/usr.bin/gdb/kgdb/kthr.c index cfa2379b8e..974472e87f 100644 --- a/gnu/usr.bin/gdb/kgdb/kthr.c +++ b/gnu/usr.bin/gdb/kgdb/kthr.c @@ -24,7 +24,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/gnu/usr.bin/gdb/kgdb/kthr.c,v 1.3 2005/09/10 18:25:53 marcel Exp $ - * $DragonFly: src/gnu/usr.bin/gdb/kgdb/kthr.c,v 1.3 2007/08/25 21:59:05 corecode Exp $ + * $DragonFly: src/gnu/usr.bin/gdb/kgdb/kthr.c,v 1.4 2007/11/25 18:10:06 swildner Exp $ */ #define _KERNEL_STRUCTURES @@ -146,11 +146,11 @@ kgdb_thr_init(void) * We are a kernel thread, so our td_pcb is * not used anyways. An exception is the * dumping thread. - * kt->pcb == NULL is a marker for + * kt->pcb == 0 is a marker for * "non-dumping kernel thread". */ if (kt->tid != dumptid) - kt->pcb = NULL; + kt->pcb = 0; } first = kt; addr = (uintptr_t)TAILQ_NEXT(&td, td_allq); diff --git a/libexec/getty/chat.c b/libexec/getty/chat.c index 658e5eb68e..75bc014ab9 100644 --- a/libexec/getty/chat.c +++ b/libexec/getty/chat.c @@ -23,7 +23,7 @@ * For semi-intelligent modem handling. * * $FreeBSD: src/libexec/getty/chat.c,v 1.6 1999/08/28 00:09:34 peter Exp $ - * $DragonFly: src/libexec/getty/chat.c,v 1.5 2005/05/07 20:00:20 corecode Exp $ + * $DragonFly: src/libexec/getty/chat.c,v 1.6 2007/11/25 18:10:06 swildner Exp $ */ #include @@ -365,7 +365,7 @@ chat_expect(const char *str) /* See if we can resync on a * partial match in our buffer */ - while (j < i && memcmp(got + j, str, i - j) != NULL) + while (j < i && memcmp(got + j, str, i - j) != 0) j++; if (j < i) memcpy(got, got + j, i - j); diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index 1b843d8e8b..73050c963a 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -24,7 +24,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/libexec/rtld-elf/rtld.c,v 1.43.2.15 2003/02/20 20:42:46 kan Exp $ - * $DragonFly: src/libexec/rtld-elf/rtld.c,v 1.27 2007/02/22 13:15:55 corecode Exp $ + * $DragonFly: src/libexec/rtld-elf/rtld.c,v 1.28 2007/11/25 18:10:06 swildner Exp $ */ /* @@ -1253,7 +1253,7 @@ load_preload_objects(void) static const char delim[] = " \t:;"; if (p == NULL) - return NULL; + return 0; p += strspn(p, delim); while (*p != '\0') { @@ -2755,7 +2755,7 @@ free_tls(struct tls_tcb *tcb) tls_end = (Elf_Addr)tcb; tls_start = (Elf_Addr)tcb - data_size; for (i = 0; i < dtv_size; i++) { - if (dtv[i+2] != NULL && (dtv[i+2] < tls_start || dtv[i+2] > tls_end)) { + if (dtv[i+2] != 0 && (dtv[i+2] < tls_start || dtv[i+2] > tls_end)) { free((void *)dtv[i+2]); } } diff --git a/sbin/init/init.c b/sbin/init/init.c index 3f1c015ac4..5aa185836c 100644 --- a/sbin/init/init.c +++ b/sbin/init/init.c @@ -36,7 +36,7 @@ * @(#) Copyright (c) 1991, 1993 The Regents of the University of California. All rights reserved. * @(#)init.c 8.1 (Berkeley) 7/15/93 * $FreeBSD: src/sbin/init/init.c,v 1.38.2.8 2001/10/22 11:27:32 des Exp $ - * $DragonFly: src/sbin/init/init.c,v 1.9 2005/11/06 12:23:40 swildner Exp $ + * $DragonFly: src/sbin/init/init.c,v 1.10 2007/11/25 18:10:07 swildner Exp $ */ #include @@ -347,7 +347,7 @@ handle(sig_t handler, ...) sa.sa_handler = handler; sigfillset(&mask_everything); - while ((sig = va_arg(ap, int)) != NULL) { + while ((sig = va_arg(ap, int)) != 0) { sa.sa_mask = mask_everything; /* XXX SA_RESTART? */ sa.sa_flags = sig == SIGCHLD ? SA_NOCLDSTOP : 0; @@ -367,7 +367,7 @@ delset(sigset_t *maskp, ...) va_start(ap, maskp); - while ((sig = va_arg(ap, int)) != NULL) + while ((sig = va_arg(ap, int)) != 0) sigdelset(maskp, sig); va_end(ap); } diff --git a/sbin/kldconfig/kldconfig.c b/sbin/kldconfig/kldconfig.c index 06aace03fb..4d6494be5b 100644 --- a/sbin/kldconfig/kldconfig.c +++ b/sbin/kldconfig/kldconfig.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sbin/kldconfig/kldconfig.c,v 1.3.2.1 2001/08/01 05:52:36 obrien Exp $ - * $DragonFly: src/sbin/kldconfig/kldconfig.c,v 1.3 2006/01/17 23:49:12 dillon Exp $ + * $DragonFly: src/sbin/kldconfig/kldconfig.c,v 1.4 2007/11/25 18:10:07 swildner Exp $ */ #include @@ -113,14 +113,14 @@ getpath(void) if (miblen == 0) getmib(); - if (sysctl(mib, miblen, NULL, &sz, NULL, NULL) == -1) + if (sysctl(mib, miblen, NULL, &sz, NULL, 0) == -1) err(1, "getting path: sysctl(%s) - size only", pathctl); if ((path = malloc(sz + 1)) == NULL) { errno = ENOMEM; err(1, "allocating %lu bytes for the path", (unsigned long)sz+1); } - if (sysctl(mib, miblen, path, &sz, NULL, NULL) == -1) + if (sysctl(mib, miblen, path, &sz, NULL, 0) == -1) err(1, "getting path: sysctl(%s)", pathctl); modpath = path; } diff --git a/sbin/kldunload/kldunload.c b/sbin/kldunload/kldunload.c index ca4a06b3c4..18b2964bfc 100644 --- a/sbin/kldunload/kldunload.c +++ b/sbin/kldunload/kldunload.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sbin/kldunload/kldunload.c,v 1.10 1999/09/08 05:46:47 bde Exp $ - * $DragonFly: src/sbin/kldunload/kldunload.c,v 1.4 2005/03/09 16:59:40 liamfoy Exp $ + * $DragonFly: src/sbin/kldunload/kldunload.c,v 1.5 2007/11/25 18:10:07 swildner Exp $ */ #include #include @@ -56,7 +56,7 @@ main(int argc, char** argv) switch (c) { case 'i': tmp = strtol(optarg, &ep, 10); - if (*ep != NULL || tmp < INT_MIN || tmp > INT_MAX) + if (*ep != '\0' || tmp < INT_MIN || tmp > INT_MAX) errx(1, "invalid file id: %s", optarg); fileid = (int)tmp; break; diff --git a/sys/boot/common/load_elf.c b/sys/boot/common/load_elf.c index f4da81292f..f7dcc35534 100644 --- a/sys/boot/common/load_elf.c +++ b/sys/boot/common/load_elf.c @@ -25,7 +25,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/boot/common/load_elf.c,v 1.29 2003/08/25 23:30:41 obrien Exp $ - * $DragonFly: src/sys/boot/common/load_elf.c,v 1.5 2005/02/20 16:30:39 swildner Exp $ + * $DragonFly: src/sys/boot/common/load_elf.c,v 1.6 2007/11/25 18:10:07 swildner Exp $ */ #include @@ -490,7 +490,7 @@ nosyms: ef->strsz = 0; for (i = 0; i < ndp; i++) { - if (dp[i].d_tag == NULL) + if (dp[i].d_tag == 0) break; switch (dp[i].d_tag) { case DT_HASH: diff --git a/usr.bin/lock/lock.c b/usr.bin/lock/lock.c index 4c8e3bab4d..c3030760af 100644 --- a/usr.bin/lock/lock.c +++ b/usr.bin/lock/lock.c @@ -36,7 +36,7 @@ * @(#) Copyright (c) 1980, 1987, 1993 The Regents of the University of California. All rights reserved. * @(#)lock.c 8.1 (Berkeley) 6/6/93 * $FreeBSD: src/usr.bin/lock/lock.c,v 1.8.2.1 2002/09/15 22:32:56 dd Exp $ - * $DragonFly: src/usr.bin/lock/lock.c,v 1.4 2005/03/13 21:17:47 liamfoy Exp $ + * $DragonFly: src/usr.bin/lock/lock.c,v 1.5 2007/11/25 18:10:07 swildner Exp $ */ /* @@ -100,7 +100,7 @@ main(int argc, char **argv) switch(ch) { case 't': tmp = strtol(optarg, &ep, 10); - if (*ep != NULL || tmp > INT_MAX || tmp < INT_MIN) + if (*ep != '\0' || tmp > INT_MAX || tmp < INT_MIN) errx(1, "illegal timeout value"); sectimeout = (int)tmp; break; diff --git a/usr.bin/msgs/msgs.c b/usr.bin/msgs/msgs.c index fcb8db84d7..48d8dd2dfb 100644 --- a/usr.bin/msgs/msgs.c +++ b/usr.bin/msgs/msgs.c @@ -33,7 +33,7 @@ * @(#) Copyright (c) 1980, 1993 The Regents of the University of California. All rights reserved. * @(#)msgs.c 8.2 (Berkeley) 4/28/95 * $FreeBSD: src/usr.bin/msgs/msgs.c,v 1.15.2.2 2003/02/11 21:31:56 mike Exp $ - * $DragonFly: src/usr.bin/msgs/msgs.c,v 1.6 2005/08/09 20:05:55 joerg Exp $ + * $DragonFly: src/usr.bin/msgs/msgs.c,v 1.7 2007/11/25 18:10:07 swildner Exp $ */ /* @@ -760,7 +760,7 @@ ask(const char *prompt) for (n=0; in[n] > ' '; n++) { /* sizeof fname? */ fname[n] = in[n]; } - fname[n] = NULL; + fname[n] = '\0'; } else strcpy(fname, "Messages"); @@ -810,7 +810,7 @@ gfrsub(FILE *infile) seensubj = seenfrom = NO; local = YES; - subj[0] = from[0] = date[0] = NULL; + subj[0] = from[0] = date[0] = '\0'; /* * Is this a normal message? @@ -833,12 +833,12 @@ gfrsub(FILE *infile) *ptr++ = *in++; } } - *ptr = NULL; + *ptr = '\0'; if (*(in = nxtfld(in))) strncpy(date, in, sizeof date); else { date[0] = '\n'; - date[1] = NULL; + date[1] = '\0'; } } else { diff --git a/usr.bin/netstat/main.c b/usr.bin/netstat/main.c index c82736d8aa..a0d04e8cb0 100644 --- a/usr.bin/netstat/main.c +++ b/usr.bin/netstat/main.c @@ -33,7 +33,7 @@ * @(#) Copyright (c) 1983, 1988, 1993 Regents of the University of California. All rights reserved. * @(#)main.c 8.4 (Berkeley) 3/1/94 * $FreeBSD: src/usr.bin/netstat/main.c,v 1.34.2.12 2001/09/17 15:17:46 ru Exp $ - * $DragonFly: src/usr.bin/netstat/main.c,v 1.13 2007/08/16 20:03:58 dillon Exp $ + * $DragonFly: src/usr.bin/netstat/main.c,v 1.14 2007/11/25 18:10:07 swildner Exp $ */ #include @@ -235,7 +235,7 @@ struct protox netgraphprotox[] = { NULL, NULL, "ctrl" }, { N_NGSOCKS, -1, 1, netgraphprotopr, NULL, NULL, "data" }, - { -1, NULL, 0, 0, + { -1, -1, 0, 0, 0, NULL, 0 } }; diff --git a/usr.bin/rdist/expand.c b/usr.bin/rdist/expand.c index 303e2f07c2..f730383a48 100644 --- a/usr.bin/rdist/expand.c +++ b/usr.bin/rdist/expand.c @@ -32,7 +32,7 @@ * * @(#)expand.c 8.1 (Berkeley) 6/9/93 * $FreeBSD: src/usr.bin/rdist/expand.c,v 1.8 1999/08/28 01:05:06 peter Exp $ - * $DragonFly: src/usr.bin/rdist/expand.c,v 1.4 2004/07/24 19:45:10 eirikn Exp $ + * $DragonFly: src/usr.bin/rdist/expand.c,v 1.5 2007/11/25 18:10:07 swildner Exp $ */ #include "defs.h" @@ -172,7 +172,7 @@ expstr(char *s) savec = *tail; *tail = '\0'; } - tp = lookup(cp, NULL, 0); + tp = lookup(cp, 0, NULL); if (savec != '\0') *tail = savec; if (tp != NULL) { diff --git a/usr.bin/vmstat/vmstat.c b/usr.bin/vmstat/vmstat.c index 1c2decc23f..cb6978f470 100644 --- a/usr.bin/vmstat/vmstat.c +++ b/usr.bin/vmstat/vmstat.c @@ -33,7 +33,7 @@ * @(#) Copyright (c) 1980, 1986, 1991, 1993 The Regents of the University of California. All rights reserved. * @(#)vmstat.c 8.1 (Berkeley) 6/6/93 * $FreeBSD: src/usr.bin/vmstat/vmstat.c,v 1.38.2.4 2001/07/31 19:52:41 tmm Exp $ - * $DragonFly: src/usr.bin/vmstat/vmstat.c,v 1.21 2007/06/03 11:49:30 y0netan1 Exp $ + * $DragonFly: src/usr.bin/vmstat/vmstat.c,v 1.22 2007/11/25 18:10:07 swildner Exp $ */ #define _KERNEL_STRUCTURES @@ -865,7 +865,7 @@ dozmem(void) for (;;) { if ((buf = realloc(buf, bufsize)) == NULL) err(1, "realloc()"); - if (sysctlbyname("vm.zone", buf, &bufsize, 0, NULL) == 0) + if (sysctlbyname("vm.zone", buf, &bufsize, NULL, 0) == 0) break; if (errno != ENOMEM) err(1, "sysctl()"); -- 2.41.0