aboutsummaryrefslogtreecommitdiff
path: root/src/channels.c
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2019-10-31 13:28:42 +0100
committerAndreas Schneider <asn@cryptomilk.org>2019-12-09 16:08:03 +0100
commit8d671efdbd9ae92e54bf031652b5b499d33d39ee (patch)
tree191c0d39e475b13fc3dafefa19460ea6387f9563 /src/channels.c
parent3bad0607384b1fd92f96ba3db5b65d094b6db8c2 (diff)
downloadlibssh-8d671efdbd9ae92e54bf031652b5b499d33d39ee.tar.gz
libssh-8d671efdbd9ae92e54bf031652b5b499d33d39ee.tar.xz
libssh-8d671efdbd9ae92e54bf031652b5b499d33d39ee.zip
channels: Reformat ssh_channel_read_nonblocking()
Fixes T188 Signed-off-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Diffstat (limited to 'src/channels.c')
-rw-r--r--src/channels.c61
1 files changed, 32 insertions, 29 deletions
diff --git a/src/channels.c b/src/channels.c
index 8d4950b7..ec5850f2 100644
--- a/src/channels.c
+++ b/src/channels.c
@@ -2973,42 +2973,45 @@ int ssh_channel_read_timeout(ssh_channel channel,
*
* @see ssh_channel_is_eof()
*/
-int ssh_channel_read_nonblocking(ssh_channel channel, void *dest, uint32_t count,
- int is_stderr) {
- ssh_session session;
- int to_read;
- int rc;
- int blocking;
+int ssh_channel_read_nonblocking(ssh_channel channel,
+ void *dest,
+ uint32_t count,
+ int is_stderr)
+{
+ ssh_session session;
+ int to_read;
+ int rc;
+ int blocking;
- if(channel == NULL) {
- return SSH_ERROR;
- }
- if(dest == NULL) {
- ssh_set_error_invalid(channel->session);
- return SSH_ERROR;
- }
+ if(channel == NULL) {
+ return SSH_ERROR;
+ }
+ if(dest == NULL) {
+ ssh_set_error_invalid(channel->session);
+ return SSH_ERROR;
+ }
- session = channel->session;
+ session = channel->session;
- to_read = ssh_channel_poll(channel, is_stderr);
+ to_read = ssh_channel_poll(channel, is_stderr);
- if (to_read <= 0) {
- if (session->session_state == SSH_SESSION_STATE_ERROR){
- return SSH_ERROR;
- }
+ if (to_read <= 0) {
+ if (session->session_state == SSH_SESSION_STATE_ERROR){
+ return SSH_ERROR;
+ }
- return to_read; /* may be an error code */
- }
+ return to_read; /* may be an error code */
+ }
- if (to_read > (int)count) {
- to_read = (int)count;
- }
- blocking = ssh_is_blocking(session);
- ssh_set_blocking(session, 0);
- rc = ssh_channel_read(channel, dest, to_read, is_stderr);
- ssh_set_blocking(session,blocking);
+ if (to_read > (int)count) {
+ to_read = (int)count;
+ }
+ blocking = ssh_is_blocking(session);
+ ssh_set_blocking(session, 0);
+ rc = ssh_channel_read(channel, dest, to_read, is_stderr);
+ ssh_set_blocking(session,blocking);
- return rc;
+ return rc;
}
/**