diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2019-06-28 13:35:06 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2019-06-28 13:35:06 +0000 |
commit | 61656abc7ff84215165af1bd464bc053b3b66158 (patch) | |
tree | c7eabb0c4fa9faa024e724e99c240c40da07ca42 /bin/mkdir | |
parent | 18603ebf99fbb890ae9666cb0c4aa9f879e7edaa (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/mkdir')
-rw-r--r-- | bin/mkdir/mkdir.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/bin/mkdir/mkdir.c b/bin/mkdir/mkdir.c index 1f94d0a51a8..635a77f23ec 100644 --- a/bin/mkdir/mkdir.c +++ b/bin/mkdir/mkdir.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mkdir.c,v 1.30 2016/10/19 18:20:25 schwarze Exp $ */ +/* $OpenBSD: mkdir.c,v 1.31 2019/06/28 13:34:59 deraadt Exp $ */ /* $NetBSD: mkdir.c,v 1.14 1995/06/25 21:59:21 mycroft Exp $ */ /* @@ -109,7 +109,7 @@ main(int argc, char *argv[]) if (rv == 0 && mode > 0777) rv = chmod(*argv, mode); } - if (rv < 0) { + if (rv == -1) { warn("%s", *argv); exitval = 1; } @@ -140,12 +140,12 @@ mkpath(char *path, mode_t mode, mode_t dir_mode) *slash = '\0'; if (mkdir(path, done ? mode : dir_mode) == 0) { - if (mode > 0777 && chmod(path, mode) < 0) + if (mode > 0777 && chmod(path, mode) == -1) return (-1); } else { int mkdir_errno = errno; - if (stat(path, &sb)) { + if (stat(path, &sb) == -1) { /* Not there; use mkdir()s errno */ errno = mkdir_errno; return (-1); |