summaryrefslogtreecommitdiff
path: root/usr.bin/sndiod/listen.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/sndiod/listen.c')
-rw-r--r--usr.bin/sndiod/listen.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/usr.bin/sndiod/listen.c b/usr.bin/sndiod/listen.c
index 5397b6019b1..552b9457b96 100644
--- a/usr.bin/sndiod/listen.c
+++ b/usr.bin/sndiod/listen.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: listen.c,v 1.12 2017/01/03 06:51:56 ratchov Exp $ */
+/* $OpenBSD: listen.c,v 1.13 2019/06/28 13:35:03 deraadt Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -84,12 +84,12 @@ listen_new_un(char *path)
struct listen *f;
sock = socket(AF_UNIX, SOCK_STREAM, 0);
- if (sock < 0) {
+ if (sock == -1) {
log_puts(path);
log_puts(": failed to create socket\n");
return 0;
}
- if (unlink(path) < 0 && errno != ENOENT) {
+ if (unlink(path) == -1 && errno != ENOENT) {
log_puts(path);
log_puts(": failed to unlink socket\n");
goto bad_close;
@@ -98,12 +98,12 @@ listen_new_un(char *path)
strlcpy(sockname.sun_path, path, sizeof(sockname.sun_path));
oldumask = umask(0111);
if (bind(sock, (struct sockaddr *)&sockname,
- sizeof(struct sockaddr_un)) < 0) {
+ sizeof(struct sockaddr_un)) == -1) {
log_puts(path);
log_puts(": failed to bind socket\n");
goto bad_close;
}
- if (listen(sock, 1) < 0) {
+ if (listen(sock, 1) == -1) {
log_puts(path);
log_puts(": failed to listen\n");
goto bad_close;
@@ -153,24 +153,24 @@ listen_new_tcp(char *addr, unsigned int port)
*/
for (ai = ailist; ai != NULL; ai = ai->ai_next) {
s = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
- if (s < 0) {
+ if (s == -1) {
log_puts(addr);
log_puts(": failed to create socket\n");
continue;
}
opt = 1;
if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR,
- &opt, sizeof(int)) < 0) {
+ &opt, sizeof(int)) == -1) {
log_puts(addr);
log_puts(": failed to set SO_REUSEADDR\n");
goto bad_close;
}
- if (bind(s, ai->ai_addr, ai->ai_addrlen) < 0) {
+ if (bind(s, ai->ai_addr, ai->ai_addrlen) == -1) {
log_puts(addr);
log_puts(": failed to bind socket\n");
goto bad_close;
}
- if (listen(s, 1) < 0) {
+ if (listen(s, 1) == -1) {
log_puts(addr);
log_puts(": failed to listen\n");
goto bad_close;
@@ -230,14 +230,14 @@ listen_in(void *arg)
int sock, opt;
caddrlen = sizeof(caddrlen);
- while ((sock = accept(f->fd, &caddr, &caddrlen)) < 0) {
+ while ((sock = accept(f->fd, &caddr, &caddrlen)) == -1) {
if (errno == EINTR)
continue;
if (errno == ENFILE || errno == EMFILE)
file_slowaccept = 1;
return;
}
- if (fcntl(sock, F_SETFL, O_NONBLOCK) < 0) {
+ if (fcntl(sock, F_SETFL, O_NONBLOCK) == -1) {
file_log(f->file);
log_puts(": failed to set non-blocking mode\n");
goto bad_close;
@@ -245,7 +245,7 @@ listen_in(void *arg)
if (f->path == NULL) {
opt = 1;
if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY,
- &opt, sizeof(int)) < 0) {
+ &opt, sizeof(int)) == -1) {
file_log(f->file);
log_puts(": failed to set TCP_NODELAY flag\n");
goto bad_close;