Hi tech, I have a diff for the patch(1) tool which copies one included in NetBSD two years ago...
Source: NetBSD src/usr.bin/patch/inp.c revision 1.23 Purpose: Don't bother mmap'ing an empty file Comments/OK? - Michael Index: inp.c =================================================================== RCS file: /usr/src/cvs/src/usr.bin/patch/inp.c,v retrieving revision 1.35 diff -u -r1.35 inp.c --- inp.c 27 Oct 2009 23:59:41 -0000 1.35 +++ inp.c 11 Nov 2011 03:12:10 -0000 @@ -243,12 +243,16 @@ if ((ifd = open(filename, O_RDONLY)) < 0) pfatal("can't open file %s", filename); - i_womp = mmap(NULL, i_size, PROT_READ, MAP_PRIVATE, ifd, 0); - if (i_womp == MAP_FAILED) { - perror("mmap failed"); + if (i_size == 0) i_womp = NULL; - close(ifd); - return false; + else { + i_womp = mmap(NULL, i_size, PROT_READ, MAP_PRIVATE, ifd, 0); + if (i_womp == MAP_FAILED) { + perror("mmap failed"); + i_womp = NULL; + close(ifd); + return false; + } } close(ifd);