summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2011-03-18 12:39:40 -0400
committerNick Mathewson <nickm@torproject.org>2011-03-18 12:39:40 -0400
commitf3d666366555226ec2ad0f647489a1d42145a2eb (patch)
tree155b093fa31b2dc980989967dd34f1a7887cb0e1
parent9dfa244484ff9c52d545daa620e034b4d03f969c (diff)
parent4aac35cafa9843d10b05921da51dcc42bc3e9176 (diff)
downloadtor-f3d666366555226ec2ad0f647489a1d42145a2eb.tar.gz
tor-f3d666366555226ec2ad0f647489a1d42145a2eb.zip
Merge remote branch 'sebastian/bug2696' into maint-0.2.2
-rw-r--r--changes/bug26965
-rw-r--r--configure.in24
-rw-r--r--src/or/geoip.c18
3 files changed, 37 insertions, 10 deletions
diff --git a/changes/bug2696 b/changes/bug2696
new file mode 100644
index 0000000000..6ea41d4a6a
--- /dev/null
+++ b/changes/bug2696
@@ -0,0 +1,5 @@
+ o Minor features:
+ - Make compilation with clang possible when using
+ --enable-gcc-warnings by removing two warnings that clang hasn't
+ implemented yet and by fixing a few warnings. Implements ticket
+ 2696.
diff --git a/configure.in b/configure.in
index f30402d5b5..4436fe2075 100644
--- a/configure.in
+++ b/configure.in
@@ -865,12 +865,13 @@ fi
# Set CFLAGS _after_ all the above checks, since our warnings are stricter
# than autoconf's macros like.
if test "$GCC" = yes; then
- CFLAGS="$CFLAGS -Wall -g -O2"
# Disable GCC's strict aliasing checks. They are an hours-to-debug
# accident waiting to happen.
- CFLAGS="$CFLAGS -fno-strict-aliasing"
+ CFLAGS="$CFLAGS -Wall -fno-strict-aliasing"
else
- CFLAGS="$CFLAGS -g -O"
+ # Autoconf sets -g -O2 by default. Override optimization level
+ # for non-gcc compilers
+ CFLAGS="$CFLAGS -O"
enable_gcc_warnings=no
enable_gcc_warnings_advisory=no
fi
@@ -894,6 +895,11 @@ if test x$enable_gcc_warnings = xyes || test x$enable_gcc_warnings_advisory = xy
#error
#endif])], have_gcc43=yes, have_gcc43=no)
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
+#if !defined(__clang__) || (__clang_major__ > 2) || (__clang_major__ == 2 && __clang_minor__ > 9)
+#error
+#endif])], have_clang29orlower=yes, have_clang29orlower=no)
+
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -Wshorten-64-to-32"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], have_shorten64_flag=yes,
@@ -924,11 +930,19 @@ if test x$enable_gcc_warnings = xyes || test x$enable_gcc_warnings_advisory = xy
if test x$have_gcc42 = xyes ; then
# These warnings break gcc 4.0.2 and work on gcc 4.2
# XXXX020 See if any of these work with earlier versions.
- CFLAGS="$CFLAGS -Waddress -Wmissing-noreturn -Wnormalized=id -Woverride-init -Wstrict-overflow=1"
+ CFLAGS="$CFLAGS -Waddress -Wmissing-noreturn -Wstrict-overflow=1"
+
# We used to use -Wstrict-overflow=5, but that breaks us heavily under 4.3.
fi
- if test x$have_gcc43 = xyes ; then
+ if test x$have_gcc42 = xyes && test x$have_clang29orlower = xno; then
+ # These warnings break gcc 4.0.2 and clang, but work on gcc 4.2
+ # We only disable these for clang 2.9 and lower, in case they are
+ # supported in later versions.
+ CFLAGS="$CFLAGS -Wnormalized=id -Woverride-init"
+ fi
+
+ if test x$have_gcc43 = xyes ; then
# These warnings break gcc 4.2 and work on gcc 4.3
# XXXX020 See if any of these work with earlier versions.
CFLAGS="$CFLAGS -Wextra -Warray-bounds"
diff --git a/src/or/geoip.c b/src/or/geoip.c
index e5694b9618..a99165488a 100644
--- a/src/or/geoip.c
+++ b/src/or/geoip.c
@@ -284,11 +284,18 @@ geoip_is_loaded(void)
typedef struct clientmap_entry_t {
HT_ENTRY(clientmap_entry_t) node;
uint32_t ipaddr;
+ /** Time when we last saw this IP address, in MINUTES since the epoch.
+ *
+ * (This will run out of space around 4011 CE. If Tor is still in use around
+ * 4000 CE, please remember to add more bits to last_seen_in_minutes.) */
unsigned int last_seen_in_minutes:30;
unsigned int action:2;
} clientmap_entry_t;
-#define ACTION_MASK 3
+/** Largest allowable value for last_seen_in_minutes. (It's a 30-bit field,
+ * so it can hold up to (1u<<30)-1, or 0x3fffffffu.
+ */
+#define MAX_LAST_SEEN_IN_MINUTES 0X3FFFFFFFu
/** Map from client IP address to last time seen. */
static HT_HEAD(clientmap, clientmap_entry_t) client_history =
@@ -413,15 +420,16 @@ geoip_note_client_seen(geoip_client_action_t action,
lookup.ipaddr = addr;
lookup.action = (int)action;
ent = HT_FIND(clientmap, &client_history, &lookup);
- if (ent) {
- ent->last_seen_in_minutes = now / 60;
- } else {
+ if (! ent) {
ent = tor_malloc_zero(sizeof(clientmap_entry_t));
ent->ipaddr = addr;
- ent->last_seen_in_minutes = now / 60;
ent->action = (int)action;
HT_INSERT(clientmap, &client_history, ent);
}
+ if (now / 60 <= MAX_LAST_SEEN_IN_MINUTES && now >= 0)
+ ent->last_seen_in_minutes = (unsigned)(now/60);
+ else
+ ent->last_seen_in_minutes = 0;
if (action == GEOIP_CLIENT_NETWORKSTATUS ||
action == GEOIP_CLIENT_NETWORKSTATUS_V2) {