summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2019-01-04 15:19:00 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2019-01-04 15:19:02 +0100
commit80b2d315ce52f469a17622538b775b10e92fc9bc (patch)
treee721e97efbb0bc1f13d94c3f17ef081b70ef5767 /net
parenteb3c1d18a0309456fbd0e6b12eaa76f1faaa3a19 (diff)
downloadbarebox-80b2d315ce52f469a17622538b775b10e92fc9bc.tar.gz
barebox-80b2d315ce52f469a17622538b775b10e92fc9bc.tar.xz
net: dns: leave host command with error on failure
When we can't resolv a host we should return an error rather than just successfully. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'net')
-rw-r--r--net/dns.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/net/dns.c b/net/dns.c
index 4516235df2..d241781939 100644
--- a/net/dns.c
+++ b/net/dns.c
@@ -258,15 +258,20 @@ static int do_host(int argc, char *argv[])
{
IPaddr_t ip;
int ret;
+ char *hostname;
if (argc != 2)
return COMMAND_ERROR_USAGE;
+ hostname = argv[1];
+
ret = resolv(argv[1], &ip);
- if (ret)
- printf("unknown host %s\n", argv[1]);
- else
- printf("%s is at %pI4\n", argv[1], &ip);
+ if (ret) {
+ printf("unknown host %s\n", hostname);
+ return 1;
+ }
+
+ printf("%s is at %pI4\n", hostname, &ip);
return 0;
}