diff options
author | 2017-01-03 06:51:56 +0000 | |
---|---|---|
committer | 2017-01-03 06:51:56 +0000 | |
commit | 61bfbbe39333c4636edc1c31cf6a467b8b433dc4 (patch) | |
tree | d4180cd36e5d83954010d13c7409b09650a6ca98 | |
parent | No need to set use_maxpkt twice. From Michael W. Bombardieri. Thanks. (diff) | |
download | wireguard-openbsd-61bfbbe39333c4636edc1c31cf6a467b8b433dc4.tar.xz wireguard-openbsd-61bfbbe39333c4636edc1c31cf6a467b8b433dc4.zip |
Use a goto to factor all calls to close() when listen_in() returns
an error. From Michael W. Bombardieri. Thanks.
-rw-r--r-- | usr.bin/sndiod/listen.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/usr.bin/sndiod/listen.c b/usr.bin/sndiod/listen.c index f1f1c312025..5397b6019b1 100644 --- a/usr.bin/sndiod/listen.c +++ b/usr.bin/sndiod/listen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: listen.c,v 1.11 2016/01/08 16:22:09 ratchov Exp $ */ +/* $OpenBSD: listen.c,v 1.12 2017/01/03 06:51:56 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -240,8 +240,7 @@ listen_in(void *arg) if (fcntl(sock, F_SETFL, O_NONBLOCK) < 0) { file_log(f->file); log_puts(": failed to set non-blocking mode\n"); - close(sock); - return; + goto bad_close; } if (f->path == NULL) { opt = 1; @@ -249,14 +248,14 @@ listen_in(void *arg) &opt, sizeof(int)) < 0) { file_log(f->file); log_puts(": failed to set TCP_NODELAY flag\n"); - close(sock); - return; + goto bad_close; } } - if (sock_new(sock) == NULL) { - close(sock); - return; - } + if (sock_new(sock) == NULL) + goto bad_close; + return; +bad_close: + close(sock); } void |