From 522760fac79536eb68dc5fc70e9166f689eb76dc Mon Sep 17 00:00:00 2001 From: antirez Date: Wed, 6 Dec 2017 12:05:11 +0100 Subject: Change indentation and other minor details of PR #4489. The main change introduced by this commit is pretending that help arrays are more text than code, thus indenting them at level 0. This improves readability, and is an old practice when defining arrays of C strings describing text. Additionally a few useless return statements are removed, and the HELP subcommand capitalized when printed to the user. --- src/cluster.c | 50 +++++++++++++++++++++++++------------------------- src/config.c | 12 ++++++------ src/debug.c | 42 +++++++++++++++++++++--------------------- src/networking.c | 33 ++++++++++++++++----------------- src/object.c | 14 ++++++-------- src/pubsub.c | 11 +++++------ src/scripting.c | 16 +++++++--------- src/server.c | 14 ++++++-------- src/slowlog.c | 15 +++++++-------- 9 files changed, 99 insertions(+), 108 deletions(-) diff --git a/src/cluster.c b/src/cluster.c index 4e695822b..6f7f982fb 100644 --- a/src/cluster.c +++ b/src/cluster.c @@ -4067,29 +4067,29 @@ void clusterCommand(client *c) { if (c->argc == 2 && !strcasecmp(c->argv[1]->ptr,"help")) { const char *help[] = { - "addslots [slot ...] -- Assign slots to current node.", - "bumpepoch -- Advance the cluster config epoch.", - "count-failure-reports -- Return number of failure reports for .", - "countkeysinslot - Return the number of keys in .", - "delslots [slot ...] -- Delete slots information from current node.", - "failover [force|takeover] -- Promote current slave node to being a master.", - "forget -- Remove a node from the cluster.", - "getkeysinslot -- Return key names stored by current node in a slot.", - "flushslots -- Delete current node own slots information.", - "info - Return onformation about the cluster.", - "keyslot -- Return the hash slot for .", - "meet [bus-port] -- Connect nodes into a working cluster.", - "myid -- Return the node id.", - "nodes -- Return cluster configuration seen by node. Output format:", - " ... ", - "replicate -- Configure current node as slave to .", - "reset [hard|soft] -- Reset current node (default: soft).", - "set-config-epoch - Set config epoch of current node.", - "setslot (importing|migrating|stable|node ) -- Set slot state.", - "slaves -- Return slaves.", - "slots -- Return information about slots range mappings. Each range is made of:", - " start, end, master and replicas IP addresses, ports and ids", - NULL +"addslots [slot ...] -- Assign slots to current node.", +"bumpepoch -- Advance the cluster config epoch.", +"count-failure-reports -- Return number of failure reports for .", +"countkeysinslot - Return the number of keys in .", +"delslots [slot ...] -- Delete slots information from current node.", +"failover [force|takeover] -- Promote current slave node to being a master.", +"forget -- Remove a node from the cluster.", +"getkeysinslot -- Return key names stored by current node in a slot.", +"flushslots -- Delete current node own slots information.", +"info - Return onformation about the cluster.", +"keyslot -- Return the hash slot for .", +"meet [bus-port] -- Connect nodes into a working cluster.", +"myid -- Return the node id.", +"nodes -- Return cluster configuration seen by node. Output format:", +" ... ", +"replicate -- Configure current node as slave to .", +"reset [hard|soft] -- Reset current node (default: soft).", +"set-config-epoch - Set config epoch of current node.", +"setslot (importing|migrating|stable|node ) -- Set slot state.", +"slaves -- Return slaves.", +"slots -- Return information about slots range mappings. Each range is made of:", +" start, end, master and replicas IP addresses, ports and ids", +NULL }; addReplyHelp(c, help); } else if (!strcasecmp(c->argv[1]->ptr,"meet") && (c->argc == 4 || c->argc == 5)) { @@ -4285,7 +4285,7 @@ void clusterCommand(client *c) { clusterAddSlot(n,slot); } else { addReplyError(c, - "Invalid CLUSTER SETSLOT action or number of arguments. Try CLUSTER help"); + "Invalid CLUSTER SETSLOT action or number of arguments. Try CLUSTER HELP"); return; } clusterDoBeforeSleep(CLUSTER_TODO_SAVE_CONFIG|CLUSTER_TODO_UPDATE_STATE); @@ -4635,7 +4635,7 @@ void clusterCommand(client *c) { clusterReset(hard); addReply(c,shared.ok); } else { - addReplyErrorFormat(c, "Unknown subcommand or wrong number of arguments for '%s'. Try CLUSTER help", + addReplyErrorFormat(c, "Unknown subcommand or wrong number of arguments for '%s'. Try CLUSTER HELP", (char*)c->argv[1]->ptr); return; } diff --git a/src/config.c b/src/config.c index 0324c4b7c..24a590caf 100644 --- a/src/config.c +++ b/src/config.c @@ -2071,11 +2071,11 @@ void configCommand(client *c) { if (c->argc == 2 && !strcasecmp(c->argv[1]->ptr,"help")) { const char *help[] = { - "get -- Return parameters matching the glob-like and their values.", - "set -- Set parameter to value.", - "resetstat -- Reset statistics reported by INFO.", - "rewrite -- Rewrite the configuration file.", - NULL +"get -- Return parameters matching the glob-like and their values.", +"set -- Set parameter to value.", +"resetstat -- Reset statistics reported by INFO.", +"rewrite -- Rewrite the configuration file.", +NULL }; addReplyHelp(c, help); } else if (!strcasecmp(c->argv[1]->ptr,"set") && c->argc == 4) { @@ -2099,7 +2099,7 @@ void configCommand(client *c) { addReply(c,shared.ok); } } else { - addReplyErrorFormat(c, "Unknown subcommand or wrong number of arguments for '%s'. Try SLOWLOG help", + addReplyErrorFormat(c, "Unknown subcommand or wrong number of arguments for '%s'. Try CONFIG HELP", (char*)c->argv[1]->ptr); return; } diff --git a/src/debug.c b/src/debug.c index c6aea6cb6..12f629428 100644 --- a/src/debug.c +++ b/src/debug.c @@ -285,26 +285,26 @@ void computeDatasetDigest(unsigned char *final) { void debugCommand(client *c) { if (c->argc == 2 && !strcasecmp(c->argv[1]->ptr,"help")) { const char *help[] = { - "assert -- Crash by assertion failed.", - "change-repl-id -- Change the replication IDs of the instance. Dangerous, should be used only for testing the replication subsystem.", - "crash-and-recovery -- Hard crash and restart after delay.", - "digest -- Outputs an hex signature representing the current DB content.", - "htstats -- Return hash table statistics of the specified Redis database.", - "loadaof -- Flush the AOF buffers on disk and reload the AOF in memory.", - "lua-always-replicate-commands (0|1) -- Setting it to 1 makes Lua replication defaulting to replicating single commands, without the script having to enable effects replication.", - "object -- Show low level info about key and associated value.", - "panic -- Crash the server simulating a panic.", - "populate [prefix] [size] -- Create string keys named key:. If a prefix is specified is used instead of the 'key' prefix.", - "reload -- Save the RDB on disk and reload it back in memory.", - "restart -- Graceful restart: save config, db, restart.", - "sdslen -- Show low level SDS string info representing key and value.", - "segfault -- Crash the server with sigsegv.", - "set-active-expire (0|1) -- Setting it to 0 disables expiring keys in background when they are not accessed (otherwise the Redis behavior). Setting it to 1 reenables back the default.", - "sleep -- Stop the server for . Decimals allowed.", - "structsize -- Return the size of different Redis core C structures.", - "ziplist -- Show low level info about the ziplist encoding.", - "error -- Return a Redis protocol error with as message. Useful for clients unit tests to simulate Redis errors.", - NULL +"assert -- Crash by assertion failed.", +"change-repl-id -- Change the replication IDs of the instance. Dangerous, should be used only for testing the replication subsystem.", +"crash-and-recovery -- Hard crash and restart after delay.", +"digest -- Outputs an hex signature representing the current DB content.", +"htstats -- Return hash table statistics of the specified Redis database.", +"loadaof -- Flush the AOF buffers on disk and reload the AOF in memory.", +"lua-always-replicate-commands (0|1) -- Setting it to 1 makes Lua replication defaulting to replicating single commands, without the script having to enable effects replication.", +"object -- Show low level info about key and associated value.", +"panic -- Crash the server simulating a panic.", +"populate [prefix] [size] -- Create string keys named key:. If a prefix is specified is used instead of the 'key' prefix.", +"reload -- Save the RDB on disk and reload it back in memory.", +"restart -- Graceful restart: save config, db, restart.", +"sdslen -- Show low level SDS string info representing key and value.", +"segfault -- Crash the server with sigsegv.", +"set-active-expire (0|1) -- Setting it to 0 disables expiring keys in background when they are not accessed (otherwise the Redis behavior). Setting it to 1 reenables back the default.", +"sleep -- Stop the server for . Decimals allowed.", +"structsize -- Return the size of different Redis core C structures.", +"ziplist -- Show low level info about the ziplist encoding.", +"error -- Return a Redis protocol error with as message. Useful for clients unit tests to simulate Redis errors.", +NULL }; addReplyHelp(c, help); } else if (!strcasecmp(c->argv[1]->ptr,"segfault")) { @@ -553,7 +553,7 @@ void debugCommand(client *c) { clearReplicationId2(); addReply(c,shared.ok); } else { - addReplyErrorFormat(c, "Unknown subcommand or wrong number of arguments for '%s'. Try DEBUG help", + addReplyErrorFormat(c, "Unknown subcommand or wrong number of arguments for '%s'. Try DEBUG HELP", (char*)c->argv[1]->ptr); return; } diff --git a/src/networking.c b/src/networking.c index a0841b992..e1b9ba048 100644 --- a/src/networking.c +++ b/src/networking.c @@ -578,7 +578,7 @@ void addReplyBulkSds(client *c, sds s) { addReply(c,shared.crlf); } -/* Add a C nul term string as bulk reply */ +/* Add a C null term string as bulk reply */ void addReplyBulkCString(client *c, const char *s) { if (s == NULL) { addReply(c,shared.nullbulk); @@ -596,7 +596,7 @@ void addReplyBulkLongLong(client *c, long long ll) { addReplyBulkCBuffer(c,buf,len); } -/* Add an array of strings as a bulk reply with a heading. +/* Add an array of C strings as status replies with a heading. * This function is typically invoked by from commands that support * subcommands in response to the 'help' subcommand. The help array * is terminated by NULL sentinel. */ @@ -609,7 +609,7 @@ void addReplyHelp(client *c, const char **help) { addReplyStatusFormat(c, "%s arg arg ... arg. Subcommands are:",cmd); sdsfree(cmd); - + while (help[blen]) addReplyStatus(c,help[blen++]); blen++; /* Account for the header line(s). */ @@ -1591,17 +1591,17 @@ void clientCommand(client *c) { if (c->argc == 2 && !strcasecmp(c->argv[1]->ptr,"help")) { const char *help[] = { - "getname -- Return the name of the current connection.", - "kill -- Kill connection made from .", - "kill