summaryrefslogtreecommitdiffstats
path: root/usr.sbin/amd
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>2019-06-28 13:32:41 +0000
committerderaadt <deraadt@openbsd.org>2019-06-28 13:32:41 +0000
commitdf69c215c7c66baf660f3f65414fd34796c96152 (patch)
tree0255639162b24c4a2f761a274e32b69c2256fd45 /usr.sbin/amd
parentminiroot prototype disklabels should attempt to contain accurate (diff)
downloadwireguard-openbsd-df69c215c7c66baf660f3f65414fd34796c96152.tar.xz
wireguard-openbsd-df69c215c7c66baf660f3f65414fd34796c96152.zip
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.sbin/amd')
-rw-r--r--usr.sbin/amd/amd/amd.c8
-rw-r--r--usr.sbin/amd/amd/rpc_fwd.c14
2 files changed, 11 insertions, 11 deletions
diff --git a/usr.sbin/amd/amd/amd.c b/usr.sbin/amd/amd/amd.c
index 3f46c4e82df..b41ee0be9ee 100644
--- a/usr.sbin/amd/amd/amd.c
+++ b/usr.sbin/amd/amd/amd.c
@@ -32,7 +32,7 @@
* SUCH DAMAGE.
*
* from: @(#)amd.c 8.1 (Berkeley) 6/6/93
- * $Id: amd.c,v 1.22 2015/09/11 19:03:30 millert Exp $
+ * $Id: amd.c,v 1.23 2019/06/28 13:32:46 deraadt Exp $
*/
/*
@@ -167,11 +167,11 @@ daemon_mode(void)
#ifdef TIOCNOTTY
{
int t = open("/dev/tty", O_RDWR);
- if (t < 0) {
+ if (t == -1) {
if (errno != ENXIO) /* not an error if already no controlling tty */
plog(XLOG_WARNING, "Could not open controlling tty: %m");
} else {
- if (ioctl(t, TIOCNOTTY, 0) < 0 && errno != ENOTTY)
+ if (ioctl(t, TIOCNOTTY, 0) == -1 && errno != ENOTTY)
plog(XLOG_WARNING, "Could not disassociate tty (TIOCNOTTY): %m");
(void) close(t);
}
@@ -211,7 +211,7 @@ main(int argc, char *argv[])
/*
* Get local machine name
*/
- if (gethostname(hostname, sizeof(hostname)) < 0) {
+ if (gethostname(hostname, sizeof(hostname)) == -1) {
plog(XLOG_FATAL, "gethostname: %m");
going_down(1);
}
diff --git a/usr.sbin/amd/amd/rpc_fwd.c b/usr.sbin/amd/amd/rpc_fwd.c
index 442912b1d36..917cf7bc421 100644
--- a/usr.sbin/amd/amd/rpc_fwd.c
+++ b/usr.sbin/amd/amd/rpc_fwd.c
@@ -32,7 +32,7 @@
* SUCH DAMAGE.
*
* from: @(#)rpc_fwd.c 8.1 (Berkeley) 6/6/93
- * $Id: rpc_fwd.c,v 1.10 2015/09/13 15:44:47 guenther Exp $
+ * $Id: rpc_fwd.c,v 1.11 2019/06/28 13:32:46 deraadt Exp $
*/
/*
@@ -162,7 +162,7 @@ int fwd_init()
* Create ping socket
*/
fwd_sock = socket(AF_INET, SOCK_DGRAM | SOCK_NONBLOCK, 0);
- if (fwd_sock < 0) {
+ if (fwd_sock == -1) {
plog(XLOG_ERROR, "Unable to create RPC forwarding socket: %m");
return errno;
}
@@ -170,7 +170,7 @@ int fwd_init()
/*
* Some things we talk to require a priv port - so make one here
*/
- if (bind_resv_port(fwd_sock, (unsigned short *) 0) < 0)
+ if (bind_resv_port(fwd_sock, (unsigned short *) 0) == -1)
plog(XLOG_ERROR, "can't bind privileged port");
return 0;
@@ -278,7 +278,7 @@ fwd_packet(int type_id, void *pkt, int len, struct sockaddr_in *fwdto,
}
#endif /* DEBUG */
if (sendto(fwd_sock, (char *) pkt, len, 0,
- (struct sockaddr *) fwdto, sizeof(*fwdto)) < 0)
+ (struct sockaddr *) fwdto, sizeof(*fwdto)) == -1)
error = errno;
/*
@@ -316,7 +316,7 @@ fwd_reply()
* Determine the length of the packet
*/
#ifdef DYNAMIC_BUFFERS
- if (ioctl(fwd_sock, FIONREAD, &len) < 0 || len < 0) {
+ if (ioctl(fwd_sock, FIONREAD, &len) == -1 || len < 0) {
plog(XLOG_ERROR, "Error reading packet size: %m");
return;
}
@@ -340,9 +340,9 @@ again:
src_addr_len = sizeof(src_addr);
rc = recvfrom(fwd_sock, (char *) pkt, len, 0,
(struct sockaddr *) &src_addr, &src_addr_len);
- if (rc < 0 || src_addr_len != sizeof(src_addr) ||
+ if (rc == -1 || src_addr_len != sizeof(src_addr) ||
src_addr.sin_family != AF_INET) {
- if (rc < 0 && errno == EINTR)
+ if (rc == -1 && errno == EINTR)
goto again;
plog(XLOG_ERROR, "Error reading RPC reply: %m");
goto out;