Message ID | 20250606064211.3091237-8-jerome.forissier@linaro.org |
---|---|
State | New |
Headers | show |
Series | sntp for NET_LWIP | expand |
On Fri, Jun 06, 2025 at 08:41:43AM +0200, Jerome Forissier wrote: > When calling "dns <hostname> <varname>", do not print out the IP address > of <hostname> onto the console. Print it only when no variable is > passed. The reason is to be able to call do_dns() from another command > in need of the DNS services without polluting the output. > > Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> As I do not know off-hand, how does this compare with other commands which can be used to set a variable? I assume it's similar. And then, oh, we don't have doc/cmd/usage/dns.rst to start with. So, follow-up to this series please, document the network commands that we have in both lwip and legacy stack and please note where there's differences if any. Thanks!
diff --git a/cmd/lwip/dns.c b/cmd/lwip/dns.c index b757638cd1e..0bfd8f198cf 100644 --- a/cmd/lwip/dns.c +++ b/cmd/lwip/dns.c @@ -42,8 +42,6 @@ static void dns_cb(const char *name, const ip_addr_t *ipaddr, void *arg) if (dns_cb_arg->var) env_set(dns_cb_arg->var, ipstr); - - printf("%s\n", ipstr); } static int dns_loop(struct udevice *udev, const char *name, const char *var) @@ -107,8 +105,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 (dns_cb_arg.done && dns_cb_arg.host_ipaddr.addr != 0) { + if (!var) + printf("%s\n", ipaddr_ntoa(&ipaddr)); return CMD_RET_SUCCESS; + } return CMD_RET_FAILURE; }
When calling "dns <hostname> <varname>", do not print out the IP address of <hostname> onto the console. Print it only when no variable is passed. The reason is to be able to call do_dns() from another command in need of the DNS services without polluting the output. Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> --- Changes in v2: - New patch cmd/lwip/dns.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)