From 7129187f877317fe6af8a5ece3638782ceb0d602 Mon Sep 17 00:00:00 2001 From: Pieter Hintjens Date: Sat, 13 Feb 2016 11:56:47 +0100 Subject: [PATCH] Problem: getting various warnings in tweetnacl libzmq used to switch off pedantic checks when using tweetnacl. As this is now the default, that means pedantic checks are always off. This is not good. Solution: in tweetnacl.c alone, use a GCC pragma to disable sign comparison warnings. We could also clean the code up yet this is simpler. In other code, we still want those warnings, hence I've used a pragma rather than global compile option. Second, use -Wno-long-long all the time, as this warning does not work with a pragma. I removed code that set -wno-long-long, for MinGW and Solaris. Related problem 2: --with-relaxed is badly named This option switches off pedantic checks, so should be called --disable-pedantic. 'with' is for optional packages. --- .gitignore | 3 +++ configure.ac | 26 ++++++-------------------- src/tweetnacl.c | 2 ++ src/tweetnacl.h | 1 + 4 files changed, 12 insertions(+), 20 deletions(-) diff --git a/.gitignore b/.gitignore index 899ad9f1..23c62096 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,9 @@ autom4te.cache *.ps *~ .*~ +.deps +.dirstamp +.libs curve_keygen test_heartbeats test_msg_ffn diff --git a/configure.ac b/configure.ac index 41590714..fc31404b 100644 --- a/configure.ac +++ b/configure.ac @@ -101,17 +101,9 @@ AC_RUN_IFELSE( AC_MSG_RESULT([$libzmq_tipc_support]) -AC_ARG_WITH([relaxed], - [AS_HELP_STRING([--with-relaxed], - [switch off pedantic compiler])], - [zmq_relaxed="yes"], - []) - -if test "x$zmq_relaxed" = "xyes"; then - libzmq_pedantic="no" -else - libzmq_pedantic="yes" -fi +AC_ARG_ENABLE([pedantic], + [AS_HELP_STRING([--disable-pedantic], [disable pedantic compiler checks [default=enabled]])], + [libzmq_pedantic=$enableval], [libzmq_pedantic=yes]) AC_ARG_WITH([militant], [AS_HELP_STRING([--with-militant], @@ -137,8 +129,8 @@ libzmq_on_android="no" libzmq_on_linux="no" libzmq_on_gnu="no" -# Set some default features required by 0MQ code. -CPPFLAGS="-D_REENTRANT -D_THREAD_SAFE $CPPFLAGS" +# Set some default features required by ZeroMQ code +CPPFLAGS="-D_REENTRANT -D_THREAD_SAFE -Wno-long-long $CPPFLAGS" # For host type checks AC_CANONICAL_HOST @@ -255,10 +247,6 @@ case "${host_os}" in [AC_MSG_ERROR([cannot link with rpcrt4.dll.])]) AC_CHECK_LIB(iphlpapi, main, , [AC_MSG_ERROR([cannot link with iphlpapi.dll.])]) - # mingw defines __int64_t as long long - AC_LANG_PUSH([C++]) - LIBZMQ_CHECK_LANG_FLAG_PREPEND([-Wno-long-long]) - AC_LANG_POP([C++]) libzmq_on_mingw="yes" libzmq_dso_visibility="no" @@ -434,7 +422,7 @@ AS_IF([test "x$with_libsodium" = "xyes"], [ AC_ARG_ENABLE([curve], AS_HELP_STRING([--disable-curve], [disable CURVE security [default=no]])) - +x if test "x$enable_curve" == "xno"; then curve_library="" AC_MSG_NOTICE([CURVE security is disabled]) @@ -450,7 +438,6 @@ elif test "x$with_libsodium" == "xyes"; then case "${host_os}" in *solaris*) LDFLAGS="-lssp $LDFLAGS" - CPPFLAGS="-Wno-long-long $CPPFLAGS" ;; esac else @@ -458,7 +445,6 @@ else AC_DEFINE(ZMQ_HAVE_CURVE, [1], [Using curve encryption]) AC_DEFINE(ZMQ_USE_TWEETNACL, [1], [Using tweetnacl for curve encryption]) curve_library="tweetnacl" - libzmq_pedantic="no" # Disable pedantic warnings fi AM_CONDITIONAL(USE_LIBSODIUM, test "$curve_library" == "libsodium") diff --git a/src/tweetnacl.c b/src/tweetnacl.c index 01cbb7e1..7fb4e76c 100644 --- a/src/tweetnacl.c +++ b/src/tweetnacl.c @@ -30,6 +30,8 @@ #include "platform.hpp" #if defined (ZMQ_USE_TWEETNACL) +#pragma GCC diagnostic ignored "-Wsign-compare" + #include "tweetnacl.h" #define FOR(i,n) for (i = 0;i < n;++i) diff --git a/src/tweetnacl.h b/src/tweetnacl.h index b152642e..4a292e01 100644 --- a/src/tweetnacl.h +++ b/src/tweetnacl.h @@ -31,6 +31,7 @@ #define TWEETNACL_H #include "platform.hpp" + #if defined (ZMQ_USE_TWEETNACL) #define crypto_box_SECRETKEYBYTES 32