diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2018-11-29 11:17:08 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2018-11-29 15:04:31 +0100 |
commit | 4b48ae4bcdbc137c80b77adc5aa614e5f4cb9f51 (patch) | |
tree | ec502443c6dd7e665a8b420d49eb5ae811de7775 /net/dhcp.c | |
parent | cd9a7567b0d5afd874dcd31fd22918868e9eab9e (diff) | |
download | barebox-4b48ae4bcdbc137c80b77adc5aa614e5f4cb9f51.tar.gz |
net: dns: return error codes
The resolv() function used to return the IP address. When net_udp_new()
fails we return an error code though which the callers of resolv() take
as an IP address. This is wrong of course and we could return 0 in this
case. Instead we return an error code and pass the resolved IP as a
pointer which allows us to return proper error codes.
This patch also adds error messages and error returns to the various
callers of resolv() which used to just continue with a zero IP and
let the user figure out what went wrong.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'net/dhcp.c')
-rw-r--r-- | net/dhcp.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/net/dhcp.c b/net/dhcp.c index 79aa75d878..670a6a6422 100644 --- a/net/dhcp.c +++ b/net/dhcp.c @@ -562,6 +562,8 @@ out: int dhcp_set_result(struct eth_device *edev, struct dhcp_result *res) { + int ret; + net_set_ip(edev, res->ip); net_set_netmask(edev, res->netmask); net_set_gateway(res->gateway); @@ -580,8 +582,8 @@ int dhcp_set_result(struct eth_device *edev, struct dhcp_result *res) if (res->tftp_server_name) { IPaddr_t ip; - ip = resolv(res->tftp_server_name); - if (ip) + ret = resolv(res->tftp_server_name, &ip); + if (!ret) net_set_serverip_empty(ip); } else if (res->serverip) { net_set_serverip_empty(res->serverip); |