Remove dead m4, and make sure that the sort buffer is always large enough to handle...
authorBrian Aker <brian@tangent.org>
Sun, 8 Jan 2012 06:52:16 +0000 (22:52 -0800)
committerBrian Aker <brian@tangent.org>
Sun, 8 Jan 2012 06:52:16 +0000 (22:52 -0800)
libmemcached-1.0/struct/server.h
libmemcached/hosts.cc
m4/pandora_canonical.m4
m4/pandora_cxx_demangle.m4 [deleted file]
m4/pandora_have_libdl.m4 [deleted file]
m4/pandora_run_cpplint.m4 [deleted file]

index 183b37393226afb9629eea876a68d08782a4b577..245b4b9bbf6964703a24c055f6d948834d02d2ab 100644 (file)
 #define MEMCACHED_NI_MAXHOST 1025
 #endif
 
+#ifdef NI_MAXSERV
+#define MEMCACHED_NI_MAXSERV NI_MAXSERV
+#else
+#define MEMCACHED_NI_MAXSERV 32
+#endif
+
 enum memcached_server_state_t {
   MEMCACHED_SERVER_STATE_NEW, // fd == -1, no address lookup has been done
   MEMCACHED_SERVER_STATE_ADDRINFO, // ADDRRESS information has been gathered
index 410b38ff1496d4a63e0400dca63754a5bdabf3e8..337a999aa91c2f397fac641c7a69eaf3fcd22db5 100644 (file)
@@ -236,21 +236,21 @@ static memcached_return_t update_continuum(memcached_st *ptr)
            pointer_index < pointer_per_server / pointer_per_hash;
            pointer_index++)
       {
-        char sort_host[MEMCACHED_MAX_HOST_SORT_LENGTH]= "";
+        char sort_host[1 +MEMCACHED_NI_MAXHOST +1 +MEMCACHED_NI_MAXSERV +1 + MEMCACHED_NI_MAXSERV ]= "";
         int sort_host_length;
 
         // Spymemcached ketema key format is: hostname/ip:port-index
         // If hostname is not available then: /ip:port-index
-        sort_host_length= snprintf(sort_host, MEMCACHED_MAX_HOST_SORT_LENGTH,
+        sort_host_length= snprintf(sort_host, sizeof(sort_host),
                                    "/%s:%u-%u",
                                    list[host_index].hostname,
                                    (uint32_t)list[host_index].port,
                                    pointer_index);
 
-        if (sort_host_length >= MEMCACHED_MAX_HOST_SORT_LENGTH || sort_host_length < 0)
+        if (size_t(sort_host_length) >= sizeof(sort_host) or sort_host_length < 0)
         {
           return memcached_set_error(*ptr, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT, 
-                                     memcached_literal_param("snprintf(MEMCACHED_DEFAULT_COMMAND_SIZE)"));
+                                     memcached_literal_param("snprintf(sizeof(sort_host))"));
         }
 
         if (DEBUG)
@@ -281,29 +281,29 @@ static memcached_return_t update_continuum(memcached_st *ptr)
            pointer_index <= pointer_per_server / pointer_per_hash;
            pointer_index++)
       {
-        char sort_host[MEMCACHED_MAX_HOST_SORT_LENGTH]= "";
+        char sort_host[MEMCACHED_NI_MAXHOST +1 +MEMCACHED_NI_MAXSERV +1 +MEMCACHED_NI_MAXSERV]= "";
         int sort_host_length;
 
         if (list[host_index].port == MEMCACHED_DEFAULT_PORT)
         {
-          sort_host_length= snprintf(sort_host, MEMCACHED_MAX_HOST_SORT_LENGTH,
+          sort_host_length= snprintf(sort_host, sizeof(sort_host),
                                      "%s-%u",
                                      list[host_index].hostname,
                                      pointer_index - 1);
         }
         else
         {
-          sort_host_length= snprintf(sort_host, MEMCACHED_MAX_HOST_SORT_LENGTH,
+          sort_host_length= snprintf(sort_host, sizeof(sort_host),
                                      "%s:%u-%u",
                                      list[host_index].hostname,
                                      (uint32_t)list[host_index].port,
                                      pointer_index - 1);
         }
 
-        if (sort_host_length >= MEMCACHED_MAX_HOST_SORT_LENGTH || sort_host_length < 0)
+        if (size_t(sort_host_length) >= sizeof(sort_host) or sort_host_length < 0)
         {
           return memcached_set_error(*ptr, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT, 
-                                     memcached_literal_param("snprintf(MEMCACHED_DEFAULT_COMMAND_SIZE)"));
+                                     memcached_literal_param("snprintf(sizeof(sort_host)))"));
         }
 
         if (is_ketama_weighted)
index e876a8fa77bea1cdcf60a1147d3859597125f95c..b7da1ac38b8cf586378913fd25fff023f66d5882 100644 (file)
@@ -171,25 +171,6 @@ AC_DEFUN([PANDORA_CANONICAL_TARGET],[
     AC_DEFINE([TIME_T_UNSIGNED], 1, [Define to 1 if time_t is unsigned])
   ])
 
-  AC_CACHE_CHECK([if system defines RUSAGE_THREAD], [ac_cv_rusage_thread],[
-  AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
-      [[
-#include <sys/time.h>
-#include <sys/resource.h>
-      ]],[[
-      int x= RUSAGE_THREAD;
-      ]])
-    ],[
-      ac_cv_rusage_thread=yes
-    ],[
-      ac_cv_rusage_thread=no
-    ])
-  ])
-  AS_IF([test "$ac_cv_rusage_thread" = "no"],[
-    AC_DEFINE([RUSAGE_THREAD], [RUSAGE_SELF],
-      [Define if system doesn't define])
-  ])
-
   AC_CHECK_FUNC(setsockopt, [], [AC_CHECK_LIB(socket, setsockopt)])
   AC_CHECK_FUNC(bind, [], [AC_CHECK_LIB(bind, bind)])
 
diff --git a/m4/pandora_cxx_demangle.m4 b/m4/pandora_cxx_demangle.m4
deleted file mode 100644 (file)
index 5ae6687..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-dnl  Copyright (C) 2009 Sun Microsystems, Inc.
-dnl This file is free software; Sun Microsystems, Inc.
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-
-dnl Check for all of the headers and libs that Drizzle needs. We check all
-dnl of these for plugins too, to ensure that all of the appropriate defines
-dnl are set.
-
-AC_DEFUN([PANDORA_CXX_DEMANGLE],[
-  AC_LANG_PUSH([C++])
-  save_CXXFLAGS="${CXXFLAGS}"
-  CXXFLAGS="${CXX_STANDARD} ${CXXFLAGS}"
-  AC_CHECK_HEADERS(cxxabi.h)
-  AC_CACHE_CHECK([checking for abi::__cxa_demangle], pandora_cv_cxa_demangle,
-  [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <cxxabi.h>]], [[
-    char *foo= 0; int bar= 0;
-    foo= abi::__cxa_demangle(foo, foo, 0, &bar);
-  ]])],[pandora_cv_cxa_demangle=yes],[pandora_cv_cxa_demangle=no])])
-  CXXFLAGS="${save_CXXFLAGS}"
-  AC_LANG_POP()
-
-  AS_IF([test "x$pandora_cv_cxa_demangle" = xyes],[
-    AC_DEFINE(HAVE_ABI_CXA_DEMANGLE, 1,
-              [Define to 1 if you have the `abi::__cxa_demangle' function.])
-  ])
-])
diff --git a/m4/pandora_have_libdl.m4 b/m4/pandora_have_libdl.m4
deleted file mode 100644 (file)
index dde7163..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-dnl  Copyright (C) 2009 Sun Microsystems, Inc.
-dnl This file is free software; Sun Microsystems, Inc.
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-
-#--------------------------------------------------------------------
-# Check for libdl
-#--------------------------------------------------------------------
-
-
-AC_DEFUN([_PANDORA_SEARCH_LIBDL],[
-
-  save_LIBS="$LIBS"
-  LIBS=""
-  AC_CHECK_LIB(dl,dlopen)
-  AC_CHECK_FUNCS(dlopen)
-  LIBDL_LIBS="$LIBS"
-  LIBS="${save_LIBS}"
-  AC_SUBST(LIBDL_LIBS)
-
-  AM_CONDITIONAL(HAVE_LIBDL, [test "x${ac_cv_func_dlopen}" = "xyes"])
-])
-
-AC_DEFUN([_PANDORA_HAVE_LIBDL],[
-
-  AC_ARG_ENABLE([libdl],
-    [AS_HELP_STRING([--disable-libdl],
-      [Build with libdl support @<:@default=on@:>@])],
-    [ac_enable_libdl="$enableval"],
-    [ac_enable_libdl="yes"])
-
-  _PANDORA_SEARCH_LIBDL
-])
-
-
-AC_DEFUN([PANDORA_HAVE_LIBDL],[
-  AC_REQUIRE([_PANDORA_HAVE_LIBDL])
-])
-
-AC_DEFUN([_PANDORA_REQUIRE_LIBDL],[
-  ac_enable_libdl="yes"
-  _PANDORA_SEARCH_LIBDL
-
-  AS_IF([test "$ac_cv_func_dlopen" != "yes"],[
-    AC_MSG_ERROR([libdl/dlopen() is required for ${PACKAGE}. On Debian this can be found in libc6-dev. On RedHat this can be found in glibc-devel.])
-  ])
-])
-
-AC_DEFUN([PANDORA_REQUIRE_LIBDL],[
-  AC_REQUIRE([_PANDORA_REQUIRE_LIBDL])
-])
diff --git a/m4/pandora_run_cpplint.m4 b/m4/pandora_run_cpplint.m4
deleted file mode 100644 (file)
index 6d3e952..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-dnl  Copyright (C) 2009 Sun Microsystems, Inc.
-dnl This file is free software; Sun Microsystems, Inc.
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-
-AC_DEFUN([PANDORA_RUN_CPPLINT],[
-  m4_syscmd([python config/make-lint.py])
-])