From 08a8bd936ce6529df08320ed709587c704405355 Mon Sep 17 00:00:00 2001 From: Eshan Kelkar Date: Wed, 14 Jun 2023 00:20:11 +0530 Subject: [PATCH] Fix error reporting in connect_host() This commit fixes connect_host() such that if ssh_new() fails, connect_host() fails and provides the reason for failure. Prior to this commit if ssh_new() failed, connect_host() failed but did not provide the reason for failure to connect to the host. Signed-off-by: Eshan Kelkar Reviewed-by: Sahana Prasad Reviewed-by: Jakub Jelen --- tests/benchmarks/benchmarks.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/benchmarks/benchmarks.c b/tests/benchmarks/benchmarks.c index 5b7c498c..0dedffe3 100644 --- a/tests/benchmarks/benchmarks.c +++ b/tests/benchmarks/benchmarks.c @@ -282,8 +282,11 @@ static ssh_session connect_host(const char *host, int verbose, char *cipher) int rc; session = ssh_new(); - if (session == NULL) - goto error; + if (session == NULL) { + fprintf(stderr, "Error connecting to \"%s\": %s\n", + host, "Unable to create a new ssh session"); + return NULL; + } rc = ssh_options_set(session, SSH_OPTIONS_HOST, host); if (rc < 0)