From: tb Date: Fri, 16 Jun 2023 10:28:43 +0000 (+0000) Subject: Now that print_host() is unused, rename it to print_addr() and simplify. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=a8c4b3e4719952080365c2c57fbbeedf7a39e3d8;p=openbsd Now that print_host() is unused, rename it to print_addr() and simplify. ok claudio tobhe --- diff --git a/sbin/iked/iked.h b/sbin/iked/iked.h index f429d554244..84999630d9f 100644 --- a/sbin/iked/iked.h +++ b/sbin/iked/iked.h @@ -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 @@ -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); diff --git a/sbin/iked/util.c b/sbin/iked/util.c index 9f827b1c899..586233abea5 100644 --- a/sbin/iked/util.c +++ b/sbin/iked/util.c @@ -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 @@ -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) {