aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelen <jjelen@redhat.com>2020-04-09 12:10:53 +0200
committerJakub Jelen <jjelen@redhat.com>2020-04-15 20:05:56 +0200
commit945829a5dd3d6d0a21d76cf67fc2998896af7f99 (patch)
treeb0533bc13999a7689be5f92680d29c1f748df4ed
parent58d53f1397c9f4af0748a07aef16c15bbd724038 (diff)
downloadlibssh-945829a5dd3d6d0a21d76cf67fc2998896af7f99.tar.gz
libssh-945829a5dd3d6d0a21d76cf67fc2998896af7f99.tar.xz
libssh-945829a5dd3d6d0a21d76cf67fc2998896af7f99.zip
Reformat ssh_bind_accept()
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
-rw-r--r--src/bind.c53
1 files changed, 28 insertions, 25 deletions
diff --git a/src/bind.c b/src/bind.c
index fa8df9ea..b326a52b 100644
--- a/src/bind.c
+++ b/src/bind.c
@@ -550,34 +550,37 @@ int ssh_bind_accept_fd(ssh_bind sshbind, ssh_session session, socket_t fd){
return SSH_OK;
}
-int ssh_bind_accept(ssh_bind sshbind, ssh_session session) {
- socket_t fd = SSH_INVALID_SOCKET;
- int rc;
- if (sshbind->bindfd == SSH_INVALID_SOCKET) {
- ssh_set_error(sshbind, SSH_FATAL,
- "Can't accept new clients on a not bound socket.");
- return SSH_ERROR;
- }
+int ssh_bind_accept(ssh_bind sshbind, ssh_session session)
+{
+ socket_t fd = SSH_INVALID_SOCKET;
+ int rc;
- if (session == NULL){
- ssh_set_error(sshbind, SSH_FATAL,"session is null");
- return SSH_ERROR;
- }
+ if (sshbind->bindfd == SSH_INVALID_SOCKET) {
+ ssh_set_error(sshbind, SSH_FATAL,
+ "Can't accept new clients on a not bound socket.");
+ return SSH_ERROR;
+ }
- fd = accept(sshbind->bindfd, NULL, NULL);
- if (fd == SSH_INVALID_SOCKET) {
- ssh_set_error(sshbind, SSH_FATAL,
- "Accepting a new connection: %s",
- strerror(errno));
- return SSH_ERROR;
- }
- rc = ssh_bind_accept_fd(sshbind, session, fd);
+ if (session == NULL) {
+ ssh_set_error(sshbind, SSH_FATAL, "session is null");
+ return SSH_ERROR;
+ }
- if(rc == SSH_ERROR){
- CLOSE_SOCKET(fd);
- ssh_socket_free(session->socket);
- }
- return rc;
+ fd = accept(sshbind->bindfd, NULL, NULL);
+ if (fd == SSH_INVALID_SOCKET) {
+ ssh_set_error(sshbind, SSH_FATAL,
+ "Accepting a new connection: %s",
+ strerror(errno));
+ return SSH_ERROR;
+ }
+ rc = ssh_bind_accept_fd(sshbind, session, fd);
+
+ if (rc == SSH_ERROR) {
+ CLOSE_SOCKET(fd);
+ ssh_socket_free(session->socket);
+ }
+
+ return rc;
}