From c0e53939272870f042a5a25905ce168bd599550c Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Thu, 31 Oct 2019 11:15:41 +0100 Subject: [PATCH] channesl: Reformat ssh_channel_poll_timeout() Fixes T188 Signed-off-by: Andreas Schneider Reviewed-by: Jakub Jelen (cherry picked from commit fbe115abba26d8c797c79f4418b92101f8bd13a6) --- src/channels.c | 65 ++++++++++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 29 deletions(-) diff --git a/src/channels.c b/src/channels.c index 19eabef7..c97e94d3 100644 --- a/src/channels.c +++ b/src/channels.c @@ -3077,38 +3077,45 @@ int ssh_channel_poll(ssh_channel channel, int is_stderr){ * * @see ssh_channel_is_eof() */ -int ssh_channel_poll_timeout(ssh_channel channel, int timeout, int is_stderr){ - ssh_session session; - ssh_buffer stdbuf; - struct ssh_channel_read_termination_struct ctx; - int rc; +int ssh_channel_poll_timeout(ssh_channel channel, int timeout, int is_stderr) +{ + ssh_session session; + ssh_buffer stdbuf; + struct ssh_channel_read_termination_struct ctx; + int rc; - if(channel == NULL) { - return SSH_ERROR; - } + if(channel == NULL) { + return SSH_ERROR; + } - session = channel->session; - stdbuf = channel->stdout_buffer; + session = channel->session; + stdbuf = channel->stdout_buffer; - if (is_stderr) { - stdbuf = channel->stderr_buffer; - } - ctx.buffer = stdbuf; - ctx.channel = channel; - ctx.count = 1; - rc = ssh_handle_packets_termination(channel->session, timeout, - ssh_channel_read_termination, &ctx); - if(rc ==SSH_ERROR || session->session_state == SSH_SESSION_STATE_ERROR){ - rc = SSH_ERROR; - goto end; - } - rc = ssh_buffer_get_len(stdbuf); - if(rc > 0) - goto end; - if (channel->remote_eof) - rc = SSH_EOF; -end: - return rc; + if (is_stderr) { + stdbuf = channel->stderr_buffer; + } + ctx.buffer = stdbuf; + ctx.channel = channel; + ctx.count = 1; + rc = ssh_handle_packets_termination(channel->session, + timeout, + ssh_channel_read_termination, + &ctx); + if (rc == SSH_ERROR || + session->session_state == SSH_SESSION_STATE_ERROR) { + rc = SSH_ERROR; + goto out; + } + rc = ssh_buffer_get_len(stdbuf); + if(rc > 0) { + goto out; + } + if (channel->remote_eof) { + rc = SSH_EOF; + } + +out: + return rc; } /**