From: Miroslav Lichvar Date: Thu, 14 Aug 2025 13:26:17 +0000 (+0200) Subject: util: avoid compiler warning in UTI_IPSockAddrToString() X-Git-Tag: 4.8-pre1~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d3f3638b3ddfcaf6567c673ac9698e321b7599cd;p=thirdparty%2Fchrony.git util: avoid compiler warning in UTI_IPSockAddrToString() Don't print directly a buffer of the pool to another buffer of the pool to avoid a -Wrestrict warning produced by a recent gcc version. --- diff --git a/util.c b/util.c index 837330b2..21fbc1bd 100644 --- a/util.c +++ b/util.c @@ -545,12 +545,14 @@ UTI_CompareIPs(const IPAddr *a, const IPAddr *b, const IPAddr *mask) char * UTI_IPSockAddrToString(const IPSockAddr *sa) { - char *result; + char buf[BUFFER_LENGTH], *result; + + /* Copy to a separate buffer to avoid a compiler warning */ + snprintf(buf, sizeof (buf), "%s", UTI_IPToString(&sa->ip_addr)); result = NEXT_BUFFER; snprintf(result, BUFFER_LENGTH, - sa->ip_addr.family != IPADDR_INET6 ? "%s:%hu" : "[%s]:%hu", - UTI_IPToString(&sa->ip_addr), sa->port); + sa->ip_addr.family != IPADDR_INET6 ? "%s:%hu" : "[%s]:%hu", buf, sa->port); return result; }