From: ray Date: Wed, 14 Jul 2010 22:15:57 +0000 (+0000) Subject: Return -1 on error as advertised. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=bdcce04dfec768beba2c9a1232bb7f98efdeb0f6;p=openbsd Return -1 on error as advertised. Handle case when only one stream failed. OK otto, millert --- 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); }