summaryrefslogtreecommitdiff
path: root/usr.bin/pctr
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 /usr.bin/pctr
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 'usr.bin/pctr')
-rw-r--r--usr.bin/pctr/pctr.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/usr.bin/pctr/pctr.c b/usr.bin/pctr/pctr.c
index 190b1963f5e..77efab964f2 100644
--- a/usr.bin/pctr/pctr.c
+++ b/usr.bin/pctr/pctr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pctr.c,v 1.23 2017/09/10 11:30:43 tom Exp $ */
+/* $OpenBSD: pctr.c,v 1.24 2019/06/28 13:35:02 deraadt Exp $ */
/*
* Copyright (c) 2007 Mike Belopuhov, Aleksey Lomovtsev
@@ -338,9 +338,9 @@ pctr_read(struct pctrst *st)
int fd, se;
fd = open(_PATH_PCTR, O_RDONLY);
- if (fd < 0)
+ if (fd == -1)
return (-1);
- if (ioctl(fd, PCIOCRD, st) < 0) {
+ if (ioctl(fd, PCIOCRD, st) == -1) {
se = errno;
close(fd);
errno = se;
@@ -355,9 +355,9 @@ pctr_write(int ctr, u_int32_t val)
int fd, se;
fd = open(_PATH_PCTR, O_WRONLY);
- if (fd < 0)
+ if (fd == -1)
return (-1);
- if (ioctl(fd, PCIOCS0 + ctr, &val) < 0) {
+ if (ioctl(fd, PCIOCS0 + ctr, &val) == -1) {
se = errno;
close(fd);
errno = se;