From d8ac4091605cafeed429956439b3365036470356 Mon Sep 17 00:00:00 2001 From: phk Date: Thu, 18 Sep 1997 14:08:40 +0000 Subject: 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 --- usr.bin/calendar/day.c | 6 +++--- usr.bin/error/touch.c | 4 ++-- usr.bin/mail/cmd1.c | 2 +- usr.bin/mail/cmd2.c | 26 +++++++++++++------------- usr.bin/mail/cmd3.c | 6 +++--- usr.bin/mail/collect.c | 4 ++-- usr.bin/mail/lex.c | 4 ++-- usr.bin/tip/libacu/multitech.c | 2 +- usr.bin/tip/libacu/unidialer.c | 4 ++-- usr.bin/tip/tip/tip.c | 4 ++-- usr.bin/tip/tip/vars.c | 4 ++-- usr.bin/tset/map.c | 4 ++-- usr.bin/uudecode/uudecode.c | 4 ++-- usr.bin/vacation/vacation.c | 4 ++-- usr.bin/vgrind/vfontedpr.c | 8 ++++---- 15 files changed, 43 insertions(+), 43 deletions(-) (limited to 'usr.bin') diff --git a/usr.bin/calendar/day.c b/usr.bin/calendar/day.c index 91b3731..b547aa5 100644 --- a/usr.bin/calendar/day.c +++ b/usr.bin/calendar/day.c @@ -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; } diff --git a/usr.bin/error/touch.c b/usr.bin/error/touch.c index a21c72d..755b313 100644 --- a/usr.bin/error/touch.c +++ b/usr.bin/error/touch.c @@ -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); } diff --git a/usr.bin/mail/cmd1.c b/usr.bin/mail/cmd1.c index e83a036..1f87fa8 100644 --- a/usr.bin/mail/cmd1.c +++ b/usr.bin/mail/cmd1.c @@ -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]; diff --git a/usr.bin/mail/cmd2.c b/usr.bin/mail/cmd2.c index ed46fb3..2c22dbe 100644 --- a/usr.bin/mail/cmd2.c +++ b/usr.bin/mail/cmd2.c @@ -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 @@ hitit: */ 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); } diff --git a/usr.bin/mail/cmd3.c b/usr.bin/mail/cmd3.c index 54a5d5e..bb0c1e5 100644 --- a/usr.bin/mail/cmd3.c +++ b/usr.bin/mail/cmd3.c @@ -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); diff --git a/usr.bin/mail/collect.c b/usr.bin/mail/collect.c index 9d54fd3..ab3a9a3 100644 --- a/usr.bin/mail/collect.c +++ b/usr.bin/mail/collect.c @@ -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; diff --git a/usr.bin/mail/lex.c b/usr.bin/mail/lex.c index 2c7cb3e..c6fee20 100644 --- a/usr.bin/mail/lex.c +++ b/usr.bin/mail/lex.c @@ -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; } diff --git a/usr.bin/tip/libacu/multitech.c b/usr.bin/tip/libacu/multitech.c index 41d42b3..2eea101 100644 --- a/usr.bin/tip/libacu/multitech.c +++ b/usr.bin/tip/libacu/multitech.c @@ -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); } diff --git a/usr.bin/tip/libacu/unidialer.c b/usr.bin/tip/libacu/unidialer.c index a8d8ef1..bac2368 100644 --- a/usr.bin/tip/libacu/unidialer.c +++ b/usr.bin/tip/libacu/unidialer.c @@ -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); } diff --git a/usr.bin/tip/tip/tip.c b/usr.bin/tip/tip/tip.c index 1b3455f..0aecc29 100644 --- a/usr.bin/tip/tip/tip.c +++ b/usr.bin/tip/tip/tip.c @@ -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 @@ notnumber: 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); diff --git a/usr.bin/tip/tip/vars.c b/usr.bin/tip/tip/vars.c index dd337fb..34d604e 100644 --- a/usr.bin/tip/tip/vars.c +++ b/usr.bin/tip/tip/vars.c @@ -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)< @@ -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; diff --git a/usr.bin/uudecode/uudecode.c b/usr.bin/uudecode/uudecode.c index f1617e1..92ed038 100644 --- a/usr.bin/uudecode/uudecode.c +++ b/usr.bin/uudecode/uudecode.c @@ -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); diff --git a/usr.bin/vacation/vacation.c b/usr.bin/vacation/vacation.c index 025a550..d3ff609 100644 --- a/usr.bin/vacation/vacation.c +++ b/usr.bin/vacation/vacation.c @@ -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; diff --git a/usr.bin/vgrind/vfontedpr.c b/usr.bin/vgrind/vfontedpr.c index 9edb65a..7ba7da9 100644 --- a/usr.bin/vgrind/vfontedpr.c +++ b/usr.bin/vgrind/vfontedpr.c @@ -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 @@ -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