提交 eab0e26e 编写于 作者: A antirez

replaced redisAssert() with redisAssertWithInfo() in a shitload of places.

上级 bab205f7
......@@ -1232,7 +1232,7 @@ void clusterCommand(redisClient *c) {
retval = del ? clusterDelSlot(j) :
clusterAddSlot(server.cluster.myself,j);
redisAssert(retval == REDIS_OK);
redisAssertWithInfo(c,NULL,retval == REDIS_OK);
}
}
zfree(slots);
......@@ -1462,23 +1462,23 @@ void migrateCommand(redisClient *c) {
}
rioInitWithBuffer(&cmd,sdsempty());
redisAssert(rioWriteBulkCount(&cmd,'*',2));
redisAssert(rioWriteBulkString(&cmd,"SELECT",6));
redisAssert(rioWriteBulkLongLong(&cmd,dbid));
redisAssertWithInfo(c,NULL,rioWriteBulkCount(&cmd,'*',2));
redisAssertWithInfo(c,NULL,rioWriteBulkString(&cmd,"SELECT",6));
redisAssertWithInfo(c,NULL,rioWriteBulkLongLong(&cmd,dbid));
ttl = getExpire(c->db,c->argv[3]);
redisAssert(rioWriteBulkCount(&cmd,'*',4));
redisAssert(rioWriteBulkString(&cmd,"RESTORE",7));
redisAssert(c->argv[3]->encoding == REDIS_ENCODING_RAW);
redisAssert(rioWriteBulkString(&cmd,c->argv[3]->ptr,sdslen(c->argv[3]->ptr)));
redisAssert(rioWriteBulkLongLong(&cmd,(ttl == -1) ? 0 : ttl));
redisAssertWithInfo(c,NULL,rioWriteBulkCount(&cmd,'*',4));
redisAssertWithInfo(c,NULL,rioWriteBulkString(&cmd,"RESTORE",7));
redisAssertWithInfo(c,NULL,c->argv[3]->encoding == REDIS_ENCODING_RAW);
redisAssertWithInfo(c,NULL,rioWriteBulkString(&cmd,c->argv[3]->ptr,sdslen(c->argv[3]->ptr)));
redisAssertWithInfo(c,NULL,rioWriteBulkLongLong(&cmd,(ttl == -1) ? 0 : ttl));
/* Finally the last argument that is the serailized object payload
* in the form: <type><rdb-serialized-object>. */
rioInitWithBuffer(&payload,sdsempty());
redisAssert(rdbSaveObjectType(&payload,o));
redisAssert(rdbSaveObject(&payload,o) != -1);
redisAssert(rioWriteBulkString(&cmd,payload.io.buffer.ptr,sdslen(payload.io.buffer.ptr)));
redisAssertWithInfo(c,NULL,rdbSaveObjectType(&payload,o));
redisAssertWithInfo(c,NULL,rdbSaveObject(&payload,o) != -1);
redisAssertWithInfo(c,NULL,rioWriteBulkString(&cmd,payload.io.buffer.ptr,sdslen(payload.io.buffer.ptr)));
sdsfree(payload.io.buffer.ptr);
/* Tranfer the query to the other node in 64K chunks. */
......@@ -1561,8 +1561,8 @@ void dumpCommand(redisClient *c) {
/* Serialize the object in a RDB-like format. It consist of an object type
* byte followed by the serialized object. This is understood by RESTORE. */
rioInitWithBuffer(&payload,sdsempty());
redisAssert(rdbSaveObjectType(&payload,o));
redisAssert(rdbSaveObject(&payload,o));
redisAssertWithInfo(c,NULL,rdbSaveObjectType(&payload,o));
redisAssertWithInfo(c,NULL,rdbSaveObject(&payload,o));
/* Transfer to the client */
dumpobj = createObject(REDIS_STRING,payload.io.buffer.ptr);
......@@ -1632,7 +1632,7 @@ clusterNode *getNodeByQuery(redisClient *c, struct redisCommand *cmd, robj **arg
slot = keyHashSlot((char*)firstkey->ptr, sdslen(firstkey->ptr));
n = server.cluster.slots[slot];
redisAssert(n != NULL);
redisAssertWithInfo(c,firstkey,n != NULL);
} else {
/* If it is not the first key, make sure it is exactly
* the same key as the first we saw. */
......
......@@ -330,8 +330,8 @@ loaderr:
void configSetCommand(redisClient *c) {
robj *o;
long long ll;
redisAssert(c->argv[2]->encoding == REDIS_ENCODING_RAW);
redisAssert(c->argv[3]->encoding == REDIS_ENCODING_RAW);
redisAssertWithInfo(c,c->argv[2],c->argv[2]->encoding == REDIS_ENCODING_RAW);
redisAssertWithInfo(c,c->argv[2],c->argv[3]->encoding == REDIS_ENCODING_RAW);
o = c->argv[3];
if (!strcasecmp(c->argv[2]->ptr,"dbfilename")) {
......@@ -503,7 +503,7 @@ void configGetCommand(redisClient *c) {
char *pattern = o->ptr;
char buf[128];
int matches = 0;
redisAssert(o->encoding == REDIS_ENCODING_RAW);
redisAssertWithInfo(c,o,o->encoding == REDIS_ENCODING_RAW);
if (stringmatch(pattern,"dir",0)) {
char buf[1024];
......
......@@ -79,7 +79,7 @@ void dbAdd(redisDb *db, robj *key, robj *val) {
sds copy = sdsdup(key->ptr);
int retval = dictAdd(db->dict, copy, val);
redisAssert(retval == REDIS_OK);
redisAssertWithInfo(NULL,key,retval == REDIS_OK);
if (server.cluster_enabled) SlotToKeyAdd(key);
}
......@@ -91,7 +91,7 @@ void dbAdd(redisDb *db, robj *key, robj *val) {
void dbOverwrite(redisDb *db, robj *key, robj *val) {
struct dictEntry *de = dictFind(db->dict,key->ptr);
redisAssert(de != NULL);
redisAssertWithInfo(NULL,key,de != NULL);
dictReplace(db->dict, key->ptr, val);
}
......@@ -419,7 +419,7 @@ void moveCommand(redisClient *c) {
int removeExpire(redisDb *db, robj *key) {
/* An expire may only be removed if there is a corresponding entry in the
* main dict. Otherwise, the key will never be freed. */
redisAssert(dictFind(db->dict,key->ptr) != NULL);
redisAssertWithInfo(NULL,key,dictFind(db->dict,key->ptr) != NULL);
return dictDelete(db->expires,key->ptr) == DICT_OK;
}
......@@ -428,7 +428,7 @@ void setExpire(redisDb *db, robj *key, time_t when) {
/* Reuse the sds from the main dict in the expire dict */
de = dictFind(db->dict,key->ptr);
redisAssert(de != NULL);
redisAssertWithInfo(NULL,key,de != NULL);
dictReplace(db->expires,dictGetEntryKey(de),(void*)when);
}
......@@ -443,7 +443,7 @@ time_t getExpire(redisDb *db, robj *key) {
/* The entry was found in the expire dict, this means it should also
* be present in the main dict (safety check). */
redisAssert(dictFind(db->dict,key->ptr) != NULL);
redisAssertWithInfo(NULL,key,dictFind(db->dict,key->ptr) != NULL);
return (time_t) dictGetEntryVal(de);
}
......@@ -525,7 +525,7 @@ void expireGenericCommand(redisClient *c, robj *key, robj *param, long offset) {
if (seconds <= 0 && !server.loading && !server.masterhost) {
robj *aux;
redisAssert(dbDelete(c->db,key));
redisAssertWithInfo(c,key,dbDelete(c->db,key));
server.dirty++;
/* Replicate/AOF this as an explicit DEL. */
......
......@@ -194,7 +194,7 @@ void unwatchAllKeys(redisClient *c) {
* from the list */
wk = listNodeValue(ln);
clients = dictFetchValue(wk->db->watched_keys, wk->key);
redisAssert(clients != NULL);
redisAssertWithInfo(c,NULL,clients != NULL);
listDelNode(clients,listSearchKey(clients,c));
/* Kill the entry at all if this was the only client */
if (listLength(clients) == 0)
......
......@@ -703,7 +703,7 @@ int processMultibulkBuffer(redisClient *c) {
if (c->multibulklen == 0) {
/* The client should have been reset */
redisAssert(c->argc == 0);
redisAssertWithInfo(c,NULL,c->argc == 0);
/* Multi bulk length cannot be read without a \r\n */
newline = strchr(c->querybuf,'\r');
......@@ -716,7 +716,7 @@ int processMultibulkBuffer(redisClient *c) {
/* We know for sure there is a whole line since newline != NULL,
* so go ahead and find out the multi bulk length. */
redisAssert(c->querybuf[0] == '*');
redisAssertWithInfo(c,NULL,c->querybuf[0] == '*');
ok = string2ll(c->querybuf+1,newline-(c->querybuf+1),&ll);
if (!ok || ll > 1024*1024) {
addReplyError(c,"Protocol error: invalid multibulk length");
......@@ -737,7 +737,7 @@ int processMultibulkBuffer(redisClient *c) {
c->argv = zmalloc(sizeof(robj*)*c->multibulklen);
}
redisAssert(c->multibulklen > 0);
redisAssertWithInfo(c,NULL,c->multibulklen > 0);
while(c->multibulklen) {
/* Read bulk length if unknown */
if (c->bulklen == -1) {
......@@ -970,7 +970,7 @@ void rewriteClientCommandVector(redisClient *c, int argc, ...) {
c->argv = argv;
c->argc = argc;
c->cmd = lookupCommand(c->argv[0]->ptr);
redisAssert(c->cmd != NULL);
redisAssertWithInfo(c,NULL,c->cmd != NULL);
va_end(ap);
}
......@@ -979,7 +979,7 @@ void rewriteClientCommandVector(redisClient *c, int argc, ...) {
void rewriteClientCommandArgument(redisClient *c, int i, robj *newval) {
robj *oldval;
redisAssert(i < c->argc);
redisAssertWithInfo(c,NULL,i < c->argc);
oldval = c->argv[i];
c->argv[i] = newval;
incrRefCount(newval);
......@@ -988,6 +988,6 @@ void rewriteClientCommandArgument(redisClient *c, int i, robj *newval) {
/* If this is the command name make sure to fix c->cmd. */
if (i == 0) {
c->cmd = lookupCommand(c->argv[0]->ptr);
redisAssert(c->cmd != NULL);
redisAssertWithInfo(c,NULL,c->cmd != NULL);
}
}
......@@ -45,7 +45,7 @@ robj *createStringObjectFromLongLong(long long value) {
}
robj *dupStringObject(robj *o) {
redisAssert(o->encoding == REDIS_ENCODING_RAW);
redisAssertWithInfo(NULL,o,o->encoding == REDIS_ENCODING_RAW);
return createStringObject(o->ptr,sdslen(o->ptr));
}
......@@ -218,7 +218,7 @@ int checkType(redisClient *c, robj *o, int type) {
}
int isObjectRepresentableAsLongLong(robj *o, long long *llval) {
redisAssert(o->type == REDIS_STRING);
redisAssertWithInfo(NULL,o,o->type == REDIS_STRING);
if (o->encoding == REDIS_ENCODING_INT) {
if (llval) *llval = (long) o->ptr;
return REDIS_OK;
......@@ -241,7 +241,7 @@ robj *tryObjectEncoding(robj *o) {
if (o->refcount > 1) return o;
/* Currently we try to encode only strings */
redisAssert(o->type == REDIS_STRING);
redisAssertWithInfo(NULL,o,o->type == REDIS_STRING);
/* Check if we can represent this string as a long integer */
if (!string2l(s,sdslen(s),&value)) return o;
......@@ -296,7 +296,7 @@ robj *getDecodedObject(robj *o) {
* sdscmp() from sds.c will apply memcmp() so this function ca be considered
* binary safe. */
int compareStringObjects(robj *a, robj *b) {
redisAssert(a->type == REDIS_STRING && b->type == REDIS_STRING);
redisAssertWithInfo(NULL,a,a->type == REDIS_STRING && b->type == REDIS_STRING);
char bufa[128], bufb[128], *astr, *bstr;
int bothsds = 1;
......@@ -331,7 +331,7 @@ int equalStringObjects(robj *a, robj *b) {
}
size_t stringObjectLen(robj *o) {
redisAssert(o->type == REDIS_STRING);
redisAssertWithInfo(NULL,o,o->type == REDIS_STRING);
if (o->encoding == REDIS_ENCODING_RAW) {
return sdslen(o->ptr);
} else {
......@@ -348,7 +348,7 @@ int getDoubleFromObject(robj *o, double *target) {
if (o == NULL) {
value = 0;
} else {
redisAssert(o->type == REDIS_STRING);
redisAssertWithInfo(NULL,o,o->type == REDIS_STRING);
if (o->encoding == REDIS_ENCODING_RAW) {
value = strtod(o->ptr, &eptr);
if (eptr[0] != '\0' || isnan(value)) return REDIS_ERR;
......@@ -385,7 +385,7 @@ int getLongLongFromObject(robj *o, long long *target) {
if (o == NULL) {
value = 0;
} else {
redisAssert(o->type == REDIS_STRING);
redisAssertWithInfo(NULL,o,o->type == REDIS_STRING);
if (o->encoding == REDIS_ENCODING_RAW) {
value = strtoll(o->ptr, &eptr, 10);
if (eptr[0] != '\0') return REDIS_ERR;
......
......@@ -63,10 +63,10 @@ int pubsubUnsubscribeChannel(redisClient *c, robj *channel, int notify) {
retval = 1;
/* Remove the client from the channel -> clients list hash table */
de = dictFind(server.pubsub_channels,channel);
redisAssert(de != NULL);
redisAssertWithInfo(c,NULL,de != NULL);
clients = dictGetEntryVal(de);
ln = listSearchKey(clients,c);
redisAssert(ln != NULL);
redisAssertWithInfo(c,NULL,ln != NULL);
listDelNode(clients,ln);
if (listLength(clients) == 0) {
/* Free the list and associated hash entry at all if this was
......
......@@ -284,7 +284,7 @@ int rdbSaveStringObject(rio *rdb, robj *obj) {
if (obj->encoding == REDIS_ENCODING_INT) {
return rdbSaveLongLongAsStringObject(rdb,(long)obj->ptr);
} else {
redisAssert(obj->encoding == REDIS_ENCODING_RAW);
redisAssertWithInfo(NULL,obj,obj->encoding == REDIS_ENCODING_RAW);
return rdbSaveRawString(rdb,obj->ptr,sdslen(obj->ptr));
}
}
......@@ -553,7 +553,7 @@ int rdbSaveObject(rio *rdb, robj *o) {
* we could switch to a faster solution. */
off_t rdbSavedObjectLen(robj *o) {
int len = rdbSaveObject(NULL,o);
redisAssert(len != -1);
redisAssertWithInfo(NULL,o,len != -1);
return len;
}
......
......@@ -531,7 +531,7 @@ void evalGenericCommand(redisClient *c, int evalsha) {
{
int retval = dictAdd(server.lua_scripts,
sdsnewlen(funcname+2,40),c->argv[1]);
redisAssert(retval == DICT_OK);
redisAssertWithInfo(c,NULL,retval == DICT_OK);
incrRefCount(c->argv[1]);
}
}
......@@ -583,7 +583,7 @@ void evalGenericCommand(redisClient *c, int evalsha) {
if (evalsha) {
robj *script = dictFetchValue(server.lua_scripts,c->argv[1]->ptr);
redisAssert(script != NULL);
redisAssertWithInfo(c,NULL,script != NULL);
rewriteClientCommandArgument(c,0,
resetRefCount(createStringObject("EVAL",4)));
rewriteClientCommandArgument(c,1,script);
......
......@@ -247,7 +247,7 @@ void sortCommand(redisClient *c) {
} else {
redisPanic("Unknown type");
}
redisAssert(j == vectorlen);
redisAssertWithInfo(c,sortval,j == vectorlen);
/* Now it's time to load the right scores in the sorting vector */
if (dontsort == 0) {
......@@ -273,7 +273,7 @@ void sortCommand(redisClient *c) {
* far. We can just cast it */
vector[j].u.score = (long)byval->ptr;
} else {
redisAssert(1 != 1);
redisAssertWithInfo(c,sortval,1 != 1);
}
}
......@@ -330,7 +330,8 @@ void sortCommand(redisClient *c) {
decrRefCount(val);
}
} else {
redisAssert(sop->type == REDIS_SORT_GET); /* always fails */
/* Always fails */
redisAssertWithInfo(c,sortval,sop->type == REDIS_SORT_GET);
}
}
}
......@@ -360,8 +361,8 @@ void sortCommand(redisClient *c) {
listTypePush(sobj,val,REDIS_TAIL);
decrRefCount(val);
} else {
/* always fails */
redisAssert(sop->type == REDIS_SORT_GET);
/* Always fails */
redisAssertWithInfo(c,sortval,sop->type == REDIS_SORT_GET);
}
}
}
......
......@@ -160,7 +160,7 @@ hashTypeIterator *hashTypeInitIterator(robj *subject) {
} else if (hi->encoding == REDIS_ENCODING_HT) {
hi->di = dictGetIterator(subject->ptr);
} else {
redisAssert(NULL);
redisAssertWithInfo(NULL,subject,0);
}
return hi;
}
......@@ -250,7 +250,7 @@ void convertToRealHash(robj *o) {
unsigned int klen, vlen;
dict *dict = dictCreate(&hashDictType,NULL);
redisAssert(o->type == REDIS_HASH && o->encoding != REDIS_ENCODING_HT);
redisAssertWithInfo(NULL,o,o->type == REDIS_HASH && o->encoding != REDIS_ENCODING_HT);
p = zipmapRewind(zm);
while((p = zipmapNext(p,&key,&klen,&val,&vlen)) != NULL) {
robj *keyobj, *valobj;
......
......@@ -198,7 +198,7 @@ void listTypeInsert(listTypeEntry *entry, robj *value, int where) {
int listTypeEqual(listTypeEntry *entry, robj *o) {
listTypeIterator *li = entry->li;
if (li->encoding == REDIS_ENCODING_ZIPLIST) {
redisAssert(o->encoding == REDIS_ENCODING_RAW);
redisAssertWithInfo(NULL,o,o->encoding == REDIS_ENCODING_RAW);
return ziplistCompare(entry->zi,o->ptr,sdslen(o->ptr));
} else if (li->encoding == REDIS_ENCODING_LINKEDLIST) {
return equalStringObjects(o,listNodeValue(entry->ln));
......@@ -235,7 +235,7 @@ void listTypeDelete(listTypeEntry *entry) {
void listTypeConvert(robj *subject, int enc) {
listTypeIterator *li;
listTypeEntry entry;
redisAssert(subject->type == REDIS_LIST);
redisAssertWithInfo(NULL,subject,subject->type == REDIS_LIST);
if (enc == REDIS_ENCODING_LINKEDLIST) {
list *l = listCreate();
......@@ -310,7 +310,7 @@ void pushxGenericCommand(redisClient *c, robj *refval, robj *val, int where) {
if (refval != NULL) {
/* Note: we expect refval to be string-encoded because it is *not* the
* last argument of the multi-bulk LINSERT. */
redisAssert(refval->encoding == REDIS_ENCODING_RAW);
redisAssertWithInfo(c,refval,refval->encoding == REDIS_ENCODING_RAW);
/* We're not sure if this value can be inserted yet, but we cannot
* convert the list inside the iterator. We don't want to loop over
......@@ -774,7 +774,7 @@ void blockForKeys(redisClient *c, robj **keys, int numkeys, time_t timeout, robj
l = listCreate();
retval = dictAdd(c->db->blocking_keys,keys[j],l);
incrRefCount(keys[j]);
redisAssert(retval == DICT_OK);
redisAssertWithInfo(c,keys[j],retval == DICT_OK);
} else {
l = dictGetEntryVal(de);
}
......@@ -791,12 +791,12 @@ void unblockClientWaitingData(redisClient *c) {
list *l;
int j;
redisAssert(c->bpop.keys != NULL);
redisAssertWithInfo(c,NULL,c->bpop.keys != NULL);
/* The client may wait for multiple keys, so unblock it for every key. */
for (j = 0; j < c->bpop.count; j++) {
/* Remove this client from the list of clients waiting for this key. */
de = dictFind(c->db->blocking_keys,c->bpop.keys[j]);
redisAssert(de != NULL);
redisAssertWithInfo(c,c->bpop.keys[j],de != NULL);
l = dictGetEntryVal(de);
listDelNode(l,listSearchKey(l,c));
/* If the list is empty we need to remove it to avoid wasting memory */
......@@ -848,7 +848,7 @@ int handleClientsWaitingListPush(redisClient *c, robj *key, robj *ele) {
* this happens, it simply tries the next client waiting for a push. */
while (numclients--) {
ln = listFirst(clients);
redisAssert(ln != NULL);
redisAssertWithInfo(c,key,ln != NULL);
receiver = ln->value;
dstkey = receiver->bpop.target;
......@@ -995,7 +995,7 @@ void brpoplpushCommand(redisClient *c) {
/* The list exists and has elements, so
* the regular rpoplpushCommand is executed. */
redisAssert(listTypeLength(key) > 0);
redisAssertWithInfo(c,key,listTypeLength(key) > 0);
rpoplpushCommand(c);
}
}
......
......@@ -37,7 +37,7 @@ int setTypeAdd(robj *subject, robj *value) {
/* The set *was* an intset and this value is not integer
* encodable, so dictAdd should always work. */
redisAssert(dictAdd(subject->ptr,value,NULL) == DICT_OK);
redisAssertWithInfo(NULL,value,dictAdd(subject->ptr,value,NULL) == DICT_OK);
incrRefCount(value);
return 1;
}
......@@ -189,8 +189,8 @@ unsigned long setTypeSize(robj *subject) {
* set. */
void setTypeConvert(robj *setobj, int enc) {
setTypeIterator *si;
redisAssert(setobj->type == REDIS_SET &&
setobj->encoding == REDIS_ENCODING_INTSET);
redisAssertWithInfo(NULL,setobj,setobj->type == REDIS_SET &&
setobj->encoding == REDIS_ENCODING_INTSET);
if (enc == REDIS_ENCODING_HT) {
int64_t intele;
......@@ -204,7 +204,7 @@ void setTypeConvert(robj *setobj, int enc) {
si = setTypeInitIterator(setobj);
while (setTypeNext(si,NULL,&intele) != -1) {
element = createStringObjectFromLongLong(intele);
redisAssert(dictAdd(d,element,NULL) == DICT_OK);
redisAssertWithInfo(NULL,element,dictAdd(d,element,NULL) == DICT_OK);
}
setTypeReleaseIterator(si);
......
......@@ -578,7 +578,7 @@ unsigned char *zzlFind(unsigned char *zl, robj *ele, double *score) {
ele = getDecodedObject(ele);
while (eptr != NULL) {
sptr = ziplistNext(zl,eptr);
redisAssert(sptr != NULL);
redisAssertWithInfo(NULL,ele,sptr != NULL);
if (ziplistCompare(eptr,ele->ptr,sdslen(ele->ptr))) {
/* Matching element, pull out score. */
......@@ -612,7 +612,7 @@ unsigned char *zzlInsertAt(unsigned char *zl, unsigned char *eptr, robj *ele, do
int scorelen;
size_t offset;
redisAssert(ele->encoding == REDIS_ENCODING_RAW);
redisAssertWithInfo(NULL,ele,ele->encoding == REDIS_ENCODING_RAW);
scorelen = d2string(scorebuf,sizeof(scorebuf),score);
if (eptr == NULL) {
zl = ziplistPush(zl,ele->ptr,sdslen(ele->ptr),ZIPLIST_TAIL);
......@@ -624,7 +624,7 @@ unsigned char *zzlInsertAt(unsigned char *zl, unsigned char *eptr, robj *ele, do
eptr = zl+offset;
/* Insert score after the element. */
redisAssert((sptr = ziplistNext(zl,eptr)) != NULL);
redisAssertWithInfo(NULL,ele,(sptr = ziplistNext(zl,eptr)) != NULL);
zl = ziplistInsert(zl,sptr,(unsigned char*)scorebuf,scorelen);
}
......@@ -640,7 +640,7 @@ unsigned char *zzlInsert(unsigned char *zl, robj *ele, double score) {
ele = getDecodedObject(ele);
while (eptr != NULL) {
sptr = ziplistNext(zl,eptr);
redisAssert(sptr != NULL);
redisAssertWithInfo(NULL,ele,sptr != NULL);
s = zzlGetScore(sptr);
if (s > score) {
......@@ -745,13 +745,13 @@ void zsetConvert(robj *zobj, int encoding) {
zs->zsl = zslCreate();
eptr = ziplistIndex(zl,0);
redisAssert(eptr != NULL);
redisAssertWithInfo(NULL,zobj,eptr != NULL);
sptr = ziplistNext(zl,eptr);
redisAssert(sptr != NULL);
redisAssertWithInfo(NULL,zobj,sptr != NULL);
while (eptr != NULL) {
score = zzlGetScore(sptr);
redisAssert(ziplistGet(eptr,&vstr,&vlen,&vlong));
redisAssertWithInfo(NULL,zobj,ziplistGet(eptr,&vstr,&vlen,&vlong));
if (vstr == NULL)
ele = createStringObjectFromLongLong(vlong);
else
......@@ -759,7 +759,7 @@ void zsetConvert(robj *zobj, int encoding) {
/* Has incremented refcount since it was just created. */
node = zslInsert(zs->zsl,score,ele);
redisAssert(dictAdd(zs->dict,ele,&node->score) == DICT_OK);
redisAssertWithInfo(NULL,zobj,dictAdd(zs->dict,ele,&node->score) == DICT_OK);
incrRefCount(ele); /* Added to dictionary. */
zzlNext(zl,&eptr,&sptr);
}
......@@ -918,7 +918,7 @@ void zaddGenericCommand(redisClient *c, int incr) {
* delete the key object from the skiplist, since the
* dictionary still has a reference to it. */
if (score != curscore) {
redisAssert(zslDelete(zs->zsl,curscore,curobj));
redisAssertWithInfo(c,curobj,zslDelete(zs->zsl,curscore,curobj));
znode = zslInsert(zs->zsl,score,curobj);
incrRefCount(curobj); /* Re-inserted in skiplist. */
dictGetEntryVal(de) = &znode->score; /* Update score ptr. */
......@@ -929,7 +929,7 @@ void zaddGenericCommand(redisClient *c, int incr) {
} else {
znode = zslInsert(zs->zsl,score,ele);
incrRefCount(ele); /* Inserted in skiplist. */
redisAssert(dictAdd(zs->dict,ele,&znode->score) == DICT_OK);
redisAssertWithInfo(c,curobj,dictAdd(zs->dict,ele,&znode->score) == DICT_OK);
incrRefCount(ele); /* Added to dictionary. */
signalModifiedKey(c->db,key);
......@@ -988,7 +988,7 @@ void zremCommand(redisClient *c) {
/* Delete from the skiplist */
score = *(double*)dictGetEntryVal(de);
redisAssert(zslDelete(zs->zsl,score,c->argv[j]));
redisAssertWithInfo(c,c->argv[j],zslDelete(zs->zsl,score,c->argv[j]));
/* Delete from the hash table */
dictDelete(zs->dict,c->argv[j]);
......@@ -1698,12 +1698,12 @@ void zrangeGenericCommand(redisClient *c, int reverse) {
else
eptr = ziplistIndex(zl,2*start);
redisAssert(eptr != NULL);
redisAssertWithInfo(c,zobj,eptr != NULL);
sptr = ziplistNext(zl,eptr);
while (rangelen--) {
redisAssert(eptr != NULL && sptr != NULL);
redisAssert(ziplistGet(eptr,&vstr,&vlen,&vlong));
redisAssertWithInfo(c,zobj,eptr != NULL && sptr != NULL);
redisAssertWithInfo(c,zobj,ziplistGet(eptr,&vstr,&vlen,&vlong));
if (vstr == NULL)
addReplyBulkLongLong(c,vlong);
else
......@@ -1736,7 +1736,7 @@ void zrangeGenericCommand(redisClient *c, int reverse) {
}
while(rangelen--) {
redisAssert(ln != NULL);
redisAssertWithInfo(c,zobj,ln != NULL);
ele = ln->obj;
addReplyBulk(c,ele);
if (withscores)
......@@ -1828,7 +1828,7 @@ void genericZrangebyscoreCommand(redisClient *c, int reverse) {
}
/* Get score pointer for the first element. */
redisAssert(eptr != NULL);
redisAssertWithInfo(c,zobj,eptr != NULL);
sptr = ziplistNext(zl,eptr);
/* We don't know in advance how many matching elements there are in the
......@@ -1857,7 +1857,7 @@ void genericZrangebyscoreCommand(redisClient *c, int reverse) {
}
/* We know the element exists, so ziplistGet should always succeed */
redisAssert(ziplistGet(eptr,&vstr,&vlen,&vlong));
redisAssertWithInfo(c,zobj,ziplistGet(eptr,&vstr,&vlen,&vlong));
rangelen++;
if (vstr == NULL) {
......@@ -1984,7 +1984,7 @@ void zcountCommand(redisClient *c) {
/* First element is in range */
sptr = ziplistNext(zl,eptr);
score = zzlGetScore(sptr);
redisAssert(zslValueLteMax(score,&range));
redisAssertWithInfo(c,zobj,zslValueLteMax(score,&range));
/* Iterate over elements in range */
while (eptr) {
......@@ -2079,15 +2079,15 @@ void zrankGenericCommand(redisClient *c, int reverse) {
checkType(c,zobj,REDIS_ZSET)) return;
llen = zsetLength(zobj);
redisAssert(ele->encoding == REDIS_ENCODING_RAW);
redisAssertWithInfo(c,ele,ele->encoding == REDIS_ENCODING_RAW);
if (zobj->encoding == REDIS_ENCODING_ZIPLIST) {
unsigned char *zl = zobj->ptr;
unsigned char *eptr, *sptr;
eptr = ziplistIndex(zl,0);
redisAssert(eptr != NULL);
redisAssertWithInfo(c,zobj,eptr != NULL);
sptr = ziplistNext(zl,eptr);
redisAssert(sptr != NULL);
redisAssertWithInfo(c,zobj,sptr != NULL);
rank = 1;
while(eptr != NULL) {
......@@ -2116,7 +2116,7 @@ void zrankGenericCommand(redisClient *c, int reverse) {
if (de != NULL) {
score = *(double*)dictGetEntryVal(de);
rank = zslGetRank(zsl,score,ele);
redisAssert(rank); /* Existing elements always have a rank. */
redisAssertWithInfo(c,ele,rank); /* Existing elements always have a rank. */
if (reverse)
addReplyLongLong(c,llen-rank);
else
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册