Now that print_host() is unused, rename it to print_addr() and simplify.
authortb <tb@openbsd.org>
Fri, 16 Jun 2023 10:28:43 +0000 (10:28 +0000)
committertb <tb@openbsd.org>
Fri, 16 Jun 2023 10:28:43 +0000 (10:28 +0000)
ok claudio tobhe

sbin/iked/iked.h
sbin/iked/util.c

index f429d55..8499963 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: iked.h,v 1.216 2023/06/13 12:34:12 tb Exp $   */
+/*     $OpenBSD: iked.h,v 1.217 2023/06/16 10:28:43 tb Exp $   */
 
 /*
  * Copyright (c) 2019 Tobias Heider <tobias.heider@stusta.de>
@@ -1250,8 +1250,6 @@ struct in6_addr *
         prefixlen2mask6(uint8_t, uint32_t *);
 uint32_t
         prefixlen2mask(uint8_t);
-const char *
-        print_host(struct sockaddr *, char *, size_t);
 const char *
         print_addr(void *);
 char   *get_string(uint8_t *, size_t);
index 9f827b1..586233a 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: util.c,v 1.41 2023/06/13 12:34:12 tb Exp $    */
+/*     $OpenBSD: util.c,v 1.42 2023/06/16 10:28:43 tb Exp $    */
 
 /*
  * Copyright (c) 2010-2013 Reyk Floeter <reyk@openbsd.org>
@@ -636,19 +636,20 @@ prefixlen2mask6(uint8_t prefixlen, uint32_t *mask)
 }
 
 const char *
-print_host(struct sockaddr *sa, char *buf, size_t len)
+print_addr(void *addr)
 {
-       static char     sbuf[IKED_CYCLE_BUFFERS][NI_MAXHOST + 7];
-       static int      idx = 0;
-       char            pbuf[7];
-       in_port_t       port;
-
-       if (buf == NULL) {
-               buf = sbuf[idx];
-               len = sizeof(sbuf[idx]);
-               if (++idx >= IKED_CYCLE_BUFFERS)
-                       idx = 0;
-       }
+       static char      sbuf[IKED_CYCLE_BUFFERS][NI_MAXHOST + 7];
+       static int       idx;
+       struct sockaddr *sa = addr;
+       char            *buf;
+       size_t           len;
+       char             pbuf[7];
+       in_port_t        port;
+
+       buf = sbuf[idx];
+       len = sizeof(sbuf[idx]);
+       if (++idx >= IKED_CYCLE_BUFFERS)
+               idx = 0;
 
        if (sa->sa_family == AF_UNSPEC) {
                strlcpy(buf, "any", len);
@@ -669,12 +670,6 @@ print_host(struct sockaddr *sa, char *buf, size_t len)
        return (buf);
 }
 
-const char *
-print_addr(void *addr)
-{
-       return print_host(addr, NULL, 0);
-}
-
 char *
 get_string(uint8_t *ptr, size_t len)
 {