summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Nosek <root@localdomain.pl>2015-04-19 11:14:03 +0200
committerGrzegorz Nosek <root@localdomain.pl>2015-04-19 11:14:03 +0200
commitd9c6cf5cdcdf18dcacd184f587324a10be5027f7 (patch)
tree45e53518ed674932fc2b64f89fc0c056e8ee356e
parentdeabe97f2108edb5715dfc4ab4609514bf3d8157 (diff)
downloadfcgiwrap-d9c6cf5cdcdf18dcacd184f587324a10be5027f7.tar.xz
fcgiwrap-d9c6cf5cdcdf18dcacd184f587324a10be5027f7.zip
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
-rw-r--r--fcgiwrap.c12
1 files changed, 8 insertions, 4 deletions
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;
}
}