[hackers] [sbase] [PATCH] cksum: Skip files with errors and continue

From: Wolfgang Corcoran-Mathe <first.lord.of.teal_AT_gmail.com>
Date: Thu, 11 Jun 2015 03:09:14 -0400

Previously, 'cksum *' would exit early if * contained a directory
or any other file causing a read error.
---
 cksum.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/cksum.c b/cksum.c
index 3355b4c..3b4f4f8 100644
--- a/cksum.c
+++ b/cksum.c
_AT_@ -71,8 +71,10 @@ cksum(FILE *fp, const char *s)
 			ck = (ck << 8) ^ crctab[(ck >> 24) ^ buf[i]];
 		len += n;
 	}
-	if (ferror(fp))
-		eprintf("fread %s:", s ? s : "<stdin>");
+	if (ferror(fp)) {
+		weprintf("fread %s:", s ? s : "<stdin>");
+		return;
+	}
 
 	for (i = len; i; i >>= 8)
 		ck = (ck << 8) ^ crctab[(ck >> 24) ^ (i & 0xFF)];
-- 
2.3.5
Received on Thu Jun 11 2015 - 09:09:14 CEST

This archive was generated by hypermail 2.3.0 : Thu Jun 18 2015 - 17:36:39 CEST