[tor-commits] [torsocks/master] Fix: put utils_is_ipv4_local static inline

dgoulet at torproject.org dgoulet at torproject.org
Fri Apr 4 22:40:27 UTC 2014


commit 88af304be86cbc633b41fde6716c33dab698c8d2
Author: David Goulet <dgoulet at ev0ke.net>
Date:   Thu Nov 7 21:22:35 2013 -0500

    Fix: put utils_is_ipv4_local static inline
    
    Also remove the assert() since 0.0.0.0 is valid :)
    
    Signed-off-by: David Goulet <dgoulet at ev0ke.net>
---
 src/common/utils.c |   15 ---------------
 src/common/utils.h |   12 +++++++++++-
 2 files changed, 11 insertions(+), 16 deletions(-)

diff --git a/src/common/utils.c b/src/common/utils.c
index 33fc109..0c5c2c8 100644
--- a/src/common/utils.c
+++ b/src/common/utils.c
@@ -24,7 +24,6 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "compat.h"
 #include "macros.h"
 #include "utils.h"
 
@@ -177,17 +176,3 @@ int utils_strcasecmpend(const char *s1, const char *s2)
 		return strncasecmp(s1 + (n1 - n2), s2, n2);
 	}
 }
-
-
-/*
- * Check if the given IPv4 is in the loopback net (127.x.x.x).
- *
- * Return 1 if so else 0 if not.
- */
-ATTR_HIDDEN
-int utils_is_ipv4_local(in_addr_t addr)
-{
-	assert(addr);
-
-	return IN_LOOPBACK(addr);
-}
diff --git a/src/common/utils.h b/src/common/utils.h
index 062441e..474b2df 100644
--- a/src/common/utils.h
+++ b/src/common/utils.h
@@ -22,6 +22,8 @@
 
 #include <netinet/in.h>
 
+#include "compat.h"
+
 char *utils_strsplit(char *separator, char **text, const char *search);
 int utils_strcasecmpend(const char *s1, const char *s2);
 int utils_tokenize_ignore_comments(const char *_line, size_t size, char **tokens);
@@ -29,6 +31,14 @@ int utils_tokenize_ignore_comments(const char *_line, size_t size, char **tokens
 int utils_is_address_ipv4(const char *ip);
 int utils_is_address_ipv6(const char *ip);
 
-int utils_is_ipv4_local(in_addr_t addr);
+/*
+ * Check if the given IPv4 is in the loopback net (127.x.x.x).
+ *
+ * Return 1 if so else 0 if not.
+ */
+static inline int utils_is_ipv4_local(in_addr_t addr)
+{
+	return IN_LOOPBACK(addr);
+}
 
 #endif /* TORSOCKS_UTILS_H */





More information about the tor-commits mailing list