From e8c44e789f47c7d24cec61298059836c626576e7 Mon Sep 17 00:00:00 2001 From: Peter Stuge Date: Sat, 13 Nov 2010 01:50:24 +0100 Subject: [PATCH] src/agent.c: Simplify _libssh2_send() error checking ever so slightly --- src/agent.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/agent.c b/src/agent.c index 7f315d6..5fa9466 100644 --- a/src/agent.c +++ b/src/agent.c @@ -178,12 +178,11 @@ agent_transact_unix(LIBSSH2_AGENT *agent, agent_transaction_ctx_t transctx) if (transctx->state == agent_NB_state_request_created) { _libssh2_htonu32(buf, transctx->request_len); rc = _libssh2_send(agent->fd, buf, sizeof buf, 0); - if (rc < 0) { - if (rc == -EAGAIN) - return LIBSSH2_ERROR_EAGAIN; + if (rc == -EAGAIN) + return LIBSSH2_ERROR_EAGAIN; + else if (rc < 0) return _libssh2_error(agent->session, LIBSSH2_ERROR_SOCKET_SEND, "agent send failed"); - } transctx->state = agent_NB_state_request_length_sent; } @@ -191,12 +190,11 @@ agent_transact_unix(LIBSSH2_AGENT *agent, agent_transaction_ctx_t transctx) if (transctx->state == agent_NB_state_request_length_sent) { rc = _libssh2_send(agent->fd, transctx->request, transctx->request_len, 0); - if (rc < 0) { - if (rc == -EAGAIN) - return LIBSSH2_ERROR_EAGAIN; + if (rc == -EAGAIN) + return LIBSSH2_ERROR_EAGAIN; + else if (rc < 0) return _libssh2_error(agent->session, LIBSSH2_ERROR_SOCKET_SEND, "agent send failed"); - } transctx->state = agent_NB_state_request_sent; }