chiark / gitweb /
noip.c (encode_inet_addr): Exit early rather than branch round.
authorMark Wooding <mdw@distorted.org.uk>
Wed, 6 Jun 2018 19:00:05 +0000 (20:00 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Wed, 6 Jun 2018 19:13:05 +0000 (20:13 +0100)
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

diff --git a/noip.c b/noip.c
index 31616de337ac01911be0fce63a3309043e90fffa..e3da246fd9065a9a689fb48d245b3922725de034 100644 (file)
--- 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++) {