The diff(1) man page (and posix) specify the following as exit values:
0 No differences were found.
1 Differences were found.
>1 An error occurred.
So I think the patch below is needed.
Index: xmalloc.c
===================================================================
RCS file: /usr/cvs/src/usr.bin/diff/xmalloc.c,v
retrieving revision 1.2
diff -u -r1.2 xmalloc.c
--- xmalloc.c 7 Jun 2009 08:39:13 -0000 1.2
+++ xmalloc.c 16 Jul 2010 08:22:29 -0000
@@ -41,12 +41,12 @@
void *ptr;
if (size == 0 || nmemb == 0)
- errx(1, "xcalloc: zero size");
+ errx(2, "xcalloc: zero size");
if (SIZE_MAX / nmemb < size)
- errx(1, "xcalloc: nmemb * size > SIZE_MAX");
+ errx(2, "xcalloc: nmemb * size > SIZE_MAX");
ptr = calloc(nmemb, size);
if (ptr == NULL)
- errx(1, "xcalloc: out of memory (allocating %lu bytes)",
+ errx(2, "xcalloc: out of memory (allocating %lu bytes)",
(u_long)(size * nmemb));
return ptr;
}