From efdacfc791d087131a91ced20a7aa910cc9a3026 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sat, 29 Apr 2023 12:53:32 +0000 Subject: [PATCH] tidy-up: add missing newline to error msg, formatting Also: - fix indent - lowercase variables names - fix formatting in `src/global.c` Cherry-picked from #1017 --- src/global.c | 2 +- tests/openssh_fixture.c | 6 +++--- tests/test_agent_forward_ok.c | 18 +++++++++--------- tests/test_read.c | 18 +++++++++--------- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/global.c b/src/global.c index 68289845..c5894364 100644 --- a/src/global.c +++ b/src/global.c @@ -74,5 +74,5 @@ void _libssh2_init_if_needed(void) { if(_libssh2_initialized == 0) - (void)libssh2_init (0); + (void)libssh2_init(0); } diff --git a/tests/openssh_fixture.c b/tests/openssh_fixture.c index 5eab3433..3989db77 100644 --- a/tests/openssh_fixture.c +++ b/tests/openssh_fixture.c @@ -177,8 +177,8 @@ static int build_openssh_server_docker_image(void) } buildcmd[sizeof(buildcmd)-1] = 0; snprintf(buildcmd, sizeof(buildcmd)-1, - "docker build --quiet -t libssh2/openssh_server %s", - srcdir_path("openssh_server")); + "docker build --quiet -t libssh2/openssh_server %s", + srcdir_path("openssh_server")); return run_command(NULL, buildcmd); } @@ -455,7 +455,7 @@ void stop_openssh_fixture(void) running_container_id = NULL; } else if(have_docker) { - fprintf(stderr, "Cannot stop container - none started"); + fprintf(stderr, "Cannot stop container - none started\n"); } } diff --git a/tests/test_agent_forward_ok.c b/tests/test_agent_forward_ok.c index 7c9cfe3c..664b724f 100644 --- a/tests/test_agent_forward_ok.c +++ b/tests/test_agent_forward_ok.c @@ -1,8 +1,8 @@ #include "runner.h" -static const char *USERNAME = "libssh2"; /* set in Dockerfile */ -static const char *KEY_FILE_PRIVATE = "key_rsa"; -static const char *KEY_FILE_PUBLIC = "key_rsa.pub"; /* set in Dockerfile */ +static const char *username = "libssh2"; /* set in Dockerfile */ +static const char *key_file_private = "key_rsa"; +static const char *key_file_public = "key_rsa.pub"; /* set in Dockerfile */ int test(LIBSSH2_SESSION *session) { @@ -10,8 +10,8 @@ int test(LIBSSH2_SESSION *session) LIBSSH2_CHANNEL *channel; const char *userauth_list = - libssh2_userauth_list(session, USERNAME, - (unsigned int)strlen(USERNAME)); + libssh2_userauth_list(session, username, + (unsigned int)strlen(username)); if(!userauth_list) { print_last_session_error("libssh2_userauth_list"); return 1; @@ -23,10 +23,10 @@ int test(LIBSSH2_SESSION *session) return 1; } - rc = libssh2_userauth_publickey_fromfile_ex(session, USERNAME, - (unsigned int)strlen(USERNAME), - srcdir_path(KEY_FILE_PUBLIC), - srcdir_path(KEY_FILE_PRIVATE), + rc = libssh2_userauth_publickey_fromfile_ex(session, username, + (unsigned int)strlen(username), + srcdir_path(key_file_public), + srcdir_path(key_file_private), NULL); if(rc) { print_last_session_error("libssh2_userauth_publickey_fromfile_ex"); diff --git a/tests/test_read.c b/tests/test_read.c index 24160b85..58fb43ac 100644 --- a/tests/test_read.c +++ b/tests/test_read.c @@ -5,9 +5,9 @@ #include /* for getenv() */ /* set in Dockerfile */ -static const char *USERNAME = "libssh2"; -static const char *KEY_FILE_PRIVATE = "key_rsa"; -static const char *KEY_FILE_PUBLIC = "key_rsa.pub"; +static const char *username = "libssh2"; +static const char *key_file_private = "key_rsa"; +static const char *key_file_public = "key_rsa.pub"; int test(LIBSSH2_SESSION *session) { @@ -29,8 +29,8 @@ int test(LIBSSH2_SESSION *session) const char *env; const char *userauth_list = - libssh2_userauth_list(session, USERNAME, - (unsigned int)strlen(USERNAME)); + libssh2_userauth_list(session, username, + (unsigned int)strlen(username)); if(!userauth_list) { print_last_session_error("libssh2_userauth_list"); return 1; @@ -42,10 +42,10 @@ int test(LIBSSH2_SESSION *session) return 1; } - rc = libssh2_userauth_publickey_fromfile_ex(session, USERNAME, - (unsigned int)strlen(USERNAME), - srcdir_path(KEY_FILE_PUBLIC), - srcdir_path(KEY_FILE_PRIVATE), + rc = libssh2_userauth_publickey_fromfile_ex(session, username, + (unsigned int)strlen(username), + srcdir_path(key_file_public), + srcdir_path(key_file_private), NULL); if(rc) { print_last_session_error("libssh2_userauth_publickey_fromfile_ex");