mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-03 17:55:07 -05:00
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:
8
util.c
8
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user