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.
This commit is contained in:
Miroslav Lichvar
2025-08-14 15:26:17 +02:00
parent 6c5973741b
commit d3f3638b3d

8
util.c
View File

@@ -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;
}