From: Date: Tue, 27 May 2008 04:19:13 +0000 (+0530) Subject: Fix for flags operation (aka not storing the final bit right). Updated X-Git-Tag: 0.22~11 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=948eeb667c78f158f769de8cc418e44e81048dc2;p=m6w6%2Flibmemcached Fix for flags operation (aka not storing the final bit right). Updated version. --- diff --git a/ChangeLog b/ChangeLog index 54646863..50d08772 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +0.22 + * Found a bug in Flags return (Jacek Ostrowski) + * Fixed issue with compiling on Visual Studio + 0.21 Fri May 23 18:34:09 PDT 2008 * Change of char * to const char * for all key based functions. * New MEMCACHED_CALLBACK_PREFIX_KEY added. You can now create domains for diff --git a/configure.ac b/configure.ac index 3352a30b..8215965b 100644 --- a/configure.ac +++ b/configure.ac @@ -7,7 +7,7 @@ MEMCACHED_LIBRARY_NAME=libmemcached #release versioning MEMCACHED_MAJOR_VERSION=0 -MEMCACHED_MINOR_VERSION=21 +MEMCACHED_MINOR_VERSION=22 MEMCACHED_MICRO_VERSION=0 #API version diff --git a/libmemcached/memcached.h b/libmemcached/memcached.h index 4c0a4207..60c63b58 100644 --- a/libmemcached/memcached.h +++ b/libmemcached/memcached.h @@ -37,7 +37,7 @@ struct memcached_continuum_item_st { uint32_t value; }; -#define LIBMEMCACHED_VERSION_STRING "0.21" +#define LIBMEMCACHED_VERSION_STRING "0.22" struct memcached_stat_st { uint32_t pid; diff --git a/libmemcached/memcached_auto.c b/libmemcached/memcached_auto.c index b3eae3b6..c847f936 100644 --- a/libmemcached/memcached_auto.c +++ b/libmemcached/memcached_auto.c @@ -55,7 +55,7 @@ static memcached_return memcached_auto(memcached_st *ptr, } else { - *value= (uint64_t)strtoll(buffer, (char **)NULL, 10); + *value= strtoull(buffer, (char **)NULL, 10); rc= MEMCACHED_SUCCESS; } diff --git a/libmemcached/memcached_fetch.c b/libmemcached/memcached_fetch.c index 2cefe65f..93215fb8 100644 --- a/libmemcached/memcached_fetch.c +++ b/libmemcached/memcached_fetch.c @@ -53,7 +53,7 @@ memcached_return value_fetch(memcached_server_st *ptr, if (end_ptr == string_ptr) goto read_error; for (next_ptr= string_ptr; isdigit(*string_ptr); string_ptr++); - result->flags= (uint32_t)strtol(next_ptr, &string_ptr, 10); + result->flags= strtoul(next_ptr, &string_ptr, 10); if (end_ptr == string_ptr) goto read_error; @@ -64,7 +64,7 @@ memcached_return value_fetch(memcached_server_st *ptr, goto read_error; for (next_ptr= string_ptr; isdigit(*string_ptr); string_ptr++); - value_length= (size_t)strtoll(next_ptr, &string_ptr, 10); + value_length= (size_t)strtoull(next_ptr, &string_ptr, 10); if (end_ptr == string_ptr) goto read_error; @@ -79,7 +79,7 @@ memcached_return value_fetch(memcached_server_st *ptr, { string_ptr++; for (next_ptr= string_ptr; isdigit(*string_ptr); string_ptr++); - result->cas= (size_t)strtoll(next_ptr, &string_ptr, 10); + result->cas= strtoull(next_ptr, &string_ptr, 10); } if (end_ptr < string_ptr) diff --git a/libmemcached/memcached_parse.c b/libmemcached/memcached_parse.c index 366e77b5..fc6a4cb1 100644 --- a/libmemcached/memcached_parse.c +++ b/libmemcached/memcached_parse.c @@ -51,7 +51,7 @@ memcached_server_st *memcached_servers_parse(char *server_strings) ptr++; - port= strtol(ptr, (char **)NULL, 10); + port= strtoul(ptr, (char **)NULL, 10); } servers= memcached_server_list_append(servers, buffer, port, &rc); diff --git a/libmemcached/memcached_storage.c b/libmemcached/memcached_storage.c index 7dcc9b7a..04f281cc 100644 --- a/libmemcached/memcached_storage.c +++ b/libmemcached/memcached_storage.c @@ -36,6 +36,8 @@ static char *storage_op_string(memcached_storage_action verb) return "append"; case CAS_OP: return "cas"; + default: + return "tosserror"; /* This is impossible, fixes issue for compiler warning in VisualStudio */ }; return SET_OP; diff --git a/tests/function.c b/tests/function.c index 5e371537..015fa49c 100644 --- a/tests/function.c +++ b/tests/function.c @@ -2003,6 +2003,33 @@ test_return user_supplied_bug15(memcached_st *memc) return 0; } +/* Check the return sizes on FLAGS to make sure it stores 32bit unsigned values correctly */ +test_return user_supplied_bug16(memcached_st *memc) +{ + uint32_t x; + memcached_return rc; + char *key= "mykey"; + char *value; + size_t length; + uint32_t flags; + + rc= memcached_set(memc, key, strlen(key), + NULL, 0, + (time_t)0, UINT32_MAX); + + assert(rc == MEMCACHED_SUCCESS); + + value= memcached_get(memc, key, strlen(key), + &length, &flags, &rc); + + assert(rc == MEMCACHED_SUCCESS); + assert(value == NULL); + assert(length == 0); + assert(flags == UINT32_MAX); + + return 0; +} + test_return result_static(memcached_st *memc) { memcached_result_st result; @@ -2745,6 +2772,7 @@ test_st user_tests[] ={ {"user_supplied_bug13", 1, user_supplied_bug13 }, {"user_supplied_bug14", 1, user_supplied_bug14 }, {"user_supplied_bug15", 1, user_supplied_bug15 }, + {"user_supplied_bug16", 1, user_supplied_bug16 }, {0, 0, 0} };