From aed729d0a140e336638204edeef2ab5d3d9e601e Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Wed, 6 Jun 2018 20:00:05 +0100 Subject: [PATCH] noip.c (encode_inet_addr): Exit early rather than branch round. Promote the wildcard probe to the main line, and leave early -- to the handy `found' label we just hoisted -- if the exact match was acceptable. This structure is more convenient for adding a more complicated search strategy later. No functional change. --- noip.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/noip.c b/noip.c index 31616de..e3da246 100644 --- a/noip.c +++ b/noip.c @@ -720,13 +720,12 @@ static int encode_inet_addr(struct sockaddr_un *sun, present_sockaddr(sa, 0, buf, sizeof(buf))); rc = unix_socket_status(sun, 0); if (rc == STALE) unlink(sun->sun_path); - if (rc != USED && !(f&ENCF_FRESH)) { - wildcard_address(sa->sa_family, &addr.sa); - port_to_sockaddr(&addr.sa, port); - snprintf(sun->sun_path, sizeof(sun->sun_path), "%s/%s", sockdir, - present_sockaddr(&addr.sa, 0, buf, sizeof(buf))); - if (unix_socket_status(sun, 0) == STALE) unlink(sun->sun_path); - } + if (rc == USED || (f&ENCF_FRESH)) goto found; + wildcard_address(sa->sa_family, &addr.sa); + port_to_sockaddr(&addr.sa, port); + snprintf(sun->sun_path, sizeof(sun->sun_path), "%s/%s", sockdir, + present_sockaddr(&addr.sa, 0, buf, sizeof(buf))); + if (unix_socket_status(sun, 0) == STALE) unlink(sun->sun_path); } else { copy_sockaddr(&addr.sa, sa); for (i = 0; i < 10; i++) { -- 2.11.0