From: Brian Aker Date: Tue, 20 Sep 2011 20:01:10 +0000 (-0700) Subject: Fix additional clang finds. X-Git-Tag: 0.53~11 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=aa2acacce631a544d7915102b7c6c22f4ef4458d;p=awesomized%2Flibmemcached Fix additional clang finds. --- diff --git a/libmemcached/auto.cc b/libmemcached/auto.cc index 9a044faa..d0b7dd48 100644 --- a/libmemcached/auto.cc +++ b/libmemcached/auto.cc @@ -75,9 +75,9 @@ static memcached_return_t text_incr_decr(memcached_st *ptr, rc= memcached_response(instance, buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, NULL); - if (rc == MEMCACHED_SUCCESS) + if (rc != MEMCACHED_SUCCESS) { - return MEMCACHED_SUCCESS; + return memcached_set_error(*instance, rc, MEMCACHED_AT); } /* diff --git a/libmemcached/protocol/cache.c b/libmemcached/protocol/cache.c index 52904df4..f92fdec1 100644 --- a/libmemcached/protocol/cache.c +++ b/libmemcached/protocol/cache.c @@ -56,7 +56,9 @@ cache_t* cache_create(const char *name, size_t bufsize, size_t align, cache_constructor_t* constructor, cache_destructor_t* destructor) { cache_t* ret = calloc(1, sizeof(cache_t)); - char* nm = strdup(name); + size_t name_length= strlen(name); + char* nm= calloc(1, (sizeof(char) * name_length) +1); + memcpy(nm, name, name_length); void** ptr = calloc(initial_pool_size, bufsize); if (ret == NULL || nm == NULL || ptr == NULL || pthread_mutex_init(&ret->mutex, NULL) == -1) { diff --git a/libmemcached/server.h b/libmemcached/server.h index 3afb5202..3ca1df32 100644 --- a/libmemcached/server.h +++ b/libmemcached/server.h @@ -42,6 +42,12 @@ #include #endif +#ifdef NI_MAXHOST +#define MEMCACHED_NI_MAXHOST NI_MAXHOST +#else +#define MEMCACHED_NI_MAXHOST 1025 +#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 @@ -87,7 +93,7 @@ struct memcached_server_st { struct memcached_error_t *error_messages; char read_buffer[MEMCACHED_MAX_BUFFER]; char write_buffer[MEMCACHED_MAX_BUFFER]; - char hostname[NI_MAXHOST]; + char hostname[MEMCACHED_NI_MAXHOST]; }; diff --git a/tests/mem_functions.cc b/tests/mem_functions.cc index dd46c82f..c0dde998 100644 --- a/tests/mem_functions.cc +++ b/tests/mem_functions.cc @@ -853,7 +853,7 @@ static test_return_t bad_key_test(memcached_st *memc) test_zero(string_length); test_false(string); } - test_compare(before_query_id, memcached_query_id(memc_clone) +1); + test_compare(before_query_id +1, memcached_query_id(memc_clone)); query_id= memcached_query_id(memc_clone); test_compare(MEMCACHED_SUCCESS,