[PATCH 3/9] net: dns: leave host command with error on failure

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When we can't resolv a host we should return an error rather than just
successfully.

Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>
---
 net/dns.c | 13 +++++++++----
 1 file 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;
 }
-- 
2.19.1


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux