Silence an aligned access warning.
clang is a bit too strict about validating address alignments when using packed structs. The only member is a 32-bit value, so the alignment was correct, but this approach is "correct" and guaranteed to work even if the structure was not aligned, at the cost of an extra temporary variable and 32-bit copy.
This commit is contained in:
@@ -552,11 +552,13 @@ namespace ZeroTier {
|
||||
int err = 0;
|
||||
if(conn->socket_family == AF_INET) {
|
||||
struct pico_ip4 zaddr;
|
||||
uint32_t tempaddr;
|
||||
memset(&zaddr, 0, sizeof (struct pico_ip4));
|
||||
struct sockaddr_in *in4 = (struct sockaddr_in*)addr;
|
||||
char ipv4_str[INET_ADDRSTRLEN];
|
||||
inet_ntop(AF_INET, (const void *)&in4->sin_addr.s_addr, ipv4_str, INET_ADDRSTRLEN);
|
||||
pico_string_to_ipv4(ipv4_str, &(zaddr.addr));
|
||||
pico_string_to_ipv4(ipv4_str, &tempaddr);
|
||||
zaddr.addr = tempaddr;
|
||||
//DEBUG_EXTRA("addr=%s:%d", ipv4_str, Utils::ntoh(in4->sin_port));
|
||||
err = pico_socket_bind(conn->picosock, &zaddr, (uint16_t *)&(in4->sin_port));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user