diff --git a/src/agent.c b/src/agent.c index 4c9e556..04f0523 100644 --- a/src/agent.c +++ b/src/agent.c @@ -124,6 +124,10 @@ struct agent_ops { agent_disconnect_func disconnect; }; +#ifndef INVALID_SOCKET +#define INVALID_SOCKET -1 +#endif + struct _LIBSSH2_AGENT { LIBSSH2_SESSION *session; /* the session this "belongs to" */ @@ -316,7 +320,7 @@ agent_transact_pageant(LIBSSH2_AGENT *agent, agent_transaction_ctx_t transctx) static int agent_disconnect_pageant(LIBSSH2_AGENT *agent) { - agent->fd = SOCKET_BAD; + agent->fd = INVALID_SOCKET; return 0; } @@ -737,7 +741,7 @@ libssh2_agent_userauth(LIBSSH2_AGENT *agent, LIBSSH2_API int libssh2_agent_disconnect(LIBSSH2_AGENT *agent) { - if (agent->ops && agent->fd != SOCKET_BAD) + if (agent->ops && agent->fd != INVALID_SOCKET) return agent->ops->disconnect(agent); return 0; } @@ -751,7 +755,7 @@ libssh2_agent_disconnect(LIBSSH2_AGENT *agent) LIBSSH2_API void libssh2_agent_free(LIBSSH2_AGENT *agent) { /* Allow connection freeing when the socket has lost its connection */ - if (agent->fd != SOCKET_BAD) { + if (agent->fd != INVALID_SOCKET) { libssh2_agent_disconnect(agent); } agent_free_identities(agent); diff --git a/src/libssh2_priv.h b/src/libssh2_priv.h index 8dfb899..1ba9354 100644 --- a/src/libssh2_priv.h +++ b/src/libssh2_priv.h @@ -151,10 +151,8 @@ static inline int writev(int sock, struct iovec *iov, int nvecs) #ifdef WIN32 typedef SOCKET libssh2_socket_t; -#define SOCKET_BAD ~0 #else /* !WIN32 */ typedef int libssh2_socket_t; -#define SOCKET_BAD -1 #endif /* WIN32 */ /* RFC4253 section 6.1 Maximum Packet Length says: