From 02c35e9f14dddc82c86f246002b91bf8e25cbaa3 Mon Sep 17 00:00:00 2001 From: Brian Aker Date: Wed, 17 Oct 2007 22:42:05 -0700 Subject: [PATCH] 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). --- lib/memcached_get.c | 8 ++++---- tests/test.c | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) 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); -- 2.30.2