diff options
author | antirez <antirez@gmail.com> | 2014-08-13 11:44:38 +0200 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2014-08-27 10:29:26 +0200 |
commit | 65d47452f82721486bd79aafe6ca420ca6dedf8b (patch) | |
tree | 42769256c271e06d259b1a1c9f79e8cf3957027f | |
parent | 09757420a4ef461bb1db65a01384f970f07c4358 (diff) | |
download | redis-65d47452f82721486bd79aafe6ca420ca6dedf8b.tar.gz |
Remove warnings and improve integer sign correctness.
-rw-r--r-- | src/anet.c | 2 | ||||
-rw-r--r-- | src/aof.c | 2 | ||||
-rw-r--r-- | src/bitops.c | 20 | ||||
-rw-r--r-- | src/config.c | 2 | ||||
-rw-r--r-- | src/db.c | 8 | ||||
-rw-r--r-- | src/hyperloglog.c | 4 | ||||
-rw-r--r-- | src/latency.c | 1 | ||||
-rw-r--r-- | src/networking.c | 2 | ||||
-rw-r--r-- | src/redis-benchmark.c | 4 | ||||
-rw-r--r-- | src/redis-cli.c | 9 | ||||
-rw-r--r-- | src/redis.c | 16 | ||||
-rw-r--r-- | src/redis.h | 4 | ||||
-rw-r--r-- | src/scripting.c | 2 | ||||
-rw-r--r-- | src/sentinel.c | 19 |
14 files changed, 53 insertions, 42 deletions
diff --git a/src/anet.c b/src/anet.c index 3458e5875..f36575bd4 100644 --- a/src/anet.c +++ b/src/anet.c @@ -117,6 +117,8 @@ int anetKeepAlive(char *err, int fd, int interval) anetSetError(err, "setsockopt TCP_KEEPCNT: %s\n", strerror(errno)); return ANET_ERR; } +#else + ((void) interval); /* Avoid unused var warning for non Linux systems. */ #endif return ANET_OK; @@ -140,7 +140,7 @@ ssize_t aofRewriteBufferWrite(int fd) { if (block->used) { nwritten = write(fd,block->buf,block->used); - if (nwritten != block->used) { + if (nwritten != (ssize_t)block->used) { if (nwritten == 0) errno = EIO; return -1; } diff --git a/src/bitops.c b/src/bitops.c index c49803f2d..209f9b0fc 100644 --- a/src/bitops.c +++ b/src/bitops.c @@ -107,12 +107,12 @@ size_t redisPopcount(void *s, long count) { * no zero bit is found, it returns count*8 assuming the string is zero * padded on the right. However if 'bit' is 1 it is possible that there is * not a single set bit in the bitmap. In this special case -1 is returned. */ -long redisBitpos(void *s, long count, int bit) { +long redisBitpos(void *s, unsigned long count, int bit) { unsigned long *l; unsigned char *c; unsigned long skipval, word = 0, one; long pos = 0; /* Position of bit, to return to the caller. */ - int j; + unsigned long j; /* Process whole words first, seeking for first word that is not * all ones or all zeros respectively if we are lookig for zeros @@ -276,11 +276,12 @@ void getbitCommand(redisClient *c) { void bitopCommand(redisClient *c) { char *opname = c->argv[1]->ptr; robj *o, *targetkey = c->argv[2]; - long op, j, numkeys; + unsigned long op, j, numkeys; robj **objects; /* Array of source objects. */ unsigned char **src; /* Array of source strings pointers. */ - long *len, maxlen = 0; /* Array of length of src strings, and max len. */ - long minlen = 0; /* Min len among the input keys. */ + unsigned long *len, maxlen = 0; /* Array of length of src strings, + and max len. */ + unsigned long minlen = 0; /* Min len among the input keys. */ unsigned char *res = NULL; /* Resulting string. */ /* Parse the operation name. */ @@ -320,9 +321,10 @@ void bitopCommand(redisClient *c) { } /* Return an error if one of the keys is not a string. */ if (checkType(c,o,REDIS_STRING)) { - for (j = j-1; j >= 0; j--) { - if (objects[j]) - decrRefCount(objects[j]); + unsigned long i; + for (i = 0; i < j; i++) { + if (objects[i]) + decrRefCount(objects[i]); } zfree(src); zfree(len); @@ -340,7 +342,7 @@ void bitopCommand(redisClient *c) { if (maxlen) { res = (unsigned char*) sdsnewlen(NULL,maxlen); unsigned char output, byte; - long i; + unsigned long i; /* Fast path: as far as we have data for all the input bitmaps we * can take a fast path that performs much better than the diff --git a/src/config.c b/src/config.c index 7e85d323f..ea0b77916 100644 --- a/src/config.c +++ b/src/config.c @@ -589,7 +589,7 @@ void configSetCommand(redisClient *c) { server.maxclients = orig_value; return; } - if (aeGetSetSize(server.el) < + if ((unsigned int) aeGetSetSize(server.el) < server.maxclients + REDIS_EVENTLOOP_FDSET_INCR) { if (aeResizeSetSize(server.el, @@ -411,9 +411,7 @@ int parseScanCursorOrReply(redisClient *c, robj *o, unsigned long *cursor) { * In the case of a Hash object the function returns both the field and value * of every element on the Hash. */ void scanGenericCommand(redisClient *c, robj *o, unsigned long cursor) { - int rv; int i, j; - char buf[REDIS_LONGSTR_SIZE]; list *keys = listCreate(); listNode *node, *nextnode; long count = 10; @@ -493,7 +491,7 @@ void scanGenericCommand(redisClient *c, robj *o, unsigned long cursor) { privdata[1] = o; do { cursor = dictScan(ht, cursor, scanCallback, privdata); - } while (cursor && listLength(keys) < count); + } while (cursor && listLength(keys) < (unsigned long)count); } else if (o->type == REDIS_SET) { int pos = 0; int64_t ll; @@ -567,9 +565,7 @@ void scanGenericCommand(redisClient *c, robj *o, unsigned long cursor) { /* Step 4: Reply to the client. */ addReplyMultiBulkLen(c, 2); - rv = snprintf(buf, sizeof(buf), "%lu", cursor); - redisAssert(rv < sizeof(buf)); - addReplyBulkCBuffer(c, buf, rv); + addReplyBulkLongLong(c,cursor); addReplyMultiBulkLen(c, listLength(keys)); while ((node = listFirst(keys)) != NULL) { diff --git a/src/hyperloglog.c b/src/hyperloglog.c index 63052a789..005beb18f 100644 --- a/src/hyperloglog.c +++ b/src/hyperloglog.c @@ -1349,7 +1349,7 @@ void pfmergeCommand(redisClient *c) { * Something that is not easy to test from within the outside. */ #define HLL_TEST_CYCLES 1000 void pfselftestCommand(redisClient *c) { - int j, i; + unsigned int j, i; sds bitcounters = sdsnewlen(NULL,HLL_DENSE_SIZE); struct hllhdr *hdr = (struct hllhdr*) bitcounters, *hdr2; robj *o = NULL; @@ -1431,7 +1431,7 @@ void pfselftestCommand(redisClient *c) { if (j == 10) maxerr = 1; if (abserr < 0) abserr = -abserr; - if (abserr > maxerr) { + if (abserr > (int64_t)maxerr) { addReplyErrorFormat(c, "TESTFAILED Too big error. card:%llu abserr:%llu", (unsigned long long) checkpoint, diff --git a/src/latency.c b/src/latency.c index fdc88210e..b7845ca29 100644 --- a/src/latency.c +++ b/src/latency.c @@ -37,6 +37,7 @@ /* Dictionary type for latency events. */ int dictStringKeyCompare(void *privdata, const void *key1, const void *key2) { + REDIS_NOTUSED(privdata); return strcmp(key1,key2) == 0; } diff --git a/src/networking.c b/src/networking.c index cbbedd481..298c99897 100644 --- a/src/networking.c +++ b/src/networking.c @@ -1028,7 +1028,7 @@ int processMultibulkBuffer(redisClient *c) { qblen = sdslen(c->querybuf); /* Hint the sds library about the amount of bytes this string is * going to contain. */ - if (qblen < ll+2) + if (qblen < (size_t)ll+2) c->querybuf = sdsMakeRoomFor(c->querybuf,ll+2-qblen); } c->bulklen = ll; diff --git a/src/redis-benchmark.c b/src/redis-benchmark.c index 5ab2625d2..e6d6f5738 100644 --- a/src/redis-benchmark.c +++ b/src/redis-benchmark.c @@ -213,7 +213,7 @@ static void readHandler(aeEventLoop *el, int fd, void *privdata, int mask) { freeReplyObject(reply); if (c->selectlen) { - int j; + size_t j; /* This is the OK from SELECT. Just discard the SELECT * from the buffer. */ @@ -359,7 +359,7 @@ static client createClient(char *cmd, size_t len, client from) { c->randfree = 0; c->randptr = zmalloc(sizeof(char*)*c->randlen); /* copy the offsets. */ - for (j = 0; j < c->randlen; j++) { + for (j = 0; j < (int)c->randlen; j++) { c->randptr[j] = c->obuf + (from->randptr[j]-from->obuf); /* Adjust for the different select prefix length. */ c->randptr[j] += c->selectlen - from->selectlen; diff --git a/src/redis-cli.c b/src/redis-cli.c index c583ce7cc..9b49ce2c6 100644 --- a/src/redis-cli.c +++ b/src/redis-cli.c @@ -1415,7 +1415,7 @@ static int toIntType(char *key, char *type) { static void getKeyTypes(redisReply *keys, int *types) { redisReply *reply; - int i; + unsigned int i; /* Pipeline TYPE commands */ for(i=0;i<keys->elements;i++) { @@ -1444,7 +1444,7 @@ static void getKeySizes(redisReply *keys, int *types, { redisReply *reply; char *sizecmds[] = {"STRLEN","LLEN","SCARD","HLEN","ZCARD"}; - int i; + unsigned int i; /* Pipeline size commands */ for(i=0;i<keys->elements;i++) { @@ -1491,7 +1491,8 @@ static void findBigKeys(void) { char *typename[] = {"string","list","set","hash","zset"}; char *typeunit[] = {"bytes","items","members","fields","members"}; redisReply *reply, *keys; - int type, *types=NULL, arrsize=0, i; + unsigned int arrsize=0, i; + int type, *types=NULL; double pct; /* Total keys pre scanning */ @@ -1778,7 +1779,7 @@ static void scanMode(void) { printf("ERROR: %s\n", reply->str); exit(1); } else { - int j; + unsigned int j; cur = strtoull(reply->element[0]->str,NULL,10); for (j = 0; j < reply->element[1]->elements; j++) diff --git a/src/redis.c b/src/redis.c index 2f80d7cc9..89d276bf9 100644 --- a/src/redis.c +++ b/src/redis.c @@ -707,8 +707,8 @@ void activeExpireCycle(int type) { static int timelimit_exit = 0; /* Time limit hit in previous call? */ static long long last_fast_cycle = 0; /* When last fast cycle ran. */ - unsigned int j, iteration = 0; - unsigned int dbs_per_call = REDIS_DBCRON_DBS_PER_CALL; + int j, iteration = 0; + int dbs_per_call = REDIS_DBCRON_DBS_PER_CALL; long long start = ustime(), timelimit; if (type == ACTIVE_EXPIRE_CYCLE_FAST) { @@ -944,8 +944,8 @@ void databasesCron(void) { * cron loop iteration. */ static unsigned int resize_db = 0; static unsigned int rehash_db = 0; - unsigned int dbs_per_call = REDIS_DBCRON_DBS_PER_CALL; - unsigned int j; + int dbs_per_call = REDIS_DBCRON_DBS_PER_CALL; + int j; /* Don't test more DBs than we have. */ if (dbs_per_call > server.dbnum) dbs_per_call = server.dbnum; @@ -1472,7 +1472,7 @@ void adjustOpenFilesLimit(void) { * to the higher value supported less than maxfiles. */ f = maxfiles; while(f > oldlimit) { - int decr_step = 16; + rlim_t decr_step = 16; limit.rlim_cur = f; limit.rlim_max = f; @@ -2223,9 +2223,9 @@ int time_independent_strcmp(char *a, char *b) { * a or b are fixed (our password) length, and the difference is only * relative to the length of the user provided string, so no information * leak is possible in the following two lines of code. */ - int alen = strlen(a); - int blen = strlen(b); - int j; + unsigned int alen = strlen(a); + unsigned int blen = strlen(b); + unsigned int j; int diff = 0; /* We can't compare strings longer than our static buffers. diff --git a/src/redis.h b/src/redis.h index 955150761..bef46d5ea 100644 --- a/src/redis.h +++ b/src/redis.h @@ -754,9 +754,9 @@ struct redisServer { /* Replication script cache. */ dict *repl_scriptcache_dict; /* SHA1 all slaves are aware of. */ list *repl_scriptcache_fifo; /* First in, first out LRU eviction. */ - int repl_scriptcache_size; /* Max number of elements. */ + unsigned int repl_scriptcache_size; /* Max number of elements. */ /* Limits */ - int maxclients; /* Max number of simultaneous clients */ + unsigned int maxclients; /* Max number of simultaneous clients */ unsigned long long maxmemory; /* Max number of memory bytes to use */ int maxmemory_policy; /* Policy for key eviction */ int maxmemory_samples; /* Pricision of random sampling */ diff --git a/src/scripting.c b/src/scripting.c index 5f5c98b1c..2c4549b70 100644 --- a/src/scripting.c +++ b/src/scripting.c @@ -212,7 +212,7 @@ int luaRedisGenericCommand(lua_State *lua, int raise_error) { static robj **argv = NULL; static int argv_size = 0; static robj *cached_objects[LUA_CMD_OBJCACHE_SIZE]; - static int cached_objects_len[LUA_CMD_OBJCACHE_SIZE]; + static size_t cached_objects_len[LUA_CMD_OBJCACHE_SIZE]; /* Require at least one argument */ if (argc == 0) { diff --git a/src/sentinel.c b/src/sentinel.c index 48e1de8dd..61ca3000a 100644 --- a/src/sentinel.c +++ b/src/sentinel.c @@ -159,7 +159,7 @@ typedef struct sentinelRedisInstance { /* Master specific. */ dict *sentinels; /* Other sentinels monitoring the same master. */ dict *slaves; /* Slaves for this master instance. */ - int quorum; /* Number of sentinels that need to agree on failure. */ + unsigned int quorum;/* Number of sentinels that need to agree on failure. */ int parallel_syncs; /* How many slaves to reconfigure at same time. */ char *auth_pass; /* Password to use for AUTH against master & slaves. */ @@ -345,6 +345,7 @@ int dictSdsKeyCompare(void *privdata, const void *key1, const void *key2); void releaseSentinelRedisInstance(sentinelRedisInstance *ri); void dictInstancesValDestructor (void *privdata, void *obj) { + REDIS_NOTUSED(privdata); releaseSentinelRedisInstance(obj); } @@ -403,7 +404,7 @@ void initSentinelConfig(void) { /* Perform the Sentinel mode initialization. */ void initSentinel(void) { - int j; + unsigned int j; /* Remove usual Redis commands from the command table, then just add * the SENTINEL command. */ @@ -1634,6 +1635,7 @@ void sentinelLinkEstablishedCallback(const redisAsyncContext *c, int status) { } void sentinelDisconnectCallback(const redisAsyncContext *c, int status) { + REDIS_NOTUSED(status); sentinelDisconnectInstanceFromContext(c); } @@ -1998,6 +2000,7 @@ void sentinelRefreshInstanceInfo(sentinelRedisInstance *ri, const char *info) { void sentinelInfoReplyCallback(redisAsyncContext *c, void *reply, void *privdata) { sentinelRedisInstance *ri = c->data; redisReply *r; + REDIS_NOTUSED(privdata); if (ri) ri->pending_commands--; if (!reply || !ri) return; @@ -2012,6 +2015,8 @@ void sentinelInfoReplyCallback(redisAsyncContext *c, void *reply, void *privdata * value of the command but its effects directly. */ void sentinelDiscardReplyCallback(redisAsyncContext *c, void *reply, void *privdata) { sentinelRedisInstance *ri = c->data; + REDIS_NOTUSED(reply); + REDIS_NOTUSED(privdata); if (ri) ri->pending_commands--; } @@ -2019,6 +2024,7 @@ void sentinelDiscardReplyCallback(redisAsyncContext *c, void *reply, void *privd void sentinelPingReplyCallback(redisAsyncContext *c, void *reply, void *privdata) { sentinelRedisInstance *ri = c->data; redisReply *r; + REDIS_NOTUSED(privdata); if (ri) ri->pending_commands--; if (!reply || !ri) return; @@ -2057,6 +2063,7 @@ void sentinelPingReplyCallback(redisAsyncContext *c, void *reply, void *privdata void sentinelPublishReplyCallback(redisAsyncContext *c, void *reply, void *privdata) { sentinelRedisInstance *ri = c->data; redisReply *r; + REDIS_NOTUSED(privdata); if (ri) ri->pending_commands--; if (!reply || !ri) return; @@ -2166,6 +2173,7 @@ cleanup: void sentinelReceiveHelloMessages(redisAsyncContext *c, void *reply, void *privdata) { sentinelRedisInstance *ri = c->data; redisReply *r; + REDIS_NOTUSED(privdata); if (!reply || !ri) return; r = reply; @@ -2559,7 +2567,7 @@ sentinelRedisInstance *sentinelGetMasterByNameOrReplyError(redisClient *c, { sentinelRedisInstance *ri; - ri = dictFetchValue(sentinel.masters,c->argv[2]->ptr); + ri = dictFetchValue(sentinel.masters,name->ptr); if (!ri) { addReplyError(c,"No such master with that name"); return NULL; @@ -2997,7 +3005,7 @@ void sentinelCheckSubjectivelyDown(sentinelRedisInstance *ri) { void sentinelCheckObjectivelyDown(sentinelRedisInstance *master) { dictIterator *di; dictEntry *de; - int quorum = 0, odown = 0; + unsigned int quorum = 0, odown = 0; if (master->flags & SRI_S_DOWN) { /* Is down for enough sentinels? */ @@ -3034,6 +3042,7 @@ void sentinelCheckObjectivelyDown(sentinelRedisInstance *master) { void sentinelReceiveIsMasterDownReply(redisAsyncContext *c, void *reply, void *privdata) { sentinelRedisInstance *ri = c->data; redisReply *r; + REDIS_NOTUSED(privdata); if (ri) ri->pending_commands--; if (!reply || !ri) return; @@ -3057,7 +3066,7 @@ void sentinelReceiveIsMasterDownReply(redisAsyncContext *c, void *reply, void *p /* If the runid in the reply is not "*" the Sentinel actually * replied with a vote. */ sdsfree(ri->leader); - if (ri->leader_epoch != r->element[2]->integer) + if ((long long)ri->leader_epoch != r->element[2]->integer) redisLog(REDIS_WARNING, "%s voted for %s %llu", ri->name, r->element[1]->str, |