On 17/01/2026 01:24, Jonas Karlman wrote: > 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 <[email protected]> > --- > net/lwip/dns.c | 15 ++++++--------- > 1 file changed, 6 insertions(+), 9 deletions(-) > > diff --git a/net/lwip/dns.c b/net/lwip/dns.c > index 2b2a5947a2b8..2222e2b0b045 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; > } >
Reviewed-by: Jerome Forissier <[email protected]> Thanks, -- Jerome

