1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-11-30 13:01:23 +03:00

channel: Reformat ssh_channel_new()

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
This commit is contained in:
Andreas Schneider
2018-09-03 17:54:50 +02:00
parent b6b5a61c97
commit 9ac6ac6c26

View File

@@ -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;
}
/**