From f29a0b9351e61ae16a7cfeaa2c05c409221988ca Mon Sep 17 00:00:00 2001 From: sundb Date: Sun, 25 Apr 2021 15:36:02 +0800 Subject: [PATCH] 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``` --- src/module.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/module.c b/src/module.c index 33bec50e9..2cc071e62 100644 --- a/src/module.c +++ b/src/module.c @@ -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 == NULL) moduleCreateEmptyKey(key,REDISMODULE_KEYTYPE_LIST); listTypePush(key->value, ele, - (where == REDISMODULE_LIST_HEAD) ? QUICKLIST_HEAD : QUICKLIST_TAIL); + (where == REDISMODULE_LIST_HEAD) ? LIST_HEAD : LIST_TAIL); return REDISMODULE_OK; } @@ -2583,7 +2583,7 @@ RedisModuleString *RM_ListPop(RedisModuleKey *key, int where) { key->value == NULL || key->value->type != OBJ_LIST) return NULL; 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); decrRefCount(ele); moduleDelKeyIfEmpty(key); @@ -8589,16 +8589,16 @@ int moduleUnload(sds name) { if (module == NULL) { errno = ENOENT; - return REDISMODULE_ERR; + return C_ERR; } else if (listLength(module->types)) { errno = EBUSY; - return REDISMODULE_ERR; + return C_ERR; } else if (listLength(module->usedby)) { errno = EPERM; - return REDISMODULE_ERR; + return C_ERR; } else if (module->blocked_clients) { errno = EAGAIN; - return REDISMODULE_ERR; + return C_ERR; } /* Give module a chance to clean up. */ @@ -8614,7 +8614,7 @@ int moduleUnload(sds name) { if (unload_status == REDISMODULE_ERR) { serverLog(LL_WARNING, "Module %s OnUnload failed. Unload canceled.", name); 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(). */ moduleFreeModuleStructure(module); - return REDISMODULE_OK; + return C_OK; } /* Helper function for the MODULE and HELLO command: send the list of the