From b9fc9a728fce9c4289b7e9a992665e28d5629a54 Mon Sep 17 00:00:00 2001 From: deraadt Date: Fri, 16 Jan 2015 06:39:28 +0000 Subject: Replace with and other less dirty headers where possible. Annotate 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) --- usr.bin/diff/diffreg.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'usr.bin/diff/diffreg.c') 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 #include #include @@ -77,11 +76,15 @@ #include #include #include +#include #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); -- cgit v1.2.3-59-g8ed1b