summaryrefslogtreecommitdiff
path: root/sbin/wsconsctl
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 /sbin/wsconsctl
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 'sbin/wsconsctl')
-rw-r--r--sbin/wsconsctl/display.c6
-rw-r--r--sbin/wsconsctl/keyboard.c38
-rw-r--r--sbin/wsconsctl/mouse.c16
-rw-r--r--sbin/wsconsctl/wsconsctl.c10
4 files changed, 35 insertions, 35 deletions
diff --git a/sbin/wsconsctl/display.c b/sbin/wsconsctl/display.c
index fba7f6cdaeb..47245bbd4a3 100644
--- a/sbin/wsconsctl/display.c
+++ b/sbin/wsconsctl/display.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: display.c,v 1.21 2019/03/27 17:24:17 fcambus Exp $ */
+/* $OpenBSD: display.c,v 1.22 2019/06/28 13:32:46 deraadt Exp $ */
/* $NetBSD: display.c,v 1.1 1998/12/28 14:01:16 hannken Exp $ */
/*-
@@ -144,7 +144,7 @@ display_get_values(int fd)
(cmd == WSDISPLAYIO_GBURNER && !bon) ||
(cmd == WSDISPLAYIO_GINFO && !fbon)) {
errno = ENOTTY;
- if (!cmd || ioctl(fd, cmd, ptr) < 0) {
+ if (!cmd || ioctl(fd, cmd, ptr) == -1) {
if (errno == ENOTTY) {
pf->flags |= FLG_DEAD;
continue;
@@ -265,7 +265,7 @@ display_put_values(int fd)
}
errno = ENOTTY;
- if (!cmd || ioctl(fd, cmd, ptr) < 0) {
+ if (!cmd || ioctl(fd, cmd, ptr) == -1) {
if (errno == ENOTTY) {
pf->flags |= FLG_DEAD;
continue;
diff --git a/sbin/wsconsctl/keyboard.c b/sbin/wsconsctl/keyboard.c
index d60261b5a06..50773c69c59 100644
--- a/sbin/wsconsctl/keyboard.c
+++ b/sbin/wsconsctl/keyboard.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: keyboard.c,v 1.13 2015/12/12 12:31:37 jung Exp $ */
+/* $OpenBSD: keyboard.c,v 1.14 2019/06/28 13:32:46 deraadt Exp $ */
/* $NetBSD: keyboard.c 1.1 1998/12/28 14:01:17 hannken Exp $ */
/*-
@@ -78,7 +78,7 @@ keyboard_get_values(int fd)
struct field *pf;
if (field_by_value(keyboard_field_tab, &kbtype)->flags & FLG_GET)
- if (ioctl(fd, WSKBDIO_GTYPE, &kbtype) < 0)
+ if (ioctl(fd, WSKBDIO_GTYPE, &kbtype) == -1)
warn("WSKBDIO_GTYPE");
bell.which = 0;
@@ -88,7 +88,7 @@ keyboard_get_values(int fd)
bell.which |= WSKBD_BELL_DOPERIOD;
if (field_by_value(keyboard_field_tab, &bell.volume)->flags & FLG_GET)
bell.which |= WSKBD_BELL_DOVOLUME;
- if (bell.which != 0 && ioctl(fd, WSKBDIO_GETBELL, &bell) < 0)
+ if (bell.which != 0 && ioctl(fd, WSKBDIO_GETBELL, &bell) == -1)
warn("WSKBDIO_GETBELL");
dfbell.which = 0;
@@ -99,14 +99,14 @@ keyboard_get_values(int fd)
if (field_by_value(keyboard_field_tab, &dfbell.volume)->flags & FLG_GET)
dfbell.which |= WSKBD_BELL_DOVOLUME;
if (dfbell.which != 0 &&
- ioctl(fd, WSKBDIO_GETDEFAULTBELL, &dfbell) < 0)
+ ioctl(fd, WSKBDIO_GETDEFAULTBELL, &dfbell) == -1)
warn("WSKBDIO_GETDEFAULTBELL");
if (field_by_value(keyboard_field_tab, &kbmap)->flags & FLG_GET) {
kbmap.maplen = KS_NUMKEYCODES;
- if (ioctl(fd, WSKBDIO_GETMAP, &kbmap) < 0)
+ if (ioctl(fd, WSKBDIO_GETMAP, &kbmap) == -1)
warn("WSKBDIO_GETMAP");
- if (ioctl(fd, WSKBDIO_GETENCODING, &kbdencoding) < 0)
+ if (ioctl(fd, WSKBDIO_GETENCODING, &kbdencoding) == -1)
warn("WSKBDIO_GETENCODING");
ksymenc(kbdencoding);
}
@@ -117,7 +117,7 @@ keyboard_get_values(int fd)
if (field_by_value(keyboard_field_tab, &repeat.delN)->flags & FLG_GET)
repeat.which |= WSKBD_KEYREPEAT_DODELN;
if (repeat.which != 0 &&
- ioctl(fd, WSKBDIO_GETKEYREPEAT, &repeat) < 0)
+ ioctl(fd, WSKBDIO_GETKEYREPEAT, &repeat) == -1)
warn("WSKBDIO_GETKEYREPEAT");
dfrepeat.which = 0;
@@ -126,21 +126,21 @@ keyboard_get_values(int fd)
if (field_by_value(keyboard_field_tab, &dfrepeat.delN)->flags & FLG_GET)
dfrepeat.which |= WSKBD_KEYREPEAT_DODELN;
if (dfrepeat.which != 0 &&
- ioctl(fd, WSKBDIO_GETDEFAULTKEYREPEAT, &dfrepeat) < 0)
+ ioctl(fd, WSKBDIO_GETDEFAULTKEYREPEAT, &dfrepeat) == -1)
warn("WSKBDIO_GETDEFAULTKEYREPEAT");
if (field_by_value(keyboard_field_tab, &ledstate)->flags & FLG_GET)
- if (ioctl(fd, WSKBDIO_GETLEDS, &ledstate) < 0)
+ if (ioctl(fd, WSKBDIO_GETLEDS, &ledstate) == -1)
warn("WSKBDIO_GETLEDS");
if (field_by_value(keyboard_field_tab, &kbdencoding)->flags & FLG_GET)
- if (ioctl(fd, WSKBDIO_GETENCODING, &kbdencoding) < 0)
+ if (ioctl(fd, WSKBDIO_GETENCODING, &kbdencoding) == -1)
warn("WSKBDIO_GETENCODING");
pf = field_by_value(keyboard_field_tab, &backlight);
if (pf->flags & FLG_GET && !(pf->flags & FLG_DEAD)) {
errno = ENOTTY;
- if (ioctl(fd, WSKBDIO_GETBACKLIGHT, &kbl) < 0) {
+ if (ioctl(fd, WSKBDIO_GETBACKLIGHT, &kbl) == -1) {
if (errno == ENOTTY)
pf->flags |= FLG_DEAD;
else
@@ -166,7 +166,7 @@ keyboard_put_values(int fd)
bell.which |= WSKBD_BELL_DOPERIOD;
if (field_by_value(keyboard_field_tab, &bell.volume)->flags & FLG_SET)
bell.which |= WSKBD_BELL_DOVOLUME;
- if (bell.which != 0 && ioctl(fd, WSKBDIO_SETBELL, &bell) < 0) {
+ if (bell.which != 0 && ioctl(fd, WSKBDIO_SETBELL, &bell) == -1) {
warn("WSKBDIO_SETBELL");
return 1;
}
@@ -179,13 +179,13 @@ keyboard_put_values(int fd)
if (field_by_value(keyboard_field_tab, &dfbell.volume)->flags & FLG_SET)
dfbell.which |= WSKBD_BELL_DOVOLUME;
if (dfbell.which != 0 &&
- ioctl(fd, WSKBDIO_SETDEFAULTBELL, &dfbell) < 0) {
+ ioctl(fd, WSKBDIO_SETDEFAULTBELL, &dfbell) == -1) {
warn("WSKBDIO_SETDEFAULTBELL");
return 1;
}
if (field_by_value(keyboard_field_tab, &kbmap)->flags & FLG_SET) {
- if (ioctl(fd, WSKBDIO_SETMAP, &kbmap) < 0) {
+ if (ioctl(fd, WSKBDIO_SETMAP, &kbmap) == -1) {
warn("WSKBDIO_SETMAP");
return 1;
}
@@ -197,7 +197,7 @@ keyboard_put_values(int fd)
if (field_by_value(keyboard_field_tab, &repeat.delN)->flags & FLG_SET)
repeat.which |= WSKBD_KEYREPEAT_DODELN;
if (repeat.which != 0 &&
- ioctl(fd, WSKBDIO_SETKEYREPEAT, &repeat) < 0) {
+ ioctl(fd, WSKBDIO_SETKEYREPEAT, &repeat) == -1) {
warn("WSKBDIO_SETKEYREPEAT");
return 1;
}
@@ -208,20 +208,20 @@ keyboard_put_values(int fd)
if (field_by_value(keyboard_field_tab, &dfrepeat.delN)->flags & FLG_SET)
dfrepeat.which |= WSKBD_KEYREPEAT_DODELN;
if (dfrepeat.which != 0 &&
- ioctl(fd, WSKBDIO_SETDEFAULTKEYREPEAT, &dfrepeat) < 0) {
+ ioctl(fd, WSKBDIO_SETDEFAULTKEYREPEAT, &dfrepeat) == -1) {
warn("WSKBDIO_SETDEFAULTKEYREPEAT");
return 1;
}
if (field_by_value(keyboard_field_tab, &ledstate)->flags & FLG_SET) {
- if (ioctl(fd, WSKBDIO_SETLEDS, &ledstate) < 0) {
+ if (ioctl(fd, WSKBDIO_SETLEDS, &ledstate) == -1) {
warn("WSKBDIO_SETLEDS");
return 1;
}
}
if (field_by_value(keyboard_field_tab, &kbdencoding)->flags & FLG_SET) {
- if (ioctl(fd, WSKBDIO_SETENCODING, &kbdencoding) < 0) {
+ if (ioctl(fd, WSKBDIO_SETENCODING, &kbdencoding) == -1) {
warn("WSKBDIO_SETENCODING");
return 1;
}
@@ -233,7 +233,7 @@ keyboard_put_values(int fd)
kbl.curval = backlight.cur;
kbl.max = backlight.max;
errno = ENOTTY;
- if (ioctl(fd, WSKBDIO_SETBACKLIGHT, &kbl) < 0) {
+ if (ioctl(fd, WSKBDIO_SETBACKLIGHT, &kbl) == -1) {
if (errno == ENOTTY)
pf->flags |= FLG_DEAD;
else {
diff --git a/sbin/wsconsctl/mouse.c b/sbin/wsconsctl/mouse.c
index a0ee9080f48..5fc70436eaa 100644
--- a/sbin/wsconsctl/mouse.c
+++ b/sbin/wsconsctl/mouse.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mouse.c,v 1.18 2018/05/07 22:15:36 bru Exp $ */
+/* $OpenBSD: mouse.c,v 1.19 2019/06/28 13:32:46 deraadt Exp $ */
/* $NetBSD: mouse.c,v 1.3 1999/11/15 13:47:30 ad Exp $ */
/*-
@@ -108,11 +108,11 @@ mouse_get_values(int fd)
struct field *f;
if (field_by_value(mouse_field_tab, &mstype)->flags & FLG_GET)
- if (ioctl(fd, WSMOUSEIO_GTYPE, &mstype) < 0)
+ if (ioctl(fd, WSMOUSEIO_GTYPE, &mstype) == -1)
warn("WSMOUSEIO_GTYPE");
if (field_by_value(mouse_field_tab, &rawmode)->flags & FLG_GET) {
- if (ioctl(fd, WSMOUSEIO_GCALIBCOORDS, &wmcoords) < 0) {
+ if (ioctl(fd, WSMOUSEIO_GCALIBCOORDS, &wmcoords) == -1) {
if (errno == ENOTTY)
field_by_value(mouse_field_tab,
&rawmode)->flags |= FLG_DEAD;
@@ -123,7 +123,7 @@ mouse_get_values(int fd)
}
if (field_by_value(mouse_field_tab, &wmcoords)->flags & FLG_GET)
- if (ioctl(fd, WSMOUSEIO_GCALIBCOORDS, &wmcoords) < 0) {
+ if (ioctl(fd, WSMOUSEIO_GCALIBCOORDS, &wmcoords) == -1) {
if (errno == ENOTTY)
field_by_value(mouse_field_tab,
&wmcoords)->flags |= FLG_DEAD;
@@ -148,14 +148,14 @@ mouse_put_values(int fd)
struct field *f;
if (field_by_value(mouse_field_tab, &resolution)->flags & FLG_SET) {
- if (ioctl(fd, WSMOUSEIO_SRES, &resolution) < 0) {
+ if (ioctl(fd, WSMOUSEIO_SRES, &resolution) == -1) {
warn("WSMOUSEIO_SRES");
return 1;
}
}
if (field_by_value(mouse_field_tab, &rawmode)->flags & FLG_SET) {
wmcoords.samplelen = rawmode;
- if (ioctl(fd, WSMOUSEIO_SCALIBCOORDS, &wmcoords) < 0) {
+ if (ioctl(fd, WSMOUSEIO_SCALIBCOORDS, &wmcoords) == -1) {
if (errno == ENOTTY) {
field_by_value(mouse_field_tab,
&rawmode)->flags |= FLG_DEAD;
@@ -166,7 +166,7 @@ mouse_put_values(int fd)
}
}
if (field_by_value(mouse_field_tab, &wmcoords)->flags & FLG_SET) {
- if (ioctl(fd, WSMOUSEIO_GCALIBCOORDS, &wmcoords_save) < 0) {
+ if (ioctl(fd, WSMOUSEIO_GCALIBCOORDS, &wmcoords_save) == -1) {
if (errno == ENOTTY)
field_by_value(mouse_field_tab,
&wmcoords)->flags |= FLG_DEAD;
@@ -174,7 +174,7 @@ mouse_put_values(int fd)
warn("WSMOUSEIO_GCALIBCOORDS");
}
wmcoords.samplelen = wmcoords_save.samplelen;
- if (ioctl(fd, WSMOUSEIO_SCALIBCOORDS, &wmcoords) < 0) {
+ if (ioctl(fd, WSMOUSEIO_SCALIBCOORDS, &wmcoords) == -1) {
if (errno == ENOTTY) {
field_by_value(mouse_field_tab,
&wmcoords)->flags |= FLG_DEAD;
diff --git a/sbin/wsconsctl/wsconsctl.c b/sbin/wsconsctl/wsconsctl.c
index 1c62df8fe5d..efb3f17613b 100644
--- a/sbin/wsconsctl/wsconsctl.c
+++ b/sbin/wsconsctl/wsconsctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wsconsctl.c,v 1.31 2017/07/21 20:38:20 bru Exp $ */
+/* $OpenBSD: wsconsctl.c,v 1.32 2019/06/28 13:32:46 deraadt Exp $ */
/* $NetBSD: wsconsctl.c,v 1.2 1998/12/29 22:40:20 hannken Exp $ */
/*-
@@ -120,8 +120,8 @@ main(int argc, char *argv[])
for (devidx = 0;; devidx++) {
device = (*sw->nextdev)(devidx);
if (!device ||
- ((devfd = open(device, O_WRONLY)) < 0 &&
- (devfd = open(device, O_RDONLY)) < 0)) {
+ ((devfd = open(device, O_WRONLY)) == -1 &&
+ (devfd = open(device, O_RDONLY)) == -1)) {
if (!device || errno != ENXIO) {
if (device && errno != ENOENT) {
warn("%s", device);
@@ -170,8 +170,8 @@ main(int argc, char *argv[])
device = wdev;
if (!device ||
- ((devfd = open(device, O_WRONLY)) < 0 &&
- (devfd = open(device, O_RDONLY)) < 0)) {
+ ((devfd = open(device, O_WRONLY)) == -1 &&
+ (devfd = open(device, O_RDONLY)) == -1)) {
if (!device) {
const char *c = strchr(argv[i], '.');
int k;