summaryrefslogtreecommitdiff
path: root/toxcore/LAN_discovery.c
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2020-05-05 22:28:59 +0100
committeriphydf <iphydf@users.noreply.github.com>2020-05-05 22:56:35 +0100
commit48bd200acbf4b4d8f3fa241373477b3a21001d17 (patch)
tree732cd71532990452c9d7c07920265ed272f3e6c9 /toxcore/LAN_discovery.c
parentc1a2ea3309969608a5553c34fa4199b05f20abc2 (diff)
refactor: Disallow multiple initialised declarators per decl.
We no longer allow: ```c int a = 0, b = 0; int a[3], b[3]; int a, *b; ``` But we do still allow (for now): ```c int a, b; ```
Diffstat (limited to 'toxcore/LAN_discovery.c')
-rw-r--r--toxcore/LAN_discovery.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/toxcore/LAN_discovery.c b/toxcore/LAN_discovery.c
index c3d06014..e23550df 100644
--- a/toxcore/LAN_discovery.c
+++ b/toxcore/LAN_discovery.c
@@ -70,14 +70,16 @@ static void fetch_broadcast_info(uint16_t port)
70 IP_ADAPTER_INFO *pAdapter = pAdapterInfo; 70 IP_ADAPTER_INFO *pAdapter = pAdapterInfo;
71 71
72 while (pAdapter) { 72 while (pAdapter) {
73 IP gateway = {0}, subnet_mask = {0}; 73 IP gateway = {0};
74 IP subnet_mask = {0};
74 75
75 if (addr_parse_ip(pAdapter->IpAddressList.IpMask.String, &subnet_mask) 76 if (addr_parse_ip(pAdapter->IpAddressList.IpMask.String, &subnet_mask)
76 && addr_parse_ip(pAdapter->GatewayList.IpAddress.String, &gateway)) { 77 && addr_parse_ip(pAdapter->GatewayList.IpAddress.String, &gateway)) {
77 if (net_family_is_ipv4(gateway.family) && net_family_is_ipv4(subnet_mask.family)) { 78 if (net_family_is_ipv4(gateway.family) && net_family_is_ipv4(subnet_mask.family)) {
78 IP_Port *ip_port = &ip_ports[count]; 79 IP_Port *ip_port = &ip_ports[count];
79 ip_port->ip.family = net_family_ipv4; 80 ip_port->ip.family = net_family_ipv4;
80 uint32_t gateway_ip = net_ntohl(gateway.ip.v4.uint32), subnet_ip = net_ntohl(subnet_mask.ip.v4.uint32); 81 uint32_t gateway_ip = net_ntohl(gateway.ip.v4.uint32);
82 uint32_t subnet_ip = net_ntohl(subnet_mask.ip.v4.uint32);
81 uint32_t broadcast_ip = gateway_ip + ~subnet_ip - 1; 83 uint32_t broadcast_ip = gateway_ip + ~subnet_ip - 1;
82 ip_port->ip.ip.v4.uint32 = net_htonl(broadcast_ip); 84 ip_port->ip.ip.v4.uint32 = net_htonl(broadcast_ip);
83 ip_port->port = port; 85 ip_port->port = port;