irced

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 46a673c73306014e31a07a0ea63af82a18f6145d
parent 15a29e196cf8195c24b8de5de71044af2b61abc2
Author: aabacchus <ben@bvnf.space>
Date:   Sun, 24 Jul 2022 00:19:54 +0100

fail() exit(3)s

Diffstat:
Mirced.c | 14++++----------
1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/irced.c b/irced.c @@ -62,10 +62,8 @@ start_listening(char *port) { hints.ai_protocol = 0; int s = getaddrinfo(NULL, port, &hints, &result); - if (s != 0) { + if (s != 0) fail("getaddrinfo: %s", gai_strerror(s)); - return -1; - } for (rp = result; rp != NULL; rp = rp->ai_next) { sfd = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol); @@ -76,24 +74,20 @@ start_listening(char *port) { break; if (close(sfd) == -1) { - fail("close: %s", strerror(errno)); freeaddrinfo(result); - return -1; + fail("close: %s", strerror(errno)); } } freeaddrinfo(result); - if (rp == NULL) { + if (rp == NULL) fail("localhost:%s: connection refused", port); - return -1; - } /* can have up to SOMAXCONN backlogged. */ if (listen(sfd, 10) == -1) { - fail("listen: %s", strerror(errno)); close(sfd); - return -1; + fail("listen: %s", strerror(errno)); } return sfd;