From 3a0ba0ad93be5a2981c0ec0efc8c7a55be0a58e6 Mon Sep 17 00:00:00 2001 From: 0del <53461381+0del@users.noreply.github.com> Date: Thu, 4 Apr 2024 01:33:38 +0700 Subject: [PATCH] rename redisCommandArgType serverCommandArgType (#182) redisCommandArgType -> serverCommandArgType redisCommandArg -> serverCommandArg https://github.com/valkey-io/valkey/issues/144 Signed-off-by: 0del --- src/cli_commands.h | 2 +- src/commands.c | 2 +- src/commands.h | 10 +++++----- src/module.c | 18 +++++++++--------- src/server.c | 4 ++-- src/server.h | 2 +- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/cli_commands.h b/src/cli_commands.h index eb5a476e3..d8455116d 100644 --- a/src/cli_commands.h +++ b/src/cli_commands.h @@ -11,7 +11,7 @@ /* Syntax specifications for a command argument. */ typedef struct cliCommandArg { char *name; - redisCommandArgType type; + serverCommandArgType type; char *token; char *since; int flags; diff --git a/src/commands.c b/src/commands.c index 6d8e5696f..bb93f9818 100644 --- a/src/commands.c +++ b/src/commands.c @@ -4,7 +4,7 @@ #define MAKE_CMD(name,summary,complexity,since,doc_flags,replaced,deprecated,group,group_enum,history,num_history,tips,num_tips,function,arity,flags,acl,key_specs,key_specs_num,get_keys,numargs) name,summary,complexity,since,doc_flags,replaced,deprecated,group_enum,history,num_history,tips,num_tips,function,arity,flags,acl,key_specs,key_specs_num,get_keys,numargs #define MAKE_ARG(name,type,key_spec_index,token,summary,since,flags,numsubargs,deprecated_since) name,type,key_spec_index,token,summary,since,flags,deprecated_since,numsubargs #define COMMAND_STRUCT serverCommand -#define COMMAND_ARG redisCommandArg +#define COMMAND_ARG serverCommandArg #ifdef LOG_REQ_RES #include "commands_with_reply_schema.def" diff --git a/src/commands.h b/src/commands.h index 1eefab481..f09378116 100644 --- a/src/commands.h +++ b/src/commands.h @@ -12,7 +12,7 @@ typedef enum { ARG_TYPE_PURE_TOKEN, ARG_TYPE_ONEOF, /* Has subargs */ ARG_TYPE_BLOCK /* Has subargs */ -} redisCommandArgType; +} serverCommandArgType; #define CMD_ARG_NONE (0) #define CMD_ARG_OPTIONAL (1<<0) @@ -20,9 +20,9 @@ typedef enum { #define CMD_ARG_MULTIPLE_TOKEN (1<<2) /* Must be compatible with RedisModuleCommandArg. See moduleCopyCommandArgs. */ -typedef struct redisCommandArg { +typedef struct serverCommandArg { const char *name; - redisCommandArgType type; + serverCommandArgType type; int key_spec_index; const char *token; const char *summary; @@ -30,9 +30,9 @@ typedef struct redisCommandArg { int flags; const char *deprecated_since; int num_args; - struct redisCommandArg *subargs; + struct serverCommandArg *subargs; const char *display_text; -} redisCommandArg; +} serverCommandArg; /* Returns the command group name by group number. */ const char *commandGroupStr(int index); diff --git a/src/module.c b/src/module.c index 231484546..44c983f2e 100644 --- a/src/module.c +++ b/src/module.c @@ -500,9 +500,9 @@ static int moduleValidateCommandInfo(const RedisModuleCommandInfo *info); static int64_t moduleConvertKeySpecsFlags(int64_t flags, int from_api); static int moduleValidateCommandArgs(RedisModuleCommandArg *args, const RedisModuleCommandInfoVersion *version); -static struct redisCommandArg *moduleCopyCommandArgs(RedisModuleCommandArg *args, +static struct serverCommandArg *moduleCopyCommandArgs(RedisModuleCommandArg *args, const RedisModuleCommandInfoVersion *version); -static redisCommandArgType moduleConvertArgType(RedisModuleCommandArgType type, int *error); +static serverCommandArgType moduleConvertArgType(RedisModuleCommandArgType type, int *error); static int moduleConvertArgFlags(int flags); void moduleCreateContext(RedisModuleCtx *out_ctx, RedisModule *module, int ctx_flags); @@ -1450,7 +1450,7 @@ moduleCmdArgAt(const RedisModuleCommandInfoVersion *version, /* Recursively populate the args structure (setting num_args to the number of * subargs) and return the number of args. */ -int populateArgsStructure(struct redisCommandArg *args) { +int populateArgsStructure(struct serverCommandArg *args) { if (!args) return 0; int count = 0; @@ -2197,13 +2197,13 @@ static int moduleValidateCommandArgs(RedisModuleCommandArg *args, } /* Converts an array of RedisModuleCommandArg into a freshly allocated array of - * struct redisCommandArg. */ -static struct redisCommandArg *moduleCopyCommandArgs(RedisModuleCommandArg *args, + * struct serverCommandArg. */ +static struct serverCommandArg *moduleCopyCommandArgs(RedisModuleCommandArg *args, const RedisModuleCommandInfoVersion *version) { size_t count = 0; while (moduleCmdArgAt(version, args, count)->name) count++; - serverAssert(count < SIZE_MAX / sizeof(struct redisCommandArg)); - struct redisCommandArg *realargs = zcalloc((count+1) * sizeof(redisCommandArg)); + serverAssert(count < SIZE_MAX / sizeof(struct serverCommandArg)); + struct serverCommandArg *realargs = zcalloc((count+1) * sizeof(serverCommandArg)); for (size_t j = 0; j < count; j++) { RedisModuleCommandArg *arg = moduleCmdArgAt(version, args, j); @@ -2224,7 +2224,7 @@ static struct redisCommandArg *moduleCopyCommandArgs(RedisModuleCommandArg *args return realargs; } -static redisCommandArgType moduleConvertArgType(RedisModuleCommandArgType type, int *error) { +static serverCommandArgType moduleConvertArgType(RedisModuleCommandArgType type, int *error) { if (error) *error = 0; switch (type) { case REDISMODULE_ARG_TYPE_STRING: return ARG_TYPE_STRING; @@ -12132,7 +12132,7 @@ void moduleFreeModuleStructure(struct RedisModule *module) { zfree(module); } -void moduleFreeArgs(struct redisCommandArg *args, int num_args) { +void moduleFreeArgs(struct serverCommandArg *args, int num_args) { for (int j = 0; j < num_args; j++) { zfree((char *)args[j].name); zfree((char *)args[j].token); diff --git a/src/server.c b/src/server.c index b073de2da..efd7f7b3b 100644 --- a/src/server.c +++ b/src/server.c @@ -4699,7 +4699,7 @@ void addReplyFlagsForKeyArgs(client *c, uint64_t flags) { addReplyCommandFlags(c, flags, docFlagNames); } -/* Must match redisCommandArgType */ +/* Must match serverCommandArgType */ const char *ARG_TYPE_STR[] = { "string", "integer", @@ -4722,7 +4722,7 @@ void addReplyFlagsForArg(client *c, uint64_t flags) { addReplyCommandFlags(c, flags, argFlagNames); } -void addReplyCommandArgList(client *c, struct redisCommandArg *args, int num_args) { +void addReplyCommandArgList(client *c, struct serverCommandArg *args, int num_args) { addReplyArrayLen(c, num_args); for (int j = 0; j