diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2019-01-04 15:19:00 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2019-01-04 15:19:02 +0100 |
commit | 80b2d315ce52f469a17622538b775b10e92fc9bc (patch) | |
tree | e721e97efbb0bc1f13d94c3f17ef081b70ef5767 /net | |
parent | eb3c1d18a0309456fbd0e6b12eaa76f1faaa3a19 (diff) | |
download | barebox-80b2d315ce52f469a17622538b775b10e92fc9bc.tar.gz |
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.c | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -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; } |