From 9ac6ac6c26f2ce9e6149aee7cd0e5fbdb15dab8d Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 3 Sep 2018 17:54:50 +0200 Subject: [PATCH] channel: Reformat ssh_channel_new() Signed-off-by: Andreas Schneider Reviewed-by: Jakub Jelen --- src/channels.c | 67 ++++++++++++++++++++++++++------------------------ 1 file changed, 35 insertions(+), 32 deletions(-) diff --git a/src/channels.c b/src/channels.c index ba06a15f..70a3745b 100644 --- a/src/channels.c +++ b/src/channels.c @@ -76,44 +76,47 @@ static ssh_channel channel_from_msg(ssh_session session, ssh_buffer packet); * * @return A pointer to a newly allocated channel, NULL on error. */ -ssh_channel ssh_channel_new(ssh_session session) { - ssh_channel channel = NULL; +ssh_channel ssh_channel_new(ssh_session session) +{ + ssh_channel channel = NULL; - if(session == NULL) { - return NULL; - } + if (session == NULL) { + return NULL; + } - channel = malloc(sizeof(struct ssh_channel_struct)); - if (channel == NULL) { - ssh_set_error_oom(session); - return NULL; - } - memset(channel,0,sizeof(struct ssh_channel_struct)); + channel = malloc(sizeof(struct ssh_channel_struct)); + if (channel == NULL) { + ssh_set_error_oom(session); + return NULL; + } + memset(channel,0,sizeof(struct ssh_channel_struct)); - channel->stdout_buffer = ssh_buffer_new(); - if (channel->stdout_buffer == NULL) { - ssh_set_error_oom(session); - SAFE_FREE(channel); - return NULL; - } + channel->stdout_buffer = ssh_buffer_new(); + if (channel->stdout_buffer == NULL) { + ssh_set_error_oom(session); + SAFE_FREE(channel); + return NULL; + } - channel->stderr_buffer = ssh_buffer_new(); - if (channel->stderr_buffer == NULL) { - ssh_set_error_oom(session); - ssh_buffer_free(channel->stdout_buffer); - SAFE_FREE(channel); - return NULL; - } + channel->stderr_buffer = ssh_buffer_new(); + if (channel->stderr_buffer == NULL) { + ssh_set_error_oom(session); + ssh_buffer_free(channel->stdout_buffer); + SAFE_FREE(channel); + return NULL; + } - channel->session = session; - channel->exit_status = -1; - channel->flags = SSH_CHANNEL_FLAG_NOT_BOUND; + channel->session = session; + channel->exit_status = -1; + channel->flags = SSH_CHANNEL_FLAG_NOT_BOUND; - if(session->channels == NULL) { - session->channels = ssh_list_new(); - } - ssh_list_prepend(session->channels, channel); - return channel; + if (session->channels == NULL) { + session->channels = ssh_list_new(); + } + + ssh_list_prepend(session->channels, channel); + + return channel; } /**