diff options
author | Ray Lai <ray@cvs.openbsd.org> | 2006-08-14 23:52:37 +0000 |
---|---|---|
committer | Ray Lai <ray@cvs.openbsd.org> | 2006-08-14 23:52:37 +0000 |
commit | d90ecb2e9a96977fd873ab27f59f5a24bc3501f6 (patch) | |
tree | 5e64ddc320077f1e53bbd05d4bcad448e7b91143 | |
parent | 6ce43c12fdb1b8f22fba254ac6ef1f1be4b8bd5f (diff) |
files_differ() should return -1 on error, according to comments. Make
it so.
Add checks for all return values.
``put it in'' xsa@
-rw-r--r-- | usr.bin/rcs/diff.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/usr.bin/rcs/diff.c b/usr.bin/rcs/diff.c index 112045649d5..12e67adcc93 100644 --- a/usr.bin/rcs/diff.c +++ b/usr.bin/rcs/diff.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diff.c,v 1.7 2006/07/27 02:57:19 deraadt Exp $ */ +/* $OpenBSD: diff.c,v 1.8 2006/08/14 23:52:36 ray Exp $ */ /* * Copyright (C) Caldera International Inc. 2001-2002. * All rights reserved. @@ -323,8 +323,17 @@ rcs_diffreg(const char *file1, const char *file2, BUF *out) goto closem; } - if (files_differ(f1, f2) != 1) + switch (files_differ(f1, f2)) { + case 1: + break; + case -1: + rval = D_ERROR; + /* FALLTHROUGH */ + case 0: goto closem; + default: + errx(D_ERROR, "files_differ: invalid case"); + } if (!asciifile(f1) || !asciifile(f2)) { rval = D_ERROR; @@ -408,7 +417,7 @@ files_differ(FILE *f1, FILE *f2) return (1); if (i == 0 && j == 0) { if (ferror(f1) || ferror(f2)) - return (1); + return (-1); return (0); } if (memcmp(buf1, buf2, i) != 0) |