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/stty/stty.c | |
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/stty/stty.c')
-rw-r--r-- | bin/stty/stty.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/bin/stty/stty.c b/bin/stty/stty.c index 4d70ae6687a..904d86996cf 100644 --- a/bin/stty/stty.c +++ b/bin/stty/stty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: stty.c,v 1.20 2016/07/23 08:57:18 bluhm Exp $ */ +/* $OpenBSD: stty.c,v 1.21 2019/06/28 13:35:00 deraadt Exp $ */ /* $NetBSD: stty.c,v 1.11 1995/03/21 09:11:30 cgd Exp $ */ /*- @@ -69,7 +69,7 @@ main(int argc, char *argv[]) fmt = BSD; break; case 'f': - if ((i.fd = open(optarg, O_RDONLY | O_NONBLOCK)) < 0) + if ((i.fd = open(optarg, O_RDONLY | O_NONBLOCK)) == -1) err(1, "%s", optarg); break; case 'g': @@ -82,12 +82,12 @@ main(int argc, char *argv[]) args: argc -= optind; argv += optind; - if (ioctl(i.fd, TIOCGETD, &i.ldisc) < 0 ) + if (ioctl(i.fd, TIOCGETD, &i.ldisc) == -1) err(1, "TIOCGETD"); - if (tcgetattr(i.fd, &i.t) < 0) + if (tcgetattr(i.fd, &i.t) == -1) errx(1, "not a terminal"); - if (ioctl(i.fd, TIOCGWINSZ, &i.win) < 0) + if (ioctl(i.fd, TIOCGWINSZ, &i.win) == -1) warn("TIOCGWINSZ"); switch(fmt) { @@ -149,9 +149,9 @@ args: argc -= optind; usage(); } - if (i.set && tcsetattr(i.fd, 0, &i.t) < 0) + if (i.set && tcsetattr(i.fd, 0, &i.t) == -1) err(1, "tcsetattr"); - if (i.wset && ioctl(i.fd, TIOCSWINSZ, &i.win) < 0) + if (i.wset && ioctl(i.fd, TIOCSWINSZ, &i.win) == -1) warn("TIOCSWINSZ"); return (0); } |