Update m4 files from ddm4, and fix clang warning.
authorBrian Aker <brian@tangent.org>
Mon, 11 Feb 2013 10:58:01 +0000 (02:58 -0800)
committerBrian Aker <brian@tangent.org>
Mon, 11 Feb 2013 10:58:01 +0000 (02:58 -0800)
m4/ax_harden_compiler_flags.m4
m4/ax_libevent.m4
tests/mem_udp.cc

index b31518aaa624e197e6e09c43951af422f473d294..c2a0d5411d0f0cc8bccd3152e74e7b5d4c88a36d 100644 (file)
@@ -1,3 +1,4 @@
+# vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
 # ===========================================================================
 #      https://github.com/BrianAker/ddm4/
 # ===========================================================================
@@ -52,7 +53,7 @@
 # ?  _APPEND_COMPILE_FLAGS_ERROR([-Wlong-long]) -- Don't turn on for
 # compatibility issues memcached_stat_st
 
-#serial 7
+#serial 8
 
 AC_DEFUN([_WARNINGS_AS_ERRORS],
     [AC_CACHE_CHECK([if all warnings into errors],[ac_cv_warnings_as_errors],
@@ -75,10 +76,12 @@ AC_DEFUN([_APPEND_COMPILE_FLAGS_ERROR],
 # Everything above this does the heavy lifting, while what follows does the specifics.
 
 AC_DEFUN([_HARDEN_LINKER_FLAGS],
-         [_APPEND_LINK_FLAGS_ERROR([-z relro -z now])
-         #_APPEND_LINK_FLAGS_ERROR([-pie])
-         AS_IF([test "x$ac_cv_warnings_as_errors" = xyes],
-               [AX_APPEND_LINK_FLAGS([-Werror])])
+         [
+         AS_IF([test "$CC" != "clang"],
+           [_APPEND_LINK_FLAGS_ERROR([-z relro -z now])
+#_APPEND_LINK_FLAGS_ERROR([-pie])
+           AS_IF([test "x$ac_cv_warnings_as_errors" = xyes],
+             [AX_APPEND_LINK_FLAGS([-Werror])])])
          ])
 
 AC_DEFUN([_HARDEN_CC_COMPILER_FLAGS],
@@ -86,6 +89,7 @@ AC_DEFUN([_HARDEN_CC_COMPILER_FLAGS],
 
          AS_IF([test "x$ax_enable_debug" = xyes],
            [CFLAGS=''
+           _APPEND_COMPILE_FLAGS_ERROR([-H])
            _APPEND_COMPILE_FLAGS_ERROR([-ggdb])
            _APPEND_COMPILE_FLAGS_ERROR([-g])
            _APPEND_COMPILE_FLAGS_ERROR([-O0])],
@@ -93,19 +97,26 @@ AC_DEFUN([_HARDEN_CC_COMPILER_FLAGS],
            _APPEND_COMPILE_FLAGS_ERROR([-O2])])
 
          AS_IF([test "x$ac_cv_vcs_checkout" = xyes],
-           [_APPEND_COMPILE_FLAGS_ERROR([-fstack-check])],
-           [_APPEND_COMPILE_FLAGS_ERROR([-Wno-pragmas])])
+           [_APPEND_COMPILE_FLAGS_ERROR([-fstack-check])
+           _APPEND_COMPILE_FLAGS_ERROR([-Wpragmas])
+           _APPEND_COMPILE_FLAGS_ERROR([-Wunknown-pragmas])],
+           [_APPEND_COMPILE_FLAGS_ERROR([-Wno-unknown-pragmas])
+           _APPEND_COMPILE_FLAGS_ERROR([-Wno-pragmas])])
+
+         AS_IF([test "$CC" = "clang"],
+           [_APPEND_COMPILE_FLAGS_ERROR([-Qunused-arguments])])
 
          _APPEND_COMPILE_FLAGS_ERROR([-Wall])
          _APPEND_COMPILE_FLAGS_ERROR([-Wextra])
-         _APPEND_COMPILE_FLAGS_ERROR([-Wunknown-pragmas])
          _APPEND_COMPILE_FLAGS_ERROR([-Wthis-test-should-fail])
          _APPEND_COMPILE_FLAGS_ERROR([-std=c99])
 # Anything below this comment please keep sorted.
-         _APPEND_COMPILE_FLAGS_ERROR([--param=ssp-buffer-size=1])
 # _APPEND_COMPILE_FLAGS_ERROR([-Wmissing-format-attribute])
+          _APPEND_COMPILE_FLAGS_ERROR([-Wunsuffixed-float-constants])
+          _APPEND_COMPILE_FLAGS_ERROR([-Wjump-misses-init])
           _APPEND_COMPILE_FLAGS_ERROR([-Wno-attributes])
           _APPEND_COMPILE_FLAGS_ERROR([-Waddress])
+          _APPEND_COMPILE_FLAGS_ERROR([-Wvarargs])
           _APPEND_COMPILE_FLAGS_ERROR([-Warray-bounds])
           _APPEND_COMPILE_FLAGS_ERROR([-Wbad-function-cast])
 # Not in use -Wc++-compat
@@ -114,6 +125,7 @@ AC_DEFUN([_HARDEN_CC_COMPILER_FLAGS],
           _APPEND_COMPILE_FLAGS_ERROR([-Wfloat-equal])
           _APPEND_COMPILE_FLAGS_ERROR([-Wformat-security])
           _APPEND_COMPILE_FLAGS_ERROR([-Wformat=2])
+          _APPEND_COMPILE_FLAGS_ERROR([-Wformat-y2k])
           _APPEND_COMPILE_FLAGS_ERROR([-Wlogical-op])
           _APPEND_COMPILE_FLAGS_ERROR([-Wmaybe-uninitialized])
           _APPEND_COMPILE_FLAGS_ERROR([-Wmissing-field-initializers])
@@ -140,10 +152,36 @@ AC_DEFUN([_HARDEN_CC_COMPILER_FLAGS],
           _APPEND_COMPILE_FLAGS_ERROR([-Wstrict-overflow=1])
           _APPEND_COMPILE_FLAGS_ERROR([-Wstrict-prototypes])
           _APPEND_COMPILE_FLAGS_ERROR([-Wswitch-enum])
+          _APPEND_COMPILE_FLAGS_ERROR([-Wtrampolines])
           _APPEND_COMPILE_FLAGS_ERROR([-Wundef])
+          _APPEND_COMPILE_FLAGS_ERROR([-Wunsafe-loop-optimizations])
+          _APPEND_COMPILE_FLAGS_ERROR([-funsafe-loop-optimizations])
+          _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=address])
+          _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=integer])
+          _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=thread])
+          _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=memory])
+          _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=alignment])
+          _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=bool])
+          _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=bounds])
+          _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=enum])
+          _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=float-cast-overflow])
+          _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=float-divide-by-zero])
+          _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=integer-divide-by-zero])
+          _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=null])
+          _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=object-size])
+          _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=return])
+          _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=shift])
+          _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=signed-integer-overflow])
+          _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=unreachable])
+          _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=unsigned-integer-overflow])
+          _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=vla-bound])
+          _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=vptr])
+          _APPEND_COMPILE_FLAGS_ERROR([-Wclobbered])
           _APPEND_COMPILE_FLAGS_ERROR([-Wunused])
           _APPEND_COMPILE_FLAGS_ERROR([-Wunused-result])
           _APPEND_COMPILE_FLAGS_ERROR([-Wunused-variable])
+          _APPEND_COMPILE_FLAGS_ERROR([-Wunused-parameter])
+          _APPEND_COMPILE_FLAGS_ERROR([-Wunused-local-typedefs])
           _APPEND_COMPILE_FLAGS_ERROR([-Wwrite-strings])
           _APPEND_COMPILE_FLAGS_ERROR([-floop-parallelize-all])
           _APPEND_COMPILE_FLAGS_ERROR([-fwrapv])
@@ -157,6 +195,7 @@ AC_DEFUN([_HARDEN_CC_COMPILER_FLAGS],
                   [_APPEND_COMPILE_FLAGS_ERROR([-D_FORTIFY_SOURCE=2])
                   #_APPEND_COMPILE_FLAGS_ERROR([-Wstack-protector])
                   #_APPEND_COMPILE_FLAGS_ERROR([-fstack-protector])
+                  #_APPEND_COMPILE_FLAGS_ERROR([--param=ssp-buffer-size=1])
                   _APPEND_COMPILE_FLAGS_ERROR([-fstack-protector-all])
                   ])])])])
 
@@ -172,6 +211,7 @@ AC_DEFUN([_HARDEN_CXX_COMPILER_FLAGS],
 
          AS_IF([test "x$ax_enable_debug" = xyes],
            [CXXFLAGS=''
+           _APPEND_COMPILE_FLAGS_ERROR([-H])
            _APPEND_COMPILE_FLAGS_ERROR([-ggdb])
            _APPEND_COMPILE_FLAGS_ERROR([-g])
            _APPEND_COMPILE_FLAGS_ERROR([-O0])],
@@ -179,17 +219,22 @@ AC_DEFUN([_HARDEN_CXX_COMPILER_FLAGS],
            _APPEND_COMPILE_FLAGS_ERROR([-O2])])
 
          AS_IF([test "x$ac_cv_vcs_checkout" = xyes],
-           [_APPEND_COMPILE_FLAGS_ERROR([-fstack-check])],
-           [_APPEND_COMPILE_FLAGS_ERROR([-Wno-pragmas])])
+           [_APPEND_COMPILE_FLAGS_ERROR([-fstack-check])
+           _APPEND_COMPILE_FLAGS_ERROR([-Wpragmas])
+           _APPEND_COMPILE_FLAGS_ERROR([-Wunknown-pragmas])],
+           [_APPEND_COMPILE_FLAGS_ERROR([-Wno-unknown-pragmas])
+           _APPEND_COMPILE_FLAGS_ERROR([-Wno-pragmas])])
+
+         AS_IF([test "$CXX" = "clang++"],
+           [_APPEND_COMPILE_FLAGS_ERROR([-Qunused-arguments])])
 
          _APPEND_COMPILE_FLAGS_ERROR([-Wall])
          _APPEND_COMPILE_FLAGS_ERROR([-Wextra])
-         _APPEND_COMPILE_FLAGS_ERROR([-Wunknown-pragmas])
          _APPEND_COMPILE_FLAGS_ERROR([-Wthis-test-should-fail])
 # Anything below this comment please keep sorted.
-         _APPEND_COMPILE_FLAGS_ERROR([--param=ssp-buffer-size=1])
 # _APPEND_COMPILE_FLAGS_ERROR([-Wmissing-format-attribute])
           _APPEND_COMPILE_FLAGS_ERROR([-Wno-attributes])
+          _APPEND_COMPILE_FLAGS_ERROR([-Wvarargs])
           _APPEND_COMPILE_FLAGS_ERROR([-Waddress])
           _APPEND_COMPILE_FLAGS_ERROR([-Warray-bounds])
           _APPEND_COMPILE_FLAGS_ERROR([-Wchar-subscripts])
@@ -197,6 +242,7 @@ AC_DEFUN([_HARDEN_CXX_COMPILER_FLAGS],
           _APPEND_COMPILE_FLAGS_ERROR([-Wctor-dtor-privacy])
           _APPEND_COMPILE_FLAGS_ERROR([-Wfloat-equal])
           _APPEND_COMPILE_FLAGS_ERROR([-Wformat=2])
+          _APPEND_COMPILE_FLAGS_ERROR([-Wformat-y2k])
           _APPEND_COMPILE_FLAGS_ERROR([-Wmaybe-uninitialized])
           _APPEND_COMPILE_FLAGS_ERROR([-Wmissing-field-initializers])
           _APPEND_COMPILE_FLAGS_ERROR([-Wlogical-op])
@@ -217,11 +263,39 @@ AC_DEFUN([_HARDEN_CXX_COMPILER_FLAGS],
           _APPEND_COMPILE_FLAGS_ERROR([-Wsign-compare])
           _APPEND_COMPILE_FLAGS_ERROR([-Wstrict-overflow=1])
           _APPEND_COMPILE_FLAGS_ERROR([-Wswitch-enum])
+          _APPEND_COMPILE_FLAGS_ERROR([-Wtrampolines])
           _APPEND_COMPILE_FLAGS_ERROR([-Wundef])
+          _APPEND_COMPILE_FLAGS_ERROR([-Wunsafe-loop-optimizations])
+          _APPEND_COMPILE_FLAGS_ERROR([-funsafe-loop-optimizations])
           _APPEND_COMPILE_FLAGS_ERROR([-Wc++11-compat])
+          _APPEND_COMPILE_FLAGS_ERROR([-Weffc++])
+          _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=address])
+          _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=integer])
+          _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=thread])
+          _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=memory])
+          _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=alignment])
+          _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=bool])
+          _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=bounds])
+          _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=enum])
+          _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=float-cast-overflow])
+          _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=float-divide-by-zero])
+          _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=integer-divide-by-zero])
+          _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=null])
+          _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=object-size])
+          _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=return])
+          _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=shift])
+          _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=signed-integer-overflow])
+          _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=unreachable])
+          _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=unsigned-integer-overflow])
+          _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=vla-bound])
+          _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=vptr])
+          _APPEND_COMPILE_FLAGS_ERROR([-Wold-style-cast])
+          _APPEND_COMPILE_FLAGS_ERROR([-Wclobbered])
           _APPEND_COMPILE_FLAGS_ERROR([-Wunused])
           _APPEND_COMPILE_FLAGS_ERROR([-Wunused-result])
           _APPEND_COMPILE_FLAGS_ERROR([-Wunused-variable])
+          _APPEND_COMPILE_FLAGS_ERROR([-Wunused-parameter])
+          _APPEND_COMPILE_FLAGS_ERROR([-Wunused-local-typedefs])
           _APPEND_COMPILE_FLAGS_ERROR([-Wwrite-strings])
           _APPEND_COMPILE_FLAGS_ERROR([-Wformat-security])
           _APPEND_COMPILE_FLAGS_ERROR([-floop-parallelize-all])
@@ -236,6 +310,7 @@ AC_DEFUN([_HARDEN_CXX_COMPILER_FLAGS],
                 [_APPEND_COMPILE_FLAGS_ERROR([-D_FORTIFY_SOURCE=2])
                 #_APPEND_COMPILE_FLAGS_ERROR([-Wstack-protector])
                 #_APPEND_COMPILE_FLAGS_ERROR([-fstack-protector])
+                #_APPEND_COMPILE_FLAGS_ERROR([--param=ssp-buffer-size=1])
                 _APPEND_COMPILE_FLAGS_ERROR([-fstack-protector-all])
                 ])])])])
 
index 686bff23aa9d5da071bd4180a2d8bc4cb9d67c04..c576bad5f082d703c11d41306aa19933c9c6dd39 100644 (file)
@@ -20,7 +20,7 @@
 #   and this notice are preserved. This file is offered as-is, without any
 #   warranty.
 
-#serial 4
+#serial 5
  
 AC_DEFUN([AX_LIBEVENT],
          [AC_PREREQ([2.63])dnl
@@ -28,15 +28,15 @@ AC_DEFUN([AX_LIBEVENT],
            [AX_SAVE_FLAGS
            LIBS="-levent $LIBS"
            AC_LANG_PUSH([C])
-           AC_RUN_IFELSE([AC_LANG_PROGRAM([
+           AC_RUN_IFELSE([AC_LANG_PROGRAM([[
 #include <sys/types.h>
 #include <sys/time.h>
 #include <stdlib.h>
 #include <event.h>
-               ],[
+               ]],[[
                struct event_base *tmp_event= event_init();
                event_base_free(tmp_event);
-               ])],
+               ]])],
              [ax_cv_libevent=yes],
              [ax_cv_libevent=no],
              [AC_MSG_WARN([test program execution failed])])
@@ -62,15 +62,15 @@ AC_DEFUN([AX_LIBEVENT2],
       [AX_SAVE_FLAGS
       LIBS="-levent $LIBS"
       AC_LANG_PUSH([C])
-      AC_RUN_IFELSE([AC_LANG_PROGRAM([
+      AC_RUN_IFELSE([AC_LANG_PROGRAM([[
 #include <sys/types.h>
 #include <sys/time.h>
 #include <stdlib.h>
 #include <event2/event.h>
-          ],[
-          struct event_base *tmp_event= event_init();
-          event_base_free(tmp_event);
-          ])],
+          ]],[[
+          struct event_base *___event_base= event_base_new();  
+          event_base_free(___event_base);
+          ]])],
         [ax_cv_libevent2=yes],
         [ax_cv_libevent2=no],
         [AC_MSG_WARN([test program execution failed])])
@@ -97,16 +97,18 @@ AC_DEFUN([AX_LIBEVENT2_EVHTTP],
       [AX_SAVE_FLAGS
       LIBS="-levent $LIBS"
       AC_LANG_PUSH([C])
-      AC_RUN_IFELSE([AC_LANG_PROGRAM([
+      AC_RUN_IFELSE([AC_LANG_PROGRAM([[
 #include <sys/types.h>
 #include <sys/time.h>
 #include <stdlib.h>
 #include <event2/event.h>
 #include <event2/http.h>
-          ],[
-          struct event_base *libbase= event_base_new();  
-          struct evhttp *libsrvr= evhttp_new(libbase);
-          ])],
+          ]],[[
+          struct event_base *___event_base= event_base_new();  
+          struct evhttp *___evhttp= evhttp_new(___event_base);
+          evhttp_free(___evhttp);
+          event_base_free(___event_base);
+          ]])],
         [ax_cv_libevent2_evhttp=yes],
         [ax_cv_libevent2_evhttp=no],
         [AC_MSG_WARN([test program execution failed])])
index d59244715f7e127af7812487c9d8bfe5a6b8f245..732773d743b933cff6629f25c47646f7cac9321b 100644 (file)
@@ -483,7 +483,7 @@ static test_return_t udp_get_test(memcached_st *memc)
   size_t vlen;
   Expected expected_ids;
   get_udp_request_ids(memc, expected_ids);
-  test_null(memcached_get(memc, test_literal_param("foo"), &vlen, (uint32_t)0, &rc));
+  test_null(memcached_get(memc, test_literal_param("foo"), &vlen, NULL, &rc));
   test_compare(MEMCACHED_NOT_SUPPORTED, rc);
 
   return post_udp_op_check(memc, expected_ids);