summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2024-11-21 13:12:36 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2024-11-21 13:12:36 +0000
commit3d390a8bbbfa60898c28bb458da47b91b54287a8 (patch)
tree60cc4955c806aaac6a075361457f0319a9e70a26
parentf6c88a9535ada120880c3cc431d0bdf48df5be3f (diff)
Convert msgbuf_write() callers to the new return logic.
OK tb@
-rw-r--r--regress/usr.sbin/rpki-client/test-http.c6
-rw-r--r--usr.sbin/ldpd/packet.c6
-rw-r--r--usr.sbin/rpki-client/filemode.c12
-rw-r--r--usr.sbin/rpki-client/http.c12
-rw-r--r--usr.sbin/rpki-client/main.c17
-rw-r--r--usr.sbin/rpki-client/parser.c12
-rw-r--r--usr.sbin/rpki-client/rrdp.c12
-rw-r--r--usr.sbin/rpki-client/rsync.c12
8 files changed, 41 insertions, 48 deletions
diff --git a/regress/usr.sbin/rpki-client/test-http.c b/regress/usr.sbin/rpki-client/test-http.c
index 830bb9ca6f5..b28cc720c44 100644
--- a/regress/usr.sbin/rpki-client/test-http.c
+++ b/regress/usr.sbin/rpki-client/test-http.c
@@ -149,12 +149,8 @@ main(int argc, char **argv)
err(1, "open %s", file);
http_request(req++, uri, mod, outfd);
- switch (msgbuf_write(&httpq)) {
- case 0:
- errx(1, "write: connection closed");
- case -1:
+ if (msgbuf_write(&httpq) == -1)
err(1, "write");
- }
error = http_response(http);
return error;
}
diff --git a/usr.sbin/ldpd/packet.c b/usr.sbin/ldpd/packet.c
index 8ea1c511b42..ddf3db38fba 100644
--- a/usr.sbin/ldpd/packet.c
+++ b/usr.sbin/ldpd/packet.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: packet.c,v 1.72 2021/01/19 15:59:25 claudio Exp $ */
+/* $OpenBSD: packet.c,v 1.73 2024/11/21 13:12:11 claudio Exp $ */
/*
* Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org>
@@ -598,8 +598,8 @@ session_write(int fd, short event, void *arg)
if (!(event & EV_WRITE))
return;
- if (msgbuf_write(&tcp->wbuf.wbuf) <= 0)
- if (errno != EAGAIN && nbr)
+ if (msgbuf_write(&tcp->wbuf.wbuf) == -1)
+ if (nbr)
nbr_fsm(nbr, NBR_EVT_CLOSE_SESSION);
if (nbr == NULL && !tcp->wbuf.wbuf.queued) {
diff --git a/usr.sbin/rpki-client/filemode.c b/usr.sbin/rpki-client/filemode.c
index 68527b26c11..bd03d993b13 100644
--- a/usr.sbin/rpki-client/filemode.c
+++ b/usr.sbin/rpki-client/filemode.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: filemode.c,v 1.52 2024/11/13 12:51:04 tb Exp $ */
+/* $OpenBSD: filemode.c,v 1.53 2024/11/21 13:12:19 claudio Exp $ */
/*
* Copyright (c) 2019 Claudio Jeker <claudio@openbsd.org>
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
@@ -784,11 +784,11 @@ proc_filemode(int fd)
}
if (pfd.revents & POLLOUT) {
- switch (msgbuf_write(&msgq)) {
- case 0:
- errx(1, "write: connection closed");
- case -1:
- err(1, "write");
+ if (msgbuf_write(&msgq) == -1) {
+ if (errno == EPIPE)
+ errx(1, "write: connection closed");
+ else
+ err(1, "write");
}
}
diff --git a/usr.sbin/rpki-client/http.c b/usr.sbin/rpki-client/http.c
index 020c48ed759..e6262742d89 100644
--- a/usr.sbin/rpki-client/http.c
+++ b/usr.sbin/rpki-client/http.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: http.c,v 1.88 2024/11/14 10:28:59 tb Exp $ */
+/* $OpenBSD: http.c,v 1.89 2024/11/21 13:12:19 claudio Exp $ */
/*
* Copyright (c) 2020 Nils Fisher <nils_fisher@hotmail.com>
* Copyright (c) 2020 Claudio Jeker <claudio@openbsd.org>
@@ -2138,11 +2138,11 @@ proc_http(char *bind_addr, int fd)
if (pfds[0].revents & POLLHUP)
break;
if (pfds[0].revents & POLLOUT) {
- switch (msgbuf_write(&msgq)) {
- case 0:
- errx(1, "write: connection closed");
- case -1:
- err(1, "write");
+ if (msgbuf_write(&msgq) == -1) {
+ if (errno == EPIPE)
+ errx(1, "write: connection closed");
+ else
+ err(1, "write");
}
}
if (pfds[0].revents & POLLIN) {
diff --git a/usr.sbin/rpki-client/main.c b/usr.sbin/rpki-client/main.c
index 13325062999..6d7867dc180 100644
--- a/usr.sbin/rpki-client/main.c
+++ b/usr.sbin/rpki-client/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.271 2024/11/14 10:28:59 tb Exp $ */
+/* $OpenBSD: main.c,v 1.272 2024/11/21 13:12:19 claudio Exp $ */
/*
* Copyright (c) 2021 Claudio Jeker <claudio@openbsd.org>
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
@@ -1310,16 +1310,13 @@ main(int argc, char *argv[])
if (pfd[i].revents & POLLHUP)
hangup = 1;
if (pfd[i].revents & POLLOUT) {
- switch (msgbuf_write(queues[i])) {
- case 0:
- warnx("write[%d]: "
- "connection closed", i);
+ if (msgbuf_write(queues[i]) == -1) {
+ if (errno == EPIPE)
+ warnx("write[%d]: "
+ "connection closed", i);
+ else
+ warn("write[%d]", i);
hangup = 1;
- break;
- case -1:
- warn("write[%d]", i);
- hangup = 1;
- break;
}
}
}
diff --git a/usr.sbin/rpki-client/parser.c b/usr.sbin/rpki-client/parser.c
index 07de94ddc7c..1512028439b 100644
--- a/usr.sbin/rpki-client/parser.c
+++ b/usr.sbin/rpki-client/parser.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: parser.c,v 1.144 2024/11/02 12:30:28 job Exp $ */
+/* $OpenBSD: parser.c,v 1.145 2024/11/21 13:12:19 claudio Exp $ */
/*
* Copyright (c) 2019 Claudio Jeker <claudio@openbsd.org>
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
@@ -1106,11 +1106,11 @@ proc_parser(int fd)
}
if (pfd.revents & POLLOUT) {
- switch (msgbuf_write(&msgq)) {
- case 0:
- errx(1, "write: connection closed");
- case -1:
- err(1, "write");
+ if (msgbuf_write(&msgq) == -1) {
+ if (errno == EPIPE)
+ errx(1, "write: connection closed");
+ else
+ err(1, "write");
}
}
diff --git a/usr.sbin/rpki-client/rrdp.c b/usr.sbin/rpki-client/rrdp.c
index c17eb7a7a1f..4e2f7142e35 100644
--- a/usr.sbin/rpki-client/rrdp.c
+++ b/usr.sbin/rpki-client/rrdp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rrdp.c,v 1.35 2024/09/02 11:56:22 job Exp $ */
+/* $OpenBSD: rrdp.c,v 1.36 2024/11/21 13:12:19 claudio Exp $ */
/*
* Copyright (c) 2020 Nils Fisher <nils_fisher@hotmail.com>
* Copyright (c) 2021 Claudio Jeker <claudio@openbsd.org>
@@ -597,11 +597,11 @@ proc_rrdp(int fd)
if (pfds[0].revents & POLLHUP)
break;
if (pfds[0].revents & POLLOUT) {
- switch (msgbuf_write(&msgq)) {
- case 0:
- errx(1, "write: connection closed");
- case -1:
- err(1, "write");
+ if (msgbuf_write(&msgq) == -1) {
+ if (errno == EPIPE)
+ errx(1, "write: connection closed");
+ else
+ err(1, "write");
}
}
if (pfds[0].revents & POLLIN)
diff --git a/usr.sbin/rpki-client/rsync.c b/usr.sbin/rpki-client/rsync.c
index ad4ce6f87f3..6fa439a4b57 100644
--- a/usr.sbin/rpki-client/rsync.c
+++ b/usr.sbin/rpki-client/rsync.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rsync.c,v 1.52 2024/11/14 10:28:59 tb Exp $ */
+/* $OpenBSD: rsync.c,v 1.53 2024/11/21 13:12:19 claudio Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -355,11 +355,11 @@ proc_rsync(char *prog, char *bind_addr, int fd)
}
if (pfd.revents & POLLOUT) {
- switch (msgbuf_write(&msgq)) {
- case 0:
- errx(1, "write: connection closed");
- case -1:
- err(1, "write");
+ if (msgbuf_write(&msgq) == -1) {
+ if (errno == EPIPE)
+ errx(1, "write: connection closed");
+ else
+ err(1, "write");
}
}