From: Michael Pucher Date: Sun, 8 Dec 2024 11:02:04 +0000 (+0100) Subject: Fix invalid pointer type for dns X-Git-Tag: RELEASE-0.18.0~1 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=0d1e874287cc1327ba934ff2fe97886f92e2d53a;p=unikraft%2Flibs%2Flwip.git Fix invalid pointer type for dns The invalid pointer warning becomes an error in gcc14, and it turns out it's actually an invalid pointer, because it expects a pointer to a struct with a type tag and not just the IPv4 address, if we have IPv4 and IPv6 enabled (otherwise it typedefs to the IPv4 address and everything is fine). Github-fixes: #59 Signed-off-by: Michael Pucher Approved-by: Razvan Deaconescu Reviewed-by: Razvan Deaconescu GitHub-Closes: #60 --- diff --git a/init.c b/init.c index c16a818..4952d22 100644 --- a/init.c +++ b/init.c @@ -165,7 +165,7 @@ static int liblwip_init(struct uk_init_ctx *ictx __unused) ip4_addr_t *gw4_arg; const char *hostname_arg; #if LWIP_DNS - ip4_addr_t dns4; + ip_addr_t dns; unsigned int nb_dns4 = 0; #endif /* LWIP_DNS */ #endif /* LWIP_IPV4 */ @@ -393,13 +393,18 @@ no_conf: if (nb_dns4 < DNS_MAX_SERVERS) { strcfg = uk_netdev_einfo_get(dev, UK_NETDEV_IPV4_DNS0); if (strcfg) { - if (ip4addr_aton(strcfg, &dns4) != 1) { +#if LWIP_IPV6 + dns.type = IPADDR_TYPE_V4; + if (ip4addr_aton(strcfg, &dns.u_addr.ip4) != 1) { +#else /* LWIP_IPV6 */ + if (ip4addr_aton(strcfg, &dns) != 1) { +#endif /* LWIP_IPV6 */ uk_pr_err("Failed to parse DNS server address: %s\n", strcfg); goto dns_secondary; } - dns_setserver(nb_dns4++, &dns4); + dns_setserver(nb_dns4++, &dns); uk_pr_info("%c%c%u: Primary DNS server: %s\n", nf->name[0], nf->name[1], nf->num, strcfg); @@ -411,13 +416,18 @@ dns_secondary: if (nb_dns4 < DNS_MAX_SERVERS) { strcfg = uk_netdev_einfo_get(dev, UK_NETDEV_IPV4_DNS1); if (strcfg) { - if (ip4addr_aton(strcfg, &dns4) != 1) { +#if LWIP_IPV6 + dns.type = IPADDR_TYPE_V4; + if (ip4addr_aton(strcfg, &dns.u_addr.ip4) != 1) { +#else /* LWIP_IPV6 */ + if (ip4addr_aton(strcfg, &dns) != 1) { +#endif /* LWIP_IPV6 */ uk_pr_err("Failed to parse DNS server address: %s\n", strcfg); goto dns_done; } - dns_setserver(nb_dns4++, &dns4); + dns_setserver(nb_dns4++, &dns); uk_pr_info("%c%c%u: Secondary DNS server: %s\n", nf->name[0], nf->name[1], nf->num, strcfg);