diff options
author | 2015-01-16 06:39:28 +0000 | |
---|---|---|
committer | 2015-01-16 06:39:28 +0000 | |
commit | b9fc9a728fce9c4289b7e9a992665e28d5629a54 (patch) | |
tree | 72b2433e418dfa1aef5fcf8305617b97979a25d8 /usr.bin/diff/diffreg.c | |
parent | improve checksum parsing slightly. now handles filenames with spaces. (diff) | |
download | wireguard-openbsd-b9fc9a728fce9c4289b7e9a992665e28d5629a54.tar.xz wireguard-openbsd-b9fc9a728fce9c4289b7e9a992665e28d5629a54.zip |
Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)
Diffstat (limited to 'usr.bin/diff/diffreg.c')
-rw-r--r-- | usr.bin/diff/diffreg.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/usr.bin/diff/diffreg.c b/usr.bin/diff/diffreg.c index f949cd27c27..83a86e6aab4 100644 --- a/usr.bin/diff/diffreg.c +++ b/usr.bin/diff/diffreg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diffreg.c,v 1.83 2014/08/27 15:22:40 kspillner Exp $ */ +/* $OpenBSD: diffreg.c,v 1.84 2015/01/16 06:40:07 deraadt Exp $ */ /* * Copyright (C) Caldera International Inc. 2001-2002. @@ -64,7 +64,6 @@ * @(#)diffreg.c 8.1 (Berkeley) 6/6/93 */ -#include <sys/param.h> #include <sys/stat.h> #include <sys/wait.h> @@ -77,11 +76,15 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include "diff.h" #include "pathnames.h" #include "xmalloc.h" +#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) +#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b)) + /* * diff - compare two files. */ @@ -495,7 +498,7 @@ files_differ(FILE *f1, FILE *f2, int flags) static FILE * opentemp(const char *file) { - char buf[BUFSIZ], *tempdir, tempfile[MAXPATHLEN]; + char buf[BUFSIZ], *tempdir, tempfile[PATH_MAX]; ssize_t nread; int ifd, ofd; @@ -653,7 +656,7 @@ stone(int *a, int n, int *b, int *c, int flags) bound = UINT_MAX; else { sq = isqrt(n); - bound = MAX(256, sq); + bound = MAXIMUM(256, sq); } k = 0; @@ -1360,10 +1363,10 @@ dump_context_vec(FILE *f1, FILE *f2, int flags) return; b = d = 0; /* gcc */ - lowa = MAX(1, cvp->a - diff_context); - upb = MIN(len[0], context_vec_ptr->b + diff_context); - lowc = MAX(1, cvp->c - diff_context); - upd = MIN(len[1], context_vec_ptr->d + diff_context); + lowa = MAXIMUM(1, cvp->a - diff_context); + upb = MINIMUM(len[0], context_vec_ptr->b + diff_context); + lowc = MAXIMUM(1, cvp->c - diff_context); + upd = MINIMUM(len[1], context_vec_ptr->d + diff_context); diff_output("***************"); if ((flags & D_PROTOTYPE)) { @@ -1463,10 +1466,10 @@ dump_unified_vec(FILE *f1, FILE *f2, int flags) return; b = d = 0; /* gcc */ - lowa = MAX(1, cvp->a - diff_context); - upb = MIN(len[0], context_vec_ptr->b + diff_context); - lowc = MAX(1, cvp->c - diff_context); - upd = MIN(len[1], context_vec_ptr->d + diff_context); + lowa = MAXIMUM(1, cvp->a - diff_context); + upb = MINIMUM(len[0], context_vec_ptr->b + diff_context); + lowc = MAXIMUM(1, cvp->c - diff_context); + upd = MINIMUM(len[1], context_vec_ptr->d + diff_context); diff_output("@@ -"); uni_range(lowa, upb); |