Commit 2d9e3eb1 authored by antirez's avatar antirez
Browse files

RDMF: redisAssert -> serverAssert.

parent 14ff5724
...@@ -70,7 +70,7 @@ int hashTypeGetFromZiplist(robj *o, robj *field, ...@@ -70,7 +70,7 @@ int hashTypeGetFromZiplist(robj *o, robj *field,
unsigned char *zl, *fptr = NULL, *vptr = NULL; unsigned char *zl, *fptr = NULL, *vptr = NULL;
int ret; int ret;
redisAssert(o->encoding == OBJ_ENCODING_ZIPLIST); serverAssert(o->encoding == OBJ_ENCODING_ZIPLIST);
field = getDecodedObject(field); field = getDecodedObject(field);
...@@ -81,7 +81,7 @@ int hashTypeGetFromZiplist(robj *o, robj *field, ...@@ -81,7 +81,7 @@ int hashTypeGetFromZiplist(robj *o, robj *field,
if (fptr != NULL) { if (fptr != NULL) {
/* Grab pointer to the value (fptr points to the field) */ /* Grab pointer to the value (fptr points to the field) */
vptr = ziplistNext(zl, fptr); vptr = ziplistNext(zl, fptr);
redisAssert(vptr != NULL); serverAssert(vptr != NULL);
} }
} }
...@@ -89,7 +89,7 @@ int hashTypeGetFromZiplist(robj *o, robj *field, ...@@ -89,7 +89,7 @@ int hashTypeGetFromZiplist(robj *o, robj *field,
if (vptr != NULL) { if (vptr != NULL) {
ret = ziplistGet(vptr, vstr, vlen, vll); ret = ziplistGet(vptr, vstr, vlen, vll);
redisAssert(ret); serverAssert(ret);
return 0; return 0;
} }
...@@ -101,7 +101,7 @@ int hashTypeGetFromZiplist(robj *o, robj *field, ...@@ -101,7 +101,7 @@ int hashTypeGetFromZiplist(robj *o, robj *field,
int hashTypeGetFromHashTable(robj *o, robj *field, robj **value) { int hashTypeGetFromHashTable(robj *o, robj *field, robj **value) {
dictEntry *de; dictEntry *de;
redisAssert(o->encoding == OBJ_ENCODING_HT); serverAssert(o->encoding == OBJ_ENCODING_HT);
de = dictFind(o->ptr, field); de = dictFind(o->ptr, field);
if (de == NULL) return -1; if (de == NULL) return -1;
...@@ -205,7 +205,7 @@ int hashTypeSet(robj *o, robj *field, robj *value) { ...@@ -205,7 +205,7 @@ int hashTypeSet(robj *o, robj *field, robj *value) {
if (fptr != NULL) { if (fptr != NULL) {
/* Grab pointer to the value (fptr points to the field) */ /* Grab pointer to the value (fptr points to the field) */
vptr = ziplistNext(zl, fptr); vptr = ziplistNext(zl, fptr);
redisAssert(vptr != NULL); serverAssert(vptr != NULL);
update = 1; update = 1;
/* Delete value */ /* Delete value */
...@@ -333,18 +333,18 @@ int hashTypeNext(hashTypeIterator *hi) { ...@@ -333,18 +333,18 @@ int hashTypeNext(hashTypeIterator *hi) {
if (fptr == NULL) { if (fptr == NULL) {
/* Initialize cursor */ /* Initialize cursor */
redisAssert(vptr == NULL); serverAssert(vptr == NULL);
fptr = ziplistIndex(zl, 0); fptr = ziplistIndex(zl, 0);
} else { } else {
/* Advance cursor */ /* Advance cursor */
redisAssert(vptr != NULL); serverAssert(vptr != NULL);
fptr = ziplistNext(zl, vptr); fptr = ziplistNext(zl, vptr);
} }
if (fptr == NULL) return REDIS_ERR; if (fptr == NULL) return REDIS_ERR;
/* Grab pointer to the value (fptr points to the field) */ /* Grab pointer to the value (fptr points to the field) */
vptr = ziplistNext(zl, fptr); vptr = ziplistNext(zl, fptr);
redisAssert(vptr != NULL); serverAssert(vptr != NULL);
/* fptr, vptr now point to the first or next pair */ /* fptr, vptr now point to the first or next pair */
hi->fptr = fptr; hi->fptr = fptr;
...@@ -366,21 +366,21 @@ void hashTypeCurrentFromZiplist(hashTypeIterator *hi, int what, ...@@ -366,21 +366,21 @@ void hashTypeCurrentFromZiplist(hashTypeIterator *hi, int what,
{ {
int ret; int ret;
redisAssert(hi->encoding == OBJ_ENCODING_ZIPLIST); serverAssert(hi->encoding == OBJ_ENCODING_ZIPLIST);
if (what & OBJ_HASH_KEY) { if (what & OBJ_HASH_KEY) {
ret = ziplistGet(hi->fptr, vstr, vlen, vll); ret = ziplistGet(hi->fptr, vstr, vlen, vll);
redisAssert(ret); serverAssert(ret);
} else { } else {
ret = ziplistGet(hi->vptr, vstr, vlen, vll); ret = ziplistGet(hi->vptr, vstr, vlen, vll);
redisAssert(ret); serverAssert(ret);
} }
} }
/* Get the field or value at iterator cursor, for an iterator on a hash value /* Get the field or value at iterator cursor, for an iterator on a hash value
* encoded as a ziplist. Prototype is similar to `hashTypeGetFromHashTable`. */ * encoded as a ziplist. Prototype is similar to `hashTypeGetFromHashTable`. */
void hashTypeCurrentFromHashTable(hashTypeIterator *hi, int what, robj **dst) { void hashTypeCurrentFromHashTable(hashTypeIterator *hi, int what, robj **dst) {
redisAssert(hi->encoding == OBJ_ENCODING_HT); serverAssert(hi->encoding == OBJ_ENCODING_HT);
if (what & OBJ_HASH_KEY) { if (what & OBJ_HASH_KEY) {
*dst = dictGetKey(hi->de); *dst = dictGetKey(hi->de);
...@@ -430,7 +430,7 @@ robj *hashTypeLookupWriteOrCreate(client *c, robj *key) { ...@@ -430,7 +430,7 @@ robj *hashTypeLookupWriteOrCreate(client *c, robj *key) {
} }
void hashTypeConvertZiplist(robj *o, int enc) { void hashTypeConvertZiplist(robj *o, int enc) {
redisAssert(o->encoding == OBJ_ENCODING_ZIPLIST); serverAssert(o->encoding == OBJ_ENCODING_ZIPLIST);
if (enc == OBJ_ENCODING_ZIPLIST) { if (enc == OBJ_ENCODING_ZIPLIST) {
/* Nothing to do... */ /* Nothing to do... */
...@@ -454,7 +454,7 @@ void hashTypeConvertZiplist(robj *o, int enc) { ...@@ -454,7 +454,7 @@ void hashTypeConvertZiplist(robj *o, int enc) {
if (ret != DICT_OK) { if (ret != DICT_OK) {
serverLogHexDump(REDIS_WARNING,"ziplist with dup elements dump", serverLogHexDump(REDIS_WARNING,"ziplist with dup elements dump",
o->ptr,ziplistBlobLen(o->ptr)); o->ptr,ziplistBlobLen(o->ptr));
redisAssert(ret == DICT_OK); serverAssert(ret == DICT_OK);
} }
} }
...@@ -768,7 +768,7 @@ void genericHgetallCommand(client *c, int flags) { ...@@ -768,7 +768,7 @@ void genericHgetallCommand(client *c, int flags) {
} }
hashTypeReleaseIterator(hi); hashTypeReleaseIterator(hi);
redisAssert(count == length); serverAssert(count == length);
} }
void hkeysCommand(client *c) { void hkeysCommand(client *c) {
......
...@@ -111,7 +111,7 @@ void listTypeReleaseIterator(listTypeIterator *li) { ...@@ -111,7 +111,7 @@ void listTypeReleaseIterator(listTypeIterator *li) {
* entry is in fact an entry, 0 otherwise. */ * entry is in fact an entry, 0 otherwise. */
int listTypeNext(listTypeIterator *li, listTypeEntry *entry) { int listTypeNext(listTypeIterator *li, listTypeEntry *entry) {
/* Protect from converting when iterating */ /* Protect from converting when iterating */
redisAssert(li->subject->encoding == li->encoding); serverAssert(li->subject->encoding == li->encoding);
entry->li = li; entry->li = li;
if (li->encoding == OBJ_ENCODING_QUICKLIST) { if (li->encoding == OBJ_ENCODING_QUICKLIST) {
...@@ -159,7 +159,7 @@ void listTypeInsert(listTypeEntry *entry, robj *value, int where) { ...@@ -159,7 +159,7 @@ void listTypeInsert(listTypeEntry *entry, robj *value, int where) {
/* Compare the given object with the entry at the current position. */ /* Compare the given object with the entry at the current position. */
int listTypeEqual(listTypeEntry *entry, robj *o) { int listTypeEqual(listTypeEntry *entry, robj *o) {
if (entry->li->encoding == OBJ_ENCODING_QUICKLIST) { if (entry->li->encoding == OBJ_ENCODING_QUICKLIST) {
redisAssertWithInfo(NULL,o,sdsEncodedObject(o)); serverAssertWithInfo(NULL,o,sdsEncodedObject(o));
return quicklistCompare(entry->entry.zi,o->ptr,sdslen(o->ptr)); return quicklistCompare(entry->entry.zi,o->ptr,sdslen(o->ptr));
} else { } else {
redisPanic("Unknown list encoding"); redisPanic("Unknown list encoding");
...@@ -177,8 +177,8 @@ void listTypeDelete(listTypeIterator *iter, listTypeEntry *entry) { ...@@ -177,8 +177,8 @@ void listTypeDelete(listTypeIterator *iter, listTypeEntry *entry) {
/* Create a quicklist from a single ziplist */ /* Create a quicklist from a single ziplist */
void listTypeConvert(robj *subject, int enc) { void listTypeConvert(robj *subject, int enc) {
redisAssertWithInfo(NULL,subject,subject->type==OBJ_LIST); serverAssertWithInfo(NULL,subject,subject->type==OBJ_LIST);
redisAssertWithInfo(NULL,subject,subject->encoding==OBJ_ENCODING_ZIPLIST); serverAssertWithInfo(NULL,subject,subject->encoding==OBJ_ENCODING_ZIPLIST);
if (enc == OBJ_ENCODING_QUICKLIST) { if (enc == OBJ_ENCODING_QUICKLIST) {
size_t zlen = server.list_max_ziplist_size; size_t zlen = server.list_max_ziplist_size;
...@@ -632,7 +632,7 @@ void blockForKeys(client *c, robj **keys, int numkeys, mstime_t timeout, robj *t ...@@ -632,7 +632,7 @@ void blockForKeys(client *c, robj **keys, int numkeys, mstime_t timeout, robj *t
l = listCreate(); l = listCreate();
retval = dictAdd(c->db->blocking_keys,keys[j],l); retval = dictAdd(c->db->blocking_keys,keys[j],l);
incrRefCount(keys[j]); incrRefCount(keys[j]);
redisAssertWithInfo(c,keys[j],retval == DICT_OK); serverAssertWithInfo(c,keys[j],retval == DICT_OK);
} else { } else {
l = dictGetVal(de); l = dictGetVal(de);
} }
...@@ -648,7 +648,7 @@ void unblockClientWaitingData(client *c) { ...@@ -648,7 +648,7 @@ void unblockClientWaitingData(client *c) {
dictIterator *di; dictIterator *di;
list *l; list *l;
redisAssertWithInfo(c,NULL,dictSize(c->bpop.keys) != 0); serverAssertWithInfo(c,NULL,dictSize(c->bpop.keys) != 0);
di = dictGetIterator(c->bpop.keys); di = dictGetIterator(c->bpop.keys);
/* The client may wait for multiple keys, so unblock it for every key. */ /* The client may wait for multiple keys, so unblock it for every key. */
while((de = dictNext(di)) != NULL) { while((de = dictNext(di)) != NULL) {
...@@ -656,7 +656,7 @@ void unblockClientWaitingData(client *c) { ...@@ -656,7 +656,7 @@ void unblockClientWaitingData(client *c) {
/* Remove this client from the list of clients waiting for this key. */ /* Remove this client from the list of clients waiting for this key. */
l = dictFetchValue(c->db->blocking_keys,key); l = dictFetchValue(c->db->blocking_keys,key);
redisAssertWithInfo(c,key,l != NULL); serverAssertWithInfo(c,key,l != NULL);
listDelNode(l,listSearchKey(l,c)); listDelNode(l,listSearchKey(l,c));
/* If the list is empty we need to remove it to avoid wasting memory */ /* If the list is empty we need to remove it to avoid wasting memory */
if (listLength(l) == 0) if (listLength(l) == 0)
...@@ -699,7 +699,7 @@ void signalListAsReady(redisDb *db, robj *key) { ...@@ -699,7 +699,7 @@ void signalListAsReady(redisDb *db, robj *key) {
* to avoid adding it multiple times into a list with a simple O(1) * to avoid adding it multiple times into a list with a simple O(1)
* check. */ * check. */
incrRefCount(key); incrRefCount(key);
redisAssert(dictAdd(db->ready_keys,key,NULL) == DICT_OK); serverAssert(dictAdd(db->ready_keys,key,NULL) == DICT_OK);
} }
/* This is a helper function for handleClientsBlockedOnLists(). It's work /* This is a helper function for handleClientsBlockedOnLists(). It's work
...@@ -882,7 +882,7 @@ void blockingPopGenericCommand(client *c, int where) { ...@@ -882,7 +882,7 @@ void blockingPopGenericCommand(client *c, int where) {
/* Non empty list, this is like a non normal [LR]POP. */ /* Non empty list, this is like a non normal [LR]POP. */
char *event = (where == REDIS_HEAD) ? "lpop" : "rpop"; char *event = (where == REDIS_HEAD) ? "lpop" : "rpop";
robj *value = listTypePop(o,where); robj *value = listTypePop(o,where);
redisAssert(value != NULL); serverAssert(value != NULL);
addReplyMultiBulkLen(c,2); addReplyMultiBulkLen(c,2);
addReplyBulk(c,c->argv[j]); addReplyBulk(c,c->argv[j]);
...@@ -950,7 +950,7 @@ void brpoplpushCommand(client *c) { ...@@ -950,7 +950,7 @@ void brpoplpushCommand(client *c) {
} else { } else {
/* The list exists and has elements, so /* The list exists and has elements, so
* the regular rpoplpushCommand is executed. */ * the regular rpoplpushCommand is executed. */
redisAssertWithInfo(c,key,listTypeLength(key) > 0); serverAssertWithInfo(c,key,listTypeLength(key) > 0);
rpoplpushCommand(c); rpoplpushCommand(c);
} }
} }
......
...@@ -74,7 +74,7 @@ int setTypeAdd(robj *subject, robj *value) { ...@@ -74,7 +74,7 @@ int setTypeAdd(robj *subject, robj *value) {
/* The set *was* an intset and this value is not integer /* The set *was* an intset and this value is not integer
* encodable, so dictAdd should always work. */ * encodable, so dictAdd should always work. */
redisAssertWithInfo(NULL,value, serverAssertWithInfo(NULL,value,
dictAdd(subject->ptr,value,NULL) == DICT_OK); dictAdd(subject->ptr,value,NULL) == DICT_OK);
incrRefCount(value); incrRefCount(value);
return 1; return 1;
...@@ -241,7 +241,7 @@ unsigned long setTypeSize(robj *subject) { ...@@ -241,7 +241,7 @@ unsigned long setTypeSize(robj *subject) {
* set. */ * set. */
void setTypeConvert(robj *setobj, int enc) { void setTypeConvert(robj *setobj, int enc) {
setTypeIterator *si; setTypeIterator *si;
redisAssertWithInfo(NULL,setobj,setobj->type == OBJ_SET && serverAssertWithInfo(NULL,setobj,setobj->type == OBJ_SET &&
setobj->encoding == OBJ_ENCODING_INTSET); setobj->encoding == OBJ_ENCODING_INTSET);
if (enc == OBJ_ENCODING_HT) { if (enc == OBJ_ENCODING_HT) {
...@@ -256,7 +256,7 @@ void setTypeConvert(robj *setobj, int enc) { ...@@ -256,7 +256,7 @@ void setTypeConvert(robj *setobj, int enc) {
si = setTypeInitIterator(setobj); si = setTypeInitIterator(setobj);
while (setTypeNext(si,&element,&intele) != -1) { while (setTypeNext(si,&element,&intele) != -1) {
element = createStringObjectFromLongLong(intele); element = createStringObjectFromLongLong(intele);
redisAssertWithInfo(NULL,element, serverAssertWithInfo(NULL,element,
dictAdd(d,element,NULL) == DICT_OK); dictAdd(d,element,NULL) == DICT_OK);
} }
setTypeReleaseIterator(si); setTypeReleaseIterator(si);
...@@ -696,10 +696,10 @@ void srandmemberWithCountCommand(client *c) { ...@@ -696,10 +696,10 @@ void srandmemberWithCountCommand(client *c) {
} else { } else {
retval = dictAdd(d,dupStringObject(ele),NULL); retval = dictAdd(d,dupStringObject(ele),NULL);
} }
redisAssert(retval == DICT_OK); serverAssert(retval == DICT_OK);
} }
setTypeReleaseIterator(si); setTypeReleaseIterator(si);
redisAssert(dictSize(d) == size); serverAssert(dictSize(d) == size);
/* Remove random elements to reach the right count. */ /* Remove random elements to reach the right count. */
while(size > count) { while(size > count) {
......
...@@ -112,7 +112,7 @@ zskiplistNode *zslInsert(zskiplist *zsl, double score, robj *obj) { ...@@ -112,7 +112,7 @@ zskiplistNode *zslInsert(zskiplist *zsl, double score, robj *obj) {
unsigned int rank[ZSKIPLIST_MAXLEVEL]; unsigned int rank[ZSKIPLIST_MAXLEVEL];
int i, level; int i, level;
redisAssert(!isnan(score)); serverAssert(!isnan(score));
x = zsl->header; x = zsl->header;
for (i = zsl->level-1; i >= 0; i--) { for (i = zsl->level-1; i >= 0; i--) {
/* store rank that is crossed to reach the insert position */ /* store rank that is crossed to reach the insert position */
...@@ -253,7 +253,7 @@ zskiplistNode *zslFirstInRange(zskiplist *zsl, zrangespec *range) { ...@@ -253,7 +253,7 @@ zskiplistNode *zslFirstInRange(zskiplist *zsl, zrangespec *range) {
/* This is an inner range, so the next node cannot be NULL. */ /* This is an inner range, so the next node cannot be NULL. */
x = x->level[0].forward; x = x->level[0].forward;
redisAssert(x != NULL); serverAssert(x != NULL);
/* Check if score <= max. */ /* Check if score <= max. */
if (!zslValueLteMax(x->score,range)) return NULL; if (!zslValueLteMax(x->score,range)) return NULL;
...@@ -278,7 +278,7 @@ zskiplistNode *zslLastInRange(zskiplist *zsl, zrangespec *range) { ...@@ -278,7 +278,7 @@ zskiplistNode *zslLastInRange(zskiplist *zsl, zrangespec *range) {
} }
/* This is an inner range, so this node cannot be NULL. */ /* This is an inner range, so this node cannot be NULL. */
redisAssert(x != NULL); serverAssert(x != NULL);
/* Check if score >= min. */ /* Check if score >= min. */
if (!zslValueGteMin(x->score,range)) return NULL; if (!zslValueGteMin(x->score,range)) return NULL;
...@@ -596,7 +596,7 @@ zskiplistNode *zslFirstInLexRange(zskiplist *zsl, zlexrangespec *range) { ...@@ -596,7 +596,7 @@ zskiplistNode *zslFirstInLexRange(zskiplist *zsl, zlexrangespec *range) {
/* This is an inner range, so the next node cannot be NULL. */ /* This is an inner range, so the next node cannot be NULL. */
x = x->level[0].forward; x = x->level[0].forward;
redisAssert(x != NULL); serverAssert(x != NULL);
/* Check if score <= max. */ /* Check if score <= max. */
if (!zslLexValueLteMax(x->obj,range)) return NULL; if (!zslLexValueLteMax(x->obj,range)) return NULL;
...@@ -621,7 +621,7 @@ zskiplistNode *zslLastInLexRange(zskiplist *zsl, zlexrangespec *range) { ...@@ -621,7 +621,7 @@ zskiplistNode *zslLastInLexRange(zskiplist *zsl, zlexrangespec *range) {
} }
/* This is an inner range, so this node cannot be NULL. */ /* This is an inner range, so this node cannot be NULL. */
redisAssert(x != NULL); serverAssert(x != NULL);
/* Check if score >= min. */ /* Check if score >= min. */
if (!zslLexValueGteMin(x->obj,range)) return NULL; if (!zslLexValueGteMin(x->obj,range)) return NULL;
...@@ -639,8 +639,8 @@ double zzlGetScore(unsigned char *sptr) { ...@@ -639,8 +639,8 @@ double zzlGetScore(unsigned char *sptr) {
char buf[128]; char buf[128];
double score; double score;
redisAssert(sptr != NULL); serverAssert(sptr != NULL);
redisAssert(ziplistGet(sptr,&vstr,&vlen,&vlong)); serverAssert(ziplistGet(sptr,&vstr,&vlen,&vlong));
if (vstr) { if (vstr) {
memcpy(buf,vstr,vlen); memcpy(buf,vstr,vlen);
...@@ -661,8 +661,8 @@ robj *ziplistGetObject(unsigned char *sptr) { ...@@ -661,8 +661,8 @@ robj *ziplistGetObject(unsigned char *sptr) {
unsigned int vlen; unsigned int vlen;
long long vlong; long long vlong;
redisAssert(sptr != NULL); serverAssert(sptr != NULL);
redisAssert(ziplistGet(sptr,&vstr,&vlen,&vlong)); serverAssert(ziplistGet(sptr,&vstr,&vlen,&vlong));
if (vstr) { if (vstr) {
return createStringObject((char*)vstr,vlen); return createStringObject((char*)vstr,vlen);
...@@ -679,7 +679,7 @@ int zzlCompareElements(unsigned char *eptr, unsigned char *cstr, unsigned int cl ...@@ -679,7 +679,7 @@ int zzlCompareElements(unsigned char *eptr, unsigned char *cstr, unsigned int cl
unsigned char vbuf[32]; unsigned char vbuf[32];
int minlen, cmp; int minlen, cmp;
redisAssert(ziplistGet(eptr,&vstr,&vlen,&vlong)); serverAssert(ziplistGet(eptr,&vstr,&vlen,&vlong));
if (vstr == NULL) { if (vstr == NULL) {
/* Store string representation of long long in buf. */ /* Store string representation of long long in buf. */
vlen = ll2string((char*)vbuf,sizeof(vbuf),vlong); vlen = ll2string((char*)vbuf,sizeof(vbuf),vlong);
...@@ -700,12 +700,12 @@ unsigned int zzlLength(unsigned char *zl) { ...@@ -700,12 +700,12 @@ unsigned int zzlLength(unsigned char *zl) {
* NULL when there is no next entry. */ * NULL when there is no next entry. */
void zzlNext(unsigned char *zl, unsigned char **eptr, unsigned char **sptr) { void zzlNext(unsigned char *zl, unsigned char **eptr, unsigned char **sptr) {
unsigned char *_eptr, *_sptr; unsigned char *_eptr, *_sptr;
redisAssert(*eptr != NULL && *sptr != NULL); serverAssert(*eptr != NULL && *sptr != NULL);
_eptr = ziplistNext(zl,*sptr); _eptr = ziplistNext(zl,*sptr);
if (_eptr != NULL) { if (_eptr != NULL) {
_sptr = ziplistNext(zl,_eptr); _sptr = ziplistNext(zl,_eptr);
redisAssert(_sptr != NULL); serverAssert(_sptr != NULL);
} else { } else {
/* No next entry. */ /* No next entry. */
_sptr = NULL; _sptr = NULL;
...@@ -719,12 +719,12 @@ void zzlNext(unsigned char *zl, unsigned char **eptr, unsigned char **sptr) { ...@@ -719,12 +719,12 @@ void zzlNext(unsigned char *zl, unsigned char **eptr, unsigned char **sptr) {
* set to NULL when there is no next entry. */ * set to NULL when there is no next entry. */
void zzlPrev(unsigned char *zl, unsigned char **eptr, unsigned char **sptr) { void zzlPrev(unsigned char *zl, unsigned char **eptr, unsigned char **sptr) {
unsigned char *_eptr, *_sptr; unsigned char *_eptr, *_sptr;
redisAssert(*eptr != NULL && *sptr != NULL); serverAssert(*eptr != NULL && *sptr != NULL);
_sptr = ziplistPrev(zl,*eptr); _sptr = ziplistPrev(zl,*eptr);
if (_sptr != NULL) { if (_sptr != NULL) {
_eptr = ziplistPrev(zl,_sptr); _eptr = ziplistPrev(zl,_sptr);
redisAssert(_eptr != NULL); serverAssert(_eptr != NULL);
} else { } else {
/* No previous entry. */ /* No previous entry. */
_eptr = NULL; _eptr = NULL;
...@@ -752,7 +752,7 @@ int zzlIsInRange(unsigned char *zl, zrangespec *range) { ...@@ -752,7 +752,7 @@ int zzlIsInRange(unsigned char *zl, zrangespec *range) {
return 0; return 0;
p = ziplistIndex(zl,1); /* First score. */ p = ziplistIndex(zl,1); /* First score. */
redisAssert(p != NULL); serverAssert(p != NULL);
score = zzlGetScore(p); score = zzlGetScore(p);
if (!zslValueLteMax(score,range)) if (!zslValueLteMax(score,range))
return 0; return 0;
...@@ -771,7 +771,7 @@ unsigned char *zzlFirstInRange(unsigned char *zl, zrangespec *range) { ...@@ -771,7 +771,7 @@ unsigned char *zzlFirstInRange(unsigned char *zl, zrangespec *range) {
while (eptr != NULL) { while (eptr != NULL) {
sptr = ziplistNext(zl,eptr); sptr = ziplistNext(zl,eptr);
redisAssert(sptr != NULL); serverAssert(sptr != NULL);
score = zzlGetScore(sptr); score = zzlGetScore(sptr);
if (zslValueGteMin(score,range)) { if (zslValueGteMin(score,range)) {
...@@ -799,7 +799,7 @@ unsigned char *zzlLastInRange(unsigned char *zl, zrangespec *range) { ...@@ -799,7 +799,7 @@ unsigned char *zzlLastInRange(unsigned char *zl, zrangespec *range) {
while (eptr != NULL) { while (eptr != NULL) {
sptr = ziplistNext(zl,eptr); sptr = ziplistNext(zl,eptr);
redisAssert(sptr != NULL); serverAssert(sptr != NULL);
score = zzlGetScore(sptr); score = zzlGetScore(sptr);
if (zslValueLteMax(score,range)) { if (zslValueLteMax(score,range)) {
...@@ -813,7 +813,7 @@ unsigned char *zzlLastInRange(unsigned char *zl, zrangespec *range) { ...@@ -813,7 +813,7 @@ unsigned char *zzlLastInRange(unsigned char *zl, zrangespec *range) {
* When this returns NULL, we know there also is no element. */ * When this returns NULL, we know there also is no element. */
sptr = ziplistPrev(zl,eptr); sptr = ziplistPrev(zl,eptr);
if (sptr != NULL) if (sptr != NULL)
redisAssert((eptr = ziplistPrev(zl,sptr)) != NULL); serverAssert((eptr = ziplistPrev(zl,sptr)) != NULL);
else else
eptr = NULL; eptr = NULL;
} }
...@@ -852,7 +852,7 @@ int zzlIsInLexRange(unsigned char *zl, zlexrangespec *range) { ...@@ -852,7 +852,7 @@ int zzlIsInLexRange(unsigned char *zl, zlexrangespec *range) {
return 0; return 0;
p = ziplistIndex(zl,0); /* First element. */ p = ziplistIndex(zl,0); /* First element. */
redisAssert(p != NULL); serverAssert(p != NULL);
if (!zzlLexValueLteMax(p,range)) if (!zzlLexValueLteMax(p,range))
return 0; return 0;
...@@ -877,7 +877,7 @@ unsigned char *zzlFirstInLexRange(unsigned char *zl, zlexrangespec *range) { ...@@ -877,7 +877,7 @@ unsigned char *zzlFirstInLexRange(unsigned char *zl, zlexrangespec *range) {
/* Move to next element. */ /* Move to next element. */
sptr = ziplistNext(zl,eptr); /* This element score. Skip it. */ sptr = ziplistNext(zl,eptr); /* This element score. Skip it. */
redisAssert(sptr != NULL); serverAssert(sptr != NULL);
eptr = ziplistNext(zl,sptr); /* Next element. */ eptr = ziplistNext(zl,sptr); /* Next element. */
} }
...@@ -904,7 +904,7 @@ unsigned char *zzlLastInLexRange(unsigned char *zl, zlexrangespec *range) { ...@@ -904,7 +904,7 @@ unsigned char *zzlLastInLexRange(unsigned char *zl, zlexrangespec *range) {
* When this returns NULL, we know there also is no element. */ * When this returns NULL, we know there also is no element. */
sptr = ziplistPrev(zl,eptr); sptr = ziplistPrev(zl,eptr);
if (sptr != NULL) if (sptr != NULL)
redisAssert((eptr = ziplistPrev(zl,sptr)) != NULL); serverAssert((eptr = ziplistPrev(zl,sptr)) != NULL);
else else
eptr = NULL; eptr = NULL;
} }
...@@ -918,7 +918,7 @@ unsigned char *zzlFind(unsigned char *zl, robj *ele, double *score) { ...@@ -918,7 +918,7 @@ unsigned char *zzlFind(unsigned char *zl, robj *ele, double *score) {
ele = getDecodedObject(ele); ele = getDecodedObject(ele);
while (eptr != NULL) { while (eptr != NULL) {
sptr = ziplistNext(zl,eptr); sptr = ziplistNext(zl,eptr);
redisAssertWithInfo(NULL,ele,sptr != NULL); serverAssertWithInfo(NULL,ele,sptr != NULL);
if (ziplistCompare(eptr,ele->ptr,sdslen(ele->ptr))) { if (ziplistCompare(eptr,ele->ptr,sdslen(ele->ptr))) {
/* Matching element, pull out score. */ /* Matching element, pull out score. */
...@@ -952,7 +952,7 @@ unsigned char *zzlInsertAt(unsigned char *zl, unsigned char *eptr, robj *ele, do ...@@ -952,7 +952,7 @@ unsigned char *zzlInsertAt(unsigned char *zl, unsigned char *eptr, robj *ele, do
int scorelen; int scorelen;
size_t offset; size_t offset;
redisAssertWithInfo(NULL,ele,sdsEncodedObject(ele)); serverAssertWithInfo(NULL,ele,sdsEncodedObject(ele));
scorelen = d2string(scorebuf,sizeof(scorebuf),score); scorelen = d2string(scorebuf,sizeof(scorebuf),score);
if (eptr == NULL) { if (eptr == NULL) {
zl = ziplistPush(zl,ele->ptr,sdslen(ele->ptr),ZIPLIST_TAIL); zl = ziplistPush(zl,ele->ptr,sdslen(ele->ptr),ZIPLIST_TAIL);
...@@ -964,7 +964,7 @@ unsigned char *zzlInsertAt(unsigned char *zl, unsigned char *eptr, robj *ele, do ...@@ -964,7 +964,7 @@ unsigned char *zzlInsertAt(unsigned char *zl, unsigned char *eptr, robj *ele, do
eptr = zl+offset; eptr = zl+offset;
/* Insert score after the element. */ /* Insert score after the element. */
redisAssertWithInfo(NULL,ele,(sptr = ziplistNext(zl,eptr)) != NULL); serverAssertWithInfo(NULL,ele,(sptr = ziplistNext(zl,eptr)) != NULL);
zl = ziplistInsert(zl,sptr,(unsigned char*)scorebuf,scorelen); zl = ziplistInsert(zl,sptr,(unsigned char*)scorebuf,scorelen);
} }
...@@ -980,7 +980,7 @@ unsigned char *zzlInsert(unsigned char *zl, robj *ele, double score) { ...@@ -980,7 +980,7 @@ unsigned char *zzlInsert(unsigned char *zl, robj *ele, double score) {
ele = getDecodedObject(ele); ele = getDecodedObject(ele);
while (eptr != NULL) { while (eptr != NULL) {
sptr = ziplistNext(zl,eptr); sptr = ziplistNext(zl,eptr);
redisAssertWithInfo(NULL,ele,sptr != NULL); serverAssertWithInfo(NULL,ele,sptr != NULL);
s = zzlGetScore(sptr); s = zzlGetScore(sptr);
if (s > score) { if (s > score) {
...@@ -1112,13 +1112,13 @@ void zsetConvert(robj *zobj, int encoding) { ...@@ -1112,13 +1112,13 @@ void zsetConvert(robj *zobj, int encoding) {
zs->zsl = zslCreate(); zs->zsl = zslCreate();
eptr = ziplistIndex(zl,0); eptr = ziplistIndex(zl,0);
redisAssertWithInfo(NULL,zobj,eptr != NULL); serverAssertWithInfo(NULL,zobj,eptr != NULL);
sptr = ziplistNext(zl,eptr); sptr = ziplistNext(zl,eptr);
redisAssertWithInfo(NULL,zobj,sptr != NULL); serverAssertWithInfo(NULL,zobj,sptr != NULL);
while (eptr != NULL) { while (eptr != NULL) {
score = zzlGetScore(sptr); score = zzlGetScore(sptr);
redisAssertWithInfo(NULL,zobj,ziplistGet(eptr,&vstr,&vlen,&vlong)); serverAssertWithInfo(NULL,zobj,ziplistGet(eptr,&vstr,&vlen,&vlong));
if (vstr == NULL) if (vstr == NULL)
ele = createStringObjectFromLongLong(vlong); ele = createStringObjectFromLongLong(vlong);
else else
...@@ -1126,7 +1126,7 @@ void zsetConvert(robj *zobj, int encoding) { ...@@ -1126,7 +1126,7 @@ void zsetConvert(robj *zobj, int encoding) {
/* Has incremented refcount since it was just created. */ /* Has incremented refcount since it was just created. */
node = zslInsert(zs->zsl,score,ele); node = zslInsert(zs->zsl,score,ele);
redisAssertWithInfo(NULL,zobj,dictAdd(zs->dict,ele,&node->score) == DICT_OK); serverAssertWithInfo(NULL,zobj,dictAdd(zs->dict,ele,&node->score) == DICT_OK);
incrRefCount(ele); /* Added to dictionary. */ incrRefCount(ele); /* Added to dictionary. */
zzlNext(zl,&eptr,&sptr); zzlNext(zl,&eptr,&sptr);
} }
...@@ -1347,7 +1347,7 @@ void zaddGenericCommand(client *c, int flags) { ...@@ -1347,7 +1347,7 @@ void zaddGenericCommand(client *c, int flags) {
* delete the key object from the skiplist, since the * delete the key object from the skiplist, since the
* dictionary still has a reference to it. */ * dictionary still has a reference to it. */
if (score != curscore) { if (score != curscore) {
redisAssertWithInfo(c,curobj,zslDelete(zs->zsl,curscore,curobj)); serverAssertWithInfo(c,curobj,zslDelete(zs->zsl,curscore,curobj));
znode = zslInsert(zs->zsl,score,curobj); znode = zslInsert(zs->zsl,score,curobj);
incrRefCount(curobj); /* Re-inserted in skiplist. */ incrRefCount(curobj); /* Re-inserted in skiplist. */
dictGetVal(de) = &znode->score; /* Update score ptr. */ dictGetVal(de) = &znode->score; /* Update score ptr. */
...@@ -1358,7 +1358,7 @@ void zaddGenericCommand(client *c, int flags) { ...@@ -1358,7 +1358,7 @@ void zaddGenericCommand(client *c, int flags) {
} else if (!xx) { } else if (!xx) {
znode = zslInsert(zs->zsl,score,ele); znode = zslInsert(zs->zsl,score,ele);
incrRefCount(ele); /* Inserted in skiplist. */ incrRefCount(ele); /* Inserted in skiplist. */
redisAssertWithInfo(c,NULL,dictAdd(zs->dict,ele,&znode->score) == DICT_OK); serverAssertWithInfo(c,NULL,dictAdd(zs->dict,ele,&znode->score) == DICT_OK);
incrRefCount(ele); /* Added to dictionary. */ incrRefCount(ele); /* Added to dictionary. */
server.dirty++; server.dirty++;
added++; added++;
...@@ -1430,7 +1430,7 @@ void zremCommand(client *c) { ...@@ -1430,7 +1430,7 @@ void zremCommand(client *c) {
/* Delete from the skiplist */ /* Delete from the skiplist */
score = *(double*)dictGetVal(de); score = *(double*)dictGetVal(de);
redisAssertWithInfo(c,c->argv[j],zslDelete(zs->zsl,score,c->argv[j])); serverAssertWithInfo(c,c->argv[j],zslDelete(zs->zsl,score,c->argv[j]));
/* Delete from the hash table */ /* Delete from the hash table */
dictDelete(zs->dict,c->argv[j]); dictDelete(zs->dict,c->argv[j]);
...@@ -1654,7 +1654,7 @@ void zuiInitIterator(zsetopsrc *op) { ...@@ -1654,7 +1654,7 @@ void zuiInitIterator(zsetopsrc *op) {
it->zl.eptr = ziplistIndex(it->zl.zl,0); it->zl.eptr = ziplistIndex(it->zl.zl,0);
if (it->zl.eptr != NULL) { if (it->zl.eptr != NULL) {
it->zl.sptr = ziplistNext(it->zl.zl,it->zl.eptr); it->zl.sptr = ziplistNext(it->zl.zl,it->zl.eptr);
redisAssert(it->zl.sptr != NULL); serverAssert(it->zl.sptr != NULL);
} }
} else if (op->encoding == OBJ_ENCODING_SKIPLIST) { } else if (op->encoding == OBJ_ENCODING_SKIPLIST) {
it->sl.zs = op->subject->ptr; it->sl.zs = op->subject->ptr;
...@@ -1762,7 +1762,7 @@ int zuiNext(zsetopsrc *op, zsetopval *val) { ...@@ -1762,7 +1762,7 @@ int zuiNext(zsetopsrc *op, zsetopval *val) {
/* No need to check both, but better be explicit. */ /* No need to check both, but better be explicit. */
if (it->zl.eptr == NULL || it->zl.sptr == NULL) if (it->zl.eptr == NULL || it->zl.sptr == NULL)
return 0; return 0;
redisAssert(ziplistGet(it->zl.eptr,&val->estr,&val->elen,&val->ell)); serverAssert(ziplistGet(it->zl.eptr,&val->estr,&val->elen,&val->ell));
val->score = zzlGetScore(it->zl.sptr); val->score = zzlGetScore(it->zl.sptr);
/* Move to next element. */ /* Move to next element. */
...@@ -2223,12 +2223,12 @@ void zrangeGenericCommand(client *c, int reverse) { ...@@ -2223,12 +2223,12 @@ void zrangeGenericCommand(client *c, int reverse) {
else else
eptr = ziplistIndex(zl,2*start); eptr = ziplistIndex(zl,2*start);
redisAssertWithInfo(c,zobj,eptr != NULL); serverAssertWithInfo(c,zobj,eptr != NULL);
sptr = ziplistNext(zl,eptr); sptr = ziplistNext(zl,eptr);
while (rangelen--) { while (rangelen--) {
redisAssertWithInfo(c,zobj,eptr != NULL && sptr != NULL); serverAssertWithInfo(c,zobj,eptr != NULL && sptr != NULL);
redisAssertWithInfo(c,zobj,ziplistGet(eptr,&vstr,&vlen,&vlong)); serverAssertWithInfo(c,zobj,ziplistGet(eptr,&vstr,&vlen,&vlong));
if (vstr == NULL) if (vstr == NULL)
addReplyBulkLongLong(c,vlong); addReplyBulkLongLong(c,vlong);
else else
...@@ -2261,7 +2261,7 @@ void zrangeGenericCommand(client *c, int reverse) { ...@@ -2261,7 +2261,7 @@ void zrangeGenericCommand(client *c, int reverse) {
} }
while(rangelen--) { while(rangelen--) {
redisAssertWithInfo(c,zobj,ln != NULL); serverAssertWithInfo(c,zobj,ln != NULL);
ele = ln->obj; ele = ln->obj;
addReplyBulk(c,ele); addReplyBulk(c,ele);
if (withscores) if (withscores)
...@@ -2353,7 +2353,7 @@ void genericZrangebyscoreCommand(client *c, int reverse) { ...@@ -2353,7 +2353,7 @@ void genericZrangebyscoreCommand(client *c, int reverse) {
} }
/* Get score pointer for the first element. */ /* Get score pointer for the first element. */
redisAssertWithInfo(c,zobj,eptr != NULL); serverAssertWithInfo(c,zobj,eptr != NULL);
sptr = ziplistNext(zl,eptr); sptr = ziplistNext(zl,eptr);
/* We don't know in advance how many matching elements there are in the /* We don't know in advance how many matching elements there are in the
...@@ -2382,7 +2382,7 @@ void genericZrangebyscoreCommand(client *c, int reverse) { ...@@ -2382,7 +2382,7 @@ void genericZrangebyscoreCommand(client *c, int reverse) {
} }
/* We know the element exists, so ziplistGet should always succeed */ /* We know the element exists, so ziplistGet should always succeed */
redisAssertWithInfo(c,zobj,ziplistGet(eptr,&vstr,&vlen,&vlong)); serverAssertWithInfo(c,zobj,ziplistGet(eptr,&vstr,&vlen,&vlong));
rangelen++; rangelen++;
if (vstr == NULL) { if (vstr == NULL) {
...@@ -2509,7 +2509,7 @@ void zcountCommand(client *c) { ...@@ -2509,7 +2509,7 @@ void zcountCommand(client *c) {
/* First element is in range */ /* First element is in range */
sptr = ziplistNext(zl,eptr); sptr = ziplistNext(zl,eptr);
score = zzlGetScore(sptr); score = zzlGetScore(sptr);
redisAssertWithInfo(c,zobj,zslValueLteMax(score,&range)); serverAssertWithInfo(c,zobj,zslValueLteMax(score,&range));
/* Iterate over elements in range */ /* Iterate over elements in range */
while (eptr) { while (eptr) {
...@@ -2589,7 +2589,7 @@ void zlexcountCommand(client *c) { ...@@ -2589,7 +2589,7 @@ void zlexcountCommand(client *c) {
/* First element is in range */ /* First element is in range */
sptr = ziplistNext(zl,eptr); sptr = ziplistNext(zl,eptr);
redisAssertWithInfo(c,zobj,zzlLexValueLteMax(eptr,&range)); serverAssertWithInfo(c,zobj,zzlLexValueLteMax(eptr,&range));
/* Iterate over elements in range */ /* Iterate over elements in range */
while (eptr) { while (eptr) {
...@@ -2705,7 +2705,7 @@ void genericZrangebylexCommand(client *c, int reverse) { ...@@ -2705,7 +2705,7 @@ void genericZrangebylexCommand(client *c, int reverse) {
} }
/* Get score pointer for the first element. */ /* Get score pointer for the first element. */
redisAssertWithInfo(c,zobj,eptr != NULL); serverAssertWithInfo(c,zobj,eptr != NULL);
sptr = ziplistNext(zl,eptr); sptr = ziplistNext(zl,eptr);
/* We don't know in advance how many matching elements there are in the /* We don't know in advance how many matching elements there are in the
...@@ -2733,7 +2733,7 @@ void genericZrangebylexCommand(client *c, int reverse) { ...@@ -2733,7 +2733,7 @@ void genericZrangebylexCommand(client *c, int reverse) {
/* We know the element exists, so ziplistGet should always /* We know the element exists, so ziplistGet should always
* succeed. */ * succeed. */
redisAssertWithInfo(c,zobj,ziplistGet(eptr,&vstr,&vlen,&vlong)); serverAssertWithInfo(c,zobj,ziplistGet(eptr,&vstr,&vlen,&vlong));
rangelen++; rangelen++;
if (vstr == NULL) { if (vstr == NULL) {
...@@ -2853,16 +2853,16 @@ void zrankGenericCommand(client *c, int reverse) { ...@@ -2853,16 +2853,16 @@ void zrankGenericCommand(client *c, int reverse) {
checkType(c,zobj,OBJ_ZSET)) return; checkType(c,zobj,OBJ_ZSET)) return;
llen = zsetLength(zobj); llen = zsetLength(zobj);
redisAssertWithInfo(c,ele,sdsEncodedObject(ele)); serverAssertWithInfo(c,ele,sdsEncodedObject(ele));
if (zobj->encoding == OBJ_ENCODING_ZIPLIST) { if (zobj->encoding == OBJ_ENCODING_ZIPLIST) {
unsigned char *zl = zobj->ptr; unsigned char *zl = zobj->ptr;
unsigned char *eptr, *sptr; unsigned char *eptr, *sptr;
eptr = ziplistIndex(zl,0); eptr = ziplistIndex(zl,0);
redisAssertWithInfo(c,zobj,eptr != NULL); serverAssertWithInfo(c,zobj,eptr != NULL);
sptr = ziplistNext(zl,eptr); sptr = ziplistNext(zl,eptr);
redisAssertWithInfo(c,zobj,sptr != NULL); serverAssertWithInfo(c,zobj,sptr != NULL);
rank = 1; rank = 1;
while(eptr != NULL) { while(eptr != NULL) {
...@@ -2891,7 +2891,7 @@ void zrankGenericCommand(client *c, int reverse) { ...@@ -2891,7 +2891,7 @@ void zrankGenericCommand(client *c, int reverse) {
if (de != NULL) { if (de != NULL) {
score = *(double*)dictGetVal(de); score = *(double*)dictGetVal(de);
rank = zslGetRank(zsl,score,ele); rank = zslGetRank(zsl,score,ele);
redisAssertWithInfo(c,ele,rank); /* Existing elements always have a rank. */ serverAssertWithInfo(c,ele,rank); /* Existing elements always have a rank. */
if (reverse) if (reverse)
addReplyLongLong(c,llen-rank); addReplyLongLong(c,llen-rank);
else else
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment