net: Remove env_get_ip helper() function
Currently, we have the function env_get_ip which takes an IP address
in string form and returns a struct in_addr representation of that
address. It is however little used and means that a number of places
indirectly (and unclearly) get <env.h> via <net.h>. To clean this up
start by replacing env_get_ip() calls with string_to_ip() calls. This is
generally a no-op as env_get_ip(str) is an inline of
string_to_ip(env_get(str)) but in a few cases we can or already have
stored the result of env_get(str) and can save the additional call.
Signed-off-by: Tom Rini <trini@konsulko.com>
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index 1943de8..c2ce4a8 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -61,8 +61,8 @@
/* update only when the environment has changed */
if (env_changed_id != env_id) {
- netmask = env_get_ip("netmask");
- our_ip = env_get_ip("ipaddr");
+ netmask = string_to_ip(env_get("netmask"));
+ our_ip = string_to_ip(env_get("ipaddr"));
env_changed_id = env_id;
}
@@ -81,11 +81,12 @@
/* update only when the environment has changed */
if (env_changed_id != env_id) {
- if (env_get("ncip")) {
- nc_ip = env_get_ip("ncip");
+ char *tmp = env_get("ncip");
+ if (tmp) {
+ nc_ip = string_to_ip(tmp);
if (!nc_ip.s_addr)
return -1; /* ncip is 0.0.0.0 */
- p = strchr(env_get("ncip"), ':');
+ p = strchr(tmp, ':');
if (p != NULL) {
nc_out_port = dectoul(p + 1, NULL);
nc_in_port = nc_out_port;