mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-03 23:45: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 *
|
char *
|
||||||
UTI_IPSockAddrToString(const IPSockAddr *sa)
|
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;
|
result = NEXT_BUFFER;
|
||||||
snprintf(result, BUFFER_LENGTH,
|
snprintf(result, BUFFER_LENGTH,
|
||||||
sa->ip_addr.family != IPADDR_INET6 ? "%s:%hu" : "[%s]:%hu",
|
sa->ip_addr.family != IPADDR_INET6 ? "%s:%hu" : "[%s]:%hu", buf, sa->port);
|
||||||
UTI_IPToString(&sa->ip_addr), sa->port);
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user