From e3fb8436baef3690034baf087e9558b480cdaac8 Mon Sep 17 00:00:00 2001 From: michael-grunder Date: Thu, 2 Jun 2016 07:49:16 -0700 Subject: [PATCH] Comment debug code, fix compiler warnings --- cluster_library.c | 38 +++++++------------------------------- crc16.h | 2 +- redis_cluster.c | 2 +- 3 files changed, 9 insertions(+), 33 deletions(-) diff --git a/cluster_library.c b/cluster_library.c index 4dc57de7..a530112e 100644 --- a/cluster_library.c +++ b/cluster_library.c @@ -8,8 +8,7 @@ extern zend_class_entry *redis_cluster_exception_ce; -/* Some debug methods that will go away when we're through with them */ - +/* Debugging methods/ static void cluster_dump_nodes(redisCluster *c) { redisClusterNode **pp, *p; @@ -40,7 +39,7 @@ static void cluster_log(char *fmt, ...) fprintf(stderr, "%s\n", buffer); } -/* Debug function to dump a clusterReply structure recursively */ +// Debug function to dump a clusterReply structure recursively static void dump_reply(clusterReply *reply, int indent) { smart_str buf = {0}; int i; @@ -87,6 +86,8 @@ static void dump_reply(clusterReply *reply, int indent) { efree(buf.c); } } +*/ + /* Recursively free our reply object. If free_data is non-zero we'll also free * the payload data (strings) themselves. If not, we just free the structs */ @@ -116,7 +117,7 @@ static void cluster_multibulk_resp_recursive(RedisSock *sock, size_t elements, clusterReply **element, int *err TSRMLS_DC) { - size_t idx = 0; + size_t idx = 0, sz; clusterReply *r; long len; char buf[1024]; @@ -137,10 +138,11 @@ cluster_multibulk_resp_recursive(RedisSock *sock, size_t elements, switch(r->type) { case TYPE_ERR: case TYPE_LINE: - if(redis_sock_gets(sock,buf,sizeof(buf),&r->len TSRMLS_CC)<0) { + if(redis_sock_gets(sock,buf,sizeof(buf),&sz TSRMLS_CC)<0) { *err = 1; return; } + r->len = (long long)sz; break; case TYPE_INT: r->integer = len; @@ -582,32 +584,6 @@ unsigned short cluster_hash_key_zval(zval *z_key) { return cluster_hash_key(kptr, klen); } -static char **split_str_by_delim(char *str, char *delim, int *len) { - char **array, *tok, *tok_buf; - int size=16; - - *len = 0; - - // Initial storage - array = emalloc(size * sizeof(char*)); - - tok = php_strtok_r(str, delim, &tok_buf); - - while(tok) { - if(size == *len) { - size *= 2; - array = erealloc(array, size * sizeof(char*)); - } - - array[*len] = tok; - (*len)++; - - tok = php_strtok_r(NULL, delim, &tok_buf); - } - - return array; -} - /* Fisher-Yates shuffle for integer array */ static void fyshuffle(int *array, size_t len) { int temp, n = len; diff --git a/crc16.h b/crc16.h index f7d2aee3..be91ffa0 100644 --- a/crc16.h +++ b/crc16.h @@ -78,7 +78,7 @@ static const uint16_t crc16tab[256]= { 0x6e17,0x7e36,0x4e55,0x5e74,0x2e93,0x3eb2,0x0ed1,0x1ef0 }; -static uint16_t crc16(const char *buf, int len) { +static inline uint16_t crc16(const char *buf, int len) { int counter; uint16_t crc = 0; for (counter = 0; counter < len; counter++) diff --git a/redis_cluster.c b/redis_cluster.c index 28aff721..1bdbc068 100644 --- a/redis_cluster.c +++ b/redis_cluster.c @@ -2037,7 +2037,7 @@ PHP_METHOD(RedisCluster, _redir) { size_t len; len = snprintf(buf, sizeof(buf), "%s:%d", c->redir_host, c->redir_port); - if(c->redir_host && c->redir_host_len) { + if(*c->redir_host && c->redir_host_len) { RETURN_STRINGL(buf, len, 1); } else { RETURN_NULL();