summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorJonas Karlman <[email protected]>2026-01-17 00:24:39 +0000
committerJerome Forissier <[email protected]>2026-02-04 09:04:36 +0100
commit3299bffc7c8e57059be3738bc53c7709b7f981be (patch)
tree8fc7d9343452cd1ef164d887cd972c93914e6f21 /net
parentf3b600efb339e5419cb10cd8177d84c7c36ee4cd (diff)
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 <[email protected]> Reviewed-by: Jerome Forissier <[email protected]>
Diffstat (limited to 'net')
-rw-r--r--net/lwip/dns.c15
1 files changed, 6 insertions, 9 deletions
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;
}