mirror of
https://github.com/libssh2/libssh2.git
synced 2025-08-01 11:26:53 +03:00
tidy-up: example, tests continued
- fix skip auth if `userauthlist` is NULL. Closes #836 (Reported-by: @sudipm-mukherjee on github) - fix most silenced `checksrc` warnings. - sync examples/tests code between each other. (output messages, error handling, declaration order, comments) - stop including unnecessary headers. - always deinitialize in case of error. - drop some redundant variables. - add error handling where missing. - show more error codes. - switch `perror()` to `fprintf()`. - fix some `printf()`s to be `fprintf()`. - formatting. Closes #960
This commit is contained in:
@ -62,7 +62,7 @@ int test(LIBSSH2_SESSION *session)
|
||||
(void)EXPECTED_ECDSA_HOSTKEY;
|
||||
|
||||
hostkey = libssh2_session_hostkey(session, &len, &type);
|
||||
if(hostkey == NULL) {
|
||||
if(!hostkey) {
|
||||
print_last_session_error("libssh2_session_hostkey");
|
||||
return 1;
|
||||
}
|
||||
@ -70,7 +70,7 @@ int test(LIBSSH2_SESSION *session)
|
||||
if(type == LIBSSH2_HOSTKEY_TYPE_ECDSA_256) {
|
||||
|
||||
md5_hash = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_MD5);
|
||||
if(md5_hash == NULL) {
|
||||
if(!md5_hash) {
|
||||
print_last_session_error(
|
||||
"libssh2_hostkey_hash(LIBSSH2_HOSTKEY_HASH_MD5)");
|
||||
return 1;
|
||||
@ -86,7 +86,7 @@ int test(LIBSSH2_SESSION *session)
|
||||
}
|
||||
|
||||
sha1_hash = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_SHA1);
|
||||
if(sha1_hash == NULL) {
|
||||
if(!sha1_hash) {
|
||||
print_last_session_error(
|
||||
"libssh2_hostkey_hash(LIBSSH2_HOSTKEY_HASH_SHA1)");
|
||||
return 1;
|
||||
@ -103,7 +103,7 @@ int test(LIBSSH2_SESSION *session)
|
||||
|
||||
sha256_hash = libssh2_hostkey_hash(session,
|
||||
LIBSSH2_HOSTKEY_HASH_SHA256);
|
||||
if(sha256_hash == NULL) {
|
||||
if(!sha256_hash) {
|
||||
print_last_session_error(
|
||||
"libssh2_hostkey_hash(LIBSSH2_HOSTKEY_HASH_SHA256)");
|
||||
return 1;
|
||||
@ -122,7 +122,7 @@ int test(LIBSSH2_SESSION *session)
|
||||
else if(type == LIBSSH2_HOSTKEY_TYPE_RSA) {
|
||||
|
||||
md5_hash = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_MD5);
|
||||
if(md5_hash == NULL) {
|
||||
if(!md5_hash) {
|
||||
print_last_session_error(
|
||||
"libssh2_hostkey_hash(LIBSSH2_HOSTKEY_HASH_MD5)");
|
||||
return 1;
|
||||
@ -138,7 +138,7 @@ int test(LIBSSH2_SESSION *session)
|
||||
}
|
||||
|
||||
sha1_hash = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_SHA1);
|
||||
if(sha1_hash == NULL) {
|
||||
if(!sha1_hash) {
|
||||
print_last_session_error(
|
||||
"libssh2_hostkey_hash(LIBSSH2_HOSTKEY_HASH_SHA1)");
|
||||
return 1;
|
||||
@ -155,7 +155,7 @@ int test(LIBSSH2_SESSION *session)
|
||||
|
||||
sha256_hash = libssh2_hostkey_hash(session,
|
||||
LIBSSH2_HOSTKEY_HASH_SHA256);
|
||||
if(sha256_hash == NULL) {
|
||||
if(!sha256_hash) {
|
||||
print_last_session_error(
|
||||
"libssh2_hostkey_hash(LIBSSH2_HOSTKEY_HASH_SHA256)");
|
||||
return 1;
|
||||
|
Reference in New Issue
Block a user