diff options
author | deraadt <deraadt@openbsd.org> | 2019-06-28 13:32:41 +0000 |
---|---|---|
committer | deraadt <deraadt@openbsd.org> | 2019-06-28 13:32:41 +0000 |
commit | df69c215c7c66baf660f3f65414fd34796c96152 (patch) | |
tree | 0255639162b24c4a2f761a274e32b69c2256fd45 /usr.sbin/rdate | |
parent | miniroot prototype disklabels should attempt to contain accurate (diff) | |
download | wireguard-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/rdate')
-rw-r--r-- | usr.sbin/rdate/ntp.c | 10 | ||||
-rw-r--r-- | usr.sbin/rdate/rfc868time.c | 8 |
2 files changed, 9 insertions, 9 deletions
diff --git a/usr.sbin/rdate/ntp.c b/usr.sbin/rdate/ntp.c index 547bdd98e53..d48b6cae19e 100644 --- a/usr.sbin/rdate/ntp.c +++ b/usr.sbin/rdate/ntp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ntp.c,v 1.34 2018/08/18 15:25:20 mestre Exp $ */ +/* $OpenBSD: ntp.c,v 1.35 2019/06/28 13:32:50 deraadt Exp $ */ /* * Copyright (c) 1996, 1997 by N.M. Maclaren. All rights reserved. @@ -146,7 +146,7 @@ ntp_client(const char *hostname, int family, struct timeval *new, s = -1; for (res = res0; res; res = res->ai_next) { s = socket(res->ai_family, res->ai_socktype, res->ai_protocol); - if (s < 0) + if (s == -1) continue; ret = sync_ntp(s, res->ai_addr, &offset, &error); @@ -188,7 +188,7 @@ sync_ntp(int fd, const struct sockaddr *peer, double *offset, double *error) *offset = 0.0; *error = NTP_INSANITY; - if (connect(fd, peer, SA_LEN(peer)) < 0) { + if (connect(fd, peer, SA_LEN(peer)) == -1) { warn("Failed to connect to server"); return (-1); } @@ -318,7 +318,7 @@ read_packet(int fd, struct ntp_data *data, double *off, double *error) retry: r = poll(pfd, 1, 1000 * MAX_DELAY / MAX_QUERIES); - if (r < 0) { + if (r == -1) { if (errno == EINTR) goto retry; warn("select"); @@ -331,7 +331,7 @@ retry: return (1); length = read(fd, receive, NTP_PACKET_MAX); - if (length < 0) { + if (length == -1) { warn("Unable to receive NTP packet from server"); return (-1); } diff --git a/usr.sbin/rdate/rfc868time.c b/usr.sbin/rdate/rfc868time.c index 2158fb632dc..a7f84fce505 100644 --- a/usr.sbin/rdate/rfc868time.c +++ b/usr.sbin/rdate/rfc868time.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rfc868time.c,v 1.11 2018/08/18 15:25:20 mestre Exp $ */ +/* $OpenBSD: rfc868time.c,v 1.12 2019/06/28 13:32:50 deraadt Exp $ */ /* $NetBSD: rdate.c,v 1.4 1996/03/16 12:37:45 pk Exp $ */ /* @@ -88,10 +88,10 @@ rfc868time_client(const char *hostname, int family, struct timeval *new, s = -1; for (res = res0; res; res = res->ai_next) { s = socket(res->ai_family, res->ai_socktype, res->ai_protocol); - if (s < 0) + if (s == -1) continue; - if (connect(s, res->ai_addr, res->ai_addrlen) < 0) { + if (connect(s, res->ai_addr, res->ai_addrlen) == -1) { close(s); s = -1; continue; @@ -99,7 +99,7 @@ rfc868time_client(const char *hostname, int family, struct timeval *new, break; } - if (s < 0) + if (s == -1) err(1, "Could not connect socket"); freeaddrinfo(res0); |