summaryrefslogtreecommitdiff
path: root/libexec/mail.local
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2019-06-28 13:32:54 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2019-06-28 13:32:54 +0000
commit86ffccf24f66032a89d70a32b3609584c0db7345 (patch)
tree2ae97fac6ea5be57cc953baf8612e8f683da0172 /libexec/mail.local
parentce9fea47562d4f179d45680d6aec00ede2877141 (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 'libexec/mail.local')
-rw-r--r--libexec/mail.local/mail.local.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/libexec/mail.local/mail.local.c b/libexec/mail.local/mail.local.c
index b823ab0d83b..ddfaae20a0a 100644
--- a/libexec/mail.local/mail.local.c
+++ b/libexec/mail.local/mail.local.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mail.local.c,v 1.35 2015/12/12 20:09:28 mmcc Exp $ */
+/* $OpenBSD: mail.local.c,v 1.36 2019/06/28 13:32:53 deraadt Exp $ */
/*-
* Copyright (c) 1996-1998 Theo de Raadt <deraadt@theos.com>
@@ -201,7 +201,7 @@ retry:
goto bad;
}
if ((mbfd = open(path, O_APPEND|O_CREAT|O_EXCL|O_WRONLY|O_EXLOCK,
- S_IRUSR|S_IWUSR)) < 0) {
+ S_IRUSR|S_IWUSR)) == -1) {
if (errno == EEXIST) {
/* file appeared since lstat */
goto retry;
@@ -216,7 +216,7 @@ retry:
* that if the ownership or permissions were changed there
* was a reason for doing so.
*/
- if (fchown(mbfd, pw->pw_uid, pw->pw_gid) < 0) {
+ if (fchown(mbfd, pw->pw_uid, pw->pw_gid) == -1) {
merr(NOTFATAL, "chown %u:%u: %s",
pw->pw_uid, pw->pw_gid, name);
goto bad;
@@ -227,11 +227,11 @@ retry:
goto bad;
}
if ((mbfd = open(path, O_APPEND|O_WRONLY|O_EXLOCK,
- S_IRUSR|S_IWUSR)) < 0) {
+ S_IRUSR|S_IWUSR)) == -1) {
merr(NOTFATAL, "%s: %s", path, strerror(errno));
goto bad;
}
- if (fstat(mbfd, &fsb)) {
+ if (fstat(mbfd, &fsb) == -1) {
/* relating error to path may be bad style */
merr(NOTFATAL, "%s: %s", path, strerror(errno));
goto bad;
@@ -256,7 +256,7 @@ retry:
while ((nr = read(fd, buf, sizeof(buf))) > 0)
for (off = 0; off < nr; off += nw)
- if ((nw = write(mbfd, buf + off, nr - off)) < 0) {
+ if ((nw = write(mbfd, buf + off, nr - off)) == -1) {
merr(NOTFATAL, "%s: %s", path, strerror(errno));
(void)ftruncate(mbfd, curoff);
goto bad;