summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormarkm <markm@FreeBSD.org>2004-03-05 08:10:19 +0000
committermarkm <markm@FreeBSD.org>2004-03-05 08:10:19 +0000
commit0b0ae8e16e50fd60ad86f4f14ec05cfc50e7eae5 (patch)
tree524ae0ef30bcdfacb05b3c2b01e1c48e80d93e3b
parentf5816d0166177c6f98d32562b93f6cf287f9b4f5 (diff)
downloadFreeBSD-src-0b0ae8e16e50fd60ad86f4f14ec05cfc50e7eae5.zip
FreeBSD-src-0b0ae8e16e50fd60ad86f4f14ec05cfc50e7eae5.tar.gz
Make NULL a (void*)0 whereever possible, and fix the warnings(-Werror)
that this provokes. "Wherever possible" means "In the kernel OR NOT C++" (implying C). There are places where (void *) pointers are not valid, such as for function pointers, but in the special case of (void *)0, agreement settles on it being OK. Most of the fixes were NULL where an integer zero was needed; many of the fixes were NULL where ascii <nul> ('\0') was needed, and a few were just "other". Tested on: i386 sparc64
-rw-r--r--bin/df/df.c2
-rw-r--r--bin/pax/options.c2
-rw-r--r--lib/libbluetooth/bluetooth.c2
-rw-r--r--lib/libbsnmp/Makefile.inc1
-rw-r--r--lib/libc/gen/dlfcn.c2
-rw-r--r--lib/libc/gen/getpwent.c2
-rw-r--r--lib/libc/net/gethostbydns.c4
-rw-r--r--lib/libc/rpc/getnetconfig.c8
-rw-r--r--lib/libpam/modules/pam_login_access/login_access.c2
-rw-r--r--lib/libthr/arch/i386/i386/_setcurthread.c2
-rw-r--r--libexec/rtld-elf/rtld.c8
-rw-r--r--sbin/atm/atmconfig/diag.c2
-rw-r--r--sbin/kldconfig/kldconfig.c4
-rw-r--r--sbin/raidctl/raidctl.c2
-rw-r--r--sbin/raidctl/rf_configure.c2
-rw-r--r--sbin/swapon/swapon.c2
-rw-r--r--sys/sys/_null.h10
-rw-r--r--usr.sbin/bluetooth/hccontrol/send_recv.c2
-rw-r--r--usr.sbin/bsnmpd/bsnmpd/Makefile1
-rw-r--r--usr.sbin/burncd/burncd.c2
-rw-r--r--usr.sbin/mountd/mountd.c2
-rw-r--r--usr.sbin/pstat/pstat.c2
22 files changed, 34 insertions, 32 deletions
diff --git a/bin/df/df.c b/bin/df/df.c
index 008fd69..2147e78 100644
--- a/bin/df/df.c
+++ b/bin/df/df.c
@@ -579,7 +579,7 @@ makenetvfslist(void)
*strptr = ',';
free(listptr[i]);
}
- *(--strptr) = NULL;
+ *(--strptr) = '\0';
free(keep_xvfsp);
free(listptr);
diff --git a/bin/pax/options.c b/bin/pax/options.c
index 1475e89..c328e79 100644
--- a/bin/pax/options.c
+++ b/bin/pax/options.c
@@ -1256,7 +1256,7 @@ cpio_options(int argc, char **argv)
*/
maxflt = 0;
while ((str = getline(stdin)) != NULL) {
- ftree_add(str, NULL);
+ ftree_add(str, 0);
}
if (getline_error) {
paxwarn(1, "Problem while reading stdin");
diff --git a/lib/libbluetooth/bluetooth.c b/lib/libbluetooth/bluetooth.c
index 4678509..f206aee 100644
--- a/lib/libbluetooth/bluetooth.c
+++ b/lib/libbluetooth/bluetooth.c
@@ -291,7 +291,7 @@ bt_aton(char const *str, bdaddr_t *ba)
memset(ba, 0, sizeof(*ba));
for (i = 5, end = strchr(str, ':');
- i > 0 && *str != NULL && end != NULL;
+ i > 0 && *str != '\0' && end != NULL;
i --, str = end + 1, end = strchr(str, ':')) {
switch (end - str) {
case 1:
diff --git a/lib/libbsnmp/Makefile.inc b/lib/libbsnmp/Makefile.inc
index 130988d..554fc93 100644
--- a/lib/libbsnmp/Makefile.inc
+++ b/lib/libbsnmp/Makefile.inc
@@ -2,4 +2,5 @@
SHLIB_MAJOR= 1
WARNS?= 6
+NO_WERROR= yes
INCSDIR= ${INCLUDEDIR}/bsnmp
diff --git a/lib/libc/gen/dlfcn.c b/lib/libc/gen/dlfcn.c
index 25aa945..be58e28 100644
--- a/lib/libc/gen/dlfcn.c
+++ b/lib/libc/gen/dlfcn.c
@@ -109,7 +109,7 @@ int
dlinfo(void * __restrict handle, int request, void * __restrict p)
{
_rtld_error(sorry);
- return NULL;
+ return 0;
}
#pragma weak _rtld_thread_init
diff --git a/lib/libc/gen/getpwent.c b/lib/libc/gen/getpwent.c
index ed65ad8..d0e4bf3 100644
--- a/lib/libc/gen/getpwent.c
+++ b/lib/libc/gen/getpwent.c
@@ -1624,7 +1624,7 @@ docompat:
case '@':
setnetgrent(&pw_name[2]);
while (getnetgrent(&host, &user, &domain) !=
- NULL) {
+ 0) {
if (user != NULL && user[0] != '\0')
compat_exclude(user,
&st->exclude);
diff --git a/lib/libc/net/gethostbydns.c b/lib/libc/net/gethostbydns.c
index 82f5152..534073a 100644
--- a/lib/libc/net/gethostbydns.c
+++ b/lib/libc/net/gethostbydns.c
@@ -591,11 +591,11 @@ _dns_gethostbyname(void *rval, void *cb_data, va_list ap)
if (n < 0) {
free(buf);
dprintf("res_search failed (%d)\n", n);
- return (NULL);
+ return (0);
} else if (n > sizeof(buf->buf)) {
free(buf);
dprintf("static buffer is too small (%d)\n", n);
- return (NULL);
+ return (0);
}
*(struct hostent **)rval = gethostanswer(buf, n, name, type);
free(buf);
diff --git a/lib/libc/rpc/getnetconfig.c b/lib/libc/rpc/getnetconfig.c
index dae03b8..ea140d4 100644
--- a/lib/libc/rpc/getnetconfig.c
+++ b/lib/libc/rpc/getnetconfig.c
@@ -684,11 +684,11 @@ struct netconfig *ncp;
*/
*p = *ncp;
p->nc_netid = (char *)strcpy(tmp,ncp->nc_netid);
- tmp = strchr(tmp, NULL) + 1;
+ tmp = strchr(tmp, '\0') + 1;
p->nc_protofmly = (char *)strcpy(tmp,ncp->nc_protofmly);
- tmp = strchr(tmp, NULL) + 1;
+ tmp = strchr(tmp, '\0') + 1;
p->nc_proto = (char *)strcpy(tmp,ncp->nc_proto);
- tmp = strchr(tmp, NULL) + 1;
+ tmp = strchr(tmp, '\0') + 1;
p->nc_device = (char *)strcpy(tmp,ncp->nc_device);
p->nc_lookups = (char **)malloc((size_t)(p->nc_nlookups+1) * sizeof(char *));
if (p->nc_lookups == NULL) {
@@ -696,7 +696,7 @@ struct netconfig *ncp;
return(NULL);
}
for (i=0; i < p->nc_nlookups; i++) {
- tmp = strchr(tmp, NULL) + 1;
+ tmp = strchr(tmp, '\0') + 1;
p->nc_lookups[i] = (char *)strcpy(tmp,ncp->nc_lookups[i]);
}
return(p);
diff --git a/lib/libpam/modules/pam_login_access/login_access.c b/lib/libpam/modules/pam_login_access/login_access.c
index 90089d8..dbc1397 100644
--- a/lib/libpam/modules/pam_login_access/login_access.c
+++ b/lib/libpam/modules/pam_login_access/login_access.c
@@ -126,7 +126,7 @@ list_match(char *list, const char *item,
for (tok = strtok(list, sep); tok != 0; tok = strtok((char *) 0, sep)) {
if (strcasecmp(tok, "EXCEPT") == 0) /* EXCEPT: give up */
break;
- if ((match = (*match_fn)(tok, item)) != NULL) /* YES */
+ if ((match = (*match_fn)(tok, item)) != 0) /* YES */
break;
}
/* Process exceptions to matches. */
diff --git a/lib/libthr/arch/i386/i386/_setcurthread.c b/lib/libthr/arch/i386/i386/_setcurthread.c
index b084880..4dd0d03 100644
--- a/lib/libthr/arch/i386/i386/_setcurthread.c
+++ b/lib/libthr/arch/i386/i386/_setcurthread.c
@@ -102,7 +102,7 @@ _set_curthread(ucontext_t *uc, struct pthread *thr, int *err)
if (thr != _thread_initial)
_SPINLOCK(&ldt_lock);
- if (ldt_inited == NULL)
+ if (ldt_inited == 0)
ldt_init();
if (ldt_free == NULL) {
diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c
index 7981fa9..7b1394b 100644
--- a/libexec/rtld-elf/rtld.c
+++ b/libexec/rtld-elf/rtld.c
@@ -331,7 +331,7 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp)
obj_tail = &obj_main->next;
obj_count++;
/* Make sure we don't call the main program's init and fini functions. */
- obj_main->init = obj_main->fini = NULL;
+ obj_main->init = obj_main->fini = (Elf_Addr)NULL;
/* Initialize a fake symbol for resolving undefined weak references. */
sym_zero.st_info = ELF_ST_INFO(STB_GLOBAL, STT_NOTYPE);
@@ -1068,11 +1068,11 @@ initlist_add_objects(Obj_Entry *obj, Obj_Entry **tail, Objlist *list)
initlist_add_neededs(obj->needed, list);
/* Add the object to the init list. */
- if (obj->init != NULL)
+ if (obj->init != (Elf_Addr)NULL)
objlist_push_tail(list, obj);
/* Add the object to the global fini list in the reverse order. */
- if (obj->fini != NULL)
+ if (obj->fini != (Elf_Addr)NULL)
objlist_push_head(&list_fini, obj);
}
@@ -1132,7 +1132,7 @@ load_preload_objects(void)
static const char delim[] = " \t:;";
if (p == NULL)
- return NULL;
+ return 0;
p += strspn(p, delim);
while (*p != '\0') {
diff --git a/sbin/atm/atmconfig/diag.c b/sbin/atm/atmconfig/diag.c
index 733c879..bd8bc7e 100644
--- a/sbin/atm/atmconfig/diag.c
+++ b/sbin/atm/atmconfig/diag.c
@@ -232,7 +232,7 @@ phy_fetch(const char *ifname, const char *var, void *val, size_t len,
if (asprintf(&str, "hw.atm.%s.phy_%s", ifname, var) == -1)
err(1, NULL);
- if (sysctlbyname(str, val, &len, NULL, NULL) == -1) {
+ if (sysctlbyname(str, val, &len, NULL, 0) == -1) {
if (err_fatal || errno != ENOENT)
err(1, "%s", str);
free(str);
diff --git a/sbin/kldconfig/kldconfig.c b/sbin/kldconfig/kldconfig.c
index 0f7c721..1f53d7c 100644
--- a/sbin/kldconfig/kldconfig.c
+++ b/sbin/kldconfig/kldconfig.c
@@ -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/raidctl/raidctl.c b/sbin/raidctl/raidctl.c
index 4b7d27d..117e651 100644
--- a/sbin/raidctl/raidctl.c
+++ b/sbin/raidctl/raidctl.c
@@ -272,7 +272,7 @@ main(argc,argv)
argc -= optind;
argv += optind;
- if ((num_options > 1) || (argc == NULL))
+ if ((num_options > 1) || (argc == 0))
usage();
strncpy(name,argv[0],PATH_MAX);
diff --git a/sbin/raidctl/rf_configure.c b/sbin/raidctl/rf_configure.c
index 8df7889..2970467 100644
--- a/sbin/raidctl/rf_configure.c
+++ b/sbin/raidctl/rf_configure.c
@@ -249,7 +249,7 @@ rf_MakeConfig(configname, cfgPtr)
}
/* Get rid of the newline at the end of the string */
if ((bfr1 = strchr(&bfr[0], '\n')) != NULL)
- *bfr1 = NULL;
+ *bfr1 = '\0';
/* Make sure the device exists */
if ((devfd = open(&bfr[0], O_RDWR)) < 0) {
RF_ERRORMSG2(
diff --git a/sbin/swapon/swapon.c b/sbin/swapon/swapon.c
index 063eff4..edcc998 100644
--- a/sbin/swapon/swapon.c
+++ b/sbin/swapon/swapon.c
@@ -254,7 +254,7 @@ swaplist(int lflag, int sflag, int hflag)
for (n = 0; ; ++n) {
mib[mibsize] = n;
size = sizeof xsw;
- if (sysctl(mib, mibsize + 1, &xsw, &size, NULL, NULL) == -1)
+ if (sysctl(mib, mibsize + 1, &xsw, &size, NULL, 0) == -1)
break;
if (xsw.xsw_version != XSWDEV_VERSION)
errx(1, "xswdev version mismatch");
diff --git a/sys/sys/_null.h b/sys/sys/_null.h
index a0ba677..72e7f85 100644
--- a/sys/sys/_null.h
+++ b/sys/sys/_null.h
@@ -28,14 +28,14 @@
#ifndef NULL
-#ifdef _KERNEL
-#define NULL (void *)0
+#if defined(_KERNEL) || !defined(__cplusplus)
+#define NULL ((void *)0)
#else
#if defined(__LP64__)
-#define NULL 0L
+#define NULL (0L)
#else
#define NULL 0
-#endif
-#endif /* _KERNEL */
+#endif /* __LP64__ */
+#endif /* _KERNEL || !__cplusplus */
#endif
diff --git a/usr.sbin/bluetooth/hccontrol/send_recv.c b/usr.sbin/bluetooth/hccontrol/send_recv.c
index fc9c549..12ea8cc 100644
--- a/usr.sbin/bluetooth/hccontrol/send_recv.c
+++ b/usr.sbin/bluetooth/hccontrol/send_recv.c
@@ -50,7 +50,7 @@ hci_request(int s, int opcode, char const *cp, int cp_size, char *rp, int *rp_si
ng_hci_event_pkt_t *e = (ng_hci_event_pkt_t *) buffer;
assert(rp != NULL);
- assert(*rp_size != NULL);
+ assert(rp_size != NULL);
assert(*rp_size > 0);
c->type = NG_HCI_CMD_PKT;
diff --git a/usr.sbin/bsnmpd/bsnmpd/Makefile b/usr.sbin/bsnmpd/bsnmpd/Makefile
index 86351b0..0f70d8f 100644
--- a/usr.sbin/bsnmpd/bsnmpd/Makefile
+++ b/usr.sbin/bsnmpd/bsnmpd/Makefile
@@ -14,6 +14,7 @@ XSYM= snmpMIB begemotSnmpdModuleTable begemotSnmpd begemotTrapSinkTable \
CLEANFILES= oid.h tree.c tree.h
MAN= bsnmpd.1 snmpmod.3
WARNS?= 6
+NO_WERROR=yes
FILESGROUPS= BMIBS DEFS
diff --git a/usr.sbin/burncd/burncd.c b/usr.sbin/burncd/burncd.c
index 778a6a6..500f070 100644
--- a/usr.sbin/burncd/burncd.c
+++ b/usr.sbin/burncd/burncd.c
@@ -274,7 +274,7 @@ main(int argc, char **argv)
if (*file_buf == '#' || *file_buf == '\n')
continue;
if ((eol = strchr(file_buf, '\n')))
- *eol = NULL;
+ *eol = '\0';
add_track(file_buf, block_size, block_type, nogap);
}
if (feof(fp))
diff --git a/usr.sbin/mountd/mountd.c b/usr.sbin/mountd/mountd.c
index 6091dab..a52ee0d 100644
--- a/usr.sbin/mountd/mountd.c
+++ b/usr.sbin/mountd/mountd.c
@@ -283,7 +283,7 @@ main(argc, argv)
in_port_t svcport = 0;
udp6conf = tcp6conf = NULL;
- udp6sock = tcp6sock = NULL;
+ udp6sock = tcp6sock = 0;
/* Check that another mountd isn't already running. */
if ((mountdlockfd = (open(MOUNTDLOCK, O_RDONLY|O_CREAT, 0444))) == -1)
diff --git a/usr.sbin/pstat/pstat.c b/usr.sbin/pstat/pstat.c
index 4a8f7a1..d93e76c 100644
--- a/usr.sbin/pstat/pstat.c
+++ b/usr.sbin/pstat/pstat.c
@@ -563,7 +563,7 @@ swapmode_sysctl(void)
for (n = 0; ; ++n) {
mib[mibsize] = n;
size = sizeof xsw;
- if (sysctl(mib, mibsize + 1, &xsw, &size, NULL, NULL) == -1)
+ if (sysctl(mib, mibsize + 1, &xsw, &size, NULL, 0) == -1)
break;
if (xsw.xsw_version != XSWDEV_VERSION)
errx(1, "xswdev version mismatch");
OpenPOWER on IntegriCloud