summaryrefslogtreecommitdiff
path: root/tests/modules
diff options
context:
space:
mode:
authorOran Agra <oran@redislabs.com>2022-05-09 13:36:53 +0300
committerGitHub <noreply@github.com>2022-05-09 13:36:53 +0300
commiteb915a82a5f4d7fd6c36ad1710b35e2b0c2abd31 (patch)
treec7a5f12b5db6f77f5cdf2ef90a54e70954c3c786 /tests/modules
parent8fc959216cbea4af100dd38011a1b5466d0628bb (diff)
downloadredis-eb915a82a5f4d7fd6c36ad1710b35e2b0c2abd31.tar.gz
Bug fixes for enum configs with overlapping bit flags (module API) (#10661)
If we want to support bits that can be overlapping, we need to make sure that: 1. we don't use the same bit for two return values. 2. values should be sorted so that prefer ones (matching more bits) come first.
Diffstat (limited to 'tests/modules')
-rw-r--r--tests/modules/moduleconfigs.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/tests/modules/moduleconfigs.c b/tests/modules/moduleconfigs.c
index 0a6380461..b48133372 100644
--- a/tests/modules/moduleconfigs.c
+++ b/tests/modules/moduleconfigs.c
@@ -121,13 +121,13 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
}
/* On the stack to make sure we're copying them. */
- const char *enum_vals[] = {"none", "one", "two", "three"};
- const int int_vals[] = {0, 1, 2, 4};
+ const char *enum_vals[] = {"none", "five", "one", "two", "four"};
+ const int int_vals[] = {0, 5, 1, 2, 4};
- if (RedisModule_RegisterEnumConfig(ctx, "enum", 1, REDISMODULE_CONFIG_DEFAULT, enum_vals, int_vals, 4, getEnumConfigCommand, setEnumConfigCommand, NULL, NULL) == REDISMODULE_ERR) {
+ if (RedisModule_RegisterEnumConfig(ctx, "enum", 1, REDISMODULE_CONFIG_DEFAULT, enum_vals, int_vals, 5, getEnumConfigCommand, setEnumConfigCommand, NULL, NULL) == REDISMODULE_ERR) {
return REDISMODULE_ERR;
}
- if (RedisModule_RegisterEnumConfig(ctx, "flags", 3, REDISMODULE_CONFIG_DEFAULT | REDISMODULE_CONFIG_BITFLAGS, enum_vals, int_vals, 4, getFlagsConfigCommand, setFlagsConfigCommand, NULL, NULL) == REDISMODULE_ERR) {
+ if (RedisModule_RegisterEnumConfig(ctx, "flags", 3, REDISMODULE_CONFIG_DEFAULT | REDISMODULE_CONFIG_BITFLAGS, enum_vals, int_vals, 5, getFlagsConfigCommand, setFlagsConfigCommand, NULL, NULL) == REDISMODULE_ERR) {
return REDISMODULE_ERR;
}
/* Memory config here. */