summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2012-04-11 14:19:35 +0000
committermillert <millert@openbsd.org>2012-04-11 14:19:35 +0000
commit8c6f34b67102571e087799c8834a05dc20fac556 (patch)
tree74436bf6b04bd66f95d4f751103de35e73d0d147
parentWhen writing a file via 'C-x C-w', ask user if they want to overwrite an (diff)
downloadwireguard-openbsd-8c6f34b67102571e087799c8834a05dc20fac556.tar.xz
wireguard-openbsd-8c6f34b67102571e087799c8834a05dc20fac556.zip
Move size == 0 check to the beginnig of copy(); ok espie@
-rw-r--r--usr.bin/xinstall/xinstall.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/usr.bin/xinstall/xinstall.c b/usr.bin/xinstall/xinstall.c
index e00b04526ce..7a914b75b04 100644
--- a/usr.bin/xinstall/xinstall.c
+++ b/usr.bin/xinstall/xinstall.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: xinstall.c,v 1.50 2012/04/11 09:27:42 espie Exp $ */
+/* $OpenBSD: xinstall.c,v 1.51 2012/04/11 14:19:35 millert Exp $ */
/* $NetBSD: xinstall.c,v 1.9 1995/12/20 10:25:17 jonathan Exp $ */
/*
@@ -405,6 +405,9 @@ copy(int from_fd, char *from_name, int to_fd, char *to_name, off_t size,
int serrno;
char *p, buf[MAXBSIZE];
+ if (size == 0)
+ return;
+
/* Rewind file descriptors. */
if (lseek(from_fd, (off_t)0, SEEK_SET) == (off_t)-1)
err(EX_OSERR, "lseek: %s", from_name);
@@ -416,9 +419,7 @@ copy(int from_fd, char *from_name, int to_fd, char *to_name, off_t size,
* trash memory on big files. This is really a minor hack, but it
* wins some CPU back. Sparse files need special treatment.
*/
- if (!size) {
- /* nothing to do */
- } else if (!sparse && size <= 8 * 1048576) {
+ if (!sparse && size <= 8 * 1048576) {
size_t siz;
if ((p = mmap(NULL, (size_t)size, PROT_READ, MAP_PRIVATE,