=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/xinstall/xinstall.c,v retrieving revision 1.49 retrieving revision 1.50 diff -u -r1.49 -r1.50 --- src/usr.bin/xinstall/xinstall.c 2009/10/27 23:59:50 1.49 +++ src/usr.bin/xinstall/xinstall.c 2012/04/11 09:27:42 1.50 @@ -1,4 +1,4 @@ -/* $OpenBSD: xinstall.c,v 1.49 2009/10/27 23:59:50 deraadt Exp $ */ +/* $OpenBSD: xinstall.c,v 1.50 2012/04/11 09:27:42 espie Exp $ */ /* $NetBSD: xinstall.c,v 1.9 1995/12/20 10:25:17 jonathan Exp $ */ /* @@ -416,8 +416,10 @@ * trash memory on big files. This is really a minor hack, but it * wins some CPU back. Sparse files need special treatment. */ - if (!sparse && size <= 8 * 1048576) { - volatile size_t siz; + if (!size) { + /* nothing to do */ + } else if (!sparse && size <= 8 * 1048576) { + size_t siz; if ((p = mmap(NULL, (size_t)size, PROT_READ, MAP_PRIVATE, from_fd, (off_t)0)) == MAP_FAILED) { @@ -425,8 +427,7 @@ (void)unlink(to_name); errx(EX_OSERR, "%s: %s", from_name, strerror(serrno)); } - if (size) - madvise(p, size, MADV_SEQUENTIAL); + madvise(p, size, MADV_SEQUENTIAL); siz = (size_t)size; if ((nw = write(to_fd, p, siz)) != siz) { serrno = errno; @@ -484,8 +485,11 @@ off_t from_off, to_off; int dfound; + if (from_len == 0 && from_len == to_len) + return (0); + if (from_len != to_len) - return(1); + return (1); /* * Compare the two files being careful not to mmap