From 06096af313a4e6ae43a87a8011392255bfb017cf Mon Sep 17 00:00:00 2001 From: Petr Kracik Date: Mon, 11 Mar 2024 23:47:24 +0100 Subject: [PATCH] Code style Signed-off-by: Petr Kracik --- mbus/mbus-tcp.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/mbus/mbus-tcp.c b/mbus/mbus-tcp.c index 7be8cb7..e90e4fe 100755 --- a/mbus/mbus-tcp.c +++ b/mbus/mbus-tcp.c @@ -63,19 +63,23 @@ mbus_tcp_connect(mbus_handle *handle) hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; - if ((status = getaddrinfo(host, port, &hints, &servinfo)) != 0) { + if ((status = getaddrinfo(host, port, &hints, &servinfo)) != 0) + { snprintf(error_str, sizeof(error_str), "%s: getaddrinfo: %s", __PRETTY_FUNCTION__, gai_strerror(status)); mbus_error_str_set(error_str); return -1; } // loop through all the results and connect to the first we can - for(p = servinfo; p != NULL; p = p->ai_next) { - if ((handle->fd = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) == -1) { + for (p = servinfo; p != NULL; p = p->ai_next) + { + if ((handle->fd = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) == -1) + { continue; } - if (connect(handle->fd, p->ai_addr, p->ai_addrlen) == -1) { + if (connect(handle->fd, p->ai_addr, p->ai_addrlen) == -1) + { close(handle->fd); continue; } @@ -83,7 +87,8 @@ mbus_tcp_connect(mbus_handle *handle) break; // if we get here, we must have connected successfully } - if (p == NULL) { + if (p == NULL) + { snprintf(error_str, sizeof(error_str), "%s: failed to connect", __PRETTY_FUNCTION__); mbus_error_str_set(error_str); return -1;