From: Monty Taylor Date: Wed, 13 May 2009 07:43:30 +0000 (+0200) Subject: Enabled warnings=errors for GCC and then made things compile. Had to turn off X-Git-Tag: 0.29~2 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=a91a68a7c685f82bc6f46c09fa2036e44a82e7f7;p=m6w6%2Flibmemcached Enabled warnings=errors for GCC and then made things compile. Had to turn off strict aliasing so we could type-pun the function pointers. I think there's a better solution there, but we're stricter than we were. --- diff --git a/clients/memstat.c b/clients/memstat.c index b8b02cfb..b3cc5851 100644 --- a/clients/memstat.c +++ b/clients/memstat.c @@ -135,9 +135,12 @@ static void run_analyzer(memcached_st *memc, memcached_stat_st *stat, if((servers[x]= memcached_create(NULL)) == NULL) { fprintf(stderr, "Failed to memcached_create()\n"); + if (x > 0) + memcached_free(servers[0]); x--; - for (; x >= 0; x--) + for (; x > 0; x--) memcached_free(servers[x]); + free(servers); return; } diff --git a/configure.ac b/configure.ac index 4ae1b722..ea06419f 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,17 @@ AC_INIT(clients/memcat.c) AC_CONFIG_AUX_DIR(config) AM_CONFIG_HEADER(libmemcached/libmemcached_config.h) -AC_CANONICAL_SYSTEM + +# Setting CFLAGS here prevents AC_CANONICAL_TARGET from injecting them +SAVE_CFLAGS=${CFLAGS} +SAVE_CXXFLAGS=${CXXFLAGS} +CFLAGS= +CXXFLAGS= + +AC_CANONICAL_TARGET + +CFLAGS=${SAVE_CFLAGS} +CXXFLAGS=${SAVE_CXXFLAGS} MEMCACHED_LIBRARY_NAME=libmemcached @@ -39,7 +49,7 @@ AC_SUBST(MEMCACHED_VERSION) VERSION=$MEMCACHED_RELEASE -AM_INIT_AUTOMAKE($PACKAGE, $VERSION, no-define) +AM_INIT_AUTOMAKE($PACKAG$, $VERSION, nostdinc no-define -Wall -Werror) AC_PROG_CC AC_PROG_CC_C99 @@ -55,6 +65,7 @@ AC_TYPE_SIZE_T AC_SEARCH_LIBS(getopt_long, gnugetopt) AC_SEARCH_LIBS(socket, socket) AC_SEARCH_LIBS(gethostbyname, nsl) +AC_SEARCH_LIBS(floorf, m) sinclude(config/pod2man.m4) sinclude(config/debug.m4) @@ -71,7 +82,7 @@ sinclude(config/util.m4) if test "$GCC" = "yes" then #CFLAGS="-W -std=iso9899:1999 -Wall -Wextra -Wstrict-aliasing -pedantic -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -O3 $CFLAGS" - CFLAGS="-Wall -O3 $CFLAGS" + CFLAGS="-W -Wall -Wextra -Wno-strict-aliasing -pedantic -Werror -O3 -ggdb $CFLAGS" if test "$ENABLE_DEBUG" = "yes" then @@ -87,6 +98,18 @@ else fi fi -LDFLAGS="-lm" + +AM_CPPFLAGS="${CPPFLAGS}" +AM_CFLAGS="${CFLAGS}" +AM_CXXFLAGS="${CXXFLAGS}" + +AC_SUBST([AM_CPPFLAGS]) +AC_SUBST([AM_CFLAGS]) +AC_SUBST([AM_CXXFLAGS]) + +dnl We've collected the flags in AM_*FLAGS now, so blank these. +CFLAGS="" +CXXFLAGS="" +CPPFLAGS="" AC_OUTPUT(Makefile clients/Makefile tests/Makefile docs/Makefile libmemcached/Makefile libmemcachedutil/Makefile support/Makefile support/libmemcached.pc support/libmemcached.spec support/libmemcached-fc.spec) diff --git a/libmemcached/Makefile.am b/libmemcached/Makefile.am index 772564cd..5763c06c 100644 --- a/libmemcached/Makefile.am +++ b/libmemcached/Makefile.am @@ -2,8 +2,7 @@ EXTRA_DIST = libmemcached_probes.d memcached/README.txt BUILT_SOURCES= @DTRACE_HEADER@ -INCLUDES = -I$(top_builddir) -LIBS = @LIBS@ +INCLUDES = -I$(top_builddir) -I$(top_srcdir) EXTRA_HEADERS = DTRACE = @DTRACE@ @@ -73,10 +72,10 @@ if BUILD_BYTEORDER libmemcached_la_SOURCES += byteorder.c endif -AM_CFLAGS = -DMEMCACHED_INTERNAL +DEFS += -DMEMCACHED_INTERNAL libmemcached_la_DEPENDENCIES = @DTRACE_OBJ@ libmemcached_la_LIBADD = @DTRACE_OBJ@ -libmemcached_la_LDFLAGS = -version-info $(MEMCACHED_LIBRARY_VERSION) +libmemcached_la_LDFLAGS = -version-info $(MEMCACHED_LIBRARY_VERSION) $(LIBM) dtrace_probes.h: libmemcached_probes.d $(DTRACE) $(DTRACEFLAGS) -o dtrace_probes.tmp -h -s libmemcached_probes.d diff --git a/libmemcached/common.h b/libmemcached/common.h index 5dc77a08..c8a1c601 100644 --- a/libmemcached/common.h +++ b/libmemcached/common.h @@ -5,6 +5,8 @@ #ifndef __COMMON_H__ #define __COMMON_H__ +#include "libmemcached_config.h" + #include #include #include @@ -22,6 +24,12 @@ #include #include + +#include +#include "memcached_io.h" + +#include "memcached/protocol_binary.h" + #ifdef TIME_WITH_SYS_TIME # include # include @@ -35,12 +43,6 @@ -#include -#include "memcached_io.h" - -#include "memcached/protocol_binary.h" -#include "libmemcached_config.h" - #if !defined(__GNUC__) || (__GNUC__ == 2 && __GNUC_MINOR__ < 96) #define likely(x) if((x)) diff --git a/libmemcached/memcached_analyze.c b/libmemcached/memcached_analyze.c index 6e5f54e7..1063fb27 100644 --- a/libmemcached/memcached_analyze.c +++ b/libmemcached/memcached_analyze.c @@ -27,7 +27,7 @@ static void calc_least_free_node(memcached_analysis_st *result, const long max_allowed_bytes, const long used_bytes) { - long remaining_bytes= max_allowed_bytes - used_bytes; + uint64_t remaining_bytes= (uint64_t)max_allowed_bytes - used_bytes; if (result->least_remaining_bytes == 0 || remaining_bytes < result->least_remaining_bytes) diff --git a/libmemcached/memcached_callback.c b/libmemcached/memcached_callback.c index bcae1a72..de792d0e 100644 --- a/libmemcached/memcached_callback.c +++ b/libmemcached/memcached_callback.c @@ -52,43 +52,43 @@ memcached_return memcached_callback_set(memcached_st *ptr, } case MEMCACHED_CALLBACK_CLEANUP_FUNCTION: { - memcached_cleanup_func func= (memcached_cleanup_func)data; + memcached_cleanup_func func= *(memcached_cleanup_func *)&data; ptr->on_cleanup= func; break; } case MEMCACHED_CALLBACK_CLONE_FUNCTION: { - memcached_clone_func func= (memcached_clone_func)data; + memcached_clone_func func= *(memcached_clone_func *)&data; ptr->on_clone= func; break; } case MEMCACHED_CALLBACK_MALLOC_FUNCTION: { - memcached_malloc_function func= (memcached_malloc_function)data; + memcached_malloc_function func= *(memcached_malloc_function *)&data; ptr->call_malloc= func; break; } case MEMCACHED_CALLBACK_REALLOC_FUNCTION: { - memcached_realloc_function func= (memcached_realloc_function)data; + memcached_realloc_function func= *(memcached_realloc_function *)&data; ptr->call_realloc= func; break; } case MEMCACHED_CALLBACK_FREE_FUNCTION: { - memcached_free_function func= (memcached_free_function)data; + memcached_free_function func= *(memcached_free_function *)&data; ptr->call_free= func; break; } case MEMCACHED_CALLBACK_GET_FAILURE: { - memcached_trigger_key func= (memcached_trigger_key)data; + memcached_trigger_key func= *(memcached_trigger_key *)&data; ptr->get_key_failure= func; break; } case MEMCACHED_CALLBACK_DELETE_TRIGGER: { - memcached_trigger_delete_key func= (memcached_trigger_delete_key)data; + memcached_trigger_delete_key func= *(memcached_trigger_delete_key *)&data; ptr->delete_trigger= func; break; } @@ -104,6 +104,7 @@ void *memcached_callback_get(memcached_st *ptr, memcached_return *error) { memcached_return local_error; + if (!error) error = &local_error; @@ -130,37 +131,37 @@ void *memcached_callback_get(memcached_st *ptr, case MEMCACHED_CALLBACK_CLEANUP_FUNCTION: { *error= ptr->on_cleanup ? MEMCACHED_SUCCESS : MEMCACHED_FAILURE; - return (void *)ptr->on_cleanup; + return *(void **)&ptr->on_cleanup; } case MEMCACHED_CALLBACK_CLONE_FUNCTION: { *error= ptr->on_clone ? MEMCACHED_SUCCESS : MEMCACHED_FAILURE; - return (void *)ptr->on_clone; + return *(void **)&ptr->on_clone; } case MEMCACHED_CALLBACK_MALLOC_FUNCTION: { *error= ptr->call_malloc ? MEMCACHED_SUCCESS : MEMCACHED_FAILURE; - return (void *)ptr->call_malloc; + return *(void **)&ptr->call_malloc; } case MEMCACHED_CALLBACK_REALLOC_FUNCTION: { *error= ptr->call_realloc ? MEMCACHED_SUCCESS : MEMCACHED_FAILURE; - return (void *)ptr->call_realloc; + return *(void **)&ptr->call_realloc; } case MEMCACHED_CALLBACK_FREE_FUNCTION: { *error= ptr->call_free ? MEMCACHED_SUCCESS : MEMCACHED_FAILURE; - return (void *)ptr->call_free; + return *(void **)&ptr->call_free; } case MEMCACHED_CALLBACK_GET_FAILURE: { *error= ptr->get_key_failure ? MEMCACHED_SUCCESS : MEMCACHED_FAILURE; - return (void *)ptr->get_key_failure; + return *(void **)&ptr->get_key_failure; } case MEMCACHED_CALLBACK_DELETE_TRIGGER: { *error= ptr->delete_trigger ? MEMCACHED_SUCCESS : MEMCACHED_FAILURE; - return (void *)ptr->delete_trigger; + return *(void **)&ptr->delete_trigger; } default: WATCHPOINT_ASSERT(0); diff --git a/libmemcached/memcached_connect.c b/libmemcached/memcached_connect.c index fb79c80a..e9ae0c76 100644 --- a/libmemcached/memcached_connect.c +++ b/libmemcached/memcached_connect.c @@ -234,7 +234,9 @@ static memcached_return network_connect(memcached_server_st *ptr) if (errno == EINPROGRESS || /* nonblocking mode - first return, */ errno == EALREADY) /* nonblocking mode - subsequent returns */ { - struct pollfd fds[1] = { [0].fd = ptr->fd, [0].events = POLLOUT }; + struct pollfd fds[1]; + fds[0].fd = ptr->fd; + fds[0].events = POLLOUT; int error= poll(fds, 1, ptr->root->connect_timeout); if (error != 1 || fds[0].revents & POLLERR) @@ -242,7 +244,7 @@ static memcached_return network_connect(memcached_server_st *ptr) if (fds[0].revents & POLLERR) { int err; - int len = sizeof (err); + socklen_t len = sizeof (err); (void)getsockopt(ptr->fd, SOL_SOCKET, SO_ERROR, &err, &len); ptr->cached_errno= (err == 0) ? errno : err; } diff --git a/libmemcached/memcached_flush_buffers.c b/libmemcached/memcached_flush_buffers.c index f955dbe6..bbf09549 100644 --- a/libmemcached/memcached_flush_buffers.c +++ b/libmemcached/memcached_flush_buffers.c @@ -5,7 +5,7 @@ memcached_return memcached_flush_buffers(memcached_st *mem) { memcached_return ret= MEMCACHED_SUCCESS; - for (int x= 0; x < mem->number_of_hosts; ++x) + for (uint32_t x= 0; x < mem->number_of_hosts; ++x) if (mem->hosts[x].write_buffer_offset != 0) { if (mem->hosts[x].fd == -1 && diff --git a/libmemcached/memcached_get.c b/libmemcached/memcached_get.c index eb6877d7..9a33fc69 100644 --- a/libmemcached/memcached_get.c +++ b/libmemcached/memcached_get.c @@ -125,7 +125,7 @@ memcached_return memcached_mget_by_key(memcached_st *ptr, memcached_return rc= MEMCACHED_NOTFOUND; char *get_command= "get "; uint8_t get_command_length= 4; - unsigned int master_server_key; /* 0 is a valid server id! */ + unsigned int master_server_key= (unsigned int)-1; /* 0 is a valid server id! */ bool is_master_key_set= false; if (ptr->flags & MEM_USE_UDP) diff --git a/libmemcached/memcached_hash.c b/libmemcached/memcached_hash.c index 0527733a..e6747db5 100644 --- a/libmemcached/memcached_hash.c +++ b/libmemcached/memcached_hash.c @@ -1,5 +1,6 @@ #include "common.h" + /* Defines */ static uint64_t FNV_64_INIT= 0xcbf29ce484222325LL; static uint64_t FNV_64_PRIME= 0x100000001b3LL; @@ -74,13 +75,13 @@ uint32_t memcached_generate_hash_value(const char *key, size_t key_length, memca } } break; -#ifdef HAVE_HSIEH_HASH case MEMCACHED_HASH_HSIEH: { +#ifdef HAVE_HSIEH_HASH hash= hsieh_hash(key, key_length); +#endif break; } -#endif case MEMCACHED_HASH_MURMUR: { hash= murmur_hash(key, key_length); diff --git a/libmemcached/memcached_hosts.c b/libmemcached/memcached_hosts.c index c8e15c4c..88256aed 100644 --- a/libmemcached/memcached_hosts.c +++ b/libmemcached/memcached_hosts.c @@ -220,7 +220,7 @@ memcached_return update_continuum(memcached_st *ptr) if (is_ketama_weighted) { - int i; + unsigned int i; for (i = 0; i < pointer_per_hash; i++) { value= ketama_server_hash(sort_host, sort_host_length, i); diff --git a/libmemcached/memcached_io.c b/libmemcached/memcached_io.c index 00b50502..3566dd2c 100644 --- a/libmemcached/memcached_io.c +++ b/libmemcached/memcached_io.c @@ -228,7 +228,9 @@ ssize_t memcached_io_write(memcached_server_st *ptr, /* If io_flush calls memcached_purge, sent_length may be 0 */ if (sent_length != 0) + { WATCHPOINT_ASSERT(sent_length == buffer_end); + } } } @@ -278,9 +280,11 @@ memcached_server_st *memcached_io_get_readable_server(memcached_st *memc) { #define MAX_SERVERS_TO_POLL 100 struct pollfd fds[MAX_SERVERS_TO_POLL]; - int index= 0; + unsigned int index= 0; - for (int x= 0; x< memc->number_of_hosts && index < MAX_SERVERS_TO_POLL; ++x) + for (unsigned int x= 0; + x< memc->number_of_hosts && index < MAX_SERVERS_TO_POLL; + ++x) { if (memc->hosts[x].read_buffer_length > 0) /* I have data in the buffer */ return &memc->hosts[x]; @@ -297,7 +301,7 @@ memcached_server_st *memcached_io_get_readable_server(memcached_st *memc) if (index < 2) { /* We have 0 or 1 server with pending events.. */ - for (int x= 0; x< memc->number_of_hosts; ++x) + for (unsigned int x= 0; x< memc->number_of_hosts; ++x) if (memcached_server_response_count(&memc->hosts[x]) > 0) return &memc->hosts[x]; @@ -312,9 +316,9 @@ memcached_server_st *memcached_io_get_readable_server(memcached_st *memc) case 0: break; default: - for (int x= 0; x < index; ++x) + for (unsigned int x= 0; x < index; ++x) if (fds[x].revents & POLLIN) - for (int y= 0; y < memc->number_of_hosts; ++y) + for (unsigned int y= 0; y < memc->number_of_hosts; ++y) if (memc->hosts[y].fd == fds[x].fd) return &memc->hosts[y]; } @@ -397,7 +401,8 @@ static ssize_t io_flush(memcached_server_st *ptr, } } - if (ptr->type == MEMCACHED_CONNECTION_UDP && sent_length != write_length) + if (ptr->type == MEMCACHED_CONNECTION_UDP && + (size_t)sent_length != write_length) { memcached_quit_server(ptr, 1); return -1; @@ -462,7 +467,7 @@ memcached_return memcached_io_readline(memcached_server_st *ptr, size_t size) { bool line_complete= false; - int total_nr= 0; + size_t total_nr= 0; while (!line_complete) { diff --git a/libmemcached/memcached_purge.c b/libmemcached/memcached_purge.c index 96bf1d27..624f6245 100644 --- a/libmemcached/memcached_purge.c +++ b/libmemcached/memcached_purge.c @@ -30,7 +30,7 @@ memcached_return memcached_purge(memcached_server_st *ptr) } WATCHPOINT_ASSERT(ptr->fd != -1); - int no_msg= memcached_server_response_count(ptr) - 1; + uint32_t no_msg= memcached_server_response_count(ptr) - 1; if (no_msg > 0) { memcached_result_st result; diff --git a/libmemcached/memcached_response.c b/libmemcached/memcached_response.c index 845052db..193bfd8c 100644 --- a/libmemcached/memcached_response.c +++ b/libmemcached/memcached_response.c @@ -179,7 +179,7 @@ static memcached_return textual_value_fetch(memcached_server_st *ptr, if (rrc != MEMCACHED_SUCCESS) return rrc; - if (read_length != (size_t)(value_length + 2)) + if (read_length != (ssize_t)(value_length + 2)) { goto read_error; } diff --git a/libmemcachedutil/memcached_pool.c b/libmemcachedutil/memcached_pool.c index 766375f1..83326b61 100644 --- a/libmemcachedutil/memcached_pool.c +++ b/libmemcachedutil/memcached_pool.c @@ -79,7 +79,7 @@ memcached_pool_st *memcached_pool_create(memcached_st* mmc, /* Try to create the initial size of the pool. An allocation failure at * this time is not fatal.. */ - for (int ii=0; ii < initial; ++ii) + for (unsigned int ii=0; ii < initial; ++ii) if (grow_pool(ret) == -1) break; } diff --git a/tests/Makefile.am b/tests/Makefile.am index d085faf8..133ec6d0 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -5,7 +5,6 @@ if BUILD_LIBMEMCACHEDUTIL LDADDS+= $(top_builddir)/libmemcachedutil/libmemcachedutil.la endif - EXTRA_DIST = output.res output2.res\ r/memcat.res\ r/memcp.res\ diff --git a/tests/function.c b/tests/function.c index 83702221..f6bbf59c 100644 --- a/tests/function.c +++ b/tests/function.c @@ -746,6 +746,7 @@ static test_return read_through(memcached_st *memc) char *string; size_t string_length; uint32_t flags; + memcached_trigger_key cb= (memcached_trigger_key)read_through_trigger; string= memcached_get(memc, key, strlen(key), &string_length, &flags, &rc); @@ -754,7 +755,8 @@ static test_return read_through(memcached_st *memc) assert(string_length == 0); assert(!string); - rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_GET_FAILURE, (void *)read_through_trigger); + rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_GET_FAILURE, + *(void **)&cb); assert(rc == MEMCACHED_SUCCESS); string= memcached_get(memc, key, strlen(key), @@ -790,9 +792,9 @@ static test_return delete_through(memcached_st *memc) memcached_trigger_delete_key callback; memcached_return rc; - callback= delete_trigger; + callback= (memcached_trigger_delete_key)delete_trigger; - rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_DELETE_TRIGGER, (void*)callback); + rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_DELETE_TRIGGER, *(void**)&callback); assert(rc == MEMCACHED_SUCCESS); return 0; @@ -1458,24 +1460,31 @@ static test_return callback_test(memcached_st *memc) /* Test Clone Callback */ { - memcached_clone_func temp_function; + memcached_clone_func clone_cb= (memcached_clone_func)clone_test_callback; + void *clone_cb_ptr= *(void **)&clone_cb; + void *temp_function= NULL; memcached_return rc; - rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_CLONE_FUNCTION, (void*)clone_test_callback); + rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_CLONE_FUNCTION, + clone_cb_ptr); assert(rc == MEMCACHED_SUCCESS); - temp_function= (memcached_clone_func)memcached_callback_get(memc, MEMCACHED_CALLBACK_CLONE_FUNCTION, &rc); - assert(temp_function == clone_test_callback); + temp_function= memcached_callback_get(memc, MEMCACHED_CALLBACK_CLONE_FUNCTION, &rc); + assert(temp_function == clone_cb_ptr); } /* Test Cleanup Callback */ { - memcached_cleanup_func temp_function; + memcached_cleanup_func cleanup_cb= + (memcached_cleanup_func)cleanup_test_callback; + void *cleanup_cb_ptr= *(void **)&cleanup_cb; + void *temp_function= NULL; memcached_return rc; - rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_CLONE_FUNCTION, (void*)cleanup_test_callback); + rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_CLONE_FUNCTION, + cleanup_cb_ptr); assert(rc == MEMCACHED_SUCCESS); - temp_function= (memcached_cleanup_func)memcached_callback_get(memc, MEMCACHED_CALLBACK_CLONE_FUNCTION, &rc); - assert(temp_function == cleanup_test_callback); + temp_function= memcached_callback_get(memc, MEMCACHED_CALLBACK_CLONE_FUNCTION, &rc); + assert(temp_function == cleanup_cb_ptr); } return 0; @@ -2416,6 +2425,8 @@ test_return user_supplied_bug18(memcached_st *trash) test_return auto_eject_hosts(memcached_st *trash) { + (void) trash; + memcached_return rc; memcached_st *memc= memcached_create(NULL); assert(memc); @@ -2830,13 +2841,6 @@ static test_return delete_buffer_generate(memcached_st *memc) return 0; } -static test_return free_data(memcached_st *memc __attribute__((unused))) -{ - pairs_free(global_pairs); - - return 0; -} - static test_return add_host_test1(memcached_st *memc) { unsigned int x; @@ -2934,6 +2938,7 @@ static memcached_return pre_hsieh(memcached_st *memc) memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_HSIEH); return MEMCACHED_SUCCESS; #else + (void) memc; return MEMCACHED_FAILURE; #endif } @@ -3105,37 +3110,45 @@ static memcached_return set_prefix(memcached_st *memc) static memcached_return set_memory_alloc(memcached_st *memc) { + void *test_ptr= NULL; + void *cb_ptr= NULL; { - memcached_malloc_function test_ptr; + memcached_malloc_function malloc_cb= + (memcached_malloc_function)my_malloc; + cb_ptr= *(void **)&malloc_cb; memcached_return rc; - rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_MALLOC_FUNCTION, (void*)&my_malloc); + rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_MALLOC_FUNCTION, cb_ptr); assert(rc == MEMCACHED_SUCCESS); - test_ptr= (memcached_malloc_function)memcached_callback_get(memc, MEMCACHED_CALLBACK_MALLOC_FUNCTION, &rc); + test_ptr= memcached_callback_get(memc, MEMCACHED_CALLBACK_MALLOC_FUNCTION, &rc); assert(rc == MEMCACHED_SUCCESS); - assert(test_ptr == my_malloc); + assert(test_ptr == cb_ptr); } { - memcached_realloc_function test_ptr; + memcached_realloc_function realloc_cb= + (memcached_realloc_function)my_realloc; + cb_ptr= *(void **)&realloc_cb; memcached_return rc; - rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_REALLOC_FUNCTION, (void*)&my_realloc); + rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_REALLOC_FUNCTION, cb_ptr); assert(rc == MEMCACHED_SUCCESS); - test_ptr= (memcached_realloc_function)memcached_callback_get(memc, MEMCACHED_CALLBACK_REALLOC_FUNCTION, &rc); + test_ptr= memcached_callback_get(memc, MEMCACHED_CALLBACK_REALLOC_FUNCTION, &rc); assert(rc == MEMCACHED_SUCCESS); - assert(test_ptr == my_realloc); + assert(test_ptr == cb_ptr); } { - memcached_free_function test_ptr; + memcached_free_function free_cb= + (memcached_free_function)my_free; + cb_ptr= *(void **)&free_cb; memcached_return rc; - rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_FREE_FUNCTION, (void*)my_free); + rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_FREE_FUNCTION, cb_ptr); assert(rc == MEMCACHED_SUCCESS); - test_ptr= (memcached_free_function)memcached_callback_get(memc, MEMCACHED_CALLBACK_FREE_FUNCTION, &rc); + test_ptr= memcached_callback_get(memc, MEMCACHED_CALLBACK_FREE_FUNCTION, &rc); assert(rc == MEMCACHED_SUCCESS); - assert(test_ptr == my_free); + assert(test_ptr == cb_ptr); } return MEMCACHED_SUCCESS; @@ -3281,7 +3294,7 @@ static test_return noreply_test(memcached_st *memc) ** way it is supposed to do!!!! */ int no_msg=0; - for (int x=0; x < memc->number_of_hosts; ++x) + for (uint32_t x=0; x < memc->number_of_hosts; ++x) no_msg+=memc->hosts[x].cursor_active; assert(no_msg == 0); @@ -3384,6 +3397,7 @@ static void* connection_release(void *arg) { usleep(250); assert(memcached_pool_push(resource->pool, resource->mmc) == MEMCACHED_SUCCESS); + return arg; } static test_return connection_pool_test(memcached_st *memc) @@ -3419,7 +3433,7 @@ static test_return connection_pool_test(memcached_st *memc) rc= memcached_set(mmc[0], key, keylen, "0", 1, 0, 0); assert(rc == MEMCACHED_SUCCESS); - for (int x= 0; x < 10; ++x) { + for (unsigned int x= 0; x < 10; ++x) { uint64_t number_value; rc= memcached_increment(mmc[x], key, keylen, 1, &number_value); assert(rc == MEMCACHED_SUCCESS); @@ -3809,6 +3823,9 @@ test_st tests[] ={ {"server_sort", 0, server_sort_test}, {"server_sort2", 0, server_sort2_test}, {"clone_test", 0, clone_test }, + {"connection_test", 0, connection_test}, + {"callback_test", 0, callback_test}, + {"behavior_test", 0, behavior_test}, {"error", 0, error_test }, {"set", 0, set_test }, {"set2", 0, set_test2 },