Use LIBSSH2_INVALID_SOCKET macro.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2016-01-07 10:34:58 +03:00
parent b3f5a0ae5e
commit 8b5f62d244
3 changed files with 14 additions and 9 deletions

View File

@ -71,12 +71,12 @@ sftpfs_open_socket (struct vfs_s_super *super, GError ** mcerror)
char port[BUF_TINY];
int e;
mc_return_val_if_error (mcerror, -1);
mc_return_val_if_error (mcerror, LIBSSH2_INVALID_SOCKET);
if (super->path_element->host == NULL || *super->path_element->host == '\0')
{
mc_propagate_error (mcerror, 0, "%s", _("sftp: Invalid host name."));
return -1;
return LIBSSH2_INVALID_SOCKET;
}
sprintf (port, "%hu", (unsigned short) super->path_element->port);
@ -108,7 +108,7 @@ sftpfs_open_socket (struct vfs_s_super *super, GError ** mcerror)
if (e != 0)
{
mc_propagate_error (mcerror, e, _("sftp: %s"), gai_strerror (e));
my_socket = -1;
my_socket = LIBSSH2_INVALID_SOCKET;
goto ret;
}
@ -124,7 +124,7 @@ sftpfs_open_socket (struct vfs_s_super *super, GError ** mcerror)
continue;
vfs_print_message (_("sftp: %s"), unix_error_string (errno));
my_socket = -1;
my_socket = LIBSSH2_INVALID_SOCKET;
goto ret;
}
@ -145,7 +145,7 @@ sftpfs_open_socket (struct vfs_s_super *super, GError ** mcerror)
else
continue;
my_socket = -1;
my_socket = LIBSSH2_INVALID_SOCKET;
break;
}
@ -376,7 +376,7 @@ sftpfs_open_connection (struct vfs_s_super *super, GError ** mcerror)
* and establishing the connection
*/
super_data->socket_handle = sftpfs_open_socket (super, mcerror);
if (super_data->socket_handle == -1)
if (super_data->socket_handle == LIBSSH2_INVALID_SOCKET)
return (-1);
/* Create a session instance */
@ -467,10 +467,10 @@ sftpfs_close_connection (struct vfs_s_super *super, const char *shutdown_message
super_data->session = NULL;
}
if (super_data->socket_handle != -1)
if (super_data->socket_handle != LIBSSH2_INVALID_SOCKET)
{
close (super_data->socket_handle);
super_data->socket_handle = -1;
super_data->socket_handle = LIBSSH2_INVALID_SOCKET;
}
}

View File

@ -16,6 +16,11 @@
#define SFTP_DEFAULT_PORT 22
/* LIBSSH2_INVALID_SOCKET is defined in libssh2 >= 1.4.1 */
#ifndef LIBSSH2_INVALID_SOCKET
#define LIBSSH2_INVALID_SOCKET -1
#endif
/*** enums ***************************************************************************************/
typedef enum

View File

@ -104,7 +104,7 @@ sftpfs_cb_open_connection (struct vfs_s_super *super,
}
sftpfs_super_data = g_new0 (sftpfs_super_data_t, 1);
sftpfs_super_data->socket_handle = -1;
sftpfs_super_data->socket_handle = LIBSSH2_INVALID_SOCKET;
sftpfs_super_data->original_connection_info = vfs_path_element_clone (vpath_element);
super->data = sftpfs_super_data;
super->path_element = vfs_path_element_clone (vpath_element);