Skip to content

Commit 0d1e874

Browse files
cluoshrazvand
authored andcommitted
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 <[email protected]> Approved-by: Razvan Deaconescu <[email protected]> Reviewed-by: Razvan Deaconescu <[email protected]> GitHub-Closes: #60
1 parent 5926e39 commit 0d1e874

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

Diff for: init.c

+15-5
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ static int liblwip_init(struct uk_init_ctx *ictx __unused)
165165
ip4_addr_t *gw4_arg;
166166
const char *hostname_arg;
167167
#if LWIP_DNS
168-
ip4_addr_t dns4;
168+
ip_addr_t dns;
169169
unsigned int nb_dns4 = 0;
170170
#endif /* LWIP_DNS */
171171
#endif /* LWIP_IPV4 */
@@ -393,13 +393,18 @@ static int liblwip_init(struct uk_init_ctx *ictx __unused)
393393
if (nb_dns4 < DNS_MAX_SERVERS) {
394394
strcfg = uk_netdev_einfo_get(dev, UK_NETDEV_IPV4_DNS0);
395395
if (strcfg) {
396-
if (ip4addr_aton(strcfg, &dns4) != 1) {
396+
#if LWIP_IPV6
397+
dns.type = IPADDR_TYPE_V4;
398+
if (ip4addr_aton(strcfg, &dns.u_addr.ip4) != 1) {
399+
#else /* LWIP_IPV6 */
400+
if (ip4addr_aton(strcfg, &dns) != 1) {
401+
#endif /* LWIP_IPV6 */
397402
uk_pr_err("Failed to parse DNS server address: %s\n",
398403
strcfg);
399404
goto dns_secondary;
400405
}
401406

402-
dns_setserver(nb_dns4++, &dns4);
407+
dns_setserver(nb_dns4++, &dns);
403408
uk_pr_info("%c%c%u: Primary DNS server: %s\n",
404409
nf->name[0], nf->name[1], nf->num,
405410
strcfg);
@@ -411,13 +416,18 @@ static int liblwip_init(struct uk_init_ctx *ictx __unused)
411416
if (nb_dns4 < DNS_MAX_SERVERS) {
412417
strcfg = uk_netdev_einfo_get(dev, UK_NETDEV_IPV4_DNS1);
413418
if (strcfg) {
414-
if (ip4addr_aton(strcfg, &dns4) != 1) {
419+
#if LWIP_IPV6
420+
dns.type = IPADDR_TYPE_V4;
421+
if (ip4addr_aton(strcfg, &dns.u_addr.ip4) != 1) {
422+
#else /* LWIP_IPV6 */
423+
if (ip4addr_aton(strcfg, &dns) != 1) {
424+
#endif /* LWIP_IPV6 */
415425
uk_pr_err("Failed to parse DNS server address: %s\n",
416426
strcfg);
417427
goto dns_done;
418428
}
419429

420-
dns_setserver(nb_dns4++, &dns4);
430+
dns_setserver(nb_dns4++, &dns);
421431
uk_pr_info("%c%c%u: Secondary DNS server: %s\n",
422432
nf->name[0], nf->name[1], nf->num,
423433
strcfg);

0 commit comments

Comments
 (0)