diff options
author | 2010-07-14 22:15:57 +0000 | |
---|---|---|
committer | 2010-07-14 22:15:57 +0000 | |
commit | bdcce04dfec768beba2c9a1232bb7f98efdeb0f6 (patch) | |
tree | e4ae2d486a472c392b5f18885e43b47b1909005c /usr.bin/diff | |
parent | implement poll() for video(4) (diff) | |
download | wireguard-openbsd-bdcce04dfec768beba2c9a1232bb7f98efdeb0f6.tar.xz wireguard-openbsd-bdcce04dfec768beba2c9a1232bb7f98efdeb0f6.zip |
Return -1 on error as advertised.
Handle case when only one stream failed.
OK otto, millert
Diffstat (limited to 'usr.bin/diff')
-rw-r--r-- | usr.bin/diff/diffreg.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/usr.bin/diff/diffreg.c b/usr.bin/diff/diffreg.c index d5cf4718326..f4e1eef9895 100644 --- a/usr.bin/diff/diffreg.c +++ b/usr.bin/diff/diffreg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diffreg.c,v 1.74 2010/03/22 19:33:19 schwarze Exp $ */ +/* $OpenBSD: diffreg.c,v 1.75 2010/07/14 22:15:57 ray Exp $ */ /* * Copyright (C) Caldera International Inc. 2001-2002. @@ -479,13 +479,12 @@ files_differ(FILE *f1, FILE *f2, int flags) for (;;) { i = fread(buf1, 1, sizeof(buf1), f1); j = fread(buf2, 1, sizeof(buf2), f2); + if ((!i && ferror(f1)) || (!j && ferror(f2))) + return (-1); if (i != j) return (1); - if (i == 0 && j == 0) { - if (ferror(f1) || ferror(f2)) - return (1); + if (i == 0) return (0); - } if (memcmp(buf1, buf2, i) != 0) return (1); } |