From: Date: Thu, 25 Oct 2007 18:15:51 +0000 (-0700) Subject: Cleaning out asserts; X-Git-Tag: 0_7~10 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=7eb4f57fd1daa46652091414e381f7842833bc6a;p=m6w6%2Flibmemcached Cleaning out asserts; --- diff --git a/include/memcached.h b/include/memcached.h index d8d471a8..6854035b 100644 --- a/include/memcached.h +++ b/include/memcached.h @@ -217,12 +217,22 @@ char ** memcached_stat_get_keys(memcached_st *ptr, memcached_stat_st *stat, #define WATCHPOINT_STRING(A) printf("\nWATCHPOINT %s:%d (%s) %s\n", __FILE__, __LINE__,__func__,A);fflush(stdout); #define WATCHPOINT_NUMBER(A) printf("\nWATCHPOINT %s:%d (%s) %zu\n", __FILE__, __LINE__,__func__,(size_t)(A));fflush(stdout); #define WATCHPOINT_ERRNO(A) printf("\nWATCHPOINT %s:%d (%s) %s\n", __FILE__, __LINE__,__func__, strerror(A));A= 0;fflush(stdout); +#define WATCHPOINT_ASSERT(A) assert((A)); #else +/* +#define WATCHPOINT { 1; }; +#define WATCHPOINT_ERROR(A) { 1; }; +#define WATCHPOINT_STRING(A) { 1; }; +#define WATCHPOINT_NUMBER(A) { 1; }; +#define WATCHPOINT_ERRNO(A) { 1; }; +#define WATCHPOINT_ASSERT(A) { 1; }; +*/ #define WATCHPOINT -#define WATCHPOINT_ERROR(A) +#define WATCHPOINT_ERROR(A) #define WATCHPOINT_STRING(A) #define WATCHPOINT_NUMBER(A) #define WATCHPOINT_ERRNO(A) +#define WATCHPOINT_ASSERT(A) #endif diff --git a/lib/memcached_behavior.c b/lib/memcached_behavior.c index 17a0d83b..319c3fa3 100644 --- a/lib/memcached_behavior.c +++ b/lib/memcached_behavior.c @@ -108,7 +108,7 @@ unsigned long long memcached_behavior_get(memcached_st *ptr, } } - assert(temp_flag); /* Programming mistake if it gets this far */ + WATCHPOINT_ASSERT(temp_flag); /* Programming mistake if it gets this far */ if (ptr->flags & temp_flag) return 1; else diff --git a/lib/memcached_connect.c b/lib/memcached_connect.c index abf15676..8ffaaef9 100644 --- a/lib/memcached_connect.c +++ b/lib/memcached_connect.c @@ -14,7 +14,7 @@ memcached_return memcached_real_connect(memcached_st *ptr, unsigned int server_k if (ptr->hosts[server_key].fd == -1) { /* Old connection junk still is in the structure */ - assert(ptr->hosts[server_key].stack_responses == 0); + WATCHPOINT_ASSERT(ptr->hosts[server_key].stack_responses == 0); if ((h= gethostbyname(ptr->hosts[server_key].hostname)) == NULL) { @@ -86,7 +86,7 @@ test_connect: } ptr->connected++; } - assert(ptr->hosts[server_key].stack_responses == 0); + WATCHPOINT_ASSERT(ptr->hosts[server_key].stack_responses == 0); } return MEMCACHED_SUCCESS; diff --git a/lib/memcached_get.c b/lib/memcached_get.c index 3ddeff88..80b9de37 100644 --- a/lib/memcached_get.c +++ b/lib/memcached_get.c @@ -168,7 +168,9 @@ char *memcached_get(memcached_st *ptr, char *key, size_t key_length, goto error; } else if (*error == MEMCACHED_END) - assert(0); /* If this happens we have somehow messed up the fetch */ + { + WATCHPOINT_ASSERT(0); /* If this happens we have somehow messed up the fetch */ + } else if (*error == MEMCACHED_SUCCESS) { memcached_return rc; @@ -298,7 +300,9 @@ char *memcached_fetch(memcached_st *ptr, char *key, size_t *key_length, else if (*error == MEMCACHED_END && *value_length == 0) return NULL; else if (*error == MEMCACHED_END) - assert(0); /* If this happens we have somehow messed up the fetch */ + { + WATCHPOINT_ASSERT(0); /* If this happens we have somehow messed up the fetch */ + } else if (*error != MEMCACHED_SUCCESS) return NULL; else diff --git a/lib/memcached_hash.c b/lib/memcached_hash.c index ca7229c2..0e26fbbe 100644 --- a/lib/memcached_hash.c +++ b/lib/memcached_hash.c @@ -22,7 +22,10 @@ unsigned int memcached_generate_hash(memcached_st *ptr, char *key, size_t key_le hash= internal_generate_hash(key, key_length); if (ptr->flags & MEM_USE_KETAMA) - assert(0); + { + WATCHPOINT_ASSERT(0); + return 0; + } else return hash % ptr->number_of_hosts; } diff --git a/lib/memcached_io.c b/lib/memcached_io.c index 77541e2a..54a0e8cc 100644 --- a/lib/memcached_io.c +++ b/lib/memcached_io.c @@ -102,7 +102,7 @@ ssize_t memcached_io_write(memcached_st *ptr, unsigned int server_key, sent_length= memcached_io_flush(ptr, server_key); - assert(sent_length == MEMCACHED_MAX_BUFFER); + WATCHPOINT_ASSERT(sent_length == MEMCACHED_MAX_BUFFER); ptr->write_buffer_offset= 0; } } diff --git a/lib/memcached_parse.c b/lib/memcached_parse.c index d3b1827e..069593e5 100644 --- a/lib/memcached_parse.c +++ b/lib/memcached_parse.c @@ -17,7 +17,7 @@ memcached_server_st *memcached_servers_parse(char *server_strings) memcached_server_st *servers= NULL; memcached_return rc; - assert(server_strings); + WATCHPOINT_ASSERT(server_strings); end_ptr= server_strings + strlen(server_strings); diff --git a/lib/memcached_response.c b/lib/memcached_response.c index d0962a2d..673ccb2f 100644 --- a/lib/memcached_response.c +++ b/lib/memcached_response.c @@ -43,7 +43,7 @@ memcached_return memcached_response(memcached_st *ptr, buffer_ptr++; total_length++; - assert(total_length < buffer_length); + WATCHPOINT_ASSERT(total_length < buffer_length); } if (memcached_server_response_count(ptr, server_key)) diff --git a/lib/memcached_storage.c b/lib/memcached_storage.c index 9d82b56f..f9ba64d6 100644 --- a/lib/memcached_storage.c +++ b/lib/memcached_storage.c @@ -33,13 +33,13 @@ static memcached_return memcached_send(memcached_st *ptr, char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; unsigned int server_key; - assert(value); - assert(value_length); + WATCHPOINT_ASSERT(value); + WATCHPOINT_ASSERT(value_length); - /* Leaving this assert in since only a library fubar could blow this */ + /* Leaving this WATCHPOINT_ASSERT in since only a library fubar could blow this */ #ifdef NOT_DONE if (!(ptr->flags & MEM_NO_BLOCK) && ptr->write_buffer_offset != 0) - assert(0); + WATCHPOINT_ASSERT(0); #endif server_key= memcached_generate_hash(ptr, key, key_length); diff --git a/lib/memcached_string.c b/lib/memcached_string.c index 47dac67e..e2f14017 100644 --- a/lib/memcached_string.c +++ b/lib/memcached_string.c @@ -49,7 +49,7 @@ memcached_string_st *memcached_string_create(memcached_st *ptr, size_t initial_s return NULL; } - assert(string->string == string->end); + WATCHPOINT_ASSERT(string->string == string->end); return string; } @@ -76,20 +76,15 @@ memcached_return memcached_string_append(memcached_st *ptr, memcached_string_st { memcached_return rc; - WATCHPOINT; rc= memcached_string_check(string, length); - WATCHPOINT; if (rc != MEMCACHED_SUCCESS) return rc; - WATCHPOINT; - assert(string->string); - assert(string->end >= string->string && string->end <= string->string + string->current_size); + WATCHPOINT_ASSERT(string->string); + WATCHPOINT_ASSERT(string->end >= string->string && string->end <= string->string + string->current_size); - WATCHPOINT; memcpy(string->end, value, length); - WATCHPOINT; string->end+= length; return MEMCACHED_SUCCESS;