From: Brian Aker Date: Thu, 18 Oct 2007 05:42:05 +0000 (-0700) Subject: Finally tracked down the oddball valgrind warning that I could never figure X-Git-Tag: 0_7~20 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=02c35e9f14dddc82c86f246002b91bf8e25cbaa3;p=m6w6%2Flibmemcached Finally tracked down the oddball valgrind warning that I could never figure out :) The check for one particular safety check was wrong (though something in the server would have to go wrong to trigger this error). --- diff --git a/lib/memcached_get.c b/lib/memcached_get.c index baff7074..147b6105 100644 --- a/lib/memcached_get.c +++ b/lib/memcached_get.c @@ -36,7 +36,7 @@ static char *memcached_value_fetch(memcached_st *ptr, char *key, size_t *key_len memset(key, 0, MEMCACHED_MAX_KEY); *key_length= 0; - for (; end_ptr == string_ptr || *string_ptr != ' '; string_ptr++) + for (; end_ptr > string_ptr && *string_ptr != ' '; string_ptr++) { *key= *string_ptr; key++; @@ -44,7 +44,7 @@ static char *memcached_value_fetch(memcached_st *ptr, char *key, size_t *key_len } } else /* Skip characters */ - for (; end_ptr == string_ptr || *string_ptr != ' '; string_ptr++); + for (; end_ptr > string_ptr && *string_ptr != ' '; string_ptr++); if (end_ptr == string_ptr) goto read_error; @@ -53,7 +53,7 @@ static char *memcached_value_fetch(memcached_st *ptr, char *key, size_t *key_len string_ptr++; if (end_ptr == string_ptr) goto read_error; - for (next_ptr= string_ptr; end_ptr == string_ptr || *string_ptr != ' '; string_ptr++); + for (next_ptr= string_ptr; end_ptr > string_ptr && *string_ptr != ' '; string_ptr++); *flags= (uint16_t)strtol(next_ptr, &string_ptr, 10); if (end_ptr == string_ptr) @@ -64,7 +64,7 @@ static char *memcached_value_fetch(memcached_st *ptr, char *key, size_t *key_len if (end_ptr == string_ptr) goto read_error; - for (next_ptr= string_ptr; end_ptr == string_ptr || *string_ptr != ' '; string_ptr++); + for (next_ptr= string_ptr; end_ptr > string_ptr && *string_ptr != ' '; string_ptr++); *value_length= (size_t)strtoll(next_ptr, &string_ptr, 10); if (end_ptr == string_ptr) diff --git a/tests/test.c b/tests/test.c index 0bdf760a..56f66d94 100644 --- a/tests/test.c +++ b/tests/test.c @@ -513,13 +513,14 @@ void user_supplied_bug1(memcached_st *memc) unsigned long long total= 0; int size= 0; - srand(time(NULL)); char key[10]; char randomstuff[6 * 1024]; memcached_return rc; memset(randomstuff, 0, 6 * 1024); + /* We just keep looking at the same values over and over */ + srandom(10); memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, &setter); memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, &setter); @@ -557,7 +558,6 @@ void user_supplied_bug2(memcached_st *memc) unsigned int x; unsigned long long total; - setter= 1; memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, &setter); memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, &setter);