From: Jonas Karlman Date: Sat, 17 Jan 2026 00:24:39 +0000 (+0000) Subject: net: lwip: dns: Call env_set() from dns loop instead of found callback X-Git-Tag: v2026.04-rc2~23^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3299bffc7c8e57059be3738bc53c7709b7f981be;p=thirdparty%2Fu-boot.git net: lwip: dns: Call env_set() from dns loop instead of found callback The lwIP dns command handle env_set() calls from the found callback and printf() to console in the dns loop. Making it more complex than it needs to be. Simplify and ensure any environment variable that is being set is the same value that would have been printed on console. There should not be any intended change in behavior, besides the change from using ip4addr helper to using version less ipaddr helper. Signed-off-by: Jonas Karlman Reviewed-by: Jerome Forissier --- diff --git a/net/lwip/dns.c b/net/lwip/dns.c index 2b2a5947a2b..2222e2b0b04 100644 --- a/net/lwip/dns.c +++ b/net/lwip/dns.c @@ -14,7 +14,6 @@ struct dns_cb_arg { ip_addr_t host_ipaddr; - const char *var; bool done; }; @@ -26,7 +25,6 @@ static void do_dns_tmr(void *arg) static void dns_cb(const char *name, const ip_addr_t *ipaddr, void *arg) { struct dns_cb_arg *dns_cb_arg = arg; - char *ipstr = ip4addr_ntoa(ipaddr); dns_cb_arg->done = true; @@ -37,21 +35,17 @@ static void dns_cb(const char *name, const ip_addr_t *ipaddr, void *arg) } dns_cb_arg->host_ipaddr.addr = ipaddr->addr; - - if (dns_cb_arg->var) - env_set(dns_cb_arg->var, ipstr); } static int dns_loop(struct udevice *udev, const char *name, const char *var) { struct dns_cb_arg dns_cb_arg = { }; struct netif *netif; + const char *ipstr; ip_addr_t ipaddr; ulong start; int ret; - dns_cb_arg.var = var; - netif = net_lwip_new_netif(udev); if (!netif) return CMD_RET_FAILURE; @@ -85,8 +79,11 @@ static int dns_loop(struct udevice *udev, const char *name, const char *var) net_lwip_remove_netif(netif); if (dns_cb_arg.done && dns_cb_arg.host_ipaddr.addr != 0) { - if (!var) - printf("%s\n", ipaddr_ntoa(&dns_cb_arg.host_ipaddr)); + ipstr = ipaddr_ntoa(&dns_cb_arg.host_ipaddr); + if (var) + env_set(var, ipstr); + else + printf("%s\n", ipstr); return CMD_RET_SUCCESS; }