summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2016-05-30 14:13:33 -0400
committerNick Mathewson <nickm@torproject.org>2016-06-11 10:11:52 -0400
commit4caed2424a449712c8ac267d521563d31536aa6a (patch)
tree262ec1efd589f9639f28c6c09d2b4ab59e1d0d03
parent8f2d2933f912c9952453b17b19636c26579e2323 (diff)
downloadtor-4caed2424a449712c8ac267d521563d31536aa6a.tar.gz
tor-4caed2424a449712c8ac267d521563d31536aa6a.zip
Enable -Woverlength-strings for GCC>=4.6 on MOST of the code.
IMO it's fine for us to make exceptions to this rule in the unit tests, but not in the code at large.
-rw-r--r--configure.ac1
-rw-r--r--src/test/test_dir_handle_get.c8
-rw-r--r--src/test/test_helpers.c8
-rw-r--r--src/test/test_microdesc.c8
4 files changed, 25 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index 38c922bdd1..f21d9de532 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1757,6 +1757,7 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
# and these should be just fine in gcc 4.6
CFLAGS="$CFLAGS -Wmissing-format-attribute -Wsuggest-attribute=noreturn -Wsync-nand -Wtrampolines -Wunused-but-set-parameter -Wunused-but-set-variable -Wvariadic-macros"
CFLAGS="$CFLAGS -Wdouble-promotion"
+ CFLAGS="$CFLAGS -Woverlength-strings"
fi
if test "x$have_gcc47" = "xyes"; then
diff --git a/src/test/test_dir_handle_get.c b/src/test/test_dir_handle_get.c
index 1416b389aa..2df705f197 100644
--- a/src/test/test_dir_handle_get.c
+++ b/src/test/test_dir_handle_get.c
@@ -38,7 +38,15 @@
#include <dirent.h>
#endif
+#if GCC_VERSION >= 406
+DISABLE_GCC_WARNING(overlength-strings)
+/* We allow huge string constants in the unit tests, but not in the code
+ * at large. */
+#endif
#include "vote_descriptors.inc"
+#if GCC_VERSION >= 406
+ENABLE_GCC_WARNING(overlength-strings)
+#endif
#define NS_MODULE dir_handle_get
diff --git a/src/test/test_helpers.c b/src/test/test_helpers.c
index c6daaf220a..bf0365a0d2 100644
--- a/src/test/test_helpers.c
+++ b/src/test/test_helpers.c
@@ -16,7 +16,15 @@
#include "test.h"
#include "test_helpers.h"
+#if GCC_VERSION >= 406
+DISABLE_GCC_WARNING(overlength-strings)
+/* We allow huge string constants in the unit tests, but not in the code
+ * at large. */
+#endif
#include "test_descriptors.inc"
+#if GCC_VERSION >= 406
+ENABLE_GCC_WARNING(overlength-strings)
+#endif
/* Return a statically allocated string representing yesterday's date
* in ISO format. We use it so that state file items are not found to
diff --git a/src/test/test_microdesc.c b/src/test/test_microdesc.c
index 581f58b45f..28c4f0706c 100644
--- a/src/test/test_microdesc.c
+++ b/src/test/test_microdesc.c
@@ -490,6 +490,11 @@ test_md_generate(void *arg)
routerinfo_free(ri);
}
+#if GCC_VERSION >= 406
+DISABLE_GCC_WARNING(overlength-strings)
+/* We allow huge string constants in the unit tests, but not in the code
+ * at large. */
+#endif
/* Taken at random from my ~/.tor/cached-microdescs file and then
* hand-munged */
static const char MD_PARSE_TEST_DATA[] =
@@ -645,6 +650,9 @@ static const char MD_PARSE_TEST_DATA[] =
"id rsa1024 2A8wYpHxnkKJ92orocvIQBzeHlE\n"
"p6 allow 80\n"
;
+#if GCC_VERSION >= 406
+ENABLE_GCC_WARNING(overlength-strings)
+#endif
/** More tests for parsing different kinds of microdescriptors, and getting
* invalid digests trackd from them. */