From a9fbc4e327db5b98943cbc134789774d1d20b908 Mon Sep 17 00:00:00 2001 From: AKuHAK <621640+AKuHAK@users.noreply.github.com> Date: Sat, 21 Aug 2021 18:33:28 +0300 Subject: [PATCH] Revert "interface/ethsupport: avoid strict aliasing warning" This reverts commit e7756f861713e69604c4e833ec46590aec5d2003. --- src/ethsupport.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/ethsupport.c b/src/ethsupport.c index c031a234e..2ac018a38 100644 --- a/src/ethsupport.c +++ b/src/ethsupport.c @@ -787,9 +787,9 @@ static int ethReadNetConfig(void) int result; if ((result = ps2ip_getconfig("sm0", &ip_info)) >= 0) { - memcpy(&lastIP, &ip_info.ipaddr, sizeof(lastIP)); - memcpy(&lastNM, &ip_info.netmask, sizeof(lastNM)); - memcpy(&lastGW, &ip_info.gw, sizeof(lastGW)); + lastIP = *(struct ip4_addr *)&ip_info.ipaddr; + lastNM = *(struct ip4_addr *)&ip_info.netmask; + lastGW = *(struct ip4_addr *)&ip_info.gw; } else { ip4_addr_set_zero(&lastIP); ip4_addr_set_zero(&lastNM); @@ -863,14 +863,10 @@ static int ethApplyIPConfig(void) { t_ip_info ip_info; struct ip4_addr ipaddr, netmask, gw, dns; - struct ip4_addr ip_info_ipaddr, ip_info_netmask, ip_info_gw; const struct ip4_addr *dns_curr; int result; if ((result = ps2ip_getconfig("sm0", &ip_info)) >= 0) { - memcpy(&ip_info_ipaddr, &ip_info.ipaddr, sizeof(ip_info_ipaddr)); - memcpy(&ip_info_netmask, &ip_info.netmask, sizeof(ip_info_netmask)); - memcpy(&ip_info_gw, &ip_info.gw, sizeof(ip_info_gw)); IP4_ADDR(&ipaddr, ps2_ip[0], ps2_ip[1], ps2_ip[2], ps2_ip[3]); IP4_ADDR(&netmask, ps2_netmask[0], ps2_netmask[1], ps2_netmask[2], ps2_netmask[3]); IP4_ADDR(&gw, ps2_gateway[0], ps2_gateway[1], ps2_gateway[2], ps2_gateway[3]); @@ -879,21 +875,21 @@ static int ethApplyIPConfig(void) // Check if it's the same. Otherwise, apply the new configuration. if ((ps2_ip_use_dhcp != ip_info.dhcp_enabled) || (!ps2_ip_use_dhcp && - (!ip_addr_cmp(&ipaddr, &ip_info_ipaddr) || - !ip_addr_cmp(&netmask, &ip_info_netmask) || - !ip_addr_cmp(&gw, &ip_info_gw) || + (!ip_addr_cmp(&ipaddr, (struct ip4_addr *)&ip_info.ipaddr) || + !ip_addr_cmp(&netmask, (struct ip4_addr *)&ip_info.netmask) || + !ip_addr_cmp(&gw, (struct ip4_addr *)&ip_info.gw) || !ip_addr_cmp(&dns, dns_curr)))) { if (ps2_ip_use_dhcp) { - memset(&ip_info.ipaddr, 0, sizeof(ip_info.ipaddr)); - memset(&ip_info.netmask, 0, sizeof(ip_info.netmask)); - memset(&ip_info.gw, 0, sizeof(ip_info.gw)); + ip4_addr_set_zero((struct ip4_addr *)&ip_info.ipaddr); + ip4_addr_set_zero((struct ip4_addr *)&ip_info.netmask); + ip4_addr_set_zero((struct ip4_addr *)&ip_info.gw); ip4_addr_set_zero(&dns); ip_info.dhcp_enabled = 1; } else { - memcpy(&ip_info.ipaddr, &ip_info_ipaddr, sizeof(ip_info_ipaddr)); - memcpy(&ip_info.netmask, &ip_info_netmask, sizeof(ip_info_netmask)); - memcpy(&ip_info.gw, &ip_info_gw, sizeof(ip_info_gw)); + ip_addr_set((struct ip4_addr *)&ip_info.ipaddr, &ipaddr); + ip_addr_set((struct ip4_addr *)&ip_info.netmask, &netmask); + ip_addr_set((struct ip4_addr *)&ip_info.gw, &gw); ip_info.dhcp_enabled = 0; }