Many places in the code NULL is used in integer context, where

plain 0 should be used.  This happens to work because we #define
NULL to 0, but is stylistically wrong and can cause problems
for people trying to port bits of code to other environments.

PR:		2752
Submitted by:	Arne Henrik Juul <arnej@imf.unit.no>
This commit is contained in:
Poul-Henning Kamp 1997-09-18 14:08:40 +00:00
parent 06bba905d0
commit d030d2d2ae
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=29574
32 changed files with 74 additions and 74 deletions

View File

@ -18,7 +18,7 @@
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#ifndef lint
static char rcsid[] = "$Id$";
static char rcsid[] = "$Id: atof-ieee.c,v 1.7 1997/02/22 15:44:21 peter Exp $";
#endif
#include "as.h"
@ -174,7 +174,7 @@ LITTLENUM_TYPE *words; /* Build the binary here. */
generic_floating_point_number.low = bits + MAX_PRECISION;
generic_floating_point_number.high = NULL;
generic_floating_point_number.leader = NULL;
generic_floating_point_number.exponent = NULL;
generic_floating_point_number.exponent = 0;
generic_floating_point_number.sign = '\0';
/* Use more LittleNums than seems */

View File

@ -27,7 +27,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: rtld.c,v 1.47 1997/08/02 04:56:44 jdp Exp $
* $Id: rtld.c,v 1.48 1997/08/19 23:33:45 nate Exp $
*/
#include <sys/param.h>
@ -2117,7 +2117,7 @@ struct env_scan_tab {
L("LD_BIND_NOW=", 0, &ld_bind_now)
L("LD_SUPPRESS_WARNINGS=", 0, &ld_suppress_warnings)
L("LD_WARN_NON_PURE_CODE=", 0, &ld_warn_non_pure_code)
{ NULL, 0, NULL }
{ NULL, 0, 0, NULL }
};
#undef L

View File

@ -468,7 +468,7 @@ is_section (name)
register char **vs;
for (vs = section_list; *vs != NULL; vs++)
if ((strcmp (*vs, name) == NULL)
if ((strcmp (*vs, name) == 0)
|| (isdigit (name[0]) && strlen(name) == 1))
return strdup (name);
@ -557,7 +557,7 @@ convert_name (name, to_cat)
t1 = strrchr (to_name, '/');
if (t1 != NULL)
{
*t1 = NULL;
*t1 = '\0';
t2 = strrchr (to_name, '/');
*t1 = '/';
}

View File

@ -358,7 +358,7 @@ __bt_first(t, key, erval, exactp)
* page) and return it.
*/
if ((ep = __bt_search(t, key, exactp)) == NULL)
return (NULL);
return (0);
if (*exactp) {
if (F_ISSET(t, B_NODUPS)) {
*erval = *ep;

View File

@ -735,7 +735,7 @@ cgetnext(bp, db_array)
}
}
rp = buf;
for(cp = nbuf; *cp != NULL; cp++)
for(cp = nbuf; *cp != '\0'; cp++)
if (*cp == '|' || *cp == ':')
break;
else

View File

@ -424,7 +424,7 @@ static inline int unwind(grp)
latch++;
}
again:
if (getnetgrent(&host, &user, &domain) == NULL) {
if (getnetgrent(&host, &user, &domain) == 0) {
if ((gr = getgrnam(grp+2)) != NULL)
goto grpagain;
latch = 0;
@ -448,7 +448,7 @@ static inline int unwind(grp)
if (grp[1] == '@') {
setnetgrent(grp+2);
rv = 0;
while(getnetgrent(&host, &user, &domain) != NULL) {
while(getnetgrent(&host, &user, &domain) != 0) {
store(user);
rv++;
}

View File

@ -14,7 +14,7 @@
* Turned inside out. Now returns xfers as new file ids, not as a special
* `state' of FTP_t
*
* $Id$
* $Id: ftpio.c,v 1.25 1997/02/22 15:06:50 peter Exp $
*
*/
@ -417,7 +417,7 @@ get_url_info(char *url_in, char *host_ret, int *port_ret, char *name_ret)
name = host = NULL;
/* XXX add http:// here or somewhere reasonable at some point XXX */
if (strncmp("ftp://", url_in, 6) != NULL)
if (strncmp("ftp://", url_in, 6) != 0)
return FAILURE;
/* We like to stomp a lot on the URL string in dissecting it, so copy it first */
strncpy(url, url_in, BUFSIZ);

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)ftpcmd.y 8.3 (Berkeley) 4/6/94
* $Id: ftpcmd.y,v 1.10 1997/02/22 14:21:27 peter Exp $
* $Id: ftpcmd.y,v 1.11 1997/07/24 09:26:10 davidn Exp $
*/
/*
@ -957,7 +957,7 @@ yylex()
}
(void) alarm(0);
#ifdef SETPROCTITLE
if (strncasecmp(cbuf, "PASS", 4) != NULL)
if (strncasecmp(cbuf, "PASS", 4) != 0)
setproctitle("%s: %s", proctitle, cbuf);
#endif /* SETPROCTITLE */
if ((cp = strchr(cbuf, '\r'))) {

View File

@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id$
* $Id: library.c,v 1.7 1997/02/22 14:21:45 peter Exp $
*/
#ifndef lint
@ -544,7 +544,7 @@ mmap_segment (fsp, segment, segbuf, use_mmap)
MAP_SHARED, fid, seg_byte);
if (*segbuf == MAP_FAILED) {
err(0, "mmap_segment: mmap failed");
return (NULL);
return (0);
}
} else {
#ifdef VERBOSE
@ -555,7 +555,7 @@ mmap_segment (fsp, segment, segbuf, use_mmap)
*segbuf = malloc(ssize);
if (!*segbuf) {
err(0, "mmap_segment: malloc failed");
return(NULL);
return(0);
}
/* read the segment data into the buffer */

View File

@ -35,7 +35,7 @@
* Center for Telecommunications Research
* Columbia University, New York City
*
* $Id: revnetgroup.c,v 1.6 1997/02/22 14:22:03 peter Exp $
* $Id: revnetgroup.c,v 1.7 1997/03/28 15:48:15 imp Exp $
*/
#include <stdio.h>
@ -46,7 +46,7 @@
#include "hash.h"
#ifndef lint
static const char rcsid[] = "$Id: revnetgroup.c,v 1.6 1997/02/22 14:22:03 peter Exp $";
static const char rcsid[] = "$Id: revnetgroup.c,v 1.7 1997/03/28 15:48:15 imp Exp $";
#endif
/* Default location of netgroup file. */
@ -150,7 +150,7 @@ main(argc, argv)
gcur = gtable[i];
while(gcur) {
__setnetgrent(gcur->key);
while(__getnetgrent(&host, &user, &domain) != NULL) {
while(__getnetgrent(&host, &user, &domain) != 0) {
if (hosts ? host && strcmp(host,"-") : user && strcmp(user, "-"))
mstore(mtable, hosts ? host : user, gcur->key, domain);
}

View File

@ -27,7 +27,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: rtld.c,v 1.47 1997/08/02 04:56:44 jdp Exp $
* $Id: rtld.c,v 1.48 1997/08/19 23:33:45 nate Exp $
*/
#include <sys/param.h>
@ -2117,7 +2117,7 @@ struct env_scan_tab {
L("LD_BIND_NOW=", 0, &ld_bind_now)
L("LD_SUPPRESS_WARNINGS=", 0, &ld_suppress_warnings)
L("LD_WARN_NON_PURE_CODE=", 0, &ld_warn_non_pure_code)
{ NULL, 0, NULL }
{ NULL, 0, 0, NULL }
};
#undef L

View File

@ -207,7 +207,7 @@ main(ac, av)
fatal("kvmread", NULL);
dev_found = 0;
while(pos_t!=NULL) {
while(pos_t!=0) {
if (kvm_read(kd, pos_t, &buf1, sizeof(struct isa_device)) < 0)
fatal("kvmread", NULL);

View File

@ -53,7 +53,7 @@ QIC_Geom geo; /* tape geometry */
int tvno = 1; /* tape volume number */
int tvlast; /* TRUE if last volume in set */
long tvsize = 0; /* tape volume size in bytes */
long tvtime = NULL; /* tape change time */
long tvtime = 0; /* tape change time */
char *tvnote = ""; /* tape note */
int doretension = 0; /* TRUE if we should retension tape */

View File

@ -35,7 +35,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id$
* $Id: dirs.c,v 1.9 1997/06/18 06:28:46 charnier Exp $
*/
#ifndef lint
@ -302,7 +302,7 @@ pathsearch(pathname)
while (*path == '/')
path++;
dp = NULL;
while ((name = strsep(&path, "/")) != NULL && *name != NULL) {
while ((name = strsep(&path, "/")) != NULL && *name != '\0') {
if ((dp = searchdir(ino, name)) == NULL)
return (NULL);
ino = dp->d_ino;

View File

@ -817,7 +817,7 @@ checkrestore()
ep->e_flags &= ~KEEP;
if (ep->e_type == NODE)
ep->e_flags &= ~(NEW|EXISTED);
if (ep->e_flags != NULL)
if (ep->e_flags != 0)
badentry(ep, "incomplete operations");
}
}

View File

@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id$
* $Id: day.c,v 1.9 1997/06/23 06:52:12 charnier Exp $
*/
@ -186,12 +186,12 @@ time_t Mktime (dp)
/* day */
*(date+2) = NULL;
*(date+2) = '\0';
tm.tm_mday = atoi(date);
/* month */
if (len >= 4) {
*(date+5) = NULL;
*(date+5) = '\0';
tm.tm_mon = atoi(date+3) - 1;
}

View File

@ -595,7 +595,7 @@ writetouched(overwrite)
botch = 0;
oktorm = 1;
while((nread = fread(edbuf, 1, sizeof(edbuf), o_touchedfile)) != NULL){
while((nread = fread(edbuf, 1, sizeof(edbuf), o_touchedfile)) != 0) {
if (nread != fwrite(edbuf, 1, nread, n_touchedfile)){
/*
* Catastrophe in temporary area: file system full?
@ -655,7 +655,7 @@ int mustoverwrite(preciousfile, tmpfile)
{
int nread;
while((nread = fread(edbuf, 1, sizeof(edbuf), tmpfile)) != NULL){
while((nread = fread(edbuf, 1, sizeof(edbuf), tmpfile)) != 0) {
if (mustwrite(edbuf, nread, preciousfile) == 0)
return(0);
}

View File

@ -152,7 +152,7 @@ from(msgvec)
{
register int *ip;
for (ip = msgvec; *ip != NULL; ip++)
for (ip = msgvec; *ip != 0; ip++)
printhead(*ip);
if (--ip >= msgvec)
dot = &message[*ip - 1];

View File

@ -58,7 +58,7 @@ next(msgvec)
register int *ip, *ip2;
int list[2], mdot;
if (*msgvec != NULL) {
if (*msgvec != 0) {
/*
* If some messages were supplied, find the
@ -73,10 +73,10 @@ next(msgvec)
* message list which follows dot.
*/
for (ip = msgvec; *ip != NULL; ip++)
for (ip = msgvec; *ip != 0; ip++)
if (*ip > mdot)
break;
if (*ip == NULL)
if (*ip == 0)
ip = msgvec;
ip2 = ip;
do {
@ -85,9 +85,9 @@ next(msgvec)
dot = mp;
goto hitit;
}
if (*ip2 != NULL)
if (*ip2 != 0)
ip2++;
if (*ip2 == NULL)
if (*ip2 == 0)
ip2 = msgvec;
} while (ip2 != ip);
printf("No messages applicable\n");
@ -121,7 +121,7 @@ next(msgvec)
*/
list[0] = dot - &message[0] + 1;
list[1] = NULL;
list[1] = 0;
return(type(list));
}
@ -170,11 +170,11 @@ save1(str, mark, cmd, ignore)
return(1);
if (!f) {
*msgvec = first(0, MMNORM);
if (*msgvec == NULL) {
if (*msgvec == 0) {
printf("No messages to %s.\n", cmd);
return(1);
}
msgvec[1] = NULL;
msgvec[1] = 0;
}
if (f && getmsglist(str, msgvec, 0) < 0)
return(1);
@ -291,7 +291,7 @@ deltype(msgvec)
list[0] = dot - &message[0] + 1;
if (list[0] > lastdot) {
touch(dot);
list[1] = NULL;
list[1] = 0;
return(type(list));
}
printf("At EOF\n");
@ -313,18 +313,18 @@ delm(msgvec)
register *ip;
int last;
last = NULL;
for (ip = msgvec; *ip != NULL; ip++) {
last = 0;
for (ip = msgvec; *ip != 0; ip++) {
mp = &message[*ip - 1];
touch(mp);
mp->m_flag |= MDELETED|MTOUCH;
mp->m_flag &= ~(MPRESERVE|MSAVED|MBOX);
last = *ip;
}
if (last != NULL) {
if (last != 0) {
dot = &message[last-1];
last = first(0, MDELETED);
if (last != NULL) {
if (last != 0) {
dot = &message[last-1];
return(0);
}

View File

@ -293,7 +293,7 @@ preserve(msgvec)
printf("Cannot \"preserve\" in edit mode\n");
return(1);
}
for (ip = msgvec; *ip != NULL; ip++) {
for (ip = msgvec; *ip != 0; ip++) {
mesg = *ip;
mp = &message[mesg-1];
mp->m_flag |= MPRESERVE;
@ -312,7 +312,7 @@ unread(msgvec)
{
register int *ip;
for (ip = msgvec; *ip != NULL; ip++) {
for (ip = msgvec; *ip != 0; ip++) {
dot = &message[*ip-1];
dot->m_flag &= ~(MREAD|MTOUCH);
dot->m_flag |= MSTATUS;
@ -330,7 +330,7 @@ messize(msgvec)
register struct message *mp;
register int *ip, mesg;
for (ip = msgvec; *ip != NULL; ip++) {
for (ip = msgvec; *ip != 0; ip++) {
mesg = *ip;
mp = &message[mesg-1];
printf("%d: %d/%ld\n", mesg, mp->m_lines, mp->m_size);

View File

@ -523,11 +523,11 @@ forward(ms, fp, f)
return(0);
if (*msgvec == 0) {
*msgvec = first(0, MMNORM);
if (*msgvec == NULL) {
if (*msgvec == 0) {
printf("No appropriate messages\n");
return(0);
}
msgvec[1] = NULL;
msgvec[1] = 0;
}
if (f == 'f' || f == 'F')
tabst = NOSTR;

View File

@ -342,9 +342,9 @@ execute(linebuf, contxt)
if (c == 0) {
*msgvec = first(com->c_msgflag,
com->c_msgmask);
msgvec[1] = NULL;
msgvec[1] = 0;
}
if (*msgvec == NULL) {
if (*msgvec == 0) {
printf("No applicable messages\n");
break;
}

View File

@ -91,7 +91,7 @@ int multitech_dialer (register char *num, char *acu)
if (lock_baud)
{
int i;
if ((i = speed(number(value(BAUDRATE)))) == NULL)
if ((i = speed(number(value(BAUDRATE)))) == 0)
return 0;
ttysetup (i);
}

View File

@ -36,7 +36,7 @@
static char sccsid[] = "@(#)unidialer.c 8.1 (Berkeley) 6/6/93";
#endif
static const char rcsid[] =
"$Id$";
"$Id: unidialer.c,v 1.5 1997/08/18 07:15:41 charnier Exp $";
#endif /* not lint */
/*
@ -421,7 +421,7 @@ static int unidialer_dialer (register char *num, char *acu)
if (lock_baud) {
int i;
if ((i = speed(number(value(BAUDRATE)))) == NULL)
if ((i = speed(number(value(BAUDRATE)))) == 0)
return 0;
ttysetup (i);
}

View File

@ -42,7 +42,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)tip.c 8.1 (Berkeley) 6/6/93";
#endif
static const char rcsid[] =
"$Id: tip.c,v 1.5 1997/08/25 05:02:10 imp Exp $";
"$Id: tip.c,v 1.6 1997/08/26 10:25:19 eivind Exp $";
#endif /* not lint */
/*
@ -189,7 +189,7 @@ main(argc, argv)
PH = _PATH_PHONES;
vinit(); /* init variables */
setparity("even"); /* set the parity table */
if ((i = speed(number(value(BAUDRATE)))) == NULL) {
if ((i = speed(number(value(BAUDRATE)))) == 0) {
printf("tip: bad baud rate %d\n", number(value(BAUDRATE)));
(void)uu_unlock(uucplock);
exit(3);

View File

@ -36,7 +36,7 @@
static char sccsid[] = "@(#)vars.c 8.1 (Berkeley) 6/6/93";
#endif
static const char rcsid[] =
"$Id$";
"$Id: vars.c,v 1.2 1997/08/18 07:16:12 charnier Exp $";
#endif /* not lint */
#include "tipconf.h"
@ -117,5 +117,5 @@ value_t vtable[] = {
"le", (char *)FALSE },
{ "parity", STRING|INIT|IREMOTE, (READ|WRITE)<<PUBLIC,
"par", (char *)&PA },
{ NOSTR, NULL, NULL, NOSTR, NOSTR }
{ NOSTR, 0, 0, NOSTR, NOSTR }
};

View File

@ -36,7 +36,7 @@
static char sccsid[] = "@(#)map.c 8.1 (Berkeley) 6/9/93";
#endif
static const char rcsid[] =
"$Id$";
"$Id: map.c,v 1.4 1997/08/18 07:27:53 charnier Exp $";
#endif /* not lint */
#include <sys/types.h>
@ -142,7 +142,7 @@ next: if (*arg == ':') {
mapp->speed = baudrate(p);
}
if (*arg == NULL) /* Non-optional type. */
if (*arg == '\0') /* Non-optional type. */
goto badmopt;
mapp->type = arg;

View File

@ -42,7 +42,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)uudecode.c 8.2 (Berkeley) 4/2/94";
#endif
static const char rcsid[] =
"$Id$";
"$Id: uudecode.c,v 1.9 1997/08/22 06:51:43 charnier Exp $";
#endif /* not lint */
/*
@ -160,7 +160,7 @@ decode2(flag)
warnx("%s: illegal ~user", filename);
return(1);
}
*p++ = NULL;
*p++ = '\0';
if (!(pw = getpwnam(buf + 1))) {
warnx("%s: no user %s", filename, buf);
return(1);

View File

@ -40,7 +40,7 @@ static char copyright[] =
#ifndef lint
static char sccsid[] = "From: @(#)vacation.c 8.2 (Berkeley) 1/26/94";
static char rcsid[] =
"$Id: vacation.c,v 1.9 1997/04/23 22:40:19 ache Exp $";
"$Id: vacation.c,v 1.10 1997/08/28 04:40:51 imp Exp $";
#endif /* not lint */
/*
@ -297,7 +297,7 @@ junkmail()
} ignore[] = {
{"-request", 8}, {"postmaster", 10}, {"uucp", 4},
{"mailer-daemon", 13}, {"mailer", 6}, {"-relay", 6},
{NULL, NULL},
{NULL, 0},
};
register struct ignore *cur;
register int len;

View File

@ -42,7 +42,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)vfontedpr.c 8.1 (Berkeley) 6/6/93";
#endif
static const char rcsid[] =
"$Id: vfontedpr.c,v 1.8 1997/08/25 06:36:03 charnier Exp $";
"$Id: vfontedpr.c,v 1.9 1997/08/26 11:08:24 charnier Exp $";
#endif /* not lint */
#include <sys/types.h>
@ -248,7 +248,7 @@ main(argc, argv)
cpp = l_keywds;
while (*cp) {
while (*cp == ' ' || *cp =='\t')
*cp++ = NULL;
*cp++ = '\0';
if (*cp)
*cpp++ = cp;
while (*cp != ' ' && *cp != '\t' && *cp)
@ -292,7 +292,7 @@ main(argc, argv)
_escaped = FALSE;
blklevel = 0;
for (psptr=0; psptr<PSMAX; psptr++) {
pstack[psptr][0] = NULL;
pstack[psptr][0] = '\0';
plstack[psptr] = 0;
}
psptr = -1;
@ -697,7 +697,7 @@ static boolean
isproc(s)
char *s;
{
pname[0] = NULL;
pname[0] = '\0';
if (!l_toplex || blklevel == 0)
if (expmatch (s, l_prcbeg, pname) != NIL) {
return (TRUE);

View File

@ -1,5 +1,5 @@
#ifndef lint
static char *rcsid = "$Id: main.c,v 1.13 1997/02/22 16:09:18 peter Exp $";
static char *rcsid = "$Id: main.c,v 1.14 1997/03/31 05:10:45 imp Exp $";
#endif
/*
@ -133,7 +133,7 @@ main(int argc, char **argv)
usage(prog_name, "Missing package name(s)");
else if (ch > 1 && AddMode == MASTER)
usage(prog_name, "Only one package name may be specified with master mode");
if ((err = pkg_perform(pkgs)) != NULL) {
if ((err = pkg_perform(pkgs)) != 0) {
if (Verbose)
fprintf(stderr, "%d package addition(s) failed.\n", err);
return err;

View File

@ -1,5 +1,5 @@
#ifndef lint
static char *rcsid = "$Id: main.c,v 1.8 1997/02/22 16:09:36 peter Exp $";
static char *rcsid = "$Id: main.c,v 1.9 1997/03/31 05:10:48 imp Exp $";
#endif
/*
@ -89,7 +89,7 @@ main(int argc, char **argv)
*pkgs = NULL;
if (!Fake && getuid() != 0)
errx(1, "You must be root to delete packages.");
if ((error = pkg_perform(start)) != NULL) {
if ((error = pkg_perform(start)) != 0) {
if (Verbose)
fprintf(stderr, "%d package deletion(s) failed.\n", error);
return error;