From d9c6cf5cdcdf18dcacd184f587324a10be5027f7 Mon Sep 17 00:00:00 2001 From: Grzegorz Nosek Date: Sun, 19 Apr 2015 11:14:03 +0200 Subject: Return the new fd directly from setup_socket() We either have a proper descriptor (>0) or an error (<0) so we don't strictly need the fd_out parameter --- fcgiwrap.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'fcgiwrap.c') diff --git a/fcgiwrap.c b/fcgiwrap.c index 3c36cf7..07892ca 100644 --- a/fcgiwrap.c +++ b/fcgiwrap.c @@ -704,7 +704,7 @@ static int listen_on_fd(int fd) { return 0; } -static int setup_socket(char *url, int *fd_out) { +static int setup_socket(char *url) { char *p = url; char *q; int fd; @@ -784,8 +784,11 @@ invalid_url: return -1; } - *fd_out = fd; - return listen_on_fd(fd); + if (listen_on_fd(fd) < 0) { + return -1; + } + + return fd; } int main(int argc, char **argv) @@ -850,7 +853,8 @@ int main(int argc, char **argv) } else #endif if (socket_url) { - if (setup_socket(socket_url, &fd) < 0) { + fd = setup_socket(socket_url); + if (fd < 0) { return 1; } } -- cgit v1.2.3