Style improvements to knownhost error handling.

Made improvements as suggested by Peter Stuge: http://www.libssh2.org/mail/libssh2-devel-archive-2010-02/0161.shtml.
This commit is contained in:
Alexander Lamaison
2010-02-26 18:47:54 +00:00
parent 942a40b482
commit a2157c8391
2 changed files with 21 additions and 56 deletions

View File

@@ -49,8 +49,6 @@
#include <errno.h>
#ifdef LIBSSH2DEBUG
int libssh2_error(LIBSSH2_SESSION* session, int errcode, char* errmsg,
int should_free)
{
@@ -61,30 +59,14 @@ int libssh2_error(LIBSSH2_SESSION* session, int errcode, char* errmsg,
session->err_msglen = strlen(errmsg);
session->err_should_free = should_free;
session->err_code = errcode;
#ifdef LIBSSH2DEBUG
_libssh2_debug(session, LIBSSH2_TRACE_ERROR, "%d - %s", session->err_code,
session->err_msg);
#endif
return errcode;
}
#else /* ! LIBSSH2DEBUG */
int libssh2_error(LIBSSH2_SESSION* session, int errcode, char* errmsg,
int should_free)
{
if (session->err_msg && session->err_should_free) {
LIBSSH2_FREE(session, session->err_msg);
}
session->err_msg = errmsg;
session->err_msglen = strlen(errmsg);
session->err_should_free = should_free;
session->err_code = errcode;
return errcode;
}
#endif /* ! LIBSSH2DEBUG */
#ifdef WIN32
static int wsa2errno(void)
{