aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelen <jjelen@redhat.com>2019-02-07 16:57:22 +0100
committerAndreas Schneider <asn@cryptomilk.org>2019-05-14 17:26:24 +0200
commit1e22a089eba5bfec1ff20d198571647e356bee69 (patch)
treee988d89561f2f6d9eb48a836fbf7398e1bb9ec33
parent8152c6aba49a4ffb9658f3c2e0ef74e670fd49ec (diff)
downloadlibssh-1e22a089eba5bfec1ff20d198571647e356bee69.tar.gz
libssh-1e22a089eba5bfec1ff20d198571647e356bee69.tar.xz
libssh-1e22a089eba5bfec1ff20d198571647e356bee69.zip
Reformat ssh_hostport()
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
-rw-r--r--src/misc.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/misc.c b/src/misc.c
index dccb12a3..a0006696 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -318,17 +318,23 @@ char *ssh_lowercase(const char* str) {
return new;
}
-char *ssh_hostport(const char *host, int port){
- char *dest;
+char *ssh_hostport(const char *host, int port)
+{
+ char *dest = NULL;
size_t len;
- if(host==NULL)
+
+ if (host == NULL) {
return NULL;
+ }
+
/* 3 for []:, 5 for 65536 and 1 for nul */
- len=strlen(host) + 3 + 5 + 1;
- dest=malloc(len);
- if(dest==NULL)
+ len = strlen(host) + 3 + 5 + 1;
+ dest = malloc(len);
+ if (dest == NULL) {
return NULL;
- snprintf(dest,len,"[%s]:%d",host,port);
+ }
+ snprintf(dest, len, "[%s]:%d", host, port);
+
return dest;
}