From: Date: Mon, 8 Sep 2008 20:08:02 +0000 (-0700) Subject: More warning cleanup. X-Git-Tag: 0.25~29 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=9bc31d7e76f2a4c84dba2ae8410cd4c382480193;p=awesomized%2Flibmemcached More warning cleanup. --- diff --git a/libmemcached/memcached_do.c b/libmemcached/memcached_do.c index 7b9da5ed..91f7506b 100644 --- a/libmemcached/memcached_do.c +++ b/libmemcached/memcached_do.c @@ -14,7 +14,7 @@ memcached_return memcached_do(memcached_server_st *ptr, const void *command, sent_length= memcached_io_write(ptr, command, command_length, with_flush); - if (sent_length == -1 || sent_length != command_length) + if (sent_length == -1 || (size_t)sent_length != command_length) rc= MEMCACHED_WRITE_FAILURE; else memcached_server_response_increment(ptr); diff --git a/libmemcached/memcached_hosts.c b/libmemcached/memcached_hosts.c index eb8f45e5..f87414da 100644 --- a/libmemcached/memcached_hosts.c +++ b/libmemcached/memcached_hosts.c @@ -23,7 +23,7 @@ static int compare_servers(const void *p1, const void *p2) return return_value; } -void sort_hosts(memcached_st *ptr) +static void sort_hosts(memcached_st *ptr) { if (ptr->number_of_hosts) { diff --git a/libmemcached/memcached_io.c b/libmemcached/memcached_io.c index ea8b2581..c9e04c9b 100644 --- a/libmemcached/memcached_io.c +++ b/libmemcached/memcached_io.c @@ -204,14 +204,16 @@ ssize_t memcached_io_write(memcached_server_st *ptr, return original_length; } -memcached_return memcached_io_close(memcached_server_st *ptr, uint8_t io_death) +memcached_return memcached_io_close(memcached_server_st *ptr) { + int r; /* in case of death shutdown to avoid blocking at close() */ - if (io_death) - shutdown(ptr->fd, SHUT_RDWR); - else - close(ptr->fd); + r= shutdown(ptr->fd, SHUT_RDWR); + WATCHPOINT_ASSERT(r == 0); + + r= close(ptr->fd); + WATCHPOINT_ASSERT(r == 0); return MEMCACHED_SUCCESS; } @@ -219,7 +221,7 @@ memcached_return memcached_io_close(memcached_server_st *ptr, uint8_t io_death) static ssize_t io_flush(memcached_server_st *ptr, memcached_return *error) { - size_t sent_length; + ssize_t sent_length; size_t return_length; char *local_write_ptr= ptr->write_buffer; size_t write_length= ptr->write_buffer_offset; @@ -230,9 +232,11 @@ static ssize_t io_flush(memcached_server_st *ptr, return 0; /* Looking for memory overflows */ +#if defined(HAVE_DEBUG) if (write_length == MEMCACHED_MAX_BUFFER) WATCHPOINT_ASSERT(ptr->write_buffer == local_write_ptr); WATCHPOINT_ASSERT((ptr->write_buffer + MEMCACHED_MAX_BUFFER) >= (local_write_ptr + write_length)); +#endif return_length= 0; while (write_length) @@ -269,7 +273,7 @@ static ssize_t io_flush(memcached_server_st *ptr, } else { - if ((ssize_t)(sent_length= write(ptr->fd, local_write_ptr, + if ((sent_length= write(ptr->fd, local_write_ptr, write_length)) == -1) { switch (errno) diff --git a/libmemcached/memcached_io.h b/libmemcached/memcached_io.h index 3f991be7..f54e5767 100644 --- a/libmemcached/memcached_io.h +++ b/libmemcached/memcached_io.h @@ -9,6 +9,6 @@ ssize_t memcached_io_write(memcached_server_st *ptr, void memcached_io_reset(memcached_server_st *ptr); ssize_t memcached_io_read(memcached_server_st *ptr, void *buffer, size_t length); -memcached_return memcached_io_close(memcached_server_st *ptr, uint8_t io_death); +memcached_return memcached_io_close(memcached_server_st *ptr); #endif __MEMCACHED_IO_H__ diff --git a/libmemcached/memcached_key.c b/libmemcached/memcached_key.c index 7513592b..b8291ed7 100644 --- a/libmemcached/memcached_key.c +++ b/libmemcached/memcached_key.c @@ -3,11 +3,11 @@ memcached_return memcachd_key_test(char **keys, size_t *key_length, unsigned int number_of_keys) { - int x; + uint32_t x; for (x= 0; x < number_of_keys; x++) { - int y; + size_t y; if (*(key_length + x) == 0) return MEMCACHED_BAD_KEY_PROVIDED; diff --git a/libmemcached/memcached_quit.c b/libmemcached/memcached_quit.c index c30b1ccd..14eca73d 100644 --- a/libmemcached/memcached_quit.c +++ b/libmemcached/memcached_quit.c @@ -40,7 +40,7 @@ void memcached_quit_server(memcached_server_st *ptr, uint8_t io_death) memcached_io_read(ptr, buffer, sizeof(buffer)/sizeof(*buffer))) > 0); } - memcached_io_close(ptr, io_death); + memcached_io_close(ptr); ptr->fd= -1; ptr->write_buffer_offset= 0; diff --git a/libmemcached/memcached_response.c b/libmemcached/memcached_response.c index c8b28965..43c6371f 100644 --- a/libmemcached/memcached_response.c +++ b/libmemcached/memcached_response.c @@ -81,7 +81,6 @@ memcached_return memcached_response(memcached_server_st *ptr, memcached_server_response_decrement(ptr); } - uint64_t auto_return_value= 0; switch(buffer[0]) { case 'V': /* VALUE || VERSION */ @@ -168,10 +167,16 @@ memcached_return memcached_response(memcached_server_st *ptr, memcached_io_reset(ptr); return MEMCACHED_CLIENT_ERROR; default: - if (sscanf(buffer, "%lld", &auto_return_value) == 1) + { + unsigned long long auto_return_value; + + if (sscanf(buffer, "%llu", &auto_return_value) == 1) return MEMCACHED_SUCCESS; - memcached_io_reset(ptr); - return MEMCACHED_UNKNOWN_READ_FAILURE; + + memcached_io_reset(ptr); + + return MEMCACHED_UNKNOWN_READ_FAILURE; + } } @@ -197,8 +202,9 @@ size_t memcached_result_length(memcached_result_st *ptr) static memcached_return safe_read(memcached_server_st *ptr, void *dta, size_t size) { - int offset= 0; + size_t offset= 0; char *data= dta; + while (offset < size) { ssize_t nread= memcached_io_read(ptr, data + offset, size - offset); diff --git a/tests/atomsmasher.c b/tests/atomsmasher.c index edc5250e..7c4c8ae3 100644 --- a/tests/atomsmasher.c +++ b/tests/atomsmasher.c @@ -36,14 +36,14 @@ static pairs_st *global_pairs; static char *global_keys[GLOBAL_COUNT]; static size_t global_keys_length[GLOBAL_COUNT]; -test_return cleanup_pairs(memcached_st *memc) +static test_return cleanup_pairs(memcached_st *memc __attribute__((unused))) { pairs_free(global_pairs); return 0; } -test_return generate_pairs(memcached_st *memc) +static test_return generate_pairs(memcached_st *memc __attribute__((unused))) { unsigned long long x; global_pairs= pairs_generate(GLOBAL_COUNT, 400); @@ -58,7 +58,7 @@ test_return generate_pairs(memcached_st *memc) return 0; } -test_return drizzle(memcached_st *memc) +static test_return drizzle(memcached_st *memc) { unsigned int x; memcached_return rc; @@ -110,28 +110,28 @@ infinite: return 0; } -memcached_return pre_nonblock(memcached_st *memc) +static memcached_return pre_nonblock(memcached_st *memc) { memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, 0); return MEMCACHED_SUCCESS; } -memcached_return pre_md5(memcached_st *memc) +static memcached_return pre_md5(memcached_st *memc) { memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_MD5); return MEMCACHED_SUCCESS; } -memcached_return pre_hsieh(memcached_st *memc) +static memcached_return pre_hsieh(memcached_st *memc) { memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_HSIEH); return MEMCACHED_SUCCESS; } -memcached_return enable_consistent(memcached_st *memc) +static memcached_return enable_consistent(memcached_st *memc) { memcached_server_distribution value= MEMCACHED_DISTRIBUTION_CONSISTENT; memcached_hash hash; @@ -152,7 +152,7 @@ memcached_return enable_consistent(memcached_st *memc) Set the value, then quit to make sure it is flushed. Come back in and test that add fails. */ -test_return add_test(memcached_st *memc) +static test_return add_test(memcached_st *memc) { memcached_return rc; char *key= "foo"; @@ -183,7 +183,7 @@ test_return add_test(memcached_st *memc) * repeating add_tests many times * may show a problem in timing */ -test_return many_adds(memcached_st *memc) +static test_return many_adds(memcached_st *memc) { unsigned int i; for (i = 0; i < TEST_COUNTER; i++){ @@ -212,7 +212,7 @@ collection_st collection[] ={ #define SERVERS_TO_CREATE 5 -void *world_create(void) +static void *world_create(void) { server_startup_st *construct; @@ -225,7 +225,7 @@ void *world_create(void) return construct; } -void world_destroy(void *p) +static void world_destroy(void *p) { server_startup_st *construct= (server_startup_st *)p; memcached_server_st *servers= (memcached_server_st *)construct->servers; diff --git a/tests/test.c b/tests/test.c index 47db82c7..49ae022a 100644 --- a/tests/test.c +++ b/tests/test.c @@ -14,7 +14,7 @@ #include "test.h" -long int timedif(struct timeval a, struct timeval b) +static long int timedif(struct timeval a, struct timeval b) { register int us, s;