diff options
author | mdodd <mdodd@FreeBSD.org> | 1999-08-20 01:24:35 +0000 |
---|---|---|
committer | mdodd <mdodd@FreeBSD.org> | 1999-08-20 01:24:35 +0000 |
commit | add3f6325f928a3acb756b34b7018942f7cfdbd7 (patch) | |
tree | 24613bef7b6a7a588e0ea9bee3aa1b944b0cc8d2 | |
parent | b47bf1ab5f378718e3afceba062ddbe540147e75 (diff) | |
download | FreeBSD-src-add3f6325f928a3acb756b34b7018942f7cfdbd7.zip FreeBSD-src-add3f6325f928a3acb756b34b7018942f7cfdbd7.tar.gz |
What the heck was I thinking? Nobody else saw this? Sheesh.
(num > MAX) ? MAX : num
rather than
(MAX > num) ? MAX : num
Also, make things a little easier to read while I'm here.
-rw-r--r-- | usr.sbin/cdcontrol/cdcontrol.c | 8 | ||||
-rw-r--r-- | usr.sbin/lpr/lpc/lpc.c | 8 | ||||
-rw-r--r-- | usr.sbin/xntpd/xntpdc/ntpdc.c | 6 |
3 files changed, 14 insertions, 8 deletions
diff --git a/usr.sbin/cdcontrol/cdcontrol.c b/usr.sbin/cdcontrol/cdcontrol.c index 539cf52..ed4f433 100644 --- a/usr.sbin/cdcontrol/cdcontrol.c +++ b/usr.sbin/cdcontrol/cdcontrol.c @@ -20,7 +20,7 @@ #ifndef lint static const char rcsid[] = - "$Id: cdcontrol.c,v 1.19 1999/08/19 03:29:11 mdodd Exp $"; + "$Id: cdcontrol.c,v 1.20 1999/08/19 04:10:31 mdodd Exp $"; #endif /* not lint */ #include <ctype.h> @@ -937,6 +937,7 @@ input (int *cmd) static History *hist = NULL; static char buf[MAXLINE]; int num = 0; + int len; const char *bp = NULL; char *p; @@ -955,8 +956,9 @@ input (int *cmd) if ((bp = el_gets(el, &num)) == NULL || num == 0) return (0); - memcpy(buf, bp, (MAXLINE > num ? MAXLINE : num)); - buf[num] = 0; + len = (num > MAXLINE) ? MAXLINE : num; + memcpy(buf, bp, len); + buf[len] = 0; history(hist, H_ENTER, bp); #undef MAXLINE diff --git a/usr.sbin/lpr/lpc/lpc.c b/usr.sbin/lpr/lpc/lpc.c index b8ee565..2372211 100644 --- a/usr.sbin/lpr/lpc/lpc.c +++ b/usr.sbin/lpr/lpc/lpc.c @@ -43,7 +43,7 @@ static const char copyright[] = static char sccsid[] = "@(#)lpc.c 8.3 (Berkeley) 4/28/95"; #endif static const char rcsid[] = - "$Id: lpc.c,v 1.9 1999/08/19 03:29:13 mdodd Exp $"; + "$Id: lpc.c,v 1.10 1999/08/19 04:10:32 mdodd Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -153,6 +153,7 @@ cmdscanner() static EditLine *el = NULL; static History *hist = NULL; int num = 0; + int len; const char *bp = NULL; for (;;) { @@ -170,8 +171,9 @@ cmdscanner() if ((bp = el_gets(el, &num)) == NULL || num == 0) return; - memcpy(cmdline, bp, (MAX_CMDLINE > num ? MAX_CMDLINE : num)); - cmdline[num] = 0; + len = (num > MAX_CMDLINE) ? MAX_CMDLINE : num); + memcpy(cmdline, bp, len); + cmdline[len] = 0; history(hist, H_ENTER, bp); } else { diff --git a/usr.sbin/xntpd/xntpdc/ntpdc.c b/usr.sbin/xntpd/xntpdc/ntpdc.c index 9897695..de4c342 100644 --- a/usr.sbin/xntpd/xntpdc/ntpdc.c +++ b/usr.sbin/xntpd/xntpdc/ntpdc.c @@ -808,6 +808,7 @@ getcmds() static History *hist = NULL; char line[MAXLINE]; int num = 0; + int len; const char *bp = NULL; for (;;) { @@ -825,8 +826,9 @@ getcmds() if ((bp = el_gets(el, &num)) == NULL || num == 0) return; - memcpy(line, bp, (MAXLINE > num ? MAXLINE : num)); - line[num] = 0; + len = (num > MAX_CMDLINE) ? MAX_CMDLINE : num); + memcpy(line, bp, len); + line[len] = 0; history(hist, H_ENTER, bp); } else { |