From: Brian Aker Date: Tue, 19 Aug 2008 17:58:25 +0000 (-0700) Subject: Turned up warnings in code X-Git-Tag: 0.23~10 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=4c88db14024912f86c1628f6bd8a05f9a6c5559b;p=awesomized%2Flibmemcached Turned up warnings in code --- diff --git a/configure.ac b/configure.ac index 3118870a..43e64257 100644 --- a/configure.ac +++ b/configure.ac @@ -60,9 +60,9 @@ if test "$GCC" = "yes" then if test "$ENABLE_DEBUG" = "yes" then - CFLAGS="-Wall -ggdb -DMEMCACHED_INTERNAL -DHAVE_DEBUG $CFLAGS" + CFLAGS="-W -Wall -Wextra -Wstrict-aliasing -pedantic -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -03 -ggdb -DMEMCACHED_INTERNAL -DHAVE_DEBUG $CFLAGS" else - CFLAGS="-Wall -O3 -DMEMCACHED_INTERNAL $CFLAGS" + CFLAGS="-W -Wall -Wextra -Wstrict-aliasing -pedantic -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -O3 -DMEMCACHED_INTERNAL $CFLAGS" fi else CFLAGS="-Xa -xstrconst -mt -D_FORTEC_ $CFLAGS" diff --git a/libmemcached/common.h b/libmemcached/common.h index 5993e57c..3ad6c3d8 100644 --- a/libmemcached/common.h +++ b/libmemcached/common.h @@ -22,11 +22,11 @@ #include #include -#if TIME_WITH_SYS_TIME +#ifdef TIME_WITH_SYS_TIME # include # include #else -# if HAVE_SYS_TIME_H +# ifdef HAVE_SYS_TIME_H # include # else # include @@ -81,7 +81,7 @@ typedef enum { MEM_VERIFY_KEY= (1 << 10), /* 11 used for weighted ketama */ MEM_KETAMA_WEIGHTED= (1 << 11), - MEM_BINARY_PROTOCOL= (1 << 12), + MEM_BINARY_PROTOCOL= (1 << 12) } memcached_flags; /* Hashing algo */ diff --git a/libmemcached/libmemcached_probes.h b/libmemcached/libmemcached_probes.h index cf59cc59..2c8114be 100644 --- a/libmemcached/libmemcached_probes.h +++ b/libmemcached/libmemcached_probes.h @@ -11,7 +11,8 @@ extern "C" { #endif -#if _DTRACE_VERSION + +#ifdef _DTRACE_VERSION #define LIBMEMCACHED_MEMCACHED_ADD_END() \ __dtrace_libmemcached___memcached_add_end() diff --git a/libmemcached/memcached/protocol_binary.h b/libmemcached/memcached/protocol_binary.h index 9d225144..e4ef3500 100644 --- a/libmemcached/memcached/protocol_binary.h +++ b/libmemcached/memcached/protocol_binary.h @@ -54,7 +54,7 @@ extern "C" */ typedef enum { PROTOCOL_BINARY_REQ = 0x80, - PROTOCOL_BINARY_RES = 0x81, + PROTOCOL_BINARY_RES = 0x81 } protocol_binary_magic; /** @@ -69,7 +69,7 @@ extern "C" PROTOCOL_BINARY_RESPONSE_EINVAL = 0x04, PROTOCOL_BINARY_RESPONSE_NOT_STORED = 0x05, PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND = 0x81, - PROTOCOL_BINARY_RESPONSE_ENOMEM = 0x82, + PROTOCOL_BINARY_RESPONSE_ENOMEM = 0x82 } protocol_binary_response_status; /** @@ -93,7 +93,7 @@ extern "C" PROTOCOL_BINARY_CMD_GETKQ = 0x0d, PROTOCOL_BINARY_CMD_APPEND = 0x0e, PROTOCOL_BINARY_CMD_PREPEND = 0x0f, - PROTOCOL_BINARY_CMD_STAT = 0x10, + PROTOCOL_BINARY_CMD_STAT = 0x10 } protocol_binary_command; /** @@ -101,7 +101,7 @@ extern "C" * See section 3.4 Data Types */ typedef enum { - PROTOCOL_BINARY_RAW_BYTES = 0x00, + PROTOCOL_BINARY_RAW_BYTES = 0x00 } protocol_binary_datatypes; /** diff --git a/libmemcached/memcached_constants.h b/libmemcached/memcached_constants.h index ca1640f0..ab640421 100644 --- a/libmemcached/memcached_constants.h +++ b/libmemcached/memcached_constants.h @@ -60,13 +60,13 @@ typedef enum { MEMCACHED_TIMEOUT, MEMCACHED_BUFFERED, MEMCACHED_BAD_KEY_PROVIDED, - MEMCACHED_MAXIMUM_RETURN, /* Always add new error code before */ + MEMCACHED_MAXIMUM_RETURN /* Always add new error code before */ } memcached_return; typedef enum { MEMCACHED_DISTRIBUTION_MODULA, MEMCACHED_DISTRIBUTION_CONSISTENT, - MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA, + MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA } memcached_server_distribution; typedef enum { @@ -91,7 +91,7 @@ typedef enum { MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, MEMCACHED_BEHAVIOR_SND_TIMEOUT, MEMCACHED_BEHAVIOR_RCV_TIMEOUT, - MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT, + MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT } memcached_behavior; typedef enum { @@ -103,7 +103,7 @@ typedef enum { MEMCACHED_CALLBACK_REALLOC_FUNCTION, MEMCACHED_CALLBACK_FREE_FUNCTION, MEMCACHED_CALLBACK_GET_FAILURE, - MEMCACHED_CALLBACK_DELETE_TRIGGER, + MEMCACHED_CALLBACK_DELETE_TRIGGER } memcached_callback; typedef enum { @@ -115,20 +115,20 @@ typedef enum { MEMCACHED_HASH_FNV1_32, MEMCACHED_HASH_FNV1A_32, MEMCACHED_HASH_HSIEH, - MEMCACHED_HASH_MURMUR, + MEMCACHED_HASH_MURMUR } memcached_hash; typedef enum { MEMCACHED_CONNECTION_UNKNOWN, MEMCACHED_CONNECTION_TCP, MEMCACHED_CONNECTION_UDP, - MEMCACHED_CONNECTION_UNIX_SOCKET, + MEMCACHED_CONNECTION_UNIX_SOCKET } memcached_connection; typedef enum { MEMCACHED_NOT_ALLOCATED, MEMCACHED_ALLOCATED, - MEMCACHED_USED, + MEMCACHED_USED } memcached_allocated; diff --git a/libmemcached/memcached_hosts.c b/libmemcached/memcached_hosts.c index 34b93c6f..54440d35 100644 --- a/libmemcached/memcached_hosts.c +++ b/libmemcached/memcached_hosts.c @@ -89,9 +89,10 @@ void server_list_free(memcached_st *ptr, memcached_server_st *servers) static int continuum_item_cmp(const void *t1, const void *t2) { - memcached_continuum_item_st *ct1 = (memcached_continuum_item_st *)t1; - memcached_continuum_item_st *ct2 = (memcached_continuum_item_st *)t2; + memcached_continuum_item_st *ct1= (memcached_continuum_item_st *)t1; + memcached_continuum_item_st *ct2= (memcached_continuum_item_st *)t2; + /* Why 153? Hmmm... */ WATCHPOINT_ASSERT(ct1->value != 153); if (ct1->value == ct2->value) return 0; @@ -169,6 +170,9 @@ memcached_return update_continuum(memcached_st *ptr) pointer_counter+= pointer_per_server; } + WATCHPOINT_ASSERT(ptr); + WATCHPOINT_ASSERT(ptr->continuum); + WATCHPOINT_ASSERT(ptr->number_of_hosts); WATCHPOINT_ASSERT(ptr->number_of_hosts * MEMCACHED_POINTS_PER_SERVER <= MEMCACHED_CONTINUUM_SIZE); qsort(ptr->continuum, ptr->number_of_hosts * MEMCACHED_POINTS_PER_SERVER, sizeof(memcached_continuum_item_st), continuum_item_cmp);