summaryrefslogtreecommitdiff
path: root/bin/cp
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2019-06-28 13:35:06 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2019-06-28 13:35:06 +0000
commit61656abc7ff84215165af1bd464bc053b3b66158 (patch)
treec7eabb0c4fa9faa024e724e99c240c40da07ca42 /bin/cp
parent18603ebf99fbb890ae9666cb0c4aa9f879e7edaa (diff)
When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?) callers of syscalls to follow this better, and let's see if this strictness helps us in the future.
Diffstat (limited to 'bin/cp')
-rw-r--r--bin/cp/cp.c4
-rw-r--r--bin/cp/utils.c8
2 files changed, 6 insertions, 6 deletions
diff --git a/bin/cp/cp.c b/bin/cp/cp.c
index c0a0d63dbeb..791e1d18c54 100644
--- a/bin/cp/cp.c
+++ b/bin/cp/cp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cp.c,v 1.52 2019/01/28 18:58:42 jca Exp $ */
+/* $OpenBSD: cp.c,v 1.53 2019/06/28 13:34:58 deraadt Exp $ */
/* $NetBSD: cp.c,v 1.14 1995/09/07 06:14:51 jtc Exp $ */
/*
@@ -425,7 +425,7 @@ copy(char *argv[], enum op type, int fts_options)
*/
if (fts_dne(curr)) {
if (mkdir(to.p_path,
- curr->fts_statp->st_mode | S_IRWXU) < 0)
+ curr->fts_statp->st_mode | S_IRWXU) == -1)
err(1, "%s", to.p_path);
else if (vflag)
(void)fprintf(stdout, "%s -> %s\n",
diff --git a/bin/cp/utils.c b/bin/cp/utils.c
index 2275c127b76..a2f480c3393 100644
--- a/bin/cp/utils.c
+++ b/bin/cp/utils.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: utils.c,v 1.47 2019/01/28 18:58:42 jca Exp $ */
+/* $OpenBSD: utils.c,v 1.48 2019/06/28 13:34:58 deraadt Exp $ */
/* $NetBSD: utils.c,v 1.6 1997/02/26 14:40:51 cgd Exp $ */
/*-
@@ -129,7 +129,7 @@ copy_file(FTSENT *entp, int exists)
rval = 1;
}
/* Some systems don't unmap on close(2). */
- if (munmap(p, fs->st_size) < 0) {
+ if (munmap(p, fs->st_size) == -1) {
warn("%s", entp->fts_path);
rval = 1;
}
@@ -152,9 +152,9 @@ copy_file(FTSENT *entp, int exists)
break;
}
}
- if (skipholes && rcount >= 0)
+ if (skipholes && rcount != -1)
rcount = ftruncate(to_fd, lseek(to_fd, 0, SEEK_CUR));
- if (rcount < 0) {
+ if (rcount == -1) {
warn("%s", entp->fts_path);
rval = 1;
}