From f3efd529df117b1b5b5c5dee54dbde7285da7b6d Mon Sep 17 00:00:00 2001 From: antirez Date: Fri, 27 Jun 2014 11:59:48 +0200 Subject: [PATCH] COMMANDS command: remove static + aesthetic changes. Static was removed since it is needed in order to get symbols in stack traces. Minor changes in the source code were operated to make it more similar to the existing Redis code base. --- src/redis.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/redis.c b/src/redis.c index bf718d62..bfe82ce0 100644 --- a/src/redis.c +++ b/src/redis.c @@ -2267,15 +2267,15 @@ void timeCommand(redisClient *c) { } -static int replyCmdFlag(redisClient *c, - struct redisCommand *cmd, int f, char *reply) { +int addReplyCommandFlag(redisClient *c, struct redisCommand *cmd, int f, char *reply) { if (cmd->flags & f) { addReplyStatus(c, reply); return 1; } return 0; } -static void replyCmd(redisClient *c, struct redisCommand *cmd) { + +void addReplyCommand(redisClient *c, struct redisCommand *cmd) { if (!cmd) { addReply(c, shared.nullbulk); } else { @@ -2286,18 +2286,18 @@ static void replyCmd(redisClient *c, struct redisCommand *cmd) { int flagcount = 0; void *flaglen = addDeferredMultiBulkLength(c); - flagcount += replyCmdFlag(c,cmd,REDIS_CMD_WRITE, "write"); - flagcount += replyCmdFlag(c,cmd,REDIS_CMD_READONLY, "readonly"); - flagcount += replyCmdFlag(c,cmd,REDIS_CMD_DENYOOM, "denyoom"); - flagcount += replyCmdFlag(c,cmd,REDIS_CMD_ADMIN, "admin"); - flagcount += replyCmdFlag(c,cmd,REDIS_CMD_PUBSUB, "pubsub"); - flagcount += replyCmdFlag(c,cmd,REDIS_CMD_NOSCRIPT, "noscript"); - flagcount += replyCmdFlag(c,cmd,REDIS_CMD_RANDOM, "random"); - flagcount += replyCmdFlag(c,cmd,REDIS_CMD_SORT_FOR_SCRIPT,"scriptsort"); - flagcount += replyCmdFlag(c,cmd,REDIS_CMD_LOADING, "loading"); - flagcount += replyCmdFlag(c,cmd,REDIS_CMD_STALE, "stale"); - flagcount += replyCmdFlag(c,cmd,REDIS_CMD_SKIP_MONITOR, "skipmonitor"); - flagcount += replyCmdFlag(c,cmd,REDIS_CMD_ASKING, "asking"); + flagcount += addReplyCommandFlag(c,cmd,REDIS_CMD_WRITE, "write"); + flagcount += addReplyCommandFlag(c,cmd,REDIS_CMD_READONLY, "readonly"); + flagcount += addReplyCommandFlag(c,cmd,REDIS_CMD_DENYOOM, "denyoom"); + flagcount += addReplyCommandFlag(c,cmd,REDIS_CMD_ADMIN, "admin"); + flagcount += addReplyCommandFlag(c,cmd,REDIS_CMD_PUBSUB, "pubsub"); + flagcount += addReplyCommandFlag(c,cmd,REDIS_CMD_NOSCRIPT, "noscript"); + flagcount += addReplyCommandFlag(c,cmd,REDIS_CMD_RANDOM, "random"); + flagcount += addReplyCommandFlag(c,cmd,REDIS_CMD_SORT_FOR_SCRIPT,"sort_for_script"); + flagcount += addReplyCommandFlag(c,cmd,REDIS_CMD_LOADING, "loading"); + flagcount += addReplyCommandFlag(c,cmd,REDIS_CMD_STALE, "stale"); + flagcount += addReplyCommandFlag(c,cmd,REDIS_CMD_SKIP_MONITOR, "skip_monitor"); + flagcount += addReplyCommandFlag(c,cmd,REDIS_CMD_ASKING, "asking"); if (cmd->getkeys_proc) { addReplyStatus(c, "movablekeys"); flagcount += 1; @@ -2309,6 +2309,7 @@ static void replyCmd(redisClient *c, struct redisCommand *cmd) { addReplyLongLong(c, cmd->keystep); } } + void commandsCommand(redisClient *c) { dictIterator *di; dictEntry *de; @@ -2317,7 +2318,7 @@ void commandsCommand(redisClient *c) { int i; addReplyMultiBulkLen(c, c->argc-2); for (i = 2; i < c->argc; i++) { - replyCmd(c, dictFetchValue(server.commands, c->argv[i]->ptr)); + addReplyCommand(c, dictFetchValue(server.commands, c->argv[i]->ptr)); } } else if (c->argc > 2) { addReplyError(c, "Unknown subcommand."); @@ -2326,13 +2327,12 @@ void commandsCommand(redisClient *c) { addReplyMultiBulkLen(c, dictSize(server.commands)); di = dictGetIterator(server.commands); while ((de = dictNext(di)) != NULL) { - replyCmd(c, dictGetVal(de)); + addReplyCommand(c, dictGetVal(de)); } dictReleaseIterator(di); } } - /* Convert an amount of bytes into a human readable string in the form * of 100B, 2G, 100M, 4K, and so forth. */ void bytesToHuman(char *s, unsigned long long n) {