From 29391ef9aea845752f5bf8f281f94c8422e35dc7 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt Date: Sun, 3 Feb 2013 23:04:41 +0100 Subject: [PATCH] Removed uiplib_ip6addrconv() from IPv4 builds. While it may very well be beneficial to have explict uiplib_ip4addrconv() and uiplib_ip6addrconv() available for IPv6 builds I'm having a hard time to see the point in uiplib_ip6addrconv() for IPv4 builds. Unrelated to the above the dispatching of uiplib_ipaddrconv() to either uiplib_ip4addrconv() or uiplib_ip6addrconv() can be accomplished by the C preprocessor only thus avoiding the size/speed overhead of an additional callframe. --- core/net/uiplib.c | 13 ++----------- core/net/uiplib.h | 6 +++++- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/core/net/uiplib.c b/core/net/uiplib.c index b062b0867..e01f7d672 100644 --- a/core/net/uiplib.c +++ b/core/net/uiplib.c @@ -41,6 +41,7 @@ #include "net/uip-debug.h" /*-----------------------------------------------------------------------------------*/ +#if UIP_CONF_IPV6 int uiplib_ip6addrconv(const char *addrstr, uip_ip6addr_t *ipaddr) { @@ -102,6 +103,7 @@ uiplib_ip6addrconv(const char *addrstr, uip_ip6addr_t *ipaddr) return 1; } +#endif /* UIP_CONF_IPV6 */ /*-----------------------------------------------------------------------------------*/ /* Parse a IPv4-address from a string. Returns the number of characters read * for the address. */ @@ -139,14 +141,3 @@ uiplib_ip4addrconv(const char *addrstr, uip_ip4addr_t *ipaddr) return charsread-1; } /*-----------------------------------------------------------------------------------*/ -int -uiplib_ipaddrconv(const char *addrstr, uip_ipaddr_t *ipaddr) -{ -#if UIP_CONF_IPV6 - return uiplib_ip6addrconv(addrstr, ipaddr); -#else /* UIP_CONF_IPV6 */ - return uiplib_ip4addrconv(addrstr, ipaddr); -#endif /* UIP_CONF_IPV6 */ -} - -/*-----------------------------------------------------------------------------------*/ diff --git a/core/net/uiplib.h b/core/net/uiplib.h index f9ba9a3bf..de446de59 100644 --- a/core/net/uiplib.h +++ b/core/net/uiplib.h @@ -66,7 +66,11 @@ * \retval 0 If the IP address could not be parsed. * \retval Non-zero If the IP address was parsed. */ -CCIF int uiplib_ipaddrconv(const char *addrstr, uip_ipaddr_t *addr); +#if UIP_CONF_IPV6 +#define uiplib_ipaddrconv uiplib_ip6addrconv +#else /* UIP_CONF_IPV6 */ +#define uiplib_ipaddrconv uiplib_ip4addrconv +#endif /* UIP_CONF_IPV6 */ CCIF int uiplib_ip4addrconv(const char *addrstr, uip_ip4addr_t *addr); CCIF int uiplib_ip6addrconv(const char *addrstr, uip_ip6addr_t *addr);