mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-23 00:28:26 -05:00
Set: setType*() API more defensive initializing both values.
This change fixes several warnings compiling at -O3 level with GCC 4.8.2, and at the same time, in case of misuse of the API, we have the pointer initialize to NULL or the integer initialized to the value -123456789 which is easy to spot by naked eye.
This commit is contained in:
parent
34460dd6ee
commit
7f330b16f9
@ -154,9 +154,13 @@ int setTypeNext(setTypeIterator *si, robj **objele, int64_t *llele) {
|
||||
dictEntry *de = dictNext(si->di);
|
||||
if (de == NULL) return -1;
|
||||
*objele = dictGetKey(de);
|
||||
*llele = -123456789; /* Not needed. Defensive. */
|
||||
} else if (si->encoding == REDIS_ENCODING_INTSET) {
|
||||
if (!intsetGet(si->subject->ptr,si->ii++,llele))
|
||||
return -1;
|
||||
*objele = NULL; /* Not needed. Defensive. */
|
||||
} else {
|
||||
redisPanic("Wrong set encoding in setTypeNext");
|
||||
}
|
||||
return si->encoding;
|
||||
}
|
||||
@ -204,8 +208,10 @@ int setTypeRandomElement(robj *setobj, robj **objele, int64_t *llele) {
|
||||
if (setobj->encoding == REDIS_ENCODING_HT) {
|
||||
dictEntry *de = dictGetRandomKey(setobj->ptr);
|
||||
*objele = dictGetKey(de);
|
||||
*llele = -123456789; /* Not needed. Defensive. */
|
||||
} else if (setobj->encoding == REDIS_ENCODING_INTSET) {
|
||||
*llele = intsetRandom(setobj->ptr);
|
||||
*objele = NULL; /* Not needed. Defensive. */
|
||||
} else {
|
||||
redisPanic("Unknown set encoding");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user