Fix some wrongly used constants in module.c (#8844)

This change does not fix any bugs.
1. ```moduleUnload``` should return ```C_OK``` or ```C_ERR```, not ```REDISMODULE_ERR``` or ```REDISMODULE_OK```.
2. The ```where``` parameter of ```listTypePush``` and ```listTypePop``` should be ```LIST_HEAD``` or ```LIST_TAIL```
This commit is contained in:
sundb 2021-04-25 15:36:02 +08:00 committed by GitHub
parent cc0091f0f9
commit f29a0b9351
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 8 deletions

View File

@ -2566,7 +2566,7 @@ int RM_ListPush(RedisModuleKey *key, int where, RedisModuleString *ele) {
if (key->value && key->value->type != OBJ_LIST) return REDISMODULE_ERR; if (key->value && key->value->type != OBJ_LIST) return REDISMODULE_ERR;
if (key->value == NULL) moduleCreateEmptyKey(key,REDISMODULE_KEYTYPE_LIST); if (key->value == NULL) moduleCreateEmptyKey(key,REDISMODULE_KEYTYPE_LIST);
listTypePush(key->value, ele, listTypePush(key->value, ele,
(where == REDISMODULE_LIST_HEAD) ? QUICKLIST_HEAD : QUICKLIST_TAIL); (where == REDISMODULE_LIST_HEAD) ? LIST_HEAD : LIST_TAIL);
return REDISMODULE_OK; return REDISMODULE_OK;
} }
@ -2583,7 +2583,7 @@ RedisModuleString *RM_ListPop(RedisModuleKey *key, int where) {
key->value == NULL || key->value == NULL ||
key->value->type != OBJ_LIST) return NULL; key->value->type != OBJ_LIST) return NULL;
robj *ele = listTypePop(key->value, robj *ele = listTypePop(key->value,
(where == REDISMODULE_LIST_HEAD) ? QUICKLIST_HEAD : QUICKLIST_TAIL); (where == REDISMODULE_LIST_HEAD) ? LIST_HEAD : LIST_TAIL);
robj *decoded = getDecodedObject(ele); robj *decoded = getDecodedObject(ele);
decrRefCount(ele); decrRefCount(ele);
moduleDelKeyIfEmpty(key); moduleDelKeyIfEmpty(key);
@ -8589,16 +8589,16 @@ int moduleUnload(sds name) {
if (module == NULL) { if (module == NULL) {
errno = ENOENT; errno = ENOENT;
return REDISMODULE_ERR; return C_ERR;
} else if (listLength(module->types)) { } else if (listLength(module->types)) {
errno = EBUSY; errno = EBUSY;
return REDISMODULE_ERR; return C_ERR;
} else if (listLength(module->usedby)) { } else if (listLength(module->usedby)) {
errno = EPERM; errno = EPERM;
return REDISMODULE_ERR; return C_ERR;
} else if (module->blocked_clients) { } else if (module->blocked_clients) {
errno = EAGAIN; errno = EAGAIN;
return REDISMODULE_ERR; return C_ERR;
} }
/* Give module a chance to clean up. */ /* Give module a chance to clean up. */
@ -8614,7 +8614,7 @@ int moduleUnload(sds name) {
if (unload_status == REDISMODULE_ERR) { if (unload_status == REDISMODULE_ERR) {
serverLog(LL_WARNING, "Module %s OnUnload failed. Unload canceled.", name); serverLog(LL_WARNING, "Module %s OnUnload failed. Unload canceled.", name);
errno = ECANCELED; errno = ECANCELED;
return REDISMODULE_ERR; return C_ERR;
} }
} }
@ -8647,7 +8647,7 @@ int moduleUnload(sds name) {
module->name = NULL; /* The name was already freed by dictDelete(). */ module->name = NULL; /* The name was already freed by dictDelete(). */
moduleFreeModuleStructure(module); moduleFreeModuleStructure(module);
return REDISMODULE_OK; return C_OK;
} }
/* Helper function for the MODULE and HELLO command: send the list of the /* Helper function for the MODULE and HELLO command: send the list of the